From 648c0fce922d5a43263d9716a538fbdbd45667be Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Wed, 8 Jan 2025 23:31:03 -0600 Subject: [PATCH] Get rid of old early prototype OpenRGBDialog, rename OpenRGBDialog2 to OpenRGBDialog --- main.cpp | 4 +- qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp | 2 +- qt/OpenRGBDialog/OpenRGBDialog.cpp | 2147 +++++++++++++++-- qt/OpenRGBDialog/OpenRGBDialog.h | 190 +- qt/OpenRGBDialog/OpenRGBDialog.ui | 317 +-- qt/OpenRGBDialog2/OpenRGBDialog2.cpp | 2032 ---------------- qt/OpenRGBDialog2/OpenRGBDialog2.h | 203 -- qt/OpenRGBDialog2/OpenRGBDialog2.ui | 206 -- .../OpenRGBNanoleafNewDeviceDialog.h | 2 +- .../OpenRGBProfileSaveDialog.cpp | 2 +- .../OpenRGBProfileSaveDialog.h | 2 +- .../OpenRGBZonesBulkResizer.cpp | 2 +- qt/i18n/OpenRGB_de_DE.ts | 4 +- qt/i18n/OpenRGB_el_GR.ts | 4 +- qt/i18n/OpenRGB_en_AU.ts | 4 +- qt/i18n/OpenRGB_en_GB.ts | 4 +- qt/i18n/OpenRGB_en_US.ts | 4 +- qt/i18n/OpenRGB_es_ES.ts | 4 +- qt/i18n/OpenRGB_fr_FR.ts | 4 +- qt/i18n/OpenRGB_hr_HR.ts | 4 +- qt/i18n/OpenRGB_it_IT.ts | 4 +- qt/i18n/OpenRGB_ja_JP.ts | 98 +- qt/i18n/OpenRGB_ko_KR.ts | 4 +- qt/i18n/OpenRGB_ms_MY.ts | 98 +- qt/i18n/OpenRGB_pl_PL.ts | 4 +- qt/i18n/OpenRGB_pt_BR.ts | 4 +- qt/i18n/OpenRGB_ru_RU.ts | 102 +- qt/i18n/OpenRGB_zh_CN.ts | 98 +- qt/i18n/OpenRGB_zh_TW.ts | 98 +- 29 files changed, 2609 insertions(+), 3042 deletions(-) delete mode 100644 qt/OpenRGBDialog2/OpenRGBDialog2.cpp delete mode 100644 qt/OpenRGBDialog2/OpenRGBDialog2.h delete mode 100644 qt/OpenRGBDialog2/OpenRGBDialog2.ui diff --git a/main.cpp b/main.cpp index 781e99ab..3168cb25 100644 --- a/main.cpp +++ b/main.cpp @@ -25,7 +25,7 @@ io_connect_t macUSPCIO_driver_connection; #endif -#include "OpenRGBDialog2.h" +#include "OpenRGBDialog.h" #ifdef __APPLE__ #include "macutils.h" @@ -224,7 +224,7 @@ int main(int argc, char* argv[]) /*---------------------------------------------------------*\ | Main UI widget | \*---------------------------------------------------------*/ - Ui::OpenRGBDialog2 dlg; + Ui::OpenRGBDialog dlg; LOG_TRACE("[main] Dialog created"); if(ret_flags & RET_FLAG_I2C_TOOLS) diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp index 09b7cb92..63d33c99 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-only | \*---------------------------------------------------------*/ -#include "OpenRGBDialog2.h" +#include "OpenRGBDialog.h" #include "OpenRGBDevicePage.h" #include "OpenRGBZoneResizeDialog.h" #include "ResourceManager.h" diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp index c52968ae..ded96533 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.cpp +++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp @@ -1,4 +1,4 @@ -/*---------------------------------------------------------*\ +/*---------------------------------------------------------*\ | OpenRGBDialog.cpp | | | | User interface for OpenRGB main window | @@ -7,68 +7,569 @@ | SPDX-License-Identifier: GPL-2.0-only | \*---------------------------------------------------------*/ +#include +#include #include "OpenRGBDialog.h" +#include "LogManager.h" +#include "PluginManager.h" +#include "OpenRGBDevicePage.h" +#include "OpenRGBDeviceInfoPage.h" +#include "OpenRGBServerInfoPage.h" +#include "OpenRGBConsolePage.h" +#include "OpenRGBPluginContainer.h" +#include "OpenRGBProfileSaveDialog.h" +#include "ResourceManager.h" +#include "SettingsManager.h" +#include "TabLabel.h" +#include "OpenRGBZonesBulkResizer.h" +#include "OpenRGBThemeManager.h" +#include +#include +#include +#include +#include +#include +#include "OpenRGBFont.h" + +#ifdef __APPLE__ +#include "macutils.h" +#endif using namespace Ui; -OpenRGBDialog::OpenRGBDialog(std::vector& bus, std::vector& control, QWidget *parent) : QMainWindow(parent), busses(bus), controllers (control), ui(new OpenRGBDialogUi) +static int GetIcon(device_type type) +{ + /*-----------------------------------------------------*\ + | Return the icon int value for the given device | + | type value | + \*-----------------------------------------------------*/ + int icon; + + switch(type) + { + case DEVICE_TYPE_ACCESSORY: + icon = OpenRGBFont::usb; + break; + case DEVICE_TYPE_MOTHERBOARD: + icon = OpenRGBFont::mainboard; + break; + case DEVICE_TYPE_DRAM: + icon = OpenRGBFont::dram; + break; + case DEVICE_TYPE_GPU: + icon = OpenRGBFont::gpu; + break; + case DEVICE_TYPE_COOLER: + icon = OpenRGBFont::cooler; + break; + case DEVICE_TYPE_LEDSTRIP: + icon = OpenRGBFont::ledstrip; + break; + case DEVICE_TYPE_KEYBOARD: + icon = OpenRGBFont::keyboard; + break; + case DEVICE_TYPE_MICROPHONE: + icon = OpenRGBFont::mic; + break; + case DEVICE_TYPE_MOUSE: + icon = OpenRGBFont::mouse; + break; + case DEVICE_TYPE_MOUSEMAT: + icon = OpenRGBFont::mousemat; + break; + case DEVICE_TYPE_HEADSET: + icon = OpenRGBFont::headset; + break; + case DEVICE_TYPE_HEADSET_STAND: + icon = OpenRGBFont::headsetstand; + break; + case DEVICE_TYPE_GAMEPAD: + icon = OpenRGBFont::gamepad; + break; + case DEVICE_TYPE_LIGHT: + icon = OpenRGBFont::bulb; + break; + case DEVICE_TYPE_SPEAKER: + icon = OpenRGBFont::music_speaker; + break; + case DEVICE_TYPE_VIRTUAL: + icon = OpenRGBFont::virtual_controller; + break; + case DEVICE_TYPE_STORAGE: + icon = OpenRGBFont::drive; + break; + case DEVICE_TYPE_CASE: + icon = OpenRGBFont::pc_case; + break; + case DEVICE_TYPE_KEYPAD: + icon = OpenRGBFont::keypad; + break; + default: + icon = OpenRGBFont::unknown; + break; + } + + return icon; +} + +static void UpdateDeviceListCallback(void * this_ptr) +{ + OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + + QMetaObject::invokeMethod(this_obj, "onDeviceListUpdated", Qt::QueuedConnection); +} + +static void UpdateDetectionProgressCallback(void * this_ptr) +{ + OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + + QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection); +} + +static void CreatePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin) +{ + OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + + this_obj->AddPlugin(plugin); +} + +static void DeletePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin) +{ + OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + + this_obj->RemovePlugin(plugin); +} + +static void DetectionEndedCallback(void * this_ptr) +{ + OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + + QMetaObject::invokeMethod(this_obj, "onDetectionEnded", Qt::QueuedConnection); +} + +static void DialogShowCallback(void * this_ptr, PLogMessage msg) +{ + OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + + this_obj->SetDialogMessage(msg); + QMetaObject::invokeMethod(this_obj, "onShowDialogMessage", Qt::QueuedConnection); +} + + +bool OpenRGBDialog::IsMinimizeOnClose() +{ + json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface"); + + if(ui_settings.contains("minimize_on_close")) + { + return ui_settings["minimize_on_close"]; + } + + return false; +} + +OpenRGBDialog::OpenRGBDialog(QWidget *parent) : QMainWindow(parent), ui(new OpenRGBDialogUi) { ui->setupUi(this); - QIcon icon(":org.openrgb.OpenRGB.png"); - setWindowIcon(icon); + /*-----------------------------------------------------*\ + | Set window icon | + \*-----------------------------------------------------*/ + QIcon logo(":org.openrgb.OpenRGB.png"); + setWindowIcon(logo); - QPalette pal; + /*-----------------------------------------------------*\ + | Set window geometry from config (if available) | + \*-----------------------------------------------------*/ + SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); + std::string ui_string = "UserInterface"; + json ui_settings; + bool new_settings_keys = false; - pal = ui->ButtonRed->palette(); - pal.setColor(QPalette::Button, QColor(255, 0, 0)); - ui->ButtonRed->setAutoFillBackground(true); - ui->ButtonRed->setPalette(pal); - ui->ButtonRed->setFlat(true); - ui->ButtonRed->update(); + ui_settings = settings_manager->GetSettings(ui_string); - pal = ui->ButtonYellow->palette(); - pal.setColor(QPalette::Button, QColor(255, 255, 0)); - ui->ButtonYellow->setAutoFillBackground(true); - ui->ButtonYellow->setPalette(pal); - ui->ButtonYellow->setFlat(true); - ui->ButtonYellow->update(); - - pal = ui->ButtonGreen->palette(); - pal.setColor(QPalette::Button, QColor(0, 255, 0)); - ui->ButtonGreen->setAutoFillBackground(true); - ui->ButtonGreen->setPalette(pal); - ui->ButtonGreen->setFlat(true); - ui->ButtonGreen->update(); - - pal = ui->ButtonCyan->palette(); - pal.setColor(QPalette::Button, QColor(0, 255, 255)); - ui->ButtonCyan->setAutoFillBackground(true); - ui->ButtonCyan->setPalette(pal); - ui->ButtonCyan->setFlat(true); - ui->ButtonCyan->update(); - - pal = ui->ButtonBlue->palette(); - pal.setColor(QPalette::Button, QColor(0, 0, 255)); - ui->ButtonBlue->setAutoFillBackground(true); - ui->ButtonBlue->setPalette(pal); - ui->ButtonBlue->setFlat(true); - ui->ButtonBlue->update(); - - pal = ui->ButtonMagenta->palette(); - pal.setColor(QPalette::Button, QColor(255, 0, 255)); - ui->ButtonMagenta->setAutoFillBackground(true); - ui->ButtonMagenta->setPalette(pal); - ui->ButtonMagenta->setFlat(true); - ui->ButtonMagenta->update(); - - for (std::size_t i = 0; i < controllers.size(); i++) + if(ui_settings.contains("show_led_view") && ui_settings["show_led_view"]) { - ui->ComboDevices->addItem(controllers[i]->name.c_str()); + ShowLEDView(); } - //Triggers on_ComboDevices_currentIndexChanged so we don't need to update the other fields here - ui->ComboDevices->setCurrentIndex(0); + /*-----------------------------------------------------*\ + | If geometry info doesn't exist, write it to config | + \*-----------------------------------------------------*/ + if(!ui_settings.contains("geometry")) + { + json geometry_settings; + + geometry_settings["load_geometry"] = false; + geometry_settings["save_on_exit"] = false; + geometry_settings["x"] = 0; + geometry_settings["y"] = 0; + geometry_settings["width"] = 0; + geometry_settings["height"] = 0; + + ui_settings["geometry"] = geometry_settings; + new_settings_keys = true; + } + + /*-----------------------------------------------------*\ + | If geometry information exists in settings, apply it | + \*-----------------------------------------------------*/ + bool load_geometry = false; + + if(ui_settings["geometry"].contains("load_geometry")) + { + load_geometry = ui_settings["geometry"]["load_geometry"].get(); + } + + if(load_geometry) + { + QRect set_window; + + /*-----------------------------------------------------*\ + | x and y can be set independent of width and height | + | QT attempts to clamp these values in case the user | + | enters invalid numbers | + \*-----------------------------------------------------*/ + if( ui_settings["geometry"].contains("x") + && ui_settings["geometry"].contains("y")) + { + set_window.setX(ui_settings["geometry"]["x"].get()); + set_window.setY(ui_settings["geometry"]["y"].get()); + } + + if( ui_settings["geometry"].contains("width") + && ui_settings["geometry"].contains("height")) + { + set_window.setWidth(ui_settings["geometry"]["width"].get()); + set_window.setHeight(ui_settings["geometry"]["height"].get()); + } + + setGeometry(set_window); + } + + /*-----------------------------------------------------*\ + | If autoload_profiles doesn't exist or has missing | + | profiles, write it to config | + \*-----------------------------------------------------*/ + json autoload_profiles; + if(ui_settings.contains("autoload_profiles")) + { + autoload_profiles = ui_settings["autoload_profiles"]; + } + else + { + new_settings_keys = true; + } + + if(!autoload_profiles.contains("exit_profile")) + { + json profile; + profile["enabled"] = false; + profile["name"] = ""; + autoload_profiles["exit_profile"] = profile; + new_settings_keys = true; + } + + if(!autoload_profiles.contains("resume_profile")) + { + json profile; + profile["enabled"] = false; + profile["name"] = ""; + autoload_profiles["resume_profile"] = profile; + new_settings_keys = true; + } + + if(!autoload_profiles.contains("suspend_profile")) + { + json profile; + profile["enabled"] = false; + profile["name"] = ""; + autoload_profiles["suspend_profile"] = profile; + new_settings_keys = true; + } + + ui_settings["autoload_profiles"] = autoload_profiles; + + /*-----------------------------------------------------*\ + | Register detection progress callback with resource | + | manager | + \*-----------------------------------------------------*/ + ResourceManager::get()->RegisterDetectionProgressCallback(UpdateDetectionProgressCallback, this); + ResourceManager::get()->RegisterDeviceListChangeCallback(UpdateDeviceListCallback, this); + ResourceManager::get()->RegisterDetectionEndCallback(DetectionEndedCallback, this); + + /*-----------------------------------------------------*\ + | Register dialog show callback with log manager | + \*-----------------------------------------------------*/ + LogManager::get()->RegisterDialogShowCallback(DialogShowCallback, this); + + /*-----------------------------------------------------*\ + | Initialize page pointers | + \*-----------------------------------------------------*/ + ClientInfoPage = NULL; + SMBusToolsPage = NULL; + SoftInfoPage = NULL; + + onDetectionProgressUpdated(); + + ui->DetectionProgressBar->setRange(0, 100); + ui->DetectionProgressBar->setValue(0); + ui->DetectionProgressBar->setTextVisible(true); + ui->DetectionProgressBar->setFormat(""); + ui->DetectionProgressBar->setAlignment(Qt::AlignCenter); + + /*-----------------------------------------------------*\ + | Set up Save Profile button action and menu | + \*-----------------------------------------------------*/ + QMenu* saveProfileMenu = new QMenu(this); + saveProfileMenu->addAction(ui->ActionSaveProfileAs); + + ui->ButtonSaveProfile->setMenu(saveProfileMenu); + ui->ButtonSaveProfile->setDefaultAction(ui->ActionSaveProfile); + + /*-----------------------------------------------------*\ + | Set up tray icon menu | + \*-----------------------------------------------------*/ + trayIconMenu = new QMenu( this ); + + trayIcon = new QSystemTrayIcon(this); + + QAction* actionShowHide = new QAction(tr("Show/Hide"), this); + connect(actionShowHide, SIGNAL(triggered()), this, SLOT(on_ShowHide())); + trayIconMenu->addAction(actionShowHide); + + profileMenu = new QMenu(tr("Profiles"), this); + + trayIconMenu->addMenu(profileMenu); + + QMenu* quickColorsMenu = new QMenu(tr("Quick Colors"), this); + + QAction* actionQuickRed = new QAction(tr("Red"), this); + connect(actionQuickRed, SIGNAL(triggered()), this, SLOT(on_QuickRed())); + quickColorsMenu->addAction(actionQuickRed); + + QAction* actionQuickYellow = new QAction(tr("Yellow"), this); + connect(actionQuickYellow, SIGNAL(triggered()), this, SLOT(on_QuickYellow())); + quickColorsMenu->addAction(actionQuickYellow); + + QAction* actionQuickGreen = new QAction(tr("Green"), this); + connect(actionQuickGreen, SIGNAL(triggered()), this, SLOT(on_QuickGreen())); + quickColorsMenu->addAction(actionQuickGreen); + + QAction* actionQuickCyan = new QAction(tr("Cyan"), this); + connect(actionQuickCyan, SIGNAL(triggered()), this, SLOT(on_QuickCyan())); + quickColorsMenu->addAction(actionQuickCyan); + + QAction* actionQuickBlue = new QAction(tr("Blue"), this); + connect(actionQuickBlue, SIGNAL(triggered()), this, SLOT(on_QuickBlue())); + quickColorsMenu->addAction(actionQuickBlue); + + QAction* actionQuickMagenta = new QAction(tr("Magenta"), this); + connect(actionQuickMagenta, SIGNAL(triggered()), this, SLOT(on_QuickMagenta())); + quickColorsMenu->addAction(actionQuickMagenta); + + QAction* actionQuickWhite = new QAction(tr("White"), this); + connect(actionQuickWhite, SIGNAL(triggered()), this, SLOT(on_QuickWhite())); + quickColorsMenu->addAction(actionQuickWhite); + + trayIconMenu->addMenu(quickColorsMenu); + + QAction* actionLightsOff = new QAction(tr("Lights Off"), this); + actionLightsOff->setObjectName("ActionLightsOff"); + connect(actionLightsOff, SIGNAL(triggered()), this, SLOT(on_LightsOff())); + trayIconMenu->addAction(actionLightsOff); + + actionExit = new QAction(tr("Exit"), this ); + connect( actionExit, SIGNAL( triggered() ), this, SLOT( on_Exit() )); + trayIconMenu->addAction(actionExit); + + /*-------------------------------------------------*\ + | If tray minimize flag isn't in the config, set | + | default value to false | + \*-------------------------------------------------*/ + if(!ui_settings.contains("minimize_on_close")) + { + ui_settings["minimize_on_close"] = false; + new_settings_keys = true; + } + + connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_ReShow(QSystemTrayIcon::ActivationReason))); + + /*-------------------------------------------------*\ + | If Greyscale Tray Icon flag is not set in config | + | then set the default value to false | + \*-------------------------------------------------*/ + if(!ui_settings.contains("greyscale_tray_icon")) + { + ui_settings["greyscale_tray_icon"] = false; + new_settings_keys = true; + } + + /*-----------------------------------------------------*\ + | If greyscale tray icon exists in settings, apply it | + | or else set the icon to the default window logo | + \*-----------------------------------------------------*/ + if(ui_settings.contains("greyscale_tray_icon")) + { + SetTrayIcon(ui_settings["greyscale_tray_icon"].get()); + } + + /*-----------------------------------------------------*\ + | Save the settings if new default values have been | + | inserted | + \*-----------------------------------------------------*/ + if(new_settings_keys) + { + settings_manager->SetSettings(ui_string, ui_settings); + settings_manager->SaveSettings(); + } + + trayIcon->setToolTip("OpenRGB"); + trayIcon->setContextMenu(trayIconMenu); + trayIcon->show(); + + OpenRGBThemeManager::Init(); + + /*-----------------------------------------------------*\ + | Update the profile list | + \*-----------------------------------------------------*/ + UpdateProfileList(); + + /*-----------------------------------------------------*\ + | Update the device list and make sure the | + | ProgressBar gets a proper value | + \*-----------------------------------------------------*/ + UpdateDevicesList(); + + /*-----------------------------------------------------*\ + | Add Client Tab | + \*-----------------------------------------------------*/ + AddClientTab(); + + /*-----------------------------------------------------*\ + | Add Server Tab | + \*-----------------------------------------------------*/ + AddServerTab(); + + /*-----------------------------------------------------*\ + | Add the Software Info page | + \*-----------------------------------------------------*/ + AddSoftwareInfoPage(); + + /*-----------------------------------------------------*\ + | Add the settings page | + \*-----------------------------------------------------*/ + AddSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Supported Devices page | + \*-----------------------------------------------------*/ + AddSupportedDevicesPage(); + + /*-----------------------------------------------------*\ + | Initialize the plugin manager | + \*-----------------------------------------------------*/ + plugin_manager = new PluginManager(); + plugin_manager->RegisterAddPluginCallback(&CreatePluginCallback, this); + plugin_manager->RegisterRemovePluginCallback(&DeletePluginCallback, this); + + /*-----------------------------------------------------*\ + | Add the Plugins page | + \*-----------------------------------------------------*/ + AddPluginsPage(); + + /*-----------------------------------------------------*\ + | Add the DMX settings page | + \*-----------------------------------------------------*/ + AddDMXSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the E1.31 settings page | + \*-----------------------------------------------------*/ + AddE131SettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Kasa Smart settings page | + \*-----------------------------------------------------*/ + AddKasaSmartSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the LIFX settings page | + \*-----------------------------------------------------*/ + AddLIFXSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Serial settings page | + \*-----------------------------------------------------*/ + AddSerialSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the QMK OpenRGB Protocol settings page | + \*-----------------------------------------------------*/ + AddQMKORGBSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Philips Hue settings page | + \*-----------------------------------------------------*/ + AddPhilipsHueSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Philips Wiz settings page | + \*-----------------------------------------------------*/ + AddPhilipsWizSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Yeelight settings page | + \*-----------------------------------------------------*/ + AddYeelightSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the Nanoleaf settings page | + \*-----------------------------------------------------*/ + AddNanoleafSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the ElgatoKeyLight settings page | + \*-----------------------------------------------------*/ + AddElgatoKeyLightSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the ElgatoLightStrip settings page | + \*-----------------------------------------------------*/ + AddElgatoLightStripSettingsPage(); + + /*-----------------------------------------------------*\ + | Add the SMBus Tools page if enabled | + \*-----------------------------------------------------*/ + if(ShowI2CTools) + { + AddI2CToolsPage(); + } + + /*-----------------------------------------------------*\ + | If log console is enabled in settings, enable it | + \*-----------------------------------------------------*/ + json log_manager_settings = settings_manager->GetSettings("LogManager"); + + bool log_console_enabled = false; + if(log_manager_settings.contains("log_console")) + { + log_console_enabled = log_manager_settings["log_console"]; + } + + /*-----------------------------------------------------*\ + | Add the log console page | + \*-----------------------------------------------------*/ + if(log_console_enabled) + { + AddConsolePage(); + } + + /*-----------------------------------------------------*\ + | Connect aboutToQuit signal to handleAboutToQuit | + \*-----------------------------------------------------*/ + connect(qApp, &QCoreApplication::aboutToQuit, this, &OpenRGBDialog::handleAboutToQuit); + } OpenRGBDialog::~OpenRGBDialog() @@ -76,132 +577,1456 @@ OpenRGBDialog::~OpenRGBDialog() delete ui; } -void OpenRGBDialog::show() -{ - QMainWindow::show(); -} -void Ui::OpenRGBDialog::on_ButtonRed_clicked() +void OpenRGBDialog::handleAboutToQuit() { - ui->EditLED0R->setText("255"); - ui->EditLED0G->setText("0"); - ui->EditLED0B->setText("0"); -} + /*-----------------------------------------------------*\ + | Write window geometry to config (if enabled) | + \*-----------------------------------------------------*/ + SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); + std::string ui_string = "UserInterface"; + json ui_settings; -void Ui::OpenRGBDialog::on_ButtonYellow_clicked() -{ - ui->EditLED0R->setText("255"); - ui->EditLED0G->setText("255"); - ui->EditLED0B->setText("0"); -} + ui_settings = settings_manager->GetSettings(ui_string); -void Ui::OpenRGBDialog::on_ButtonGreen_clicked() -{ - ui->EditLED0R->setText("0"); - ui->EditLED0G->setText("255"); - ui->EditLED0B->setText("0"); -} - -void Ui::OpenRGBDialog::on_ButtonCyan_clicked() -{ - ui->EditLED0R->setText("0"); - ui->EditLED0G->setText("255"); - ui->EditLED0B->setText("255"); -} - -void Ui::OpenRGBDialog::on_ButtonBlue_clicked() -{ - ui->EditLED0R->setText("0"); - ui->EditLED0G->setText("0"); - ui->EditLED0B->setText("255"); -} - -void Ui::OpenRGBDialog::on_ButtonMagenta_clicked() -{ - ui->EditLED0R->setText("255"); - ui->EditLED0G->setText("0"); - ui->EditLED0B->setText("255"); -} - -void Ui::OpenRGBDialog::on_ButtonSetAll_clicked() -{ - RGBColor color = ToRGBColor( - ui->EditLED0R->text().toInt(), - ui->EditLED0G->text().toInt(), - ui->EditLED0B->text().toInt() - ); - - for (std::size_t i = 0; i < controllers.size(); i++) + if(ui_settings.contains("geometry")) { - controllers[i]->SetCustomMode(); - controllers[i]->SetAllLEDs(color); + if( ui_settings["geometry"].contains("load_geometry") + && ui_settings["geometry"].contains("save_on_exit")) + { + if( ui_settings["geometry"]["load_geometry"].get() + && ui_settings["geometry"]["save_on_exit"].get()) + { + ui_settings["geometry"]["x"] = geometry().x(); + ui_settings["geometry"]["y"] = geometry().y(); + ui_settings["geometry"]["width"] = geometry().width(); + ui_settings["geometry"]["height"] = geometry().height(); + + settings_manager->SetSettings(ui_string, ui_settings); + settings_manager->SaveSettings(); + } + } + } + + QCloseEvent* closeEvent = new QCloseEvent; + this->closeEvent(closeEvent); + delete closeEvent; +} + + +void OpenRGBDialog::changeEvent(QEvent *event) +{ + if(event->type() == QEvent::LanguageChange) + { + ui->retranslateUi(this); + for(int i = 0; i < ui->MainTabBar->count(); i++) + { + /*-----------------------------------------------------*\ + | if the objectName is either of the SDK tabs | + | then translate tab text (TODO: improve workaround) | + \*-----------------------------------------------------*/ + std::string label = ui->MainTabBar->widget(i)->objectName().toStdString(); + + if(label.substr(0,3) == "SDK") + { + ui->MainTabBar->setTabText(i, tr(label.c_str())); + } + } } } -void Ui::OpenRGBDialog::on_ButtonSetDevice_clicked() +void OpenRGBDialog::closeEvent(QCloseEvent *event) { - RGBColor color = ToRGBColor( - ui->EditLED0R->text().toInt(), - ui->EditLED0G->text().toInt(), - ui->EditLED0B->text().toInt() - ); + ResourceManager::get()->WaitForDeviceDetection(); - controllers[ui->ComboDevices->currentIndex()]->SetAllLEDs(color); -} - -void Ui::OpenRGBDialog::on_ButtonSetZone_clicked() -{ - RGBColor color = ToRGBColor( - ui->EditLED0R->text().toInt(), - ui->EditLED0G->text().toInt(), - ui->EditLED0B->text().toInt() - ); - - controllers[ui->ComboDevices->currentIndex()]->SetAllZoneLEDs(ui->ComboZones->currentIndex(), color); -} - -void Ui::OpenRGBDialog::on_ButtonSetLED_clicked() -{ - RGBColor color = ToRGBColor( - ui->EditLED0R->text().toInt(), - ui->EditLED0G->text().toInt(), - ui->EditLED0B->text().toInt() - ); - - controllers[ui->ComboDevices->currentIndex()]->SetLED(ui->ComboLEDs->currentIndex(), color); -} - -void Ui::OpenRGBDialog::on_ComboDevices_currentIndexChanged() -{ - ui->ComboModes->clear(); - - for (std::size_t i = 0; i < controllers[ui->ComboDevices->currentIndex()]->modes.size(); i++) + if (IsMinimizeOnClose() && !this->isHidden()) { - ui->ComboModes->addItem(controllers[ui->ComboDevices->currentIndex()]->modes[i].name.c_str()); +#ifdef __APPLE__ + MacUtils::ToggleApplicationDocklessState(false); +#endif + hide(); + event->ignore(); + } + else + { + plugin_manager->UnloadPlugins(); + + if(SelectConfigProfile("exit_profile")) + { + on_ButtonLoadProfile_clicked(); + + /*-----------------------------------------------------*\ + | Pause briefly to ensure that all profiles are loaded. | + \*-----------------------------------------------------*/ + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + + event->accept(); + QApplication::exit(0); + } +} + +void OpenRGBDialog::keyPressEvent(QKeyEvent *event) +{ + if(event->key() == Qt::Key_F11) + { + if(isFullScreen()) + { + showNormal(); + } + else + { + showFullScreen(); + } + event->accept(); + } + else + { + QMainWindow::keyPressEvent(event); + } +} + +bool OpenRGBDialog::SelectConfigProfile(const std::string name) +{ + /*-----------------------------------------------------*\ + | Set automatic profile (if enabled and valid) | + \*-----------------------------------------------------*/ + json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface"); + + if(ui_settings.contains("autoload_profiles")) + { + json autoload_profiles = ui_settings["autoload_profiles"]; + if(autoload_profiles.contains(name)) + { + json profile = autoload_profiles[name]; + if (profile.contains("enabled") && profile["enabled"].get() && profile.contains("name")) + { + /*-----------------------------------------------------*\ + | Set the profile name from settings and check the | + | profile combobox for a match | + \*-----------------------------------------------------*/ + std::string profile_name = profile["name"].get(); + int profile_index = ui->ProfileBox->findText(QString::fromStdString(profile_name)); + + if(profile_index > -1) + { + ui->ProfileBox->setCurrentIndex(profile_index); + return true; + } + } + } + } + return false; +} + +void OpenRGBDialog::AddPluginsPage() +{ + /*-----------------------------------------------------*\ + | Create the Plugins page | + \*-----------------------------------------------------*/ + PluginsPage = new OpenRGBPluginsPage(plugin_manager); + + ui->SettingsTabBar->addTab(PluginsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* PluginTabLabel = new TabLabel(OpenRGBFont::extension, tr("Plugins"), (char *)"Plugins", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, PluginTabLabel); +} + +void OpenRGBDialog::AddSoftwareInfoPage() +{ + /*-----------------------------------------------------*\ + | Create the Software Information page | + \*-----------------------------------------------------*/ + SoftInfoPage = new OpenRGBSoftwareInfoPage(); + + ui->InformationTabBar->addTab(SoftInfoPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SoftwareTabLabel = new TabLabel(OpenRGBFont::info, tr("Software"), (char *)"Software", (char *)context); + + ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel); +} + +void OpenRGBDialog::AddSupportedDevicesPage() +{ + /*-----------------------------------------------------*\ + | Create the Supported Devices page | + \*-----------------------------------------------------*/ + SupportedPage = new OpenRGBSupportedDevicesPage(); + + ui->SettingsTabBar->addTab(SupportedPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SupportedTabLabel = new TabLabel(OpenRGBFont::controller, tr("Supported Devices"), (char *)"Supported Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SupportedTabLabel); +} + +void OpenRGBDialog::AddSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + SettingsPage = new OpenRGBSettingsPage(); + + ui->SettingsTabBar->addTab(SettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::options, tr("General Settings"), (char *)"General Settings", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); + + /*-----------------------------------------------------*\ + | Connect signals to slots | + \*-----------------------------------------------------*/ + connect(SettingsPage, SIGNAL(TrayIconChanged(bool)), this, SLOT(SetTrayIcon(bool))); + connect(this, SIGNAL(ProfileListChanged()), SettingsPage, SLOT(UpdateProfiles())); +} + +void OpenRGBDialog::AddDMXSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + DMXSettingsPage = new OpenRGBDMXSettingsPage(); + + ui->SettingsTabBar->addTab(DMXSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::serial, tr("DMX Devices"), (char *)"DMX Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddE131SettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + E131SettingsPage = new OpenRGBE131SettingsPage(); + + ui->SettingsTabBar->addTab(E131SettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::data, tr("E1.31 Devices"), (char *)"E1.31 Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddKasaSmartSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + KasaSmartSettingsPage = new OpenRGBKasaSmartSettingsPage(); + + ui->SettingsTabBar->addTab(KasaSmartSettingsPage, ""); + + QString SettingsLabelString; + + if(OpenRGBThemeManager::IsDarkTheme()) + { + SettingsLabelString = "light_dark.png"; + } + else + { + SettingsLabelString = "light.png"; } - ui->ComboModes->setCurrentIndex(controllers[ui->ComboDevices->currentIndex()]->GetMode()); + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Kasa Smart Devices"), (char *)"Kasa Smart Devices", (char *)context); - ui->ComboZones->clear(); - - for (std::size_t i = 0; i < controllers[ui->ComboDevices->currentIndex()]->zones.size(); i++) - { - ui->ComboZones->addItem(controllers[ui->ComboDevices->currentIndex()]->zones[i].name.c_str()); - } - - ui->ComboZones->setCurrentIndex(0); - - ui->ComboLEDs->clear(); - - for (std::size_t i = 0; i < controllers[ui->ComboDevices->currentIndex()]->leds.size(); i++) - { - ui->ComboLEDs->addItem(controllers[ui->ComboDevices->currentIndex()]->leds[i].name.c_str()); - } - - ui->ComboLEDs->setCurrentIndex(0); + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); } -void Ui::OpenRGBDialog::on_ComboModes_currentIndexChanged() +void OpenRGBDialog::AddLIFXSettingsPage() { - controllers[ui->ComboDevices->currentIndex()]->SetMode(ui->ComboModes->currentIndex()); + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + LIFXSettingsPage = new OpenRGBLIFXSettingsPage(); + + ui->SettingsTabBar->addTab(LIFXSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("LIFX Devices"), (char *)"LIFX Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddPhilipsHueSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + PhilipsHueSettingsPage = new OpenRGBPhilipsHueSettingsPage(); + + ui->SettingsTabBar->addTab(PhilipsHueSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Philips Hue Devices"), (char *)"Philips Hue Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddPhilipsWizSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + PhilipsWizSettingsPage = new OpenRGBPhilipsWizSettingsPage(); + + ui->SettingsTabBar->addTab(PhilipsWizSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Philips Wiz Devices"), (char *)"Philips Wiz Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddQMKORGBSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + QMKORGBSettingsPage = new OpenRGBQMKORGBSettingsPage(); + + ui->SettingsTabBar->addTab(QMKORGBSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::keyboard, tr("OpenRGB QMK Protocol"), (char *)"OpenRGB QMK Protocol", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddSerialSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + SerialSettingsPage = new OpenRGBSerialSettingsPage(); + + ui->SettingsTabBar->addTab(SerialSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SerialSettingsTabLabel = new TabLabel(OpenRGBFont::serial, tr("Serial Devices"), (char *)"Serial Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SerialSettingsTabLabel); +} + +void OpenRGBDialog::AddYeelightSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + YeelightSettingsPage = new OpenRGBYeelightSettingsPage(); + + ui->SettingsTabBar->addTab(YeelightSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Yeelight Devices"), (char *)"Yeelight Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddNanoleafSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + NanoleafSettingsPage = new OpenRGBNanoleafSettingsPage(); + + ui->SettingsTabBar->addTab(NanoleafSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Nanoleaf Devices"), (char *)"Nanoleaf Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddElgatoKeyLightSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + ElgatoKeyLightSettingsPage = new OpenRGBElgatoKeyLightSettingsPage(); + + ui->SettingsTabBar->addTab(ElgatoKeyLightSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Elgato KeyLight Devices"), (char *)"Elgato KeyLight Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddElgatoLightStripSettingsPage() +{ + /*-----------------------------------------------------*\ + | Create the Settings page | + \*-----------------------------------------------------*/ + ElgatoLightStripSettingsPage = new OpenRGBElgatoLightStripSettingsPage(); + + ui->SettingsTabBar->addTab(ElgatoLightStripSettingsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Elgato LightStrip Devices"), (char *)"Elgato LightStrip Devices", (char *)context); + + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); +} + +void OpenRGBDialog::AddPlugin(OpenRGBPluginEntry* plugin) +{ + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* PluginTabLabel = new TabLabel(OpenRGBFont::extension, QString::fromStdString(plugin->info.Label), (char *)plugin->info.Label.c_str(), (char *)context); + + /*-----------------------------------------------------*\ + | Place plugin as its own top level tab | + \*-----------------------------------------------------*/ + if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_TOP) + { + QWidget* NewPluginTab = plugin->plugin->GetWidget(); + + plugin->widget = NewPluginTab; + + OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); + + ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin->info.Label)); + } + /*-----------------------------------------------------*\ + | Place plugin in the Devices tab | + \*-----------------------------------------------------*/ + else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_DEVICES) + { + QWidget* NewPluginTab = plugin->plugin->GetWidget(); + + plugin->widget = NewPluginTab; + + OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); + + ui->DevicesTabBar->addTab(NewPluginContainer," "); + + ui->DevicesTabBar->tabBar()->setTabButton((ui->DevicesTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel); + } + /*-----------------------------------------------------*\ + | Place plugin in the Information tab | + \*-----------------------------------------------------*/ + else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_INFORMATION) + { + QWidget* NewPluginTab = plugin->plugin->GetWidget(); + + plugin->widget = NewPluginTab; + + OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); + + ui->InformationTabBar->addTab(NewPluginContainer," "); + + ui->InformationTabBar->tabBar()->setTabButton((ui->InformationTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel); + } + /*-----------------------------------------------------*\ + | Place plugin in the Settings tab | + \*-----------------------------------------------------*/ + else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_SETTINGS) + { + QWidget* NewPluginTab = plugin->plugin->GetWidget(); + + plugin->widget = NewPluginTab; + + OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); + + ui->SettingsTabBar->addTab(NewPluginContainer," "); + + ui->SettingsTabBar->tabBar()->setTabButton((ui->SettingsTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel); + } + /*-----------------------------------------------------*\ + | Display an error message if the plugin does not | + | specify a valid location | + \*-----------------------------------------------------*/ + else + { + std::cout << ("Cannot load plugin '" + plugin->info.Name + "' as it does not specify a valid location.\n"); + } + + QMenu* NewTrayMenu = plugin->plugin->GetTrayMenu(); + + plugin->traymenu = NewTrayMenu; + + if(NewTrayMenu) + { + trayIconMenu->insertMenu(actionExit, NewTrayMenu); + } +} + +void OpenRGBDialog::RemovePlugin(OpenRGBPluginEntry* plugin) +{ + /*-----------------------------------------------------*\ + | Remove plugin's tray menu | + \*-----------------------------------------------------*/ + if(plugin->traymenu) + { + QWidget* plugin_tray_entry = trayIconMenu->find(plugin->traymenu->winId()); + + if(plugin_tray_entry) + { + trayIconMenu->removeAction(plugin->traymenu->menuAction()); + } + + //delete plugin->traymenu; + } + + /*-----------------------------------------------------*\ + | Find plugin's container | + \*-----------------------------------------------------*/ + QTabWidget *plugin_parent_widget = nullptr; + + switch(plugin->info.Location) + { + case OPENRGB_PLUGIN_LOCATION_TOP: + plugin_parent_widget = ui->MainTabBar; + break; + case OPENRGB_PLUGIN_LOCATION_DEVICES: + plugin_parent_widget = ui->DevicesTabBar; + break; + case OPENRGB_PLUGIN_LOCATION_INFORMATION: + plugin_parent_widget = ui->InformationTabBar; + break; + case OPENRGB_PLUGIN_LOCATION_SETTINGS: + plugin_parent_widget = ui->InformationTabBar; + break; + default: + break; + } + + /*-----------------------------------------------------*\ + | Remove plugin from its container | + \*-----------------------------------------------------*/ + if(plugin_parent_widget != nullptr) + { + for(int tab_idx = 0; tab_idx < plugin_parent_widget->count(); tab_idx++) + { + if(dynamic_cast(plugin_parent_widget->widget(tab_idx)) != nullptr) + { + if(dynamic_cast(plugin_parent_widget->widget(tab_idx))->plugin_widget == plugin->widget) + { + plugin_parent_widget->removeTab(tab_idx); + //delete plugin->widget; + break; + } + } + } + } +} + +void OpenRGBDialog::AddI2CToolsPage() +{ + ShowI2CTools = true; + + /*-----------------------------------------------------*\ + | Create the I2C Tools page if it doesn't exist yet | + \*-----------------------------------------------------*/ + SMBusToolsPage = new OpenRGBSystemInfoPage(ResourceManager::get()->GetI2CBusses()); + + /*-----------------------------------------------------*\ + | Create the I2C Tools tab in the Information bar | + \*-----------------------------------------------------*/ + ui->InformationTabBar->addTab(SMBusToolsPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SMBusToolsTabLabel = new TabLabel(OpenRGBFont::toolbox, tr("SMBus Tools"), (char *)"SMBus Tools", (char *)context); + + ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel); +} + +void OpenRGBDialog::AddClientTab() +{ + /*-----------------------------------------------------*\ + | Add client information tab if it doesn't exist yet | + \*-----------------------------------------------------*/ + if(ClientInfoPage == NULL) + { + ClientInfoPage = new OpenRGBClientInfoPage(); + ClientInfoPage->setObjectName(QString("SDK Client")); + ui->MainTabBar->insertTab(2, ClientInfoPage, tr("SDK Client")); + } +} + +void OpenRGBDialog::AddClient(NetworkClient* new_client) +{ + /*-----------------------------------------------------*\ + | Add a client to the client information page | + \*-----------------------------------------------------*/ + if(ClientInfoPage != NULL) + { + ClientInfoPage->AddClient(new_client); + } +} + +void OpenRGBDialog::AddServerTab() +{ + /*-----------------------------------------------------*\ + | Add server information tab if there is a server | + \*-----------------------------------------------------*/ + OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(ResourceManager::get()->GetServer()); + ServerInfoPage->setObjectName(QString("SDK Server")); + ui->MainTabBar->insertTab(2, ServerInfoPage, tr("SDK Server")); +} + +void OpenRGBDialog::ClearDevicesList() +{ + for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++) + { + if(dynamic_cast(ui->DevicesTabBar->widget(tab_idx)) == nullptr) + { + delete ui->DevicesTabBar->widget(tab_idx); + ui->DevicesTabBar->removeTab(tab_idx); + } + } + + for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++) + { + if(dynamic_cast(ui->InformationTabBar->widget(tab_idx)) == nullptr) + { + delete ui->InformationTabBar->widget(tab_idx); + ui->InformationTabBar->removeTab(tab_idx); + } + } +} + +void OpenRGBDialog::UpdateDevicesList() +{ + std::vector controllers = ResourceManager::get()->GetRGBControllers(); + + /*-----------------------------------------------------*\ + | Loop through each controller in the list. | + \*-----------------------------------------------------*/ + for(unsigned int controller_idx = 0; controller_idx < controllers.size(); controller_idx++) + { + /*-----------------------------------------------------*\ + | Loop through each tab in the devices tab bar | + \*-----------------------------------------------------*/ + bool found = false; + + for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++) + { + QWidget* page = ui->DevicesTabBar->widget(tab_idx); + + if(dynamic_cast(page) != nullptr) + { + /*-----------------------------------------------------*\ + | If the current tab matches the current controller, | + | move the tab to the correct position | + \*-----------------------------------------------------*/ + if(controllers[controller_idx] == ((OpenRGBDevicePage*)page)->GetController()) + { + found = true; + ui->DevicesTabBar->tabBar()->moveTab(tab_idx, controller_idx); + break; + } + } + } + + if(!found) + { + /*-----------------------------------------------------*\ + | The controller does not have a tab already created | + | Create a new tab and move it to the correct position | + \*-----------------------------------------------------*/ + OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(controllers[controller_idx]); + ui->DevicesTabBar->addTab(NewPage, ""); + + /*-----------------------------------------------------*\ + | Connect the page's Set All button to the Set All slot | + \*-----------------------------------------------------*/ + connect(NewPage, + SIGNAL(SetAllDevices(unsigned char, unsigned char, unsigned char)), + this, + SLOT(on_SetAllDevices(unsigned char, unsigned char, unsigned char))); + + /*-----------------------------------------------------*\ + | Connect the page's Resize signal to the Save Size slot| + \*-----------------------------------------------------*/ + connect(NewPage, + SIGNAL(SaveSizeProfile()), + this, + SLOT(on_SaveSizeProfile())); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* NewTabLabel = new TabLabel(GetIcon(controllers[controller_idx]->type), QString::fromStdString(controllers[controller_idx]->name), (char *)controllers[controller_idx]->name.c_str(), (char *)context); + + ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); + ui->DevicesTabBar->tabBar()->setTabToolTip(ui->DevicesTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name)); + + /*-----------------------------------------------------*\ + | Now move the new tab to the correct position | + \*-----------------------------------------------------*/ + ui->DevicesTabBar->tabBar()->moveTab(ui->DevicesTabBar->count() - 1, controller_idx); + } + + /*-----------------------------------------------------*\ + | Loop through each tab in the information tab bar | + \*-----------------------------------------------------*/ + found = false; + + for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++) + { + /*-----------------------------------------------------*\ + | If type is a device info page, check it | + \*-----------------------------------------------------*/ + std::string type_str = ui->InformationTabBar->widget(tab_idx)->metaObject()->className(); + if(type_str == "Ui::OpenRGBDeviceInfoPage") + { + OpenRGBDeviceInfoPage* page = (OpenRGBDeviceInfoPage*) ui->InformationTabBar->widget(tab_idx); + + /*-----------------------------------------------------*\ + | If the current tab matches the current controller, | + | move the tab to the correct position | + \*-----------------------------------------------------*/ + if(controllers[controller_idx] == page->GetController()) + { + found = true; + ui->InformationTabBar->tabBar()->moveTab(tab_idx, controller_idx); + break; + } + } + } + + if(!found) + { + /*-----------------------------------------------------*\ + | The controller does not have a tab already created | + | Create a new tab and move it to the correct position | + \*-----------------------------------------------------*/ + OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(controllers[controller_idx]); + ui->InformationTabBar->addTab(NewPage, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* NewTabLabel = new TabLabel(GetIcon(controllers[controller_idx]->type), QString::fromStdString(controllers[controller_idx]->name), (char *)controllers[controller_idx]->name.c_str(), (char *)context); + + ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); + ui->InformationTabBar->tabBar()->setTabToolTip(ui->InformationTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name)); + + /*-----------------------------------------------------*\ + | Now move the new tab to the correct position | + \*-----------------------------------------------------*/ + ui->InformationTabBar->tabBar()->moveTab(ui->InformationTabBar->count() - 1, controller_idx); + } + } + + /*-----------------------------------------------------*\ + | Remove all remaining device tabs | + \*-----------------------------------------------------*/ + unsigned int tab_count = ui->DevicesTabBar->count(); + unsigned int base_tab = (unsigned int)controllers.size(); + + for(std::size_t tab_idx = controllers.size(); tab_idx < tab_count; tab_idx++) + { + QWidget* tab_widget = ui->DevicesTabBar->widget(base_tab); + + if(dynamic_cast(tab_widget) == nullptr) + { + ui->DevicesTabBar->removeTab(base_tab); + delete tab_widget; + } + } + + bool found = true; + + while(found) + { + found = false; + + /*-----------------------------------------------------*\ + | Remove all remaining device information tabs, leaving | + | other information tabs alone | + \*-----------------------------------------------------*/ + for(std::size_t tab_idx = controllers.size(); tab_idx < ui->InformationTabBar->count(); tab_idx++) + { + std::string type_str = ui->InformationTabBar->widget(base_tab)->metaObject()->className(); + if(type_str == "Ui::OpenRGBDeviceInfoPage") + { + found = true; + QWidget* tab_widget = ui->InformationTabBar->widget(base_tab); + + ui->InformationTabBar->removeTab(base_tab); + + delete tab_widget; + break; + } + base_tab += 1; + } + } + + if(device_view_showing) + { + ShowLEDView(); + } +} + +void OpenRGBDialog::SetDialogMessage(PLogMessage msg) +{ + dialog_message = QString::fromStdString(msg->buffer); +} + +void OpenRGBDialog::UpdateProfileList() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + /*-----------------------------------------------------*\ + | Clear profile combo box and tray icon menu | + \*-----------------------------------------------------*/ + ui->ProfileBox->clear(); + profileMenu->clear(); + + for(std::size_t profile_index = 0; profile_index < profile_manager->profile_list.size(); profile_index++) + { + /*-----------------------------------------------------*\ + | Fill in profile combo box | + \*-----------------------------------------------------*/ + ui->ProfileBox->addItem(profile_manager->profile_list[profile_index].c_str()); + + /*-----------------------------------------------------*\ + | Fill in profile tray icon menu | + \*-----------------------------------------------------*/ + QAction* actionProfileSelected = new QAction(profile_manager->profile_list[profile_index].c_str(), this); + actionProfileSelected->setObjectName(profile_manager->profile_list[profile_index].c_str()); + connect(actionProfileSelected, SIGNAL(triggered()), this, SLOT(on_ProfileSelected())); + profileMenu->addAction(actionProfileSelected); + } + } + + emit ProfileListChanged(); +} + +void OpenRGBDialog::OnSuspend() +{ + if(SelectConfigProfile("suspend_profile")) + { + plugin_manager->UnloadPlugins(); + on_ButtonLoadProfile_clicked(); + } +} + +void OpenRGBDialog::OnResume() +{ + if(SelectConfigProfile("resume_profile")) + { + on_ButtonLoadProfile_clicked(); + } + plugin_manager->LoadPlugins(); +} + +void OpenRGBDialog::on_Exit() +{ + /*-----------------------------------------------*\ + | This is the exit from the tray icon | + | NOT the main exit button (top right on Windows) | + | | + | The hide is important, otherwise it won't close | + | when minimize on close is enabled | + \*-----------------------------------------------*/ + this->hide(); + trayIcon->hide(); + close(); +} + +void OpenRGBDialog::on_LightsOff() +{ + on_SetAllDevices(0x00, 0x00, 0x00); +} + +void OpenRGBDialog::on_QuickRed() +{ + on_SetAllDevices(0xFF, 0x00, 0x00); +} + +void OpenRGBDialog::on_QuickYellow() +{ + on_SetAllDevices(0xFF, 0xFF, 0x00); +} + +void OpenRGBDialog::on_QuickGreen() +{ + on_SetAllDevices(0x00, 0xFF, 0x00); +} + +void OpenRGBDialog::on_QuickCyan() +{ + on_SetAllDevices(0x00, 0xFF, 0xFF); +} + +void OpenRGBDialog::on_QuickBlue() +{ + on_SetAllDevices(0x00, 0x00, 0xFF); +} + +void OpenRGBDialog::on_QuickMagenta() +{ + on_SetAllDevices(0xFF, 0x00, 0xFF); +} + +void OpenRGBDialog::on_QuickWhite() +{ + on_SetAllDevices(0xFF, 0xFF, 0xFF); +} + +void OpenRGBDialog::onDeviceListUpdated() +{ + UpdateDevicesList(); +} + +void OpenRGBDialog::onDetectionProgressUpdated() +{ + ui->DetectionProgressBar->setValue(ResourceManager::get()->GetDetectionPercent()); + ui->DetectionProgressBar->setFormat(QString::fromStdString(ResourceManager::get()->GetDetectionString())); + + if(ResourceManager::get()->GetDetectionPercent() == 100) + { + SetDetectionViewState(false); + } + else + { + SetDetectionViewState(true); + } +} + +void OpenRGBDialog::onDetectionEnded() +{ + /*-------------------------------------------------------*\ + | Detect unconfigured zones and prompt for resizing | + \*-------------------------------------------------------*/ + OpenRGBZonesBulkResizer::RunChecks(this); + + /*-------------------------------------------------------*\ + | Load plugins after the first detection (ONLY the first) | + \*-------------------------------------------------------*/ + if(!plugins_loaded) + { + plugin_manager->ScanAndLoadPlugins(); + plugins_loaded = true; + PluginsPage->RefreshList(); + } + + if(device_view_showing) + { + ShowLEDView(); + } +} + +void OpenRGBDialog::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue) +{ + for(int device = 0; device < ui->DevicesTabBar->count(); device++) + { + qobject_cast(ui->DevicesTabBar->widget(device))->SetCustomMode(red, green, blue); + } +} + +void OpenRGBDialog::on_SaveSizeProfile() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + /*---------------------------------------------------------*\ + | Save the profile | + \*---------------------------------------------------------*/ + profile_manager->SaveProfile("sizes", true); + } +} + +void OpenRGBDialog::on_ShowHide() +{ + if(isHidden()) + { +#ifdef __APPLE__ + MacUtils::ToggleApplicationDocklessState(true); +#endif + show(); + if(isMinimized()) + { + bool maximize = isMaximized(); + showNormal(); + if(maximize) + { + showMaximized(); + } + } + } + else + { +#ifdef __APPLE__ + MacUtils::ToggleApplicationDocklessState(false); +#endif + hide(); + } +} + +void OpenRGBDialog::onShowDialogMessage() +{ + std::size_t hash = std::hash{}(dialog_message.toStdString()); + + /*-----------------------------------------------------*\ + | Load the LogManager settings and check if the hash of | + | this message is in the no-show list | + \*-----------------------------------------------------*/ + SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); + std::string log_manager_string = "LogManager"; + json log_manager_settings; + + log_manager_settings = settings_manager->GetSettings(log_manager_string); + + /*-----------------------------------------------------*\ + | If in the no-show list, clear the message string and | + | return without displaying message box | + \*-----------------------------------------------------*/ + if(log_manager_settings.contains("dialog_no_show_hashes")) + { + for(unsigned int list_idx = 0; list_idx < log_manager_settings["dialog_no_show_hashes"].size(); list_idx++) + { + if(log_manager_settings["dialog_no_show_hashes"][list_idx] == hash) + { + dialog_message.clear(); + return; + } + } + } + + QMessageBox box; + + box.setInformativeText(dialog_message); + + QCheckBox* CheckBox_DontShowAgain = new QCheckBox("Don't show this message again"); + + DontShowAgain = false; + + QObject::connect(CheckBox_DontShowAgain, &QCheckBox::stateChanged, [this](int state) + { + if(static_cast(state) == Qt::CheckState::Checked) + { + this->DontShowAgain = true; + } + }); + + box.setCheckBox(CheckBox_DontShowAgain); + box.setTextFormat(Qt::RichText); + box.setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextBrowserInteraction); + + box.exec(); + + if(DontShowAgain) + { + /*-----------------------------------------------------*\ + | Add hash of dialog text to no-show list in LogManager | + | settings | + \*-----------------------------------------------------*/ + log_manager_settings["dialog_no_show_hashes"].push_back(hash); + + settings_manager->SetSettings(log_manager_string, log_manager_settings); + settings_manager->SaveSettings(); + } + + DontShowAgain = false; + + dialog_message.clear(); +} + +void OpenRGBDialog::on_ReShow(QSystemTrayIcon::ActivationReason reason) +{ + if (reason == QSystemTrayIcon::DoubleClick) + { + if (isHidden()) + { + show(); + if(isMinimized()) + { + bool maximize = isMaximized(); + showNormal(); + if(maximize) + { + showMaximized(); + } + } + } + } +} + +void Ui::OpenRGBDialog::on_ProfileSelected() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + /*---------------------------------------------------------*\ + | Get the profile filename from the selected object | + \*---------------------------------------------------------*/ + std::string profile_name = QObject::sender()->objectName().toStdString(); + + /*---------------------------------------------------------*\ + | Load the profile | + \*---------------------------------------------------------*/ + if(profile_manager->LoadProfile(profile_name)) + { + for(int device = 0; device < ui->DevicesTabBar->count(); device++) + { + qobject_cast(ui->DevicesTabBar->widget(device))->UpdateDevice(); + } + } + + ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name))); + } +} + +void Ui::OpenRGBDialog::on_ButtonLoadProfile_clicked() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + /*---------------------------------------------------------*\ + | Get the profile filename from the profiles list | + \*---------------------------------------------------------*/ + std::string profile_name = ui->ProfileBox->currentText().toStdString(); + + /*---------------------------------------------------------*\ + | Load the profile | + \*---------------------------------------------------------*/ + if(profile_manager->LoadProfile(profile_name)) + { + for(int device = 0; device < ui->DevicesTabBar->count(); device++) + { + qobject_cast(ui->DevicesTabBar->widget(device))->UpdateDevice(); + } + } + } +} + +void Ui::OpenRGBDialog::on_ButtonDeleteProfile_clicked() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + /*---------------------------------------------------------*\ + | Get the profile filename from the profiles list | + \*---------------------------------------------------------*/ + std::string profile_name = ui->ProfileBox->currentText().toStdString(); + + /*---------------------------------------------------------*\ + | Confirm we want to delete the profile | + \*---------------------------------------------------------*/ + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, tr("Delete Profile"), tr("Do you really want to delete this profile?"), QMessageBox::Yes|QMessageBox::No); + + /*---------------------------------------------------------*\ + | Load the profile | + \*---------------------------------------------------------*/ + if(reply == QMessageBox::Yes) + { + profile_manager->DeleteProfile(profile_name); + + UpdateProfileList(); + } + } +} + +void Ui::OpenRGBDialog::on_ButtonToggleDeviceView_clicked() +{ + if(device_view_showing) + { + HideLEDView(); + } + else + { + ShowLEDView(); + } +} + +void Ui::OpenRGBDialog::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::OpenRGBDialog::HideLEDView() +{ + for(int device = 0; device < ui->DevicesTabBar->count(); device++) + { + qobject_cast(ui->DevicesTabBar->widget(device))->HideDeviceView(); + } + device_view_showing = false; +} + + +void Ui::OpenRGBDialog::on_ButtonStopDetection_clicked() +{ + /*---------------------------------------------------------*\ + | Notify the detection thread that it has to die | + \*---------------------------------------------------------*/ + ResourceManager::get()->StopDeviceDetection(); + + /*---------------------------------------------------------*\ + | Pretend we're done already by hiding the progress bar | + \*---------------------------------------------------------*/ + SetDetectionViewState(false); +} + +void Ui::OpenRGBDialog::SetDetectionViewState(bool detection_showing) +{ + if(detection_showing) + { + /*---------------------------------------------------------*\ + | Show the detection progress and hide the normal buttons | + \*---------------------------------------------------------*/ + ui->ButtonToggleDeviceView->setVisible(false); + ui->ButtonRescan->setVisible(false); + ui->ButtonLoadProfile->setVisible(false); + ui->ButtonSaveProfile->setVisible(false); + ui->ButtonDeleteProfile->setVisible(false); + ui->ProfileBox->setVisible(false); + + ui->DetectionProgressBar->setVisible(true); + ui->DetectionProgressLabel->setVisible(true); + ui->ButtonStopDetection->setVisible(true); + } + else + { + /*---------------------------------------------------------*\ + | Hide the detection progress and show the normal buttons | + \*---------------------------------------------------------*/ + ui->DetectionProgressBar->setVisible(false); + ui->DetectionProgressLabel->setVisible(false); + ui->ButtonStopDetection->setVisible(false); + + ui->ButtonToggleDeviceView->setVisible(true); + ui->ButtonRescan->setVisible(true); + ui->ButtonLoadProfile->setVisible(true); + ui->ButtonSaveProfile->setVisible(true); + ui->ButtonDeleteProfile->setVisible(true); + ui->ProfileBox->setVisible(true); + } +} + +void OpenRGBDialog::SetTrayIcon(bool tray_icon) +{ + if(tray_icon) + { + trayIcon->setIcon(QIcon(":OpenRGBGreyscale.png")); + } + else + { + trayIcon->setIcon(QIcon(":org.openrgb.OpenRGB.png")); + } +} + +void OpenRGBDialog::SaveProfile() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + /*---------------------------------------------------------*\ + | Get the profile filename from the profiles list | + \*---------------------------------------------------------*/ + std::string filename = ui->ProfileBox->currentText().toStdString(); + + /*---------------------------------------------------------*\ + | Save the profile | + \*---------------------------------------------------------*/ + profile_manager->SaveProfile(filename); + } +} + +void OpenRGBDialog::SaveProfileAs() +{ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + OpenRGBProfileSaveDialog dialog; + + /*---------------------------------------------------------*\ + | Open Profile Name Dialog | + \*---------------------------------------------------------*/ + std::string profile_name = dialog.show(); + + if(!profile_name.empty()) + { + /*---------------------------------------------------------*\ + | Extension .orp - OpenRgb Profile | + \*---------------------------------------------------------*/ + std::string filename = profile_name; + + /*---------------------------------------------------------*\ + | Save the profile | + \*---------------------------------------------------------*/ + if(profile_manager->SaveProfile(filename)) + { + UpdateProfileList(); + + ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name))); + } + } + } +} + +void Ui::OpenRGBDialog::on_ButtonRescan_clicked() +{ + /*---------------------------------------------------------*\ + | Hide devices view on rescan so it stops handling paint | + | events. | + | Memorize previous value of device_view_showing and | + | restore it. | + \*---------------------------------------------------------*/ + bool device_view_showing_prev = device_view_showing; + + HideLEDView(); + + device_view_showing = device_view_showing_prev; + + /*---------------------------------------------------------*\ + | Show the detection progress bar. | + \*---------------------------------------------------------*/ + SetDetectionViewState(true); + + /*---------------------------------------------------------*\ + | Show the detection progress bar. | + \*---------------------------------------------------------*/ + ResourceManager::get()->DetectDevices(); +} + +void Ui::OpenRGBDialog::on_ActionSaveProfile_triggered() +{ + if(ui->ProfileBox->currentIndex() >= 0) + { + SaveProfile(); + } + else + { + SaveProfileAs(); + } +} + +void Ui::OpenRGBDialog::on_ActionSaveProfileAs_triggered() +{ + SaveProfileAs(); +} + + +void Ui::OpenRGBDialog::on_InformationTabBar_currentChanged(int tab_idx) +{ + TogglePluginsVisibility(tab_idx, ui->InformationTabBar); +} + +void Ui::OpenRGBDialog::on_DevicesTabBar_currentChanged(int tab_idx) +{ + TogglePluginsVisibility(tab_idx, ui->DevicesTabBar); +} + +void Ui::OpenRGBDialog::on_MainTabBar_currentChanged(int tab_idx) +{ + TogglePluginsVisibility(tab_idx, ui->MainTabBar); +} + +void Ui::OpenRGBDialog::on_SettingsTabBar_currentChanged(int tab_idx) +{ + TogglePluginsVisibility(tab_idx, ui->SettingsTabBar); +} + +void Ui::OpenRGBDialog::TogglePluginsVisibility(int tab_idx, QTabWidget* tabBar) +{ + /*---------------------------------------------------------*\ + | Hide all plugins | + \*---------------------------------------------------------*/ + for(int i = 0; i < (tabBar->count()); i++) + { + QWidget* tab = tabBar->widget(i); + + /*-----------------------------------------------------*\ + | Dynamic cast is essential in this check to ensure the | + | tab is actually a plugin container | + \*-----------------------------------------------------*/ + if((i != tab_idx) && (dynamic_cast(tab) != nullptr)) + { + ((OpenRGBPluginContainer*) tab)->Hide(); + ui->MainButtonsFrame->setVisible(true); + } + } + + /*---------------------------------------------------------*\ + | Show plugin if needed | + \*---------------------------------------------------------*/ + QWidget* tab = tabBar->widget(tab_idx); + + /*---------------------------------------------------------*\ + | Dynamic cast is essential in this check to ensure the tab | + | is actually a plugin container | + \*---------------------------------------------------------*/ + if(dynamic_cast(tab) != nullptr) + { + ((OpenRGBPluginContainer*) tab)->Show(); + ui->MainButtonsFrame->setVisible(false); + } +} + +void Ui::OpenRGBDialog::AddConsolePage() +{ + OpenRGBConsolePage* page = new OpenRGBConsolePage(); + + ui->InformationTabBar->addTab(page, ""); + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* ConsoleTabLabel = new TabLabel(OpenRGBFont::terminal, tr("Log Console"), (char *)"Log Console", (char *)context); + + ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, ConsoleTabLabel); } diff --git a/qt/OpenRGBDialog/OpenRGBDialog.h b/qt/OpenRGBDialog/OpenRGBDialog.h index f65335c7..cfaa1bb5 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.h +++ b/qt/OpenRGBDialog/OpenRGBDialog.h @@ -9,55 +9,195 @@ #pragma once +#include #include #include #include #include #include +#include + #include "ui_OpenRGBDialog.h" + +#include "OpenRGBClientInfoPage.h" +#include "OpenRGBPluginsPage/OpenRGBPluginsPage.h" +#include "OpenRGBSoftwareInfoPage.h" +#include "OpenRGBSystemInfoPage.h" +#include "OpenRGBSupportedDevicesPage.h" +#include "OpenRGBSettingsPage.h" +#include "OpenRGBDMXSettingsPage/OpenRGBDMXSettingsPage.h" +#include "OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h" +#include "OpenRGBElgatoKeyLightSettingsPage/OpenRGBElgatoKeyLightSettingsPage.h" +#include "OpenRGBElgatoLightStripSettingsPage/OpenRGBElgatoLightStripSettingsPage.h" +#include "OpenRGBKasaSmartSettingsPage/OpenRGBKasaSmartSettingsPage.h" +#include "OpenRGBLIFXSettingsPage/OpenRGBLIFXSettingsPage.h" +#include "OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsPage.h" +#include "OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.h" +#include "OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h" +#include "OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h" +#include "OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsPage.h" +#include "OpenRGBNanoleafSettingsPage/OpenRGBNanoleafSettingsPage.h" +#include "PluginManager.h" +#include "SuspendResume.h" + #include "i2c_smbus.h" +#include "LogManager.h" #include "RGBController.h" +#include "ProfileManager.h" +#include "NetworkClient.h" +#include "NetworkServer.h" namespace Ui { class OpenRGBDialog; } -class Ui::OpenRGBDialog : public QMainWindow +class Ui::OpenRGBDialog : public QMainWindow, private SuspendResumeListener { Q_OBJECT public: - explicit OpenRGBDialog(std::vector& bus, std::vector& control, QWidget *parent = 0); + explicit OpenRGBDialog(QWidget *parent = 0); ~OpenRGBDialog(); - void show(); + void AddClient(NetworkClient* new_client); + void AddClientTab(); + void AddI2CToolsPage(); + void AddServerTab(); + + void AddPlugin(OpenRGBPluginEntry* plugin); + void RemovePlugin(OpenRGBPluginEntry* plugin); + void setMode(unsigned char mode_val); + static bool IsMinimizeOnClose(); + + void SetDialogMessage(PLogMessage msg); + + bool DontShowAgain; + +signals: + void ProfileListChanged(); + +public slots: + void changeEvent(QEvent *event); + void SetTrayIcon(bool tray_icon); + void handleAboutToQuit(); + protected: - std::vector& busses; - std::vector& controllers; - -private slots: - void on_ButtonRed_clicked(); - void on_ButtonYellow_clicked(); - void on_ButtonGreen_clicked(); - void on_ButtonCyan_clicked(); - void on_ButtonBlue_clicked(); - void on_ButtonMagenta_clicked(); - - void on_ButtonSetAll_clicked(); - - void on_ButtonSetDevice_clicked(); - - void on_ButtonSetZone_clicked(); - - void on_ButtonSetLED_clicked(); - - void on_ComboDevices_currentIndexChanged(); - - void on_ComboModes_currentIndexChanged(); + void keyPressEvent(QKeyEvent *event) override; private: + const char* context = "Ui::OpenRGBDialog"; + + /*-------------------------------------*\ + | Page pointers | + \*-------------------------------------*/ + OpenRGBClientInfoPage *ClientInfoPage; + OpenRGBPluginsPage *PluginsPage; + OpenRGBSystemInfoPage *SMBusToolsPage; + OpenRGBSoftwareInfoPage *SoftInfoPage; + OpenRGBSupportedDevicesPage *SupportedPage; + OpenRGBSettingsPage *SettingsPage; + OpenRGBDMXSettingsPage *DMXSettingsPage; + OpenRGBE131SettingsPage *E131SettingsPage; + OpenRGBElgatoKeyLightSettingsPage *ElgatoKeyLightSettingsPage; + OpenRGBElgatoLightStripSettingsPage *ElgatoLightStripSettingsPage; + OpenRGBKasaSmartSettingsPage *KasaSmartSettingsPage; + OpenRGBLIFXSettingsPage *LIFXSettingsPage; + OpenRGBPhilipsHueSettingsPage *PhilipsHueSettingsPage; + OpenRGBPhilipsWizSettingsPage *PhilipsWizSettingsPage; + OpenRGBQMKORGBSettingsPage *QMKORGBSettingsPage; + OpenRGBSerialSettingsPage *SerialSettingsPage; + OpenRGBYeelightSettingsPage *YeelightSettingsPage; + OpenRGBNanoleafSettingsPage *NanoleafSettingsPage; + + bool ShowI2CTools = false; + bool plugins_loaded = false; + + /*-------------------------------------*\ + | System tray icon and menu | + \*-------------------------------------*/ + QSystemTrayIcon* trayIcon; + QMenu* trayIconMenu; + QMenu* profileMenu; + + /*-------------------------------------*\ + | User interface | + \*-------------------------------------*/ Ui::OpenRGBDialogUi *ui; + + void AddSoftwareInfoPage(); + void AddSupportedDevicesPage(); + void AddSettingsPage(); + void AddDMXSettingsPage(); + void AddE131SettingsPage(); + void AddElgatoKeyLightSettingsPage(); + void AddElgatoLightStripSettingsPage(); + void AddKasaSmartSettingsPage(); + void AddLIFXSettingsPage(); + void AddPhilipsHueSettingsPage(); + void AddPhilipsWizSettingsPage(); + void AddQMKORGBSettingsPage(); + void AddSerialSettingsPage(); + void AddYeelightSettingsPage(); + void AddNanoleafSettingsPage(); + void AddPluginsPage(); + void AddConsolePage(); + + void ClearDevicesList(); + void UpdateDevicesList(); + void UpdateProfileList(); + void closeEvent(QCloseEvent *event); + bool SelectConfigProfile(const std::string name); + + void SetDetectionViewState(bool detection_showing); + void SaveProfile(); + void SaveProfileAs(); + + void TogglePluginsVisibility(int, QTabWidget*); + + bool device_view_showing = false; + + PluginManager* plugin_manager = nullptr; + + QAction* actionExit; + QString dialog_message; + + void ShowLEDView(); + void HideLEDView(); + + void OnSuspend(); + void OnResume(); + +private slots: + void on_Exit(); + void on_LightsOff(); + void on_QuickRed(); + void on_QuickYellow(); + void on_QuickGreen(); + void on_QuickCyan(); + void on_QuickBlue(); + void on_QuickMagenta(); + void on_QuickWhite(); + void onDeviceListUpdated(); + void onDetectionProgressUpdated(); + void onDetectionEnded(); + void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue); + void on_SaveSizeProfile(); + void on_ShowHide(); + void onShowDialogMessage(); + void on_ReShow(QSystemTrayIcon::ActivationReason reason); + void on_ProfileSelected(); + void on_ButtonLoadProfile_clicked(); + void on_ButtonDeleteProfile_clicked(); + void on_ButtonToggleDeviceView_clicked(); + void on_ButtonStopDetection_clicked(); + void on_ButtonRescan_clicked(); + void on_ActionSaveProfile_triggered(); + void on_ActionSaveProfileAs_triggered(); + void on_MainTabBar_currentChanged(int); + void on_InformationTabBar_currentChanged(int); + void on_DevicesTabBar_currentChanged(int); + void on_SettingsTabBar_currentChanged(int); }; diff --git a/qt/OpenRGBDialog/OpenRGBDialog.ui b/qt/OpenRGBDialog/OpenRGBDialog.ui index 86826057..b37168e7 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.ui +++ b/qt/OpenRGBDialog/OpenRGBDialog.ui @@ -6,8 +6,8 @@ 0 0 - 500 - 160 + 700 + 350 @@ -15,148 +15,191 @@ - - - - + + + + QTabWidget::Rounded + + 0 + + + + 20 + 20 + + + + + Devices + + + + + + QTabWidget::West + + + + + + + + Information + + + + + + QTabWidget::West + + + -1 + + + + + + + + Settings + + + + + + QTabWidget::West + + + -1 + + + + + - - - - - - + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Toggle LED View + + + + + + + Rescan Devices + + + + + + + + 0 + 0 + + + + Save Profile + + + QToolButton::MenuButtonPopup + + + + + + + Delete Profile + + + + + + + Load Profile + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Device - - - - - - - - - - Red - - - - - - - Green - - - - - - - Blue - - - - - - - Mode - - - - - - - - - - - - - - - - - - - Set All - - - - - - - Set Device - - - - - - - Zone - - - - - - - - - - Set Zone - - - - - - - Set LED - - - - - - - LED - - - - - + + + + + + OpenRGB is detecting devices... + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 24 + + + + + + + Cancel + + + + + + + Save Profile + + + Save Profile + + + + + Save Profile As... + + + Save Profile with custom name + + diff --git a/qt/OpenRGBDialog2/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2/OpenRGBDialog2.cpp deleted file mode 100644 index c9a50fc4..00000000 --- a/qt/OpenRGBDialog2/OpenRGBDialog2.cpp +++ /dev/null @@ -1,2032 +0,0 @@ -/*---------------------------------------------------------*\ -| OpenRGBDialog2.cpp | -| | -| User interface for OpenRGB main window | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-only | -\*---------------------------------------------------------*/ - -#include -#include -#include "OpenRGBDialog2.h" -#include "LogManager.h" -#include "PluginManager.h" -#include "OpenRGBDevicePage.h" -#include "OpenRGBDeviceInfoPage.h" -#include "OpenRGBServerInfoPage.h" -#include "OpenRGBConsolePage.h" -#include "OpenRGBPluginContainer.h" -#include "OpenRGBProfileSaveDialog.h" -#include "ResourceManager.h" -#include "SettingsManager.h" -#include "TabLabel.h" -#include "OpenRGBZonesBulkResizer.h" -#include "OpenRGBThemeManager.h" -#include -#include -#include -#include -#include -#include -#include "OpenRGBFont.h" - -#ifdef __APPLE__ -#include "macutils.h" -#endif - -using namespace Ui; - -static int GetIcon(device_type type) -{ - /*-----------------------------------------------------*\ - | Return the icon int value for the given device | - | type value | - \*-----------------------------------------------------*/ - int icon; - - switch(type) - { - case DEVICE_TYPE_ACCESSORY: - icon = OpenRGBFont::usb; - break; - case DEVICE_TYPE_MOTHERBOARD: - icon = OpenRGBFont::mainboard; - break; - case DEVICE_TYPE_DRAM: - icon = OpenRGBFont::dram; - break; - case DEVICE_TYPE_GPU: - icon = OpenRGBFont::gpu; - break; - case DEVICE_TYPE_COOLER: - icon = OpenRGBFont::cooler; - break; - case DEVICE_TYPE_LEDSTRIP: - icon = OpenRGBFont::ledstrip; - break; - case DEVICE_TYPE_KEYBOARD: - icon = OpenRGBFont::keyboard; - break; - case DEVICE_TYPE_MICROPHONE: - icon = OpenRGBFont::mic; - break; - case DEVICE_TYPE_MOUSE: - icon = OpenRGBFont::mouse; - break; - case DEVICE_TYPE_MOUSEMAT: - icon = OpenRGBFont::mousemat; - break; - case DEVICE_TYPE_HEADSET: - icon = OpenRGBFont::headset; - break; - case DEVICE_TYPE_HEADSET_STAND: - icon = OpenRGBFont::headsetstand; - break; - case DEVICE_TYPE_GAMEPAD: - icon = OpenRGBFont::gamepad; - break; - case DEVICE_TYPE_LIGHT: - icon = OpenRGBFont::bulb; - break; - case DEVICE_TYPE_SPEAKER: - icon = OpenRGBFont::music_speaker; - break; - case DEVICE_TYPE_VIRTUAL: - icon = OpenRGBFont::virtual_controller; - break; - case DEVICE_TYPE_STORAGE: - icon = OpenRGBFont::drive; - break; - case DEVICE_TYPE_CASE: - icon = OpenRGBFont::pc_case; - break; - case DEVICE_TYPE_KEYPAD: - icon = OpenRGBFont::keypad; - break; - default: - icon = OpenRGBFont::unknown; - break; - } - - return icon; -} - -static void UpdateDeviceListCallback(void * this_ptr) -{ - OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; - - QMetaObject::invokeMethod(this_obj, "onDeviceListUpdated", Qt::QueuedConnection); -} - -static void UpdateDetectionProgressCallback(void * this_ptr) -{ - OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; - - QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection); -} - -static void CreatePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin) -{ - OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; - - this_obj->AddPlugin(plugin); -} - -static void DeletePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin) -{ - OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; - - this_obj->RemovePlugin(plugin); -} - -static void DetectionEndedCallback(void * this_ptr) -{ - OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; - - QMetaObject::invokeMethod(this_obj, "onDetectionEnded", Qt::QueuedConnection); -} - -static void DialogShowCallback(void * this_ptr, PLogMessage msg) -{ - OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr; - - this_obj->SetDialogMessage(msg); - QMetaObject::invokeMethod(this_obj, "onShowDialogMessage", Qt::QueuedConnection); -} - - -bool OpenRGBDialog2::IsMinimizeOnClose() -{ - json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface"); - - if(ui_settings.contains("minimize_on_close")) - { - return ui_settings["minimize_on_close"]; - } - - return false; -} - -OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new OpenRGBDialog2Ui) -{ - ui->setupUi(this); - - /*-----------------------------------------------------*\ - | Set window icon | - \*-----------------------------------------------------*/ - QIcon logo(":org.openrgb.OpenRGB.png"); - setWindowIcon(logo); - - /*-----------------------------------------------------*\ - | Set window geometry from config (if available) | - \*-----------------------------------------------------*/ - SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); - std::string ui_string = "UserInterface"; - json ui_settings; - bool new_settings_keys = false; - - 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 | - \*-----------------------------------------------------*/ - if(!ui_settings.contains("geometry")) - { - json geometry_settings; - - geometry_settings["load_geometry"] = false; - geometry_settings["save_on_exit"] = false; - geometry_settings["x"] = 0; - geometry_settings["y"] = 0; - geometry_settings["width"] = 0; - geometry_settings["height"] = 0; - - ui_settings["geometry"] = geometry_settings; - new_settings_keys = true; - } - - /*-----------------------------------------------------*\ - | If geometry information exists in settings, apply it | - \*-----------------------------------------------------*/ - bool load_geometry = false; - - if(ui_settings["geometry"].contains("load_geometry")) - { - load_geometry = ui_settings["geometry"]["load_geometry"].get(); - } - - if(load_geometry) - { - QRect set_window; - - /*-----------------------------------------------------*\ - | x and y can be set independent of width and height | - | QT attempts to clamp these values in case the user | - | enters invalid numbers | - \*-----------------------------------------------------*/ - if( ui_settings["geometry"].contains("x") - && ui_settings["geometry"].contains("y")) - { - set_window.setX(ui_settings["geometry"]["x"].get()); - set_window.setY(ui_settings["geometry"]["y"].get()); - } - - if( ui_settings["geometry"].contains("width") - && ui_settings["geometry"].contains("height")) - { - set_window.setWidth(ui_settings["geometry"]["width"].get()); - set_window.setHeight(ui_settings["geometry"]["height"].get()); - } - - setGeometry(set_window); - } - - /*-----------------------------------------------------*\ - | If autoload_profiles doesn't exist or has missing | - | profiles, write it to config | - \*-----------------------------------------------------*/ - json autoload_profiles; - if(ui_settings.contains("autoload_profiles")) - { - autoload_profiles = ui_settings["autoload_profiles"]; - } - else - { - new_settings_keys = true; - } - - if(!autoload_profiles.contains("exit_profile")) - { - json profile; - profile["enabled"] = false; - profile["name"] = ""; - autoload_profiles["exit_profile"] = profile; - new_settings_keys = true; - } - - if(!autoload_profiles.contains("resume_profile")) - { - json profile; - profile["enabled"] = false; - profile["name"] = ""; - autoload_profiles["resume_profile"] = profile; - new_settings_keys = true; - } - - if(!autoload_profiles.contains("suspend_profile")) - { - json profile; - profile["enabled"] = false; - profile["name"] = ""; - autoload_profiles["suspend_profile"] = profile; - new_settings_keys = true; - } - - ui_settings["autoload_profiles"] = autoload_profiles; - - /*-----------------------------------------------------*\ - | Register detection progress callback with resource | - | manager | - \*-----------------------------------------------------*/ - ResourceManager::get()->RegisterDetectionProgressCallback(UpdateDetectionProgressCallback, this); - ResourceManager::get()->RegisterDeviceListChangeCallback(UpdateDeviceListCallback, this); - ResourceManager::get()->RegisterDetectionEndCallback(DetectionEndedCallback, this); - - /*-----------------------------------------------------*\ - | Register dialog show callback with log manager | - \*-----------------------------------------------------*/ - LogManager::get()->RegisterDialogShowCallback(DialogShowCallback, this); - - /*-----------------------------------------------------*\ - | Initialize page pointers | - \*-----------------------------------------------------*/ - ClientInfoPage = NULL; - SMBusToolsPage = NULL; - SoftInfoPage = NULL; - - onDetectionProgressUpdated(); - - ui->DetectionProgressBar->setRange(0, 100); - ui->DetectionProgressBar->setValue(0); - ui->DetectionProgressBar->setTextVisible(true); - ui->DetectionProgressBar->setFormat(""); - ui->DetectionProgressBar->setAlignment(Qt::AlignCenter); - - /*-----------------------------------------------------*\ - | Set up Save Profile button action and menu | - \*-----------------------------------------------------*/ - QMenu* saveProfileMenu = new QMenu(this); - saveProfileMenu->addAction(ui->ActionSaveProfileAs); - - ui->ButtonSaveProfile->setMenu(saveProfileMenu); - ui->ButtonSaveProfile->setDefaultAction(ui->ActionSaveProfile); - - /*-----------------------------------------------------*\ - | Set up tray icon menu | - \*-----------------------------------------------------*/ - trayIconMenu = new QMenu( this ); - - trayIcon = new QSystemTrayIcon(this); - - QAction* actionShowHide = new QAction(tr("Show/Hide"), this); - connect(actionShowHide, SIGNAL(triggered()), this, SLOT(on_ShowHide())); - trayIconMenu->addAction(actionShowHide); - - profileMenu = new QMenu(tr("Profiles"), this); - - trayIconMenu->addMenu(profileMenu); - - QMenu* quickColorsMenu = new QMenu(tr("Quick Colors"), this); - - QAction* actionQuickRed = new QAction(tr("Red"), this); - connect(actionQuickRed, SIGNAL(triggered()), this, SLOT(on_QuickRed())); - quickColorsMenu->addAction(actionQuickRed); - - QAction* actionQuickYellow = new QAction(tr("Yellow"), this); - connect(actionQuickYellow, SIGNAL(triggered()), this, SLOT(on_QuickYellow())); - quickColorsMenu->addAction(actionQuickYellow); - - QAction* actionQuickGreen = new QAction(tr("Green"), this); - connect(actionQuickGreen, SIGNAL(triggered()), this, SLOT(on_QuickGreen())); - quickColorsMenu->addAction(actionQuickGreen); - - QAction* actionQuickCyan = new QAction(tr("Cyan"), this); - connect(actionQuickCyan, SIGNAL(triggered()), this, SLOT(on_QuickCyan())); - quickColorsMenu->addAction(actionQuickCyan); - - QAction* actionQuickBlue = new QAction(tr("Blue"), this); - connect(actionQuickBlue, SIGNAL(triggered()), this, SLOT(on_QuickBlue())); - quickColorsMenu->addAction(actionQuickBlue); - - QAction* actionQuickMagenta = new QAction(tr("Magenta"), this); - connect(actionQuickMagenta, SIGNAL(triggered()), this, SLOT(on_QuickMagenta())); - quickColorsMenu->addAction(actionQuickMagenta); - - QAction* actionQuickWhite = new QAction(tr("White"), this); - connect(actionQuickWhite, SIGNAL(triggered()), this, SLOT(on_QuickWhite())); - quickColorsMenu->addAction(actionQuickWhite); - - trayIconMenu->addMenu(quickColorsMenu); - - QAction* actionLightsOff = new QAction(tr("Lights Off"), this); - actionLightsOff->setObjectName("ActionLightsOff"); - connect(actionLightsOff, SIGNAL(triggered()), this, SLOT(on_LightsOff())); - trayIconMenu->addAction(actionLightsOff); - - actionExit = new QAction(tr("Exit"), this ); - connect( actionExit, SIGNAL( triggered() ), this, SLOT( on_Exit() )); - trayIconMenu->addAction(actionExit); - - /*-------------------------------------------------*\ - | If tray minimize flag isn't in the config, set | - | default value to false | - \*-------------------------------------------------*/ - if(!ui_settings.contains("minimize_on_close")) - { - ui_settings["minimize_on_close"] = false; - new_settings_keys = true; - } - - connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_ReShow(QSystemTrayIcon::ActivationReason))); - - /*-------------------------------------------------*\ - | If Greyscale Tray Icon flag is not set in config | - | then set the default value to false | - \*-------------------------------------------------*/ - if(!ui_settings.contains("greyscale_tray_icon")) - { - ui_settings["greyscale_tray_icon"] = false; - new_settings_keys = true; - } - - /*-----------------------------------------------------*\ - | If greyscale tray icon exists in settings, apply it | - | or else set the icon to the default window logo | - \*-----------------------------------------------------*/ - if(ui_settings.contains("greyscale_tray_icon")) - { - SetTrayIcon(ui_settings["greyscale_tray_icon"].get()); - } - - /*-----------------------------------------------------*\ - | Save the settings if new default values have been | - | inserted | - \*-----------------------------------------------------*/ - if(new_settings_keys) - { - settings_manager->SetSettings(ui_string, ui_settings); - settings_manager->SaveSettings(); - } - - trayIcon->setToolTip("OpenRGB"); - trayIcon->setContextMenu(trayIconMenu); - trayIcon->show(); - - OpenRGBThemeManager::Init(); - - /*-----------------------------------------------------*\ - | Update the profile list | - \*-----------------------------------------------------*/ - UpdateProfileList(); - - /*-----------------------------------------------------*\ - | Update the device list and make sure the | - | ProgressBar gets a proper value | - \*-----------------------------------------------------*/ - UpdateDevicesList(); - - /*-----------------------------------------------------*\ - | Add Client Tab | - \*-----------------------------------------------------*/ - AddClientTab(); - - /*-----------------------------------------------------*\ - | Add Server Tab | - \*-----------------------------------------------------*/ - AddServerTab(); - - /*-----------------------------------------------------*\ - | Add the Software Info page | - \*-----------------------------------------------------*/ - AddSoftwareInfoPage(); - - /*-----------------------------------------------------*\ - | Add the settings page | - \*-----------------------------------------------------*/ - AddSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Supported Devices page | - \*-----------------------------------------------------*/ - AddSupportedDevicesPage(); - - /*-----------------------------------------------------*\ - | Initialize the plugin manager | - \*-----------------------------------------------------*/ - plugin_manager = new PluginManager(); - plugin_manager->RegisterAddPluginCallback(&CreatePluginCallback, this); - plugin_manager->RegisterRemovePluginCallback(&DeletePluginCallback, this); - - /*-----------------------------------------------------*\ - | Add the Plugins page | - \*-----------------------------------------------------*/ - AddPluginsPage(); - - /*-----------------------------------------------------*\ - | Add the DMX settings page | - \*-----------------------------------------------------*/ - AddDMXSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the E1.31 settings page | - \*-----------------------------------------------------*/ - AddE131SettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Kasa Smart settings page | - \*-----------------------------------------------------*/ - AddKasaSmartSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the LIFX settings page | - \*-----------------------------------------------------*/ - AddLIFXSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Serial settings page | - \*-----------------------------------------------------*/ - AddSerialSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the QMK OpenRGB Protocol settings page | - \*-----------------------------------------------------*/ - AddQMKORGBSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Philips Hue settings page | - \*-----------------------------------------------------*/ - AddPhilipsHueSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Philips Wiz settings page | - \*-----------------------------------------------------*/ - AddPhilipsWizSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Yeelight settings page | - \*-----------------------------------------------------*/ - AddYeelightSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the Nanoleaf settings page | - \*-----------------------------------------------------*/ - AddNanoleafSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the ElgatoKeyLight settings page | - \*-----------------------------------------------------*/ - AddElgatoKeyLightSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the ElgatoLightStrip settings page | - \*-----------------------------------------------------*/ - AddElgatoLightStripSettingsPage(); - - /*-----------------------------------------------------*\ - | Add the SMBus Tools page if enabled | - \*-----------------------------------------------------*/ - if(ShowI2CTools) - { - AddI2CToolsPage(); - } - - /*-----------------------------------------------------*\ - | If log console is enabled in settings, enable it | - \*-----------------------------------------------------*/ - json log_manager_settings = settings_manager->GetSettings("LogManager"); - - bool log_console_enabled = false; - if(log_manager_settings.contains("log_console")) - { - log_console_enabled = log_manager_settings["log_console"]; - } - - /*-----------------------------------------------------*\ - | Add the log console page | - \*-----------------------------------------------------*/ - if(log_console_enabled) - { - AddConsolePage(); - } - - /*-----------------------------------------------------*\ - | Connect aboutToQuit signal to handleAboutToQuit | - \*-----------------------------------------------------*/ - connect(qApp, &QCoreApplication::aboutToQuit, this, &OpenRGBDialog2::handleAboutToQuit); - -} - -OpenRGBDialog2::~OpenRGBDialog2() -{ - delete ui; -} - - -void OpenRGBDialog2::handleAboutToQuit() -{ - /*-----------------------------------------------------*\ - | Write window geometry to config (if enabled) | - \*-----------------------------------------------------*/ - SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); - std::string ui_string = "UserInterface"; - json ui_settings; - - ui_settings = settings_manager->GetSettings(ui_string); - - if(ui_settings.contains("geometry")) - { - if( ui_settings["geometry"].contains("load_geometry") - && ui_settings["geometry"].contains("save_on_exit")) - { - if( ui_settings["geometry"]["load_geometry"].get() - && ui_settings["geometry"]["save_on_exit"].get()) - { - ui_settings["geometry"]["x"] = geometry().x(); - ui_settings["geometry"]["y"] = geometry().y(); - ui_settings["geometry"]["width"] = geometry().width(); - ui_settings["geometry"]["height"] = geometry().height(); - - settings_manager->SetSettings(ui_string, ui_settings); - settings_manager->SaveSettings(); - } - } - } - - QCloseEvent* closeEvent = new QCloseEvent; - this->closeEvent(closeEvent); - delete closeEvent; -} - - -void OpenRGBDialog2::changeEvent(QEvent *event) -{ - if(event->type() == QEvent::LanguageChange) - { - ui->retranslateUi(this); - for(int i = 0; i < ui->MainTabBar->count(); i++) - { - /*-----------------------------------------------------*\ - | if the objectName is either of the SDK tabs | - | then translate tab text (TODO: improve workaround) | - \*-----------------------------------------------------*/ - std::string label = ui->MainTabBar->widget(i)->objectName().toStdString(); - - if(label.substr(0,3) == "SDK") - { - ui->MainTabBar->setTabText(i, tr(label.c_str())); - } - } - } -} - -void OpenRGBDialog2::closeEvent(QCloseEvent *event) -{ - ResourceManager::get()->WaitForDeviceDetection(); - - if (IsMinimizeOnClose() && !this->isHidden()) - { -#ifdef __APPLE__ - MacUtils::ToggleApplicationDocklessState(false); -#endif - hide(); - event->ignore(); - } - else - { - plugin_manager->UnloadPlugins(); - - if(SelectConfigProfile("exit_profile")) - { - on_ButtonLoadProfile_clicked(); - - /*-----------------------------------------------------*\ - | Pause briefly to ensure that all profiles are loaded. | - \*-----------------------------------------------------*/ - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - } - - event->accept(); - QApplication::exit(0); - } -} - -void OpenRGBDialog2::keyPressEvent(QKeyEvent *event) -{ - if(event->key() == Qt::Key_F11) - { - if(isFullScreen()) - { - showNormal(); - } - else - { - showFullScreen(); - } - event->accept(); - } - else - { - QMainWindow::keyPressEvent(event); - } -} - -bool OpenRGBDialog2::SelectConfigProfile(const std::string name) -{ - /*-----------------------------------------------------*\ - | Set automatic profile (if enabled and valid) | - \*-----------------------------------------------------*/ - json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface"); - - if(ui_settings.contains("autoload_profiles")) - { - json autoload_profiles = ui_settings["autoload_profiles"]; - if(autoload_profiles.contains(name)) - { - json profile = autoload_profiles[name]; - if (profile.contains("enabled") && profile["enabled"].get() && profile.contains("name")) - { - /*-----------------------------------------------------*\ - | Set the profile name from settings and check the | - | profile combobox for a match | - \*-----------------------------------------------------*/ - std::string profile_name = profile["name"].get(); - int profile_index = ui->ProfileBox->findText(QString::fromStdString(profile_name)); - - if(profile_index > -1) - { - ui->ProfileBox->setCurrentIndex(profile_index); - return true; - } - } - } - } - return false; -} - -void OpenRGBDialog2::AddPluginsPage() -{ - /*-----------------------------------------------------*\ - | Create the Plugins page | - \*-----------------------------------------------------*/ - PluginsPage = new OpenRGBPluginsPage(plugin_manager); - - ui->SettingsTabBar->addTab(PluginsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* PluginTabLabel = new TabLabel(OpenRGBFont::extension, tr("Plugins"), (char *)"Plugins", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, PluginTabLabel); -} - -void OpenRGBDialog2::AddSoftwareInfoPage() -{ - /*-----------------------------------------------------*\ - | Create the Software Information page | - \*-----------------------------------------------------*/ - SoftInfoPage = new OpenRGBSoftwareInfoPage(); - - ui->InformationTabBar->addTab(SoftInfoPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SoftwareTabLabel = new TabLabel(OpenRGBFont::info, tr("Software"), (char *)"Software", (char *)context); - - ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel); -} - -void OpenRGBDialog2::AddSupportedDevicesPage() -{ - /*-----------------------------------------------------*\ - | Create the Supported Devices page | - \*-----------------------------------------------------*/ - SupportedPage = new OpenRGBSupportedDevicesPage(); - - ui->SettingsTabBar->addTab(SupportedPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SupportedTabLabel = new TabLabel(OpenRGBFont::controller, tr("Supported Devices"), (char *)"Supported Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SupportedTabLabel); -} - -void OpenRGBDialog2::AddSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - SettingsPage = new OpenRGBSettingsPage(); - - ui->SettingsTabBar->addTab(SettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::options, tr("General Settings"), (char *)"General Settings", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); - - /*-----------------------------------------------------*\ - | Connect signals to slots | - \*-----------------------------------------------------*/ - connect(SettingsPage, SIGNAL(TrayIconChanged(bool)), this, SLOT(SetTrayIcon(bool))); - connect(this, SIGNAL(ProfileListChanged()), SettingsPage, SLOT(UpdateProfiles())); -} - -void OpenRGBDialog2::AddDMXSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - DMXSettingsPage = new OpenRGBDMXSettingsPage(); - - ui->SettingsTabBar->addTab(DMXSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::serial, tr("DMX Devices"), (char *)"DMX Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddE131SettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - E131SettingsPage = new OpenRGBE131SettingsPage(); - - ui->SettingsTabBar->addTab(E131SettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::data, tr("E1.31 Devices"), (char *)"E1.31 Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddKasaSmartSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - KasaSmartSettingsPage = new OpenRGBKasaSmartSettingsPage(); - - ui->SettingsTabBar->addTab(KasaSmartSettingsPage, ""); - - QString SettingsLabelString; - - if(OpenRGBThemeManager::IsDarkTheme()) - { - SettingsLabelString = "light_dark.png"; - } - else - { - SettingsLabelString = "light.png"; - } - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Kasa Smart Devices"), (char *)"Kasa Smart Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddLIFXSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - LIFXSettingsPage = new OpenRGBLIFXSettingsPage(); - - ui->SettingsTabBar->addTab(LIFXSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("LIFX Devices"), (char *)"LIFX Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddPhilipsHueSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - PhilipsHueSettingsPage = new OpenRGBPhilipsHueSettingsPage(); - - ui->SettingsTabBar->addTab(PhilipsHueSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Philips Hue Devices"), (char *)"Philips Hue Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddPhilipsWizSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - PhilipsWizSettingsPage = new OpenRGBPhilipsWizSettingsPage(); - - ui->SettingsTabBar->addTab(PhilipsWizSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Philips Wiz Devices"), (char *)"Philips Wiz Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddQMKORGBSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - QMKORGBSettingsPage = new OpenRGBQMKORGBSettingsPage(); - - ui->SettingsTabBar->addTab(QMKORGBSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::keyboard, tr("OpenRGB QMK Protocol"), (char *)"OpenRGB QMK Protocol", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddSerialSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - SerialSettingsPage = new OpenRGBSerialSettingsPage(); - - ui->SettingsTabBar->addTab(SerialSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SerialSettingsTabLabel = new TabLabel(OpenRGBFont::serial, tr("Serial Devices"), (char *)"Serial Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SerialSettingsTabLabel); -} - -void OpenRGBDialog2::AddYeelightSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - YeelightSettingsPage = new OpenRGBYeelightSettingsPage(); - - ui->SettingsTabBar->addTab(YeelightSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Yeelight Devices"), (char *)"Yeelight Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddNanoleafSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - NanoleafSettingsPage = new OpenRGBNanoleafSettingsPage(); - - ui->SettingsTabBar->addTab(NanoleafSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Nanoleaf Devices"), (char *)"Nanoleaf Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddElgatoKeyLightSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - ElgatoKeyLightSettingsPage = new OpenRGBElgatoKeyLightSettingsPage(); - - ui->SettingsTabBar->addTab(ElgatoKeyLightSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Elgato KeyLight Devices"), (char *)"Elgato KeyLight Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddElgatoLightStripSettingsPage() -{ - /*-----------------------------------------------------*\ - | Create the Settings page | - \*-----------------------------------------------------*/ - ElgatoLightStripSettingsPage = new OpenRGBElgatoLightStripSettingsPage(); - - ui->SettingsTabBar->addTab(ElgatoLightStripSettingsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SettingsTabLabel = new TabLabel(OpenRGBFont::bulb, tr("Elgato LightStrip Devices"), (char *)"Elgato LightStrip Devices", (char *)context); - - ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); -} - -void OpenRGBDialog2::AddPlugin(OpenRGBPluginEntry* plugin) -{ - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* PluginTabLabel = new TabLabel(OpenRGBFont::extension, QString::fromStdString(plugin->info.Label), (char *)plugin->info.Label.c_str(), (char *)context); - - /*-----------------------------------------------------*\ - | Place plugin as its own top level tab | - \*-----------------------------------------------------*/ - if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_TOP) - { - QWidget* NewPluginTab = plugin->plugin->GetWidget(); - - plugin->widget = NewPluginTab; - - OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); - - ui->MainTabBar->addTab(NewPluginContainer,QString().fromStdString(plugin->info.Label)); - } - /*-----------------------------------------------------*\ - | Place plugin in the Devices tab | - \*-----------------------------------------------------*/ - else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_DEVICES) - { - QWidget* NewPluginTab = plugin->plugin->GetWidget(); - - plugin->widget = NewPluginTab; - - OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); - - ui->DevicesTabBar->addTab(NewPluginContainer," "); - - ui->DevicesTabBar->tabBar()->setTabButton((ui->DevicesTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel); - } - /*-----------------------------------------------------*\ - | Place plugin in the Information tab | - \*-----------------------------------------------------*/ - else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_INFORMATION) - { - QWidget* NewPluginTab = plugin->plugin->GetWidget(); - - plugin->widget = NewPluginTab; - - OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); - - ui->InformationTabBar->addTab(NewPluginContainer," "); - - ui->InformationTabBar->tabBar()->setTabButton((ui->InformationTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel); - } - /*-----------------------------------------------------*\ - | Place plugin in the Settings tab | - \*-----------------------------------------------------*/ - else if(plugin->info.Location == OPENRGB_PLUGIN_LOCATION_SETTINGS) - { - QWidget* NewPluginTab = plugin->plugin->GetWidget(); - - plugin->widget = NewPluginTab; - - OpenRGBPluginContainer* NewPluginContainer = new OpenRGBPluginContainer(NewPluginTab, this); - - ui->SettingsTabBar->addTab(NewPluginContainer," "); - - ui->SettingsTabBar->tabBar()->setTabButton((ui->SettingsTabBar->count() - 1),QTabBar::LeftSide , PluginTabLabel); - } - /*-----------------------------------------------------*\ - | Display an error message if the plugin does not | - | specify a valid location | - \*-----------------------------------------------------*/ - else - { - std::cout << ("Cannot load plugin '" + plugin->info.Name + "' as it does not specify a valid location.\n"); - } - - QMenu* NewTrayMenu = plugin->plugin->GetTrayMenu(); - - plugin->traymenu = NewTrayMenu; - - if(NewTrayMenu) - { - trayIconMenu->insertMenu(actionExit, NewTrayMenu); - } -} - -void OpenRGBDialog2::RemovePlugin(OpenRGBPluginEntry* plugin) -{ - /*-----------------------------------------------------*\ - | Remove plugin's tray menu | - \*-----------------------------------------------------*/ - if(plugin->traymenu) - { - QWidget* plugin_tray_entry = trayIconMenu->find(plugin->traymenu->winId()); - - if(plugin_tray_entry) - { - trayIconMenu->removeAction(plugin->traymenu->menuAction()); - } - - //delete plugin->traymenu; - } - - /*-----------------------------------------------------*\ - | Find plugin's container | - \*-----------------------------------------------------*/ - QTabWidget *plugin_parent_widget = nullptr; - - switch(plugin->info.Location) - { - case OPENRGB_PLUGIN_LOCATION_TOP: - plugin_parent_widget = ui->MainTabBar; - break; - case OPENRGB_PLUGIN_LOCATION_DEVICES: - plugin_parent_widget = ui->DevicesTabBar; - break; - case OPENRGB_PLUGIN_LOCATION_INFORMATION: - plugin_parent_widget = ui->InformationTabBar; - break; - case OPENRGB_PLUGIN_LOCATION_SETTINGS: - plugin_parent_widget = ui->InformationTabBar; - break; - default: - break; - } - - /*-----------------------------------------------------*\ - | Remove plugin from its container | - \*-----------------------------------------------------*/ - if(plugin_parent_widget != nullptr) - { - for(int tab_idx = 0; tab_idx < plugin_parent_widget->count(); tab_idx++) - { - if(dynamic_cast(plugin_parent_widget->widget(tab_idx)) != nullptr) - { - if(dynamic_cast(plugin_parent_widget->widget(tab_idx))->plugin_widget == plugin->widget) - { - plugin_parent_widget->removeTab(tab_idx); - //delete plugin->widget; - break; - } - } - } - } -} - -void OpenRGBDialog2::AddI2CToolsPage() -{ - ShowI2CTools = true; - - /*-----------------------------------------------------*\ - | Create the I2C Tools page if it doesn't exist yet | - \*-----------------------------------------------------*/ - SMBusToolsPage = new OpenRGBSystemInfoPage(ResourceManager::get()->GetI2CBusses()); - - /*-----------------------------------------------------*\ - | Create the I2C Tools tab in the Information bar | - \*-----------------------------------------------------*/ - ui->InformationTabBar->addTab(SMBusToolsPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* SMBusToolsTabLabel = new TabLabel(OpenRGBFont::toolbox, tr("SMBus Tools"), (char *)"SMBus Tools", (char *)context); - - ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel); -} - -void OpenRGBDialog2::AddClientTab() -{ - /*-----------------------------------------------------*\ - | Add client information tab if it doesn't exist yet | - \*-----------------------------------------------------*/ - if(ClientInfoPage == NULL) - { - ClientInfoPage = new OpenRGBClientInfoPage(); - ClientInfoPage->setObjectName(QString("SDK Client")); - ui->MainTabBar->insertTab(2, ClientInfoPage, tr("SDK Client")); - } -} - -void OpenRGBDialog2::AddClient(NetworkClient* new_client) -{ - /*-----------------------------------------------------*\ - | Add a client to the client information page | - \*-----------------------------------------------------*/ - if(ClientInfoPage != NULL) - { - ClientInfoPage->AddClient(new_client); - } -} - -void OpenRGBDialog2::AddServerTab() -{ - /*-----------------------------------------------------*\ - | Add server information tab if there is a server | - \*-----------------------------------------------------*/ - OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(ResourceManager::get()->GetServer()); - ServerInfoPage->setObjectName(QString("SDK Server")); - ui->MainTabBar->insertTab(2, ServerInfoPage, tr("SDK Server")); -} - -void OpenRGBDialog2::ClearDevicesList() -{ - for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++) - { - if(dynamic_cast(ui->DevicesTabBar->widget(tab_idx)) == nullptr) - { - delete ui->DevicesTabBar->widget(tab_idx); - ui->DevicesTabBar->removeTab(tab_idx); - } - } - - for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++) - { - if(dynamic_cast(ui->InformationTabBar->widget(tab_idx)) == nullptr) - { - delete ui->InformationTabBar->widget(tab_idx); - ui->InformationTabBar->removeTab(tab_idx); - } - } -} - -void OpenRGBDialog2::UpdateDevicesList() -{ - std::vector controllers = ResourceManager::get()->GetRGBControllers(); - - /*-----------------------------------------------------*\ - | Loop through each controller in the list. | - \*-----------------------------------------------------*/ - for(unsigned int controller_idx = 0; controller_idx < controllers.size(); controller_idx++) - { - /*-----------------------------------------------------*\ - | Loop through each tab in the devices tab bar | - \*-----------------------------------------------------*/ - bool found = false; - - for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++) - { - QWidget* page = ui->DevicesTabBar->widget(tab_idx); - - if(dynamic_cast(page) != nullptr) - { - /*-----------------------------------------------------*\ - | If the current tab matches the current controller, | - | move the tab to the correct position | - \*-----------------------------------------------------*/ - if(controllers[controller_idx] == ((OpenRGBDevicePage*)page)->GetController()) - { - found = true; - ui->DevicesTabBar->tabBar()->moveTab(tab_idx, controller_idx); - break; - } - } - } - - if(!found) - { - /*-----------------------------------------------------*\ - | The controller does not have a tab already created | - | Create a new tab and move it to the correct position | - \*-----------------------------------------------------*/ - OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(controllers[controller_idx]); - ui->DevicesTabBar->addTab(NewPage, ""); - - /*-----------------------------------------------------*\ - | Connect the page's Set All button to the Set All slot | - \*-----------------------------------------------------*/ - connect(NewPage, - SIGNAL(SetAllDevices(unsigned char, unsigned char, unsigned char)), - this, - SLOT(on_SetAllDevices(unsigned char, unsigned char, unsigned char))); - - /*-----------------------------------------------------*\ - | Connect the page's Resize signal to the Save Size slot| - \*-----------------------------------------------------*/ - connect(NewPage, - SIGNAL(SaveSizeProfile()), - this, - SLOT(on_SaveSizeProfile())); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* NewTabLabel = new TabLabel(GetIcon(controllers[controller_idx]->type), QString::fromStdString(controllers[controller_idx]->name), (char *)controllers[controller_idx]->name.c_str(), (char *)context); - - ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); - ui->DevicesTabBar->tabBar()->setTabToolTip(ui->DevicesTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name)); - - /*-----------------------------------------------------*\ - | Now move the new tab to the correct position | - \*-----------------------------------------------------*/ - ui->DevicesTabBar->tabBar()->moveTab(ui->DevicesTabBar->count() - 1, controller_idx); - } - - /*-----------------------------------------------------*\ - | Loop through each tab in the information tab bar | - \*-----------------------------------------------------*/ - found = false; - - for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++) - { - /*-----------------------------------------------------*\ - | If type is a device info page, check it | - \*-----------------------------------------------------*/ - std::string type_str = ui->InformationTabBar->widget(tab_idx)->metaObject()->className(); - if(type_str == "Ui::OpenRGBDeviceInfoPage") - { - OpenRGBDeviceInfoPage* page = (OpenRGBDeviceInfoPage*) ui->InformationTabBar->widget(tab_idx); - - /*-----------------------------------------------------*\ - | If the current tab matches the current controller, | - | move the tab to the correct position | - \*-----------------------------------------------------*/ - if(controllers[controller_idx] == page->GetController()) - { - found = true; - ui->InformationTabBar->tabBar()->moveTab(tab_idx, controller_idx); - break; - } - } - } - - if(!found) - { - /*-----------------------------------------------------*\ - | The controller does not have a tab already created | - | Create a new tab and move it to the correct position | - \*-----------------------------------------------------*/ - OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(controllers[controller_idx]); - ui->InformationTabBar->addTab(NewPage, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* NewTabLabel = new TabLabel(GetIcon(controllers[controller_idx]->type), QString::fromStdString(controllers[controller_idx]->name), (char *)controllers[controller_idx]->name.c_str(), (char *)context); - - ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); - ui->InformationTabBar->tabBar()->setTabToolTip(ui->InformationTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name)); - - /*-----------------------------------------------------*\ - | Now move the new tab to the correct position | - \*-----------------------------------------------------*/ - ui->InformationTabBar->tabBar()->moveTab(ui->InformationTabBar->count() - 1, controller_idx); - } - } - - /*-----------------------------------------------------*\ - | Remove all remaining device tabs | - \*-----------------------------------------------------*/ - unsigned int tab_count = ui->DevicesTabBar->count(); - unsigned int base_tab = (unsigned int)controllers.size(); - - for(std::size_t tab_idx = controllers.size(); tab_idx < tab_count; tab_idx++) - { - QWidget* tab_widget = ui->DevicesTabBar->widget(base_tab); - - if(dynamic_cast(tab_widget) == nullptr) - { - ui->DevicesTabBar->removeTab(base_tab); - delete tab_widget; - } - } - - bool found = true; - - while(found) - { - found = false; - - /*-----------------------------------------------------*\ - | Remove all remaining device information tabs, leaving | - | other information tabs alone | - \*-----------------------------------------------------*/ - for(std::size_t tab_idx = controllers.size(); tab_idx < ui->InformationTabBar->count(); tab_idx++) - { - std::string type_str = ui->InformationTabBar->widget(base_tab)->metaObject()->className(); - if(type_str == "Ui::OpenRGBDeviceInfoPage") - { - found = true; - QWidget* tab_widget = ui->InformationTabBar->widget(base_tab); - - ui->InformationTabBar->removeTab(base_tab); - - delete tab_widget; - break; - } - base_tab += 1; - } - } - - if(device_view_showing) - { - ShowLEDView(); - } -} - -void OpenRGBDialog2::SetDialogMessage(PLogMessage msg) -{ - dialog_message = QString::fromStdString(msg->buffer); -} - -void OpenRGBDialog2::UpdateProfileList() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*-----------------------------------------------------*\ - | Clear profile combo box and tray icon menu | - \*-----------------------------------------------------*/ - ui->ProfileBox->clear(); - profileMenu->clear(); - - for(std::size_t profile_index = 0; profile_index < profile_manager->profile_list.size(); profile_index++) - { - /*-----------------------------------------------------*\ - | Fill in profile combo box | - \*-----------------------------------------------------*/ - ui->ProfileBox->addItem(profile_manager->profile_list[profile_index].c_str()); - - /*-----------------------------------------------------*\ - | Fill in profile tray icon menu | - \*-----------------------------------------------------*/ - QAction* actionProfileSelected = new QAction(profile_manager->profile_list[profile_index].c_str(), this); - actionProfileSelected->setObjectName(profile_manager->profile_list[profile_index].c_str()); - connect(actionProfileSelected, SIGNAL(triggered()), this, SLOT(on_ProfileSelected())); - profileMenu->addAction(actionProfileSelected); - } - } - - emit ProfileListChanged(); -} - -void OpenRGBDialog2::OnSuspend() -{ - if(SelectConfigProfile("suspend_profile")) - { - plugin_manager->UnloadPlugins(); - on_ButtonLoadProfile_clicked(); - } -} - -void OpenRGBDialog2::OnResume() -{ - if(SelectConfigProfile("resume_profile")) - { - on_ButtonLoadProfile_clicked(); - } - plugin_manager->LoadPlugins(); -} - -void OpenRGBDialog2::on_Exit() -{ - /*-----------------------------------------------*\ - | This is the exit from the tray icon | - | NOT the main exit button (top right on Windows) | - | | - | The hide is important, otherwise it won't close | - | when minimize on close is enabled | - \*-----------------------------------------------*/ - this->hide(); - trayIcon->hide(); - close(); -} - -void OpenRGBDialog2::on_LightsOff() -{ - on_SetAllDevices(0x00, 0x00, 0x00); -} - -void OpenRGBDialog2::on_QuickRed() -{ - on_SetAllDevices(0xFF, 0x00, 0x00); -} - -void OpenRGBDialog2::on_QuickYellow() -{ - on_SetAllDevices(0xFF, 0xFF, 0x00); -} - -void OpenRGBDialog2::on_QuickGreen() -{ - on_SetAllDevices(0x00, 0xFF, 0x00); -} - -void OpenRGBDialog2::on_QuickCyan() -{ - on_SetAllDevices(0x00, 0xFF, 0xFF); -} - -void OpenRGBDialog2::on_QuickBlue() -{ - on_SetAllDevices(0x00, 0x00, 0xFF); -} - -void OpenRGBDialog2::on_QuickMagenta() -{ - on_SetAllDevices(0xFF, 0x00, 0xFF); -} - -void OpenRGBDialog2::on_QuickWhite() -{ - on_SetAllDevices(0xFF, 0xFF, 0xFF); -} - -void OpenRGBDialog2::onDeviceListUpdated() -{ - UpdateDevicesList(); -} - -void OpenRGBDialog2::onDetectionProgressUpdated() -{ - ui->DetectionProgressBar->setValue(ResourceManager::get()->GetDetectionPercent()); - ui->DetectionProgressBar->setFormat(QString::fromStdString(ResourceManager::get()->GetDetectionString())); - - if(ResourceManager::get()->GetDetectionPercent() == 100) - { - SetDetectionViewState(false); - } - else - { - SetDetectionViewState(true); - } -} - -void OpenRGBDialog2::onDetectionEnded() -{ - /*-------------------------------------------------------*\ - | Detect unconfigured zones and prompt for resizing | - \*-------------------------------------------------------*/ - OpenRGBZonesBulkResizer::RunChecks(this); - - /*-------------------------------------------------------*\ - | Load plugins after the first detection (ONLY the first) | - \*-------------------------------------------------------*/ - if(!plugins_loaded) - { - plugin_manager->ScanAndLoadPlugins(); - plugins_loaded = true; - PluginsPage->RefreshList(); - } - - if(device_view_showing) - { - ShowLEDView(); - } -} - -void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue) -{ - for(int device = 0; device < ui->DevicesTabBar->count(); device++) - { - qobject_cast(ui->DevicesTabBar->widget(device))->SetCustomMode(red, green, blue); - } -} - -void OpenRGBDialog2::on_SaveSizeProfile() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*---------------------------------------------------------*\ - | Save the profile | - \*---------------------------------------------------------*/ - profile_manager->SaveProfile("sizes", true); - } -} - -void OpenRGBDialog2::on_ShowHide() -{ - if(isHidden()) - { -#ifdef __APPLE__ - MacUtils::ToggleApplicationDocklessState(true); -#endif - show(); - if(isMinimized()) - { - bool maximize = isMaximized(); - showNormal(); - if(maximize) - { - showMaximized(); - } - } - } - else - { -#ifdef __APPLE__ - MacUtils::ToggleApplicationDocklessState(false); -#endif - hide(); - } -} - -void OpenRGBDialog2::onShowDialogMessage() -{ - std::size_t hash = std::hash{}(dialog_message.toStdString()); - - /*-----------------------------------------------------*\ - | Load the LogManager settings and check if the hash of | - | this message is in the no-show list | - \*-----------------------------------------------------*/ - SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); - std::string log_manager_string = "LogManager"; - json log_manager_settings; - - log_manager_settings = settings_manager->GetSettings(log_manager_string); - - /*-----------------------------------------------------*\ - | If in the no-show list, clear the message string and | - | return without displaying message box | - \*-----------------------------------------------------*/ - if(log_manager_settings.contains("dialog_no_show_hashes")) - { - for(unsigned int list_idx = 0; list_idx < log_manager_settings["dialog_no_show_hashes"].size(); list_idx++) - { - if(log_manager_settings["dialog_no_show_hashes"][list_idx] == hash) - { - dialog_message.clear(); - return; - } - } - } - - QMessageBox box; - - box.setInformativeText(dialog_message); - - QCheckBox* CheckBox_DontShowAgain = new QCheckBox("Don't show this message again"); - - DontShowAgain = false; - - QObject::connect(CheckBox_DontShowAgain, &QCheckBox::stateChanged, [this](int state) - { - if(static_cast(state) == Qt::CheckState::Checked) - { - this->DontShowAgain = true; - } - }); - - box.setCheckBox(CheckBox_DontShowAgain); - box.setTextFormat(Qt::RichText); - box.setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextBrowserInteraction); - - box.exec(); - - if(DontShowAgain) - { - /*-----------------------------------------------------*\ - | Add hash of dialog text to no-show list in LogManager | - | settings | - \*-----------------------------------------------------*/ - log_manager_settings["dialog_no_show_hashes"].push_back(hash); - - settings_manager->SetSettings(log_manager_string, log_manager_settings); - settings_manager->SaveSettings(); - } - - DontShowAgain = false; - - dialog_message.clear(); -} - -void OpenRGBDialog2::on_ReShow(QSystemTrayIcon::ActivationReason reason) -{ - if (reason == QSystemTrayIcon::DoubleClick) - { - if (isHidden()) - { - show(); - if(isMinimized()) - { - bool maximize = isMaximized(); - showNormal(); - if(maximize) - { - showMaximized(); - } - } - } - } -} - -void Ui::OpenRGBDialog2::on_ProfileSelected() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*---------------------------------------------------------*\ - | Get the profile filename from the selected object | - \*---------------------------------------------------------*/ - std::string profile_name = QObject::sender()->objectName().toStdString(); - - /*---------------------------------------------------------*\ - | Load the profile | - \*---------------------------------------------------------*/ - if(profile_manager->LoadProfile(profile_name)) - { - for(int device = 0; device < ui->DevicesTabBar->count(); device++) - { - qobject_cast(ui->DevicesTabBar->widget(device))->UpdateDevice(); - } - } - - ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name))); - } -} - -void Ui::OpenRGBDialog2::on_ButtonLoadProfile_clicked() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*---------------------------------------------------------*\ - | Get the profile filename from the profiles list | - \*---------------------------------------------------------*/ - std::string profile_name = ui->ProfileBox->currentText().toStdString(); - - /*---------------------------------------------------------*\ - | Load the profile | - \*---------------------------------------------------------*/ - if(profile_manager->LoadProfile(profile_name)) - { - for(int device = 0; device < ui->DevicesTabBar->count(); device++) - { - qobject_cast(ui->DevicesTabBar->widget(device))->UpdateDevice(); - } - } - } -} - -void Ui::OpenRGBDialog2::on_ButtonDeleteProfile_clicked() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*---------------------------------------------------------*\ - | Get the profile filename from the profiles list | - \*---------------------------------------------------------*/ - std::string profile_name = ui->ProfileBox->currentText().toStdString(); - - /*---------------------------------------------------------*\ - | Confirm we want to delete the profile | - \*---------------------------------------------------------*/ - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this, tr("Delete Profile"), tr("Do you really want to delete this profile?"), QMessageBox::Yes|QMessageBox::No); - - /*---------------------------------------------------------*\ - | Load the profile | - \*---------------------------------------------------------*/ - if(reply == QMessageBox::Yes) - { - profile_manager->DeleteProfile(profile_name); - - UpdateProfileList(); - } - } -} - -void Ui::OpenRGBDialog2::on_ButtonToggleDeviceView_clicked() -{ - if(device_view_showing) - { - HideLEDView(); - } - else - { - 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() -{ - /*---------------------------------------------------------*\ - | Notify the detection thread that it has to die | - \*---------------------------------------------------------*/ - ResourceManager::get()->StopDeviceDetection(); - - /*---------------------------------------------------------*\ - | Pretend we're done already by hiding the progress bar | - \*---------------------------------------------------------*/ - SetDetectionViewState(false); -} - -void Ui::OpenRGBDialog2::SetDetectionViewState(bool detection_showing) -{ - if(detection_showing) - { - /*---------------------------------------------------------*\ - | Show the detection progress and hide the normal buttons | - \*---------------------------------------------------------*/ - ui->ButtonToggleDeviceView->setVisible(false); - ui->ButtonRescan->setVisible(false); - ui->ButtonLoadProfile->setVisible(false); - ui->ButtonSaveProfile->setVisible(false); - ui->ButtonDeleteProfile->setVisible(false); - ui->ProfileBox->setVisible(false); - - ui->DetectionProgressBar->setVisible(true); - ui->DetectionProgressLabel->setVisible(true); - ui->ButtonStopDetection->setVisible(true); - } - else - { - /*---------------------------------------------------------*\ - | Hide the detection progress and show the normal buttons | - \*---------------------------------------------------------*/ - ui->DetectionProgressBar->setVisible(false); - ui->DetectionProgressLabel->setVisible(false); - ui->ButtonStopDetection->setVisible(false); - - ui->ButtonToggleDeviceView->setVisible(true); - ui->ButtonRescan->setVisible(true); - ui->ButtonLoadProfile->setVisible(true); - ui->ButtonSaveProfile->setVisible(true); - ui->ButtonDeleteProfile->setVisible(true); - ui->ProfileBox->setVisible(true); - } -} - -void OpenRGBDialog2::SetTrayIcon(bool tray_icon) -{ - if(tray_icon) - { - trayIcon->setIcon(QIcon(":OpenRGBGreyscale.png")); - } - else - { - trayIcon->setIcon(QIcon(":org.openrgb.OpenRGB.png")); - } -} - -void OpenRGBDialog2::SaveProfile() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*---------------------------------------------------------*\ - | Get the profile filename from the profiles list | - \*---------------------------------------------------------*/ - std::string filename = ui->ProfileBox->currentText().toStdString(); - - /*---------------------------------------------------------*\ - | Save the profile | - \*---------------------------------------------------------*/ - profile_manager->SaveProfile(filename); - } -} - -void OpenRGBDialog2::SaveProfileAs() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - OpenRGBProfileSaveDialog dialog; - - /*---------------------------------------------------------*\ - | Open Profile Name Dialog | - \*---------------------------------------------------------*/ - std::string profile_name = dialog.show(); - - if(!profile_name.empty()) - { - /*---------------------------------------------------------*\ - | Extension .orp - OpenRgb Profile | - \*---------------------------------------------------------*/ - std::string filename = profile_name; - - /*---------------------------------------------------------*\ - | Save the profile | - \*---------------------------------------------------------*/ - if(profile_manager->SaveProfile(filename)) - { - UpdateProfileList(); - - ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name))); - } - } - } -} - -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. | - \*---------------------------------------------------------*/ - bool device_view_showing_prev = device_view_showing; - - HideLEDView(); - - device_view_showing = device_view_showing_prev; - - /*---------------------------------------------------------*\ - | Show the detection progress bar. | - \*---------------------------------------------------------*/ - SetDetectionViewState(true); - - /*---------------------------------------------------------*\ - | Show the detection progress bar. | - \*---------------------------------------------------------*/ - ResourceManager::get()->DetectDevices(); -} - -void Ui::OpenRGBDialog2::on_ActionSaveProfile_triggered() -{ - if(ui->ProfileBox->currentIndex() >= 0) - { - SaveProfile(); - } - else - { - SaveProfileAs(); - } -} - -void Ui::OpenRGBDialog2::on_ActionSaveProfileAs_triggered() -{ - SaveProfileAs(); -} - - -void Ui::OpenRGBDialog2::on_InformationTabBar_currentChanged(int tab_idx) -{ - TogglePluginsVisibility(tab_idx, ui->InformationTabBar); -} - -void Ui::OpenRGBDialog2::on_DevicesTabBar_currentChanged(int tab_idx) -{ - TogglePluginsVisibility(tab_idx, ui->DevicesTabBar); -} - -void Ui::OpenRGBDialog2::on_MainTabBar_currentChanged(int tab_idx) -{ - TogglePluginsVisibility(tab_idx, ui->MainTabBar); -} - -void Ui::OpenRGBDialog2::on_SettingsTabBar_currentChanged(int tab_idx) -{ - TogglePluginsVisibility(tab_idx, ui->SettingsTabBar); -} - -void Ui::OpenRGBDialog2::TogglePluginsVisibility(int tab_idx, QTabWidget* tabBar) -{ - /*---------------------------------------------------------*\ - | Hide all plugins | - \*---------------------------------------------------------*/ - for(int i = 0; i < (tabBar->count()); i++) - { - QWidget* tab = tabBar->widget(i); - - /*-----------------------------------------------------*\ - | Dynamic cast is essential in this check to ensure the | - | tab is actually a plugin container | - \*-----------------------------------------------------*/ - if((i != tab_idx) && (dynamic_cast(tab) != nullptr)) - { - ((OpenRGBPluginContainer*) tab)->Hide(); - ui->MainButtonsFrame->setVisible(true); - } - } - - /*---------------------------------------------------------*\ - | Show plugin if needed | - \*---------------------------------------------------------*/ - QWidget* tab = tabBar->widget(tab_idx); - - /*---------------------------------------------------------*\ - | Dynamic cast is essential in this check to ensure the tab | - | is actually a plugin container | - \*---------------------------------------------------------*/ - if(dynamic_cast(tab) != nullptr) - { - ((OpenRGBPluginContainer*) tab)->Show(); - ui->MainButtonsFrame->setVisible(false); - } -} - -void Ui::OpenRGBDialog2::AddConsolePage() -{ - OpenRGBConsolePage* page = new OpenRGBConsolePage(); - - ui->InformationTabBar->addTab(page, ""); - - /*-----------------------------------------------------*\ - | Create the tab label | - \*-----------------------------------------------------*/ - TabLabel* ConsoleTabLabel = new TabLabel(OpenRGBFont::terminal, tr("Log Console"), (char *)"Log Console", (char *)context); - - ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, ConsoleTabLabel); -} diff --git a/qt/OpenRGBDialog2/OpenRGBDialog2.h b/qt/OpenRGBDialog2/OpenRGBDialog2.h deleted file mode 100644 index 761dd046..00000000 --- a/qt/OpenRGBDialog2/OpenRGBDialog2.h +++ /dev/null @@ -1,203 +0,0 @@ -/*---------------------------------------------------------*\ -| OpenRGBDialog2.h | -| | -| User interface for OpenRGB main window | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-only | -\*---------------------------------------------------------*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "ui_OpenRGBDialog2.h" - -#include "OpenRGBClientInfoPage.h" -#include "OpenRGBPluginsPage/OpenRGBPluginsPage.h" -#include "OpenRGBSoftwareInfoPage.h" -#include "OpenRGBSystemInfoPage.h" -#include "OpenRGBSupportedDevicesPage.h" -#include "OpenRGBSettingsPage.h" -#include "OpenRGBDMXSettingsPage/OpenRGBDMXSettingsPage.h" -#include "OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h" -#include "OpenRGBElgatoKeyLightSettingsPage/OpenRGBElgatoKeyLightSettingsPage.h" -#include "OpenRGBElgatoLightStripSettingsPage/OpenRGBElgatoLightStripSettingsPage.h" -#include "OpenRGBKasaSmartSettingsPage/OpenRGBKasaSmartSettingsPage.h" -#include "OpenRGBLIFXSettingsPage/OpenRGBLIFXSettingsPage.h" -#include "OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsPage.h" -#include "OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.h" -#include "OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h" -#include "OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h" -#include "OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsPage.h" -#include "OpenRGBNanoleafSettingsPage/OpenRGBNanoleafSettingsPage.h" -#include "PluginManager.h" -#include "SuspendResume.h" - -#include "i2c_smbus.h" -#include "LogManager.h" -#include "RGBController.h" -#include "ProfileManager.h" -#include "NetworkClient.h" -#include "NetworkServer.h" - -namespace Ui -{ - class OpenRGBDialog2; -} - -class Ui::OpenRGBDialog2 : public QMainWindow, private SuspendResumeListener -{ - Q_OBJECT - -public: - explicit OpenRGBDialog2(QWidget *parent = 0); - ~OpenRGBDialog2(); - - void AddClient(NetworkClient* new_client); - void AddClientTab(); - void AddI2CToolsPage(); - void AddServerTab(); - - void AddPlugin(OpenRGBPluginEntry* plugin); - void RemovePlugin(OpenRGBPluginEntry* plugin); - - void setMode(unsigned char mode_val); - - static bool IsMinimizeOnClose(); - - void SetDialogMessage(PLogMessage msg); - - bool DontShowAgain; - -signals: - void ProfileListChanged(); - -public slots: - void changeEvent(QEvent *event); - void SetTrayIcon(bool tray_icon); - void handleAboutToQuit(); - -protected: - void keyPressEvent(QKeyEvent *event) override; - -private: - const char* context = "Ui::OpenRGBDialog2"; - - /*-------------------------------------*\ - | Page pointers | - \*-------------------------------------*/ - OpenRGBClientInfoPage *ClientInfoPage; - OpenRGBPluginsPage *PluginsPage; - OpenRGBSystemInfoPage *SMBusToolsPage; - OpenRGBSoftwareInfoPage *SoftInfoPage; - OpenRGBSupportedDevicesPage *SupportedPage; - OpenRGBSettingsPage *SettingsPage; - OpenRGBDMXSettingsPage *DMXSettingsPage; - OpenRGBE131SettingsPage *E131SettingsPage; - OpenRGBElgatoKeyLightSettingsPage *ElgatoKeyLightSettingsPage; - OpenRGBElgatoLightStripSettingsPage *ElgatoLightStripSettingsPage; - OpenRGBKasaSmartSettingsPage *KasaSmartSettingsPage; - OpenRGBLIFXSettingsPage *LIFXSettingsPage; - OpenRGBPhilipsHueSettingsPage *PhilipsHueSettingsPage; - OpenRGBPhilipsWizSettingsPage *PhilipsWizSettingsPage; - OpenRGBQMKORGBSettingsPage *QMKORGBSettingsPage; - OpenRGBSerialSettingsPage *SerialSettingsPage; - OpenRGBYeelightSettingsPage *YeelightSettingsPage; - OpenRGBNanoleafSettingsPage *NanoleafSettingsPage; - - bool ShowI2CTools = false; - bool plugins_loaded = false; - - /*-------------------------------------*\ - | System tray icon and menu | - \*-------------------------------------*/ - QSystemTrayIcon* trayIcon; - QMenu* trayIconMenu; - QMenu* profileMenu; - - /*-------------------------------------*\ - | User interface | - \*-------------------------------------*/ - Ui::OpenRGBDialog2Ui *ui; - - void AddSoftwareInfoPage(); - void AddSupportedDevicesPage(); - void AddSettingsPage(); - void AddDMXSettingsPage(); - void AddE131SettingsPage(); - void AddElgatoKeyLightSettingsPage(); - void AddElgatoLightStripSettingsPage(); - void AddKasaSmartSettingsPage(); - void AddLIFXSettingsPage(); - void AddPhilipsHueSettingsPage(); - void AddPhilipsWizSettingsPage(); - void AddQMKORGBSettingsPage(); - void AddSerialSettingsPage(); - void AddYeelightSettingsPage(); - void AddNanoleafSettingsPage(); - void AddPluginsPage(); - void AddConsolePage(); - - void ClearDevicesList(); - void UpdateDevicesList(); - void UpdateProfileList(); - void closeEvent(QCloseEvent *event); - bool SelectConfigProfile(const std::string name); - - void SetDetectionViewState(bool detection_showing); - void SaveProfile(); - void SaveProfileAs(); - - void TogglePluginsVisibility(int, QTabWidget*); - - bool device_view_showing = false; - - PluginManager* plugin_manager = nullptr; - - QAction* actionExit; - QString dialog_message; - - void ShowLEDView(); - void HideLEDView(); - - void OnSuspend(); - void OnResume(); - -private slots: - void on_Exit(); - void on_LightsOff(); - void on_QuickRed(); - void on_QuickYellow(); - void on_QuickGreen(); - void on_QuickCyan(); - void on_QuickBlue(); - void on_QuickMagenta(); - void on_QuickWhite(); - void onDeviceListUpdated(); - void onDetectionProgressUpdated(); - void onDetectionEnded(); - void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue); - void on_SaveSizeProfile(); - void on_ShowHide(); - void onShowDialogMessage(); - void on_ReShow(QSystemTrayIcon::ActivationReason reason); - void on_ProfileSelected(); - void on_ButtonLoadProfile_clicked(); - void on_ButtonDeleteProfile_clicked(); - void on_ButtonToggleDeviceView_clicked(); - void on_ButtonStopDetection_clicked(); - void on_ButtonRescan_clicked(); - void on_ActionSaveProfile_triggered(); - void on_ActionSaveProfileAs_triggered(); - void on_MainTabBar_currentChanged(int); - void on_InformationTabBar_currentChanged(int); - void on_DevicesTabBar_currentChanged(int); - void on_SettingsTabBar_currentChanged(int); -}; diff --git a/qt/OpenRGBDialog2/OpenRGBDialog2.ui b/qt/OpenRGBDialog2/OpenRGBDialog2.ui deleted file mode 100644 index e7864802..00000000 --- a/qt/OpenRGBDialog2/OpenRGBDialog2.ui +++ /dev/null @@ -1,206 +0,0 @@ - - - OpenRGBDialog2Ui - - - - 0 - 0 - 700 - 350 - - - - OpenRGB - - - - - - - QTabWidget::Rounded - - - 0 - - - - 20 - 20 - - - - - Devices - - - - - - QTabWidget::West - - - - - - - - Information - - - - - - QTabWidget::West - - - -1 - - - - - - - - Settings - - - - - - QTabWidget::West - - - -1 - - - - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Toggle LED View - - - - - - - Rescan Devices - - - - - - - - 0 - 0 - - - - Save Profile - - - QToolButton::MenuButtonPopup - - - - - - - Delete Profile - - - - - - - Load Profile - - - - - - - - - - - - - - - - - OpenRGB is detecting devices... - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 24 - - - - - - - Cancel - - - - - - - - - - Save Profile - - - Save Profile - - - - - Save Profile As... - - - Save Profile with custom name - - - - - - diff --git a/qt/OpenRGBNanoleafSettingsPage/OpenRGBNanoleafNewDeviceDialog.h b/qt/OpenRGBNanoleafSettingsPage/OpenRGBNanoleafNewDeviceDialog.h index 04a71223..bca2a393 100644 --- a/qt/OpenRGBNanoleafSettingsPage/OpenRGBNanoleafNewDeviceDialog.h +++ b/qt/OpenRGBNanoleafSettingsPage/OpenRGBNanoleafNewDeviceDialog.h @@ -9,7 +9,7 @@ #include #include "ui_OpenRGBNanoleafNewDeviceDialog.h" -#include "OpenRGBDialog2.h" +#include "OpenRGBDialog.h" struct NanoleafDevice { diff --git a/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.cpp b/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.cpp index 3bda9123..f958b79d 100644 --- a/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.cpp +++ b/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.cpp @@ -9,7 +9,7 @@ #include #include "ResourceManager.h" -#include "OpenRGBDialog2.h" +#include "OpenRGBDialog.h" #include "ProfileManager.h" #include "OpenRGBProfileSaveDialog.h" #include "ui_OpenRGBProfileSaveDialog.h" diff --git a/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.h b/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.h index e0a38c10..6d25b96c 100644 --- a/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.h +++ b/qt/OpenRGBProfileSaveDialog/OpenRGBProfileSaveDialog.h @@ -11,7 +11,7 @@ #include #include "ui_OpenRGBProfileSaveDialog.h" -#include "OpenRGBDialog2.h" +#include "OpenRGBDialog.h" namespace Ui { diff --git a/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp b/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp index 6fb7477e..b48e95f6 100644 --- a/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp +++ b/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp @@ -14,7 +14,7 @@ #include "ResourceManager.h" #include "SettingsManager.h" #include "LogManager.h" -#include "OpenRGBDialog2.h" +#include "OpenRGBDialog.h" using namespace Ui; diff --git a/qt/i18n/OpenRGB_de_DE.ts b/qt/i18n/OpenRGB_de_DE.ts index 2b096c77..75e48ce7 100644 --- a/qt/i18n/OpenRGB_de_DE.ts +++ b/qt/i18n/OpenRGB_de_DE.ts @@ -197,7 +197,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1325,7 +1325,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Einblenden/Ausblenden diff --git a/qt/i18n/OpenRGB_el_GR.ts b/qt/i18n/OpenRGB_el_GR.ts index b5aa3c2b..655d3aaf 100644 --- a/qt/i18n/OpenRGB_el_GR.ts +++ b/qt/i18n/OpenRGB_el_GR.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1279,7 +1279,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Εμφάνιση/Απόκρυψη diff --git a/qt/i18n/OpenRGB_en_AU.ts b/qt/i18n/OpenRGB_en_AU.ts index 585af4df..035e6cc3 100644 --- a/qt/i18n/OpenRGB_en_AU.ts +++ b/qt/i18n/OpenRGB_en_AU.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB @@ -1217,7 +1217,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide diff --git a/qt/i18n/OpenRGB_en_GB.ts b/qt/i18n/OpenRGB_en_GB.ts index 571ead99..633ee15a 100644 --- a/qt/i18n/OpenRGB_en_GB.ts +++ b/qt/i18n/OpenRGB_en_GB.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB @@ -1217,7 +1217,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide diff --git a/qt/i18n/OpenRGB_en_US.ts b/qt/i18n/OpenRGB_en_US.ts index 5da74611..5137bf03 100644 --- a/qt/i18n/OpenRGB_en_US.ts +++ b/qt/i18n/OpenRGB_en_US.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB @@ -1278,7 +1278,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide diff --git a/qt/i18n/OpenRGB_es_ES.ts b/qt/i18n/OpenRGB_es_ES.ts index 98e4c681..2c3daa80 100644 --- a/qt/i18n/OpenRGB_es_ES.ts +++ b/qt/i18n/OpenRGB_es_ES.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1235,7 +1235,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Mostrar/esconder diff --git a/qt/i18n/OpenRGB_fr_FR.ts b/qt/i18n/OpenRGB_fr_FR.ts index ccd65ac6..0dd39ca6 100644 --- a/qt/i18n/OpenRGB_fr_FR.ts +++ b/qt/i18n/OpenRGB_fr_FR.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1233,7 +1233,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Afficher/Cacher diff --git a/qt/i18n/OpenRGB_hr_HR.ts b/qt/i18n/OpenRGB_hr_HR.ts index 721d0e27..bd5fc884 100644 --- a/qt/i18n/OpenRGB_hr_HR.ts +++ b/qt/i18n/OpenRGB_hr_HR.ts @@ -194,7 +194,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1219,7 +1219,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Prikaži/Sakrij diff --git a/qt/i18n/OpenRGB_it_IT.ts b/qt/i18n/OpenRGB_it_IT.ts index 73a6427f..b113db0e 100644 --- a/qt/i18n/OpenRGB_it_IT.ts +++ b/qt/i18n/OpenRGB_it_IT.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1217,7 +1217,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Mostra/Nascondi diff --git a/qt/i18n/OpenRGB_ja_JP.ts b/qt/i18n/OpenRGB_ja_JP.ts index 529cbb6f..c3d29fea 100644 --- a/qt/i18n/OpenRGB_ja_JP.ts +++ b/qt/i18n/OpenRGB_ja_JP.ts @@ -1285,71 +1285,71 @@ Using an effect on a device WILL damage the flash or controller - OpenRGBDialog2Ui + OpenRGBDialogUi - + OpenRGB OpenRGB(日本語化:R4NDO) - + Devices デバイス - + Information Information - + Settings 設定 - + Toggle LED View LEDビューに切替え - + Rescan Devices デバイス再検索 - - - + + + Save Profile プロファイルを保存 - + Delete Profile プロファイル削除 - + Load Profile プロファイルをロード - + OpenRGB is detecting devices... デバイスを検索しています... - + Cancel キャンセル - + Save Profile As... 名前をつけて保存... - + Save Profile with custom name 名前をつけてプロファイルを保存 @@ -2991,164 +2991,164 @@ Using an effect on a device WILL damage the flash or controller - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog - + Show/Hide 表示/隠す - + Profiles プロファイル - + Quick Colors 簡易色指定 - + Red - + Yellow 黄色 - + Green - + Cyan シアン - + Blue - + Magenta マゼンタ - + White - + Lights Off 消灯 - + Exit Exit - + Plugins プラグイン - + Software ソフトウェア - + Supported Devices 対応デバイス - + General Settings 一般設定 - + E1.31 Devices E1.31デバイス - + LIFX Devices LIFX デバイス - + Philips Hue Devices フィリップスHueデバイス - + Philips Wiz Devices フィリップスWizデバイス - + OpenRGB QMK Protocol OpenRGB QMK プロトコル - + Serial Devices シリアルデバイス - + Yeelight Devices Yeelightデバイス - + Nanoleaf Devices Nanoleaf デバイス - + Elgato KeyLight Devices Elgato KeyLight デバイス - + Elgato LightStrip Devices Elgato LightStrip デバイス - + SMBus Tools SMBus ツール - + SDK Client SDKクライアント - + SDK Server SDKサーバー - + Delete Profile プロファイル削除 - + Do you really want to delete this profile? 本当にプロファイルを削除しますか? - + Log Console ログコンソール diff --git a/qt/i18n/OpenRGB_ko_KR.ts b/qt/i18n/OpenRGB_ko_KR.ts index 64171a14..f75a8904 100644 --- a/qt/i18n/OpenRGB_ko_KR.ts +++ b/qt/i18n/OpenRGB_ko_KR.ts @@ -247,7 +247,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB (한국어화: OctopusET) @@ -1415,7 +1415,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide 표시/숨김 diff --git a/qt/i18n/OpenRGB_ms_MY.ts b/qt/i18n/OpenRGB_ms_MY.ts index 5c8b0f7b..d1983a71 100644 --- a/qt/i18n/OpenRGB_ms_MY.ts +++ b/qt/i18n/OpenRGB_ms_MY.ts @@ -237,71 +237,71 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi - + OpenRGB OpenRGB - + Devices Peranti - + Information Maklumat - + Settings Seting - + Toggle LED View Togol Pandangan LED - + Rescan Devices Imbasan Semula Peranti - - - + + + Save Profile Simpan Profil - + Delete Profile Padam Profil - + Load Profile Muat Profil - + OpenRGB is detecting devices... OpenRGB sedang mengesan peranti... - + Cancel Batal - + Save Profile As... Simpan Profil Sebagai... - + Save Profile with custom name Simpan Profil dengan nama tersuai @@ -1489,164 +1489,164 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog - + Show/Hide Tunjukkan/Sembunyikan - + Profiles Profil - + Quick Colors Warna Pantas - + Red Merah - + Yellow Kuning - + Green Hijau - + Cyan Sian - + Blue Biru - + Magenta Magenta - + White Putih - + Lights Off Lampu padam - + Exit Keluar - + Plugins Plugin - + Software Perisian - + Supported Devices Peranti yang Disokong - + General Settings Seting Umum - + E1.31 Devices Peranti E1.31 - + LIFX Devices Peranti LIFX - + Philips Hue Devices Peranti Philips Hue - + Philips Wiz Devices Peranti Philips Wiz - + OpenRGB QMK Protocol Protokol QMK OpenRGB - + Serial Devices Peranti Bersiri - + Yeelight Devices Peranti Yeelight - + Nanoleaf Devices Peranti Nanoleaf - + Elgato KeyLight Devices Peranti Elgato KeyLight - + Elgato LightStrip Devices Peranti Elgato LightStrip - + SMBus Tools Alat SMBus - + SDK Client Klient SDK - + SDK Server Pelayan SDK - + Delete Profile Padam Profil - + Do you really want to delete this profile? Adakah anda benar-benar mahu memadamkan profil ini? - + Log Console Konsol Log diff --git a/qt/i18n/OpenRGB_pl_PL.ts b/qt/i18n/OpenRGB_pl_PL.ts index 7fd74a33..557dcba2 100644 --- a/qt/i18n/OpenRGB_pl_PL.ts +++ b/qt/i18n/OpenRGB_pl_PL.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1217,7 +1217,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Pokaż/Ukryj diff --git a/qt/i18n/OpenRGB_pt_BR.ts b/qt/i18n/OpenRGB_pt_BR.ts index 506d02b5..6f5ad703 100644 --- a/qt/i18n/OpenRGB_pt_BR.ts +++ b/qt/i18n/OpenRGB_pt_BR.ts @@ -193,7 +193,7 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi OpenRGB OpenRGB @@ -1233,7 +1233,7 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog Show/Hide Mostrar/Esconder diff --git a/qt/i18n/OpenRGB_ru_RU.ts b/qt/i18n/OpenRGB_ru_RU.ts index 7f992b4a..d37d364c 100644 --- a/qt/i18n/OpenRGB_ru_RU.ts +++ b/qt/i18n/OpenRGB_ru_RU.ts @@ -309,71 +309,71 @@ - OpenRGBDialog2Ui + OpenRGBDialogUi - + OpenRGB - + Devices Устройства - + Information Информация - + Settings Настройки - + Toggle LED View LED View (On/Off) - + Rescan Devices Обновить список устройств - - - + + + Save Profile Сохранить профиль - + Delete Profile Удалить профиль - + Load Profile Применить профиль - + OpenRGB is detecting devices... OpenRGB обнаруживает устройства... - + Cancel Отменить - + Save Profile As... Сохранить профиль как... - + Save Profile with custom name Сохранить профиль с другим названием @@ -1774,174 +1774,174 @@ - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog - + Show/Hide Показать/скрыть - + Profiles Профили - + Quick Colors Палитра - + Red Красный - + Yellow Жёлтый - + Green Зелёный - + Cyan Бирюзовый - + Blue Синий - + Magenta Лиловый - + White Белый - + Lights Off Цвета выкл. - + Exit Выход - + Plugins Подключаемые модули - + Software Приложение - + Supported Devices Поддерживаемые устройства - + General Settings Общие настройки - + DMX Devices Устройства DMX - + E1.31 Devices Устройства E1.31 - + Kasa Smart Devices Устройства Kasa Smart - + Philips Hue Devices Устройства Philips Hue - + Philips Wiz Devices Устройства Philips Wiz - + OpenRGB QMK Protocol Протокол OpenRGB QMK - + Serial Devices Устройства последовательного порта - + Yeelight Devices Устройства Yeelight - + SMBus Tools Инструменты SMBus - + SDK Client Клиент SDK - + SDK Server Сервер SDK - + Delete Profile Удалить профиль - + Do you really want to delete this profile? Вы действительно хотите удалить этот профиль? - + Log Console Консоль журналирования - + LIFX Devices Устройства LIFX - + Nanoleaf Devices Устройства Nanoleaf - + Elgato KeyLight Devices Устройства Elgato KeyLight - + Elgato LightStrip Devices Устройства Elgato LightStrip diff --git a/qt/i18n/OpenRGB_zh_CN.ts b/qt/i18n/OpenRGB_zh_CN.ts index b838a2d7..994cb3e3 100644 --- a/qt/i18n/OpenRGB_zh_CN.ts +++ b/qt/i18n/OpenRGB_zh_CN.ts @@ -1286,71 +1286,71 @@ Using an effect on a device WILL damage the flash or controller - OpenRGBDialog2Ui + OpenRGBDialogUi - + OpenRGB OpenRGB (汉化:画板当吃生菜、绿鲤驴与鱼、我唔係MentaL) - + Devices 设备 - + Information 信息 - + Settings 设置 - + Toggle LED View 开关 LED 视图 - + Rescan Devices 重新扫描设备 - - - + + + Save Profile 保存配置文件 - + Delete Profile 删除配置文件 - + Load Profile 加载配置文件 - + OpenRGB is detecting devices... OpenRGB 正在检测设备... - + Cancel 取消 - + Save Profile As... 保存配置文件为... - + Save Profile with custom name 使用自定义名称保存配置文件 @@ -2992,164 +2992,164 @@ Using an effect on a device WILL damage the flash or controller - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog - + Show/Hide 显示/隐藏 - + Profiles 配置文件 - + Quick Colors 快速着色 - + Red 红色 - + Yellow 黄色 - + Green 绿色 - + Cyan 青色 - + Blue 蓝色 - + Magenta 品红 - + White - + Lights Off 关灯 - + Exit 退出 - + Plugins 插件 - + Software 软件 - + Supported Devices 兼容设备选择 - + General Settings 常规设置 - + E1.31 Devices E1.31 设备 - + LIFX Devices LIFX 设备 - + Philips Hue Devices 飞利浦 Hue 设备 - + Philips Wiz Devices 飞利浦 Wiz 设备 - + OpenRGB QMK Protocol OpenRGB QMK 协议 - + Serial Devices 串行设备 - + Yeelight Devices Yeelight 设备 - + Nanoleaf Devices 绿诺设备 - + Elgato KeyLight Devices Elgato KeyLight 设备 - + Elgato LightStrip Devices Elgato 灯条设备 - + SMBus Tools SMBus 工具 - + SDK Client SDK 客户端 - + SDK Server SDK 服务器 - + Delete Profile 删除配置文件 - + Do you really want to delete this profile? 是否确定删除此配置文件? - + Log Console 日志控制台 diff --git a/qt/i18n/OpenRGB_zh_TW.ts b/qt/i18n/OpenRGB_zh_TW.ts index fd2f417d..19287aea 100644 --- a/qt/i18n/OpenRGB_zh_TW.ts +++ b/qt/i18n/OpenRGB_zh_TW.ts @@ -1286,71 +1286,71 @@ Using an effect on a device WILL damage the flash or controller - OpenRGBDialog2Ui + OpenRGBDialogUi - + OpenRGB OpenRGB(漢化:畫板當吃生菜、綠鯉驢與魚) - + Devices 設備 - + Information 訊息 - + Settings 設置 - + Toggle LED View 開關 LED 視圖 - + Rescan Devices 重新掃描設備 - - - + + + Save Profile 保存配置文件 - + Delete Profile 刪除配置文件 - + Load Profile 載入配置文件 - + OpenRGB is detecting devices... OpenRGB 正在檢測設備... - + Cancel 取消 - + Save Profile As... 保存配置文件為... - + Save Profile with custom name 使用自訂名稱保存配置文件 @@ -2992,164 +2992,164 @@ Using an effect on a device WILL damage the flash or controller - Ui::OpenRGBDialog2 + Ui::OpenRGBDialog - + Show/Hide 顯示/隱藏 - + Profiles 配置文件 - + Quick Colors 快速著色 - + Red 紅色 - + Yellow 黃色 - + Green 綠色 - + Cyan 青色 - + Blue 藍色 - + Magenta 品紅 - + White - + Lights Off 關燈 - + Exit 退出 - + Plugins 插件 - + Software 軟體 - + Supported Devices 相容設備選擇 - + General Settings 常規設置 - + E1.31 Devices E1.31 設備 - + LIFX Devices LIFX 設備 - + Philips Hue Devices 飛利浦 Hue 設備 - + Philips Wiz Devices 飛利浦 Wiz 設備 - + OpenRGB QMK Protocol OpenRGB QMK 協議 - + Serial Devices 串列設備 - + Yeelight Devices Yeelight 設備 - + Nanoleaf Devices 綠諾設備 - + Elgato KeyLight Devices Elgato KeyLight 設備 - + Elgato LightStrip Devices Elgato 燈條設備 - + SMBus Tools SMBus 工具 - + SDK Client SDK 用戶端 - + SDK Server SDK 伺服器 - + Delete Profile 刪除配置文件 - + Do you really want to delete this profile? 是否確定刪除此配置文件? - + Log Console 日誌控制台