diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp index da305d87..62ecf9b2 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp @@ -1360,6 +1360,38 @@ void Ui::OpenRGBDevicePage::on_ValSpinBox_valueChanged(int val) colorChanged(); } +void Ui::OpenRGBDevicePage::on_HexLineEdit_textChanged(const QString &arg1) +{ + /*-----------------------------------------------------*\ + | Make an editable copy of the string | + \*-----------------------------------------------------*/ + QString temp = arg1; + + /*-----------------------------------------------------*\ + | Remove # character so that #XXXXXX color codes are | + | acceptable. 0xXXXXXX codes are already accepted by | + | toInt(). Convert into an RGBColor. Mask off the | + | unused bits. | + \*-----------------------------------------------------*/ + RGBColor color = (RGBColor)(0x00FFFFFF & temp.replace("#", "").toInt(NULL, 16)); + + /*-----------------------------------------------------*\ + | Store new color into the current color QColor | + \*-----------------------------------------------------*/ + 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 | + | false so the hex edit box isn't updated while the user| + | is in the middle of typing a value. | + \*-----------------------------------------------------*/ + UpdateHex = false; + colorChanged(); + UpdateHex = true; +} + void Ui::OpenRGBDevicePage::on_DeviceViewBox_selectionChanged(QVector indices) { if(device->modes[device->active_mode].color_mode == MODE_COLORS_PER_LED) @@ -1694,4 +1726,14 @@ void Ui::OpenRGBDevicePage::updateColorUi() ui->ValSpinBox->blockSignals(true); ui->ValSpinBox->setValue(current_color.value()); ui->ValSpinBox->blockSignals(false); + + /*-----------------------------------------------------*\ + | Update Hex edit box | + \*-----------------------------------------------------*/ + if(UpdateHex) + { + ui->HexLineEdit->blockSignals(true); + ui->HexLineEdit->setText(QString().asprintf("%06X", (0x00FFFFFF & current_color.rgb()))); + ui->HexLineEdit->blockSignals(false); + } } diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage/OpenRGBDevicePage.h index aa874c4b..bae56f2d 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.h @@ -46,6 +46,7 @@ private slots: void on_SatSpinBox_valueChanged(int sat); void on_BlueSpinBox_valueChanged(int blue); void on_ValSpinBox_valueChanged(int val); + void on_HexLineEdit_textChanged(const QString &arg1); void on_DeviceViewBox_selectionChanged(QVector); void on_SetAllButton_clicked(); @@ -68,6 +69,7 @@ private: bool InvertedBrightness = false; bool MultipleSelected = false; bool DeviceViewShowing = false; + bool UpdateHex = true; QColor current_color; void updateColorUi(); diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.ui b/qt/OpenRGBDevicePage/OpenRGBDevicePage.ui index 07cf8418..758e952d 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.ui +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.ui @@ -13,9 +13,9 @@ Device page - + - + 0 @@ -26,21 +26,21 @@ true - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Sunken + QFrame::Shadow::Sunken - + - + - QFrame::NoFrame + QFrame::Shape::NoFrame - QFrame::Raised + QFrame::Shadow::Raised - + 0 @@ -137,16 +137,23 @@ + + + + Hex: + + + + + + + 8 + + + - - - - Save To Device - - - @@ -170,11 +177,18 @@ + + + + Save To Device + + + - + 0 @@ -185,12 +199,12 @@ true - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Sunken + QFrame::Shadow::Sunken - + @@ -228,7 +242,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -304,7 +318,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -339,12 +353,12 @@ true - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Sunken + QFrame::Shadow::Sunken - +