mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-07-08 04:14:50 -04:00
Settings Rework
* Add JSON string configuration field to RGBController to store device-specific configurations
* This JSON string holds both configuration and schema
* Add settings schema tracking to SettingsManager
* Implement dynamic settings widget that generates a settings UI based on a JSON schema
* Implement SettingsManager callback for notifying of settings changes and settings schema updates
* Always enable Entire Device zone option and use it to enable Edit Device
* Rename SaveSizes to SaveConfiguration in ProfileManager and Sizes.json to Configuration.json
* Add zone flag for indicating that a zone's geometry may change, informing profile manager to ignore this check
* Remove Theme setting and Theme Manager, as this didn't work on most setups anyways and Qt6 has proper Windows dark theming
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
#include "ResourceManager.h"
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "RGBController.h"
|
||||
#include "SettingsManager.h"
|
||||
|
||||
#define MAX_COLS 20
|
||||
#define PAD_LED 0.1f
|
||||
@@ -256,6 +255,14 @@ QSize DeviceView::sizeHint() const
|
||||
\*---------------------------------------------------------*/
|
||||
bool DeviceView::SelectLED(unsigned int led_idx)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Check validity |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -289,6 +296,14 @@ bool DeviceView::SelectLED(unsigned int led_idx)
|
||||
|
||||
bool DeviceView::SelectLEDs(std::vector<unsigned int> leds)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Check validity |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -339,6 +354,14 @@ bool DeviceView::SelectLEDs(std::vector<unsigned int> leds)
|
||||
|
||||
bool DeviceView::SelectSegment(unsigned int zone_idx, unsigned int segment_idx, bool add)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Check validity |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -400,6 +423,14 @@ bool DeviceView::SelectSegment(unsigned int zone_idx, unsigned int segment_idx,
|
||||
|
||||
bool DeviceView::SelectZone(unsigned int zone_idx, bool add)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Check validity |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -458,6 +489,14 @@ bool DeviceView::SelectZone(unsigned int zone_idx, bool add)
|
||||
\*---------------------------------------------------------*/
|
||||
void DeviceView::ClearSelection()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Same as selecting the entire device |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -482,12 +521,24 @@ void DeviceView::SetController(RGBController * controller_ptr)
|
||||
controller = controller_ptr;
|
||||
}
|
||||
|
||||
void DeviceView::SetDisableKeyExpansion(bool disable_key_expansion)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Store the disable key expansion flag |
|
||||
\*-----------------------------------------------------*/
|
||||
disable_expansion = disable_key_expansion;
|
||||
|
||||
InitDeviceView();
|
||||
}
|
||||
|
||||
void DeviceView::SetNumericalLabels(bool enable)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Store the numerical labels flag |
|
||||
\*-----------------------------------------------------*/
|
||||
numerical_labels = enable;
|
||||
|
||||
InitDeviceView();
|
||||
}
|
||||
|
||||
void DeviceView::SetPerLED(bool per_led_mode)
|
||||
@@ -505,6 +556,14 @@ void DeviceView::SetPerLED(bool per_led_mode)
|
||||
|
||||
void DeviceView::SetSelectionColor(RGBColor color)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If no LEDs are selected, set entire device using the |
|
||||
| SetAllColors function |
|
||||
@@ -541,6 +600,14 @@ void DeviceView::SetSelectionColor(RGBColor color)
|
||||
\*---------------------------------------------------------*/
|
||||
void DeviceView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Only handle events when in per-LED mode |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -592,6 +659,14 @@ void DeviceView::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void DeviceView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Only handle events when in per-LED mode |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -656,6 +731,14 @@ void DeviceView::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void DeviceView::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Only handle events when in per-LED mode |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -780,6 +863,14 @@ void DeviceView::resizeEvent(QResizeEvent* /*event*/)
|
||||
|
||||
void DeviceView::paintEvent(QPaintEvent* /* event */)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Device View is hidden, don't paint |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -1014,6 +1105,14 @@ void DeviceView::paintEvent(QPaintEvent* /* event */)
|
||||
\*---------------------------------------------------------*/
|
||||
void DeviceView::InitDeviceView()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the size of the selection flags vector |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -1033,19 +1132,6 @@ void DeviceView::InitDeviceView()
|
||||
unsigned int segment_count = 0;
|
||||
float total_height = 0.0f;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get device view settings |
|
||||
\*-----------------------------------------------------*/
|
||||
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
|
||||
std::string ui_string = "UserInterface";
|
||||
json ui_settings = settings_manager->GetSettings(ui_string);
|
||||
bool disable_expansion = false;
|
||||
|
||||
if(ui_settings.contains("disable_key_expansion"))
|
||||
{
|
||||
disable_expansion = ui_settings["disable_key_expansion"];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine the total height (in LEDs) of all zones |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -1325,6 +1411,10 @@ void DeviceView::InitDeviceView()
|
||||
{
|
||||
led_labels[led_idx] = QString::number(led_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
led_labels[led_idx] = "";
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -1377,6 +1467,14 @@ void DeviceView::InitDeviceView()
|
||||
|
||||
void DeviceView::UpdateSelection()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Verify controller exists |
|
||||
\*-----------------------------------------------------*/
|
||||
if(controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Clear existing selection |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user