Adds a setting for automatically showing LED view

This commit is contained in:
morg 2024-11-02 17:34:28 +00:00 committed by Adam Honse
parent ab7e281c1c
commit 1368f83d77
5 changed files with 207 additions and 156 deletions

View file

@ -185,6 +185,11 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
ui_settings = settings_manager->GetSettings(ui_string);
if(ui_settings.contains("show_led_view") && ui_settings["show_led_view"])
{
ShowLEDView();
}
/*-----------------------------------------------------*\
| If geometry info doesn't exist, write it to config |
\*-----------------------------------------------------*/
@ -1332,6 +1337,11 @@ void OpenRGBDialog2::UpdateDevicesList()
base_tab += 1;
}
}
if(device_view_showing)
{
ShowLEDView();
}
}
void OpenRGBDialog2::SetDialogMessage(PLogMessage msg)
@ -1460,6 +1470,11 @@ void OpenRGBDialog2::onDetectionEnded()
plugin_manager->ScanAndLoadPlugins();
plugins_loaded = true;
}
if(device_view_showing)
{
ShowLEDView();
}
}
void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
@ -1664,26 +1679,37 @@ void Ui::OpenRGBDialog2::on_ButtonToggleDeviceView_clicked()
{
if(device_view_showing)
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->HideDeviceView();
}
device_view_showing = false;
HideLEDView();
}
else
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
OpenRGBDevicePage* device_page = qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device));
if(device_page) // Check the cast to make sure it is a device and not plugin
{
device_page->ShowDeviceView();
}
}
device_view_showing = true;
ShowLEDView();
}
}
void Ui::OpenRGBDialog2::ShowLEDView()
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
OpenRGBDevicePage* device_page = qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device));
if(device_page) // Check the cast to make sure it is a device and not plugin
{
device_page->ShowDeviceView();
}
}
device_view_showing = true;
}
void Ui::OpenRGBDialog2::HideLEDView()
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->HideDeviceView();
}
device_view_showing = false;
}
void Ui::OpenRGBDialog2::on_ButtonStopDetection_clicked()
{
/*---------------------------------------------------------*\
@ -1801,17 +1827,14 @@ void Ui::OpenRGBDialog2::on_ButtonRescan_clicked()
/*---------------------------------------------------------*\
| Hide devices view on rescan so it stops handling paint |
| events. |
| Memorize previous value of device_view_showing and |
| restore it. |
\*---------------------------------------------------------*/
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
OpenRGBDevicePage* device_page = qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device));
if(device_page) // Check the cast to make sure it is a device and not plugin
{
device_page->HideDeviceView();
}
}
bool device_view_showing_prev = device_view_showing;
device_view_showing = false;
HideLEDView();
device_view_showing = device_view_showing_prev;
/*---------------------------------------------------------*\
| Show the detection progress bar. |

View file

@ -159,6 +159,9 @@ private:
QAction* actionExit;
QString dialog_message;
void ShowLEDView();
void HideLEDView();
private slots:
void on_Exit();
void on_LightsOff();

View file

@ -149,6 +149,15 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) :
ui->CheckboxDisableKeyExpansion->setChecked(false);
}
if(ui_settings.contains("show_led_view"))
{
ui->CheckboxShowLEDView->setChecked(ui_settings["show_led_view"]);
}
else
{
ui->CheckboxShowLEDView->setChecked(false);
}
/*---------------------------------------------------------*\
| Load LogManager settings |
\*---------------------------------------------------------*/
@ -823,3 +832,11 @@ void Ui::OpenRGBSettingsPage::on_CheckboxDisableKeyExpansion_clicked()
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
SaveSettings();
}
void Ui::OpenRGBSettingsPage::on_CheckboxShowLEDView_clicked()
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["show_led_view"] = ui->CheckboxShowLEDView->isChecked();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
SaveSettings();
}

View file

@ -82,4 +82,5 @@ private slots:
void on_CheckboxSetOnExit_clicked(bool checked);
void on_ComboBoxExitProfile_currentTextChanged(const QString exit_profile_name);
void on_CheckboxDisableKeyExpansion_clicked();
void on_CheckboxShowLEDView_clicked();
};

View file

@ -31,48 +31,48 @@
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>654</height>
<width>678</width>
<height>980</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="13" column="0">
<widget class="QLabel" name="DriversSettingsLabel">
<item row="28" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
<property name="text">
<string>Drivers Settings</string>
<string>Load Profile</string>
</property>
</widget>
</item>
<item row="23" column="1">
<widget class="QLineEdit" name="TextServerHost"/>
<item row="29" column="0">
<widget class="QCheckBox" name="CheckboxSetOnExit">
<property name="text">
<string>Set Profile on Exit</string>
</property>
</widget>
</item>
<item row="27" column="1">
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
</item>
<item row="24" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerPort">
<property name="text">
<string>Set Server Port</string>
</property>
</widget>
</item>
<item row="26" column="1">
<widget class="QLineEdit" name="TextCustomArgs"/>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="CheckboxRunZoneChecks">
<item row="26" column="1">
<widget class="QLineEdit" name="TextClientHost"/>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="CheckboxTrayIconGreyscale">
<property name="text">
<string>Run zone checks on rescan</string>
<string>Greyscale Tray Icon</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="LogManagerSettingsLabel">
<item row="27" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
<property name="text">
<string>Log Manager Settings:</string>
<string>Custom Arguments</string>
</property>
</widget>
</item>
<item row="24" column="1">
<widget class="QLineEdit" name="TextServerHost"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="LabelLanguage">
<property name="text">
@ -80,38 +80,90 @@
</property>
</widget>
</item>
<item row="29" column="0">
<item row="7" column="0">
<widget class="QCheckBox" name="CheckboxLoadGeometry">
<property name="text">
<string>Load Window Geometry</string>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
<property name="text">
<string>Start Minimized</string>
</property>
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="AutoStartStatusLabel">
<property name="text">
<string>Start at Login Status</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ThemeLabel">
<item row="24" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerHost">
<property name="text">
<string>Theme (restart required)</string>
<string>Set Server Host</string>
</property>
</widget>
</item>
<item row="29" column="1">
<widget class="QComboBox" name="ComboBoxExitProfile"/>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="CheckboxSaveGeometry">
<property name="text">
<string>Save Geometry On Close</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QCheckBox" name="CheckboxSharedSMBusAccess">
<property name="text">
<string>Shared SMBus Access (restart required)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="ComboBoxLanguage"/>
</item>
<item row="18" column="0">
<widget class="QCheckBox" name="CheckboxAutoStart">
<property name="text">
<string>Start At Login</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="UserInterfaceSettingsLabel">
<property name="text">
<string>User Interface Settings:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
<property name="text">
<string>Minimize On Close</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="DriversSettingsLabel">
<property name="text">
<string>Drivers Settings</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QCheckBox" name="CheckboxLogConsole">
<property name="text">
<string>Enable Log Console (restart required)</string>
</property>
</widget>
</item>
<item row="25" column="1">
<widget class="QLineEdit" name="TextClientHost"/>
</item>
<item row="28" column="0">
<widget class="QCheckBox" name="CheckboxSetOnExit">
<property name="text">
<string>Set Profile on Exit</string>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartServer">
<property name="text">
<string>Start Server</string>
</property>
</widget>
</item>
<item row="24" column="1">
<widget class="QLineEdit" name="TextServerPort">
<property name="inputMask">
<string>90000</string>
@ -124,21 +176,48 @@
</property>
</widget>
</item>
<item row="25" column="0">
<item row="28" column="1">
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
</item>
<item row="15" column="0">
<widget class="QCheckBox" name="CheckboxAMDSMBusReduceCPU">
<property name="text">
<string>AMD SMBus: Reduce CPU Usage (restart required)</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="ComboBoxTheme"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ThemeLabel">
<property name="text">
<string>Theme (restart required)</string>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartServer">
<property name="text">
<string>Start Server</string>
</property>
</widget>
</item>
<item row="26" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartClient">
<property name="text">
<string>Start Client</string>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerHost">
<item row="9" column="0">
<widget class="QCheckBox" name="CheckboxRunZoneChecks">
<property name="text">
<string>Set Server Host</string>
<string>Run zone checks on rescan</string>
</property>
</widget>
</item>
<item row="30" column="0">
<item row="31" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -154,110 +233,38 @@
</property>
</spacer>
</item>
<item row="17" column="0">
<widget class="QCheckBox" name="CheckboxAutoStart">
<item row="10" column="0">
<widget class="QCheckBox" name="CheckboxDisableKeyExpansion">
<property name="text">
<string>Start At Login</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QCheckBox" name="CheckboxSharedSMBusAccess">
<property name="text">
<string>Shared SMBus Access (restart required)</string>
</property>
</widget>
</item>
<item row="28" column="1">
<widget class="QComboBox" name="ComboBoxExitProfile"/>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="ComboBoxLanguage"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="UserInterfaceSettingsLabel">
<property name="text">
<string>User Interface Settings:</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="CheckboxSaveGeometry">
<property name="text">
<string>Save Geometry On Close</string>
</property>
</widget>
</item>
<item row="26" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
<property name="text">
<string>Custom Arguments</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="CheckboxLoadGeometry">
<property name="text">
<string>Load Window Geometry</string>
<string>Disable key expansion in device view</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="CheckboxLogConsole">
<widget class="QLabel" name="LogManagerSettingsLabel">
<property name="text">
<string>Enable Log Console (restart required)</string>
<string>Log Manager Settings:</string>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
<property name="text">
<string>Start Minimized</string>
</property>
</widget>
</item>
<item row="16" column="0">
<item row="17" column="0">
<widget class="QLabel" name="AutoStartLabel">
<property name="text">
<string>Start At Login Settings:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
<item row="25" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerPort">
<property name="text">
<string>Minimize On Close</string>
<string>Set Server Port</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="ComboBoxTheme"/>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="CheckboxTrayIconGreyscale">
<item row="11" column="0">
<widget class="QCheckBox" name="CheckboxShowLEDView">
<property name="text">
<string>Greyscale Tray Icon</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QCheckBox" name="CheckboxAMDSMBusReduceCPU">
<property name="text">
<string>AMD SMBus: Reduce CPU Usage (restart required)</string>
</property>
</widget>
</item>
<item row="27" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="CheckboxDisableKeyExpansion">
<property name="text">
<string>Disable key expansion in device view</string>
<string>Show LED view by default</string>
</property>
</widget>
</item>