diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp index d8376239..5489f28d 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp @@ -78,7 +78,7 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) : /*-----------------------------------------------------*\ | Get the UserInterface settings and check the | - | numerical labels setting | + | numerical labels and hex format settings | \*-----------------------------------------------------*/ SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); std::string ui_string = "UserInterface"; @@ -93,6 +93,18 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) : ui->DeviceViewBox->setNumericalLabels(numerical_labels); } + if(ui_settings.contains("hex_format")) + { + if(ui_settings["hex_format"] == "RGB") + { + HexFormatRGB = true; + } + else if(ui_settings["hex_format"] == "BGR") + { + HexFormatRGB = false; + } + } + ui->DeviceViewBox->setController(device); ui->DeviceViewBoxFrame->hide(); @@ -1458,10 +1470,22 @@ void Ui::OpenRGBDevicePage::on_HexLineEdit_textChanged(const QString &arg1) /*-----------------------------------------------------*\ | Store new color into the current color QColor | + | Because RGBColor stores color in BGR format, we have | + | to reverse the R and B channels if the hex format is | + | RGB. | \*-----------------------------------------------------*/ - current_color.setRed(RGBGetRValue(color)); - current_color.setGreen(RGBGetGValue(color)); - current_color.setBlue(RGBGetBValue(color)); + if(HexFormatRGB) + { + current_color.setRed(RGBGetBValue(color)); + current_color.setGreen(RGBGetGValue(color)); + current_color.setBlue(RGBGetRValue(color)); + } + else + { + current_color.setRed(RGBGetRValue(color)); + current_color.setGreen(RGBGetGValue(color)); + current_color.setBlue(RGBGetBValue(color)); + } /*-----------------------------------------------------*\ | Update the color UI, but set the UpdateHex flag to | @@ -1832,8 +1856,21 @@ void Ui::OpenRGBDevicePage::updateColorUi() \*-----------------------------------------------------*/ if(UpdateHex) { + RGBColor color = (0x00FFFFFF & current_color.rgb()); + + /*-------------------------------------------------*\ + | If the hex format is BGR, swap R and B before | + | displaying as hex | + \*-------------------------------------------------*/ + if(!HexFormatRGB) + { + color = RGBGetRValue(color) << 16 + | RGBGetGValue(color) << 8 + | RGBGetBValue(color); + } + ui->HexLineEdit->blockSignals(true); - ui->HexLineEdit->setText(QString().asprintf("%06X", (0x00FFFFFF & current_color.rgb()))); + ui->HexLineEdit->setText(QString().asprintf("%06X", color)); ui->HexLineEdit->blockSignals(false); } } diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage/OpenRGBDevicePage.h index 8750ed1c..7e56b85a 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.h @@ -78,6 +78,7 @@ private: bool MultipleSelected = false; bool DeviceViewShowing = false; bool UpdateHex = true; + bool HexFormatRGB = true; QColor current_color; void updateColorUi(); diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp index bf886d9a..0f832ccb 100644 --- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp +++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.cpp @@ -62,6 +62,14 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) : } ui->ComboBoxLanguage->blockSignals(false); + /*---------------------------------------------------------*\ + | Populate hex format combo box | + \*---------------------------------------------------------*/ + ui->ComboBoxHexFormat->addItem("RGB"); + ui->ComboBoxHexFormat->addItem("BGR"); + + hex_format_initialized = true; + /*---------------------------------------------------------*\ | Load theme settings | \*---------------------------------------------------------*/ @@ -158,6 +166,18 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) : ui->CheckboxShowLEDView->setChecked(false); } + if(ui_settings.contains("hex_format")) + { + if(ui_settings["hex_format"] == "RGB") + { + ui->ComboBoxHexFormat->setCurrentIndex(0); + } + else if(ui_settings["hex_format"] == "BGR") + { + ui->ComboBoxHexFormat->setCurrentIndex(1); + } + } + /*---------------------------------------------------------*\ | Load LogManager settings | \*---------------------------------------------------------*/ @@ -386,6 +406,17 @@ void OpenRGBSettingsPage::on_ComboBoxTheme_currentTextChanged(const QString them } } +void OpenRGBSettingsPage::on_ComboBoxHexFormat_currentTextChanged(const QString hex_format) +{ + if(hex_format_initialized) + { + json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface"); + ui_settings["hex_format"] = hex_format.toStdString(); + ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface",ui_settings); + SaveSettings(); + } +} + void OpenRGBSettingsPage::on_CheckboxTrayIconGreyscale_clicked() { json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface"); diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h index 13ac9e11..917a47fc 100644 --- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h +++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.h @@ -50,12 +50,14 @@ private: bool theme_initialized = false; bool autostart_initialized = false; + bool hex_format_initialized = false; QTranslator translator; private slots: void changeEvent(QEvent *event); void on_ComboBoxLanguage_currentTextChanged(const QString); void on_ComboBoxTheme_currentTextChanged(const QString); + void on_ComboBoxHexFormat_currentTextChanged(const QString); void on_CheckboxMinimizeOnClose_clicked(); void on_CheckboxTrayIconGreyscale_clicked(); void on_CheckboxLoadGeometry_clicked(); diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui index 4236cbfe..a0ce4362 100644 --- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui +++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui @@ -6,7 +6,7 @@ 0 0 - 432 + 475 500 @@ -31,30 +31,31 @@ 0 0 - 678 - 980 + 441 + 856 - + Load Profile - - + + - Set Profile on Exit + Custom Arguments - - - - - + + + + Start At Login + + @@ -63,131 +64,33 @@ - - - - Custom Arguments - - - - - - - - - - Language - - - - - - - Load Window Geometry - - - - - - - Start Minimized - - - - - - - Start at Login Status - - - - - - - Set Server Host - - - - - - - - - - Save Geometry On Close - - - - - - Shared SMBus Access (restart required) - - - - - - - - - - Start At Login - - - - - - - User Interface Settings: - - - - - - - Minimize On Close - - - - - - - Drivers Settings - - - - - - - Enable Log Console (restart required) - - - - - - - 90000 - - - - - - - - - - - - - AMD SMBus: Reduce CPU Usage (restart required) - - + + + + Start At Login Settings: + + + + + + + Start Server + + + + + + + Set Profile on Exit + + @@ -196,19 +99,18 @@ - - + + + + + - Start Server + Show LED view by default - - - - Start Client - - + + @@ -217,7 +119,41 @@ + + + + + + + Enable Log Console (restart required) + + + + + + + + + + Start Client + + + + + + + Disable key expansion in device view + + + + + + Start at Login Status + + + + Qt::Vertical @@ -233,41 +169,115 @@ - - + + + + + - Disable key expansion in device view + Save Geometry On Close - - + + - Log Manager Settings: + Minimize On Close + + + + Start Minimized + + + + + + + User Interface Settings: + + + + + + - + - Start At Login Settings: + Shared SMBus Access (restart required) - + + + + Drivers Settings + + + + + + + Set Server Port - - + + - Show LED view by default + Load Window Geometry + + + + 90000 + + + + + + + + + + + + + Log Manager Settings: + + + + + + + Language + + + + + + + Set Server Host + + + + + + + Hex Format + + + + + +