From 1368f83d77194526835bde27e638b42cbe21d554 Mon Sep 17 00:00:00 2001 From: morg Date: Sat, 2 Nov 2024 17:34:28 +0000 Subject: [PATCH] Adds a setting for automatically showing LED view --- qt/OpenRGBDialog2/OpenRGBDialog2.cpp | 69 +++-- qt/OpenRGBDialog2/OpenRGBDialog2.h | 3 + .../OpenRGBSettingsPage.cpp | 17 ++ qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h | 1 + qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui | 273 +++++++++--------- 5 files changed, 207 insertions(+), 156 deletions(-) diff --git a/qt/OpenRGBDialog2/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2/OpenRGBDialog2.cpp index f4addfd3..c0883a9a 100644 --- a/qt/OpenRGBDialog2/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2/OpenRGBDialog2.cpp @@ -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(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(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(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(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(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. | diff --git a/qt/OpenRGBDialog2/OpenRGBDialog2.h b/qt/OpenRGBDialog2/OpenRGBDialog2.h index 582e637a..fde6dc62 100644 --- a/qt/OpenRGBDialog2/OpenRGBDialog2.h +++ b/qt/OpenRGBDialog2/OpenRGBDialog2.h @@ -159,6 +159,9 @@ private: QAction* actionExit; QString dialog_message; + void ShowLEDView(); + void HideLEDView(); + private slots: void on_Exit(); void on_LightsOff(); diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp index ece3e7f8..bf886d9a 100644 --- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp +++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp @@ -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(); +} diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h index 5f1d085d..13ac9e11 100644 --- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h +++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h @@ -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(); }; diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui index 9615eaae..4236cbfe 100644 --- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui +++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui @@ -31,48 +31,48 @@ 0 0 - 395 - 654 + 678 + 980 - - + + - Drivers Settings + Load Profile - - + + + + Set Profile on Exit + + - - - - - - Set Server Port - - - - - - + + + + + - Run zone checks on rescan + Greyscale Tray Icon - - + + - Log Manager Settings: + Custom Arguments + + + @@ -80,38 +80,90 @@ - + + + + Load Window Geometry + + + + + + + Start Minimized + + + + Start at Login Status - - + + - Theme (restart required) + Set Server Host + + + + + + + + + + Save Geometry On Close + + + + + + + Shared SMBus Access (restart required) + + + + + + + + + + Start At Login + + + + + + + User Interface Settings: + + + + + + + Minimize On Close + + + + + + + Drivers Settings + + + + + + + Enable Log Console (restart required) - - - - - - Set Profile on Exit - - - - - - - Start Server - - - - 90000 @@ -124,21 +176,48 @@ - + + + + + + + AMD SMBus: Reduce CPU Usage (restart required) + + + + + + + + + + Theme (restart required) + + + + + + + Start Server + + + + Start Client - - + + - Set Server Host + Run zone checks on rescan - + Qt::Vertical @@ -154,110 +233,38 @@ - - + + - Start At Login - - - - - - - Shared SMBus Access (restart required) - - - - - - - - - - - - - User Interface Settings: - - - - - - - Save Geometry On Close - - - - - - - Custom Arguments - - - - - - - Load Window Geometry + Disable key expansion in device view - + - Enable Log Console (restart required) + Log Manager Settings: - - - - Start Minimized - - - - + Start At Login Settings: - - + + - Minimize On Close + Set Server Port - - - - - + + - Greyscale Tray Icon - - - - - - - AMD SMBus: Reduce CPU Usage (restart required) - - - - - - - Load Profile - - - - - - - Disable key expansion in device view + Show LED view by default