From 1598fc8de47da01a0982a44d7d80bd0aa2623aad Mon Sep 17 00:00:00 2001 From: k1-801 Date: Fri, 21 Aug 2020 21:32:13 +0400 Subject: [PATCH] Add apply and select all buttons. Select all button and some minor rework by Adam Honse --- qt/OpenRGBDevicePage.cpp | 141 ++++++++++++----- qt/OpenRGBDevicePage.h | 4 + qt/OpenRGBDevicePage.ui | 320 ++++++++++++++++++++------------------- 3 files changed, 273 insertions(+), 192 deletions(-) diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index f06d4c4da..ff72adf1f 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -23,14 +23,22 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) : device = dev; /*-----------------------------------------------------*\ - | Set up the color palette buttons | + | Register update callback with the device | \*-----------------------------------------------------*/ - QPalette pal; + device->RegisterUpdateCallback(UpdateCallback, this); + + /*-----------------------------------------------------*\ + | Set up the device view | + \*-----------------------------------------------------*/ + connect(ui->DeviceViewBox, &DeviceView::selectionChanged, this, &OpenRGBDevicePage::on_DeviceViewBox_selectionChanged); ui->DeviceViewBox->setController(device); ui->DeviceViewBox->hide(); - device->RegisterUpdateCallback(UpdateCallback, this); + /*-----------------------------------------------------*\ + | Set up the color palette buttons | + \*-----------------------------------------------------*/ + QPalette pal; pal = ui->ButtonRed->palette(); pal.setColor(QPalette::Button, QColor(255, 0, 0)); @@ -92,8 +100,6 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) : | Update mode user interface elements | \*-----------------------------------------------------*/ UpdateModeUi(); - - connect(ui->DeviceViewBox, &DeviceView::selectionChanged, this, &OpenRGBDevicePage::on_DeviceViewBox_selectionChanged); } OpenRGBDevicePage::~OpenRGBDevicePage() @@ -129,7 +135,7 @@ void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int /*index*/) { if(device->leds.size() > 1) { - ui->LEDBox->addItem("Entire device"); + ui->LEDBox->addItem("Entire Device"); ui->LEDBox->setEnabled(1); } else @@ -161,7 +167,7 @@ void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int /*index*/) // Disable led box if there's only one LED anyway if(device->zones[selected_zone].leds_count > 1) { - ui->LEDBox->addItem("Entire zone"); + ui->LEDBox->addItem("Entire Zone"); ui->LEDBox->setEnabled(1); } else @@ -569,6 +575,8 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() ui->LEDBox->blockSignals(false); ui->ResizeButton->setEnabled(false); + ui->ApplyColorsButton->setEnabled(false); + //ui->AutoFillCheck->setEnabled(false); break; case MODE_COLORS_PER_LED: @@ -592,6 +600,8 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() ui->ZoneBox->setCurrentIndex(0); ui->ZoneBox->blockSignals(false); + ui->ApplyColorsButton->setEnabled(true); + //ui->AutoFillCheck->setEnabled(true); /*-----------------------------------------------------*\ | Update LED box | @@ -632,6 +642,8 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() ui->LEDBox->setCurrentIndex(0); on_LEDBox_currentIndexChanged(0); ui->LEDBox->blockSignals(false); + ui->ApplyColorsButton->setEnabled(true); + //ui->AutoFillCheck->setEnabled(true); break; } } @@ -955,42 +967,45 @@ void Ui::OpenRGBDevicePage::updateWheel() void Ui::OpenRGBDevicePage::updateDeviceView() { - /*-----------------------------------------------------*\ - | Read selected mode | - \*-----------------------------------------------------*/ - unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex(); - - switch(device->modes[selected_mode].color_mode) + if(false)//ui->AutoFillCheck->isChecked()) { - case MODE_COLORS_PER_LED: - { - RGBColor qrgb = ToRGBColor - ( - ui->RedSpinBox->value(), - ui->GreenSpinBox->value(), - ui->BlueSpinBox->value()); - ui->DeviceViewBox->setSelectionColor(qrgb); - } - break; + /*-----------------------------------------------------*\ + | Read selected mode | + \*-----------------------------------------------------*/ + unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex(); - case MODE_COLORS_MODE_SPECIFIC: - { - unsigned int index = ui->LEDBox->currentIndex(); + switch(device->modes[selected_mode].color_mode) + { + case MODE_COLORS_PER_LED: + { + RGBColor qrgb = ToRGBColor + ( + ui->RedSpinBox->value(), + ui->GreenSpinBox->value(), + ui->BlueSpinBox->value()); + ui->DeviceViewBox->setSelectionColor(qrgb); + } + break; - /*-----------------------------------------------------*\ - | Set all device LEDs to the current color | - \*-----------------------------------------------------*/ - RGBColor color = ToRGBColor( - ui->RedSpinBox->text().toInt(), - ui->GreenSpinBox->text().toInt(), - ui->BlueSpinBox->text().toInt() - ); + case MODE_COLORS_MODE_SPECIFIC: + { + unsigned int index = ui->LEDBox->currentIndex(); - device->modes[selected_mode].colors[index] = color; + /*-----------------------------------------------------*\ + | Set all device LEDs to the current color | + \*-----------------------------------------------------*/ + RGBColor color = ToRGBColor( + ui->RedSpinBox->text().toInt(), + ui->GreenSpinBox->text().toInt(), + ui->BlueSpinBox->text().toInt() + ); - device->UpdateMode(); - } - break; + device->modes[selected_mode].colors[index] = color; + + device->UpdateMode(); + } + break; + } } } @@ -1156,3 +1171,53 @@ void Ui::OpenRGBDevicePage::HideDeviceView() { ui->DeviceViewBox->hide(); } + +void Ui::OpenRGBDevicePage::on_ApplyColorsButton_clicked() +{ + /*-----------------------------------------------------*\ + | Read selected mode | + \*-----------------------------------------------------*/ + unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex(); + + switch(device->modes[selected_mode].color_mode) + { + case MODE_COLORS_PER_LED: + { + RGBColor qrgb = ToRGBColor + ( + ui->RedSpinBox->value(), + ui->GreenSpinBox->value(), + ui->BlueSpinBox->value()); + ui->DeviceViewBox->setSelectionColor(qrgb); + } + break; + + case MODE_COLORS_MODE_SPECIFIC: + { + unsigned int index = ui->LEDBox->currentIndex(); + + /*-----------------------------------------------------*\ + | Set all device LEDs to the current color | + \*-----------------------------------------------------*/ + RGBColor color = ToRGBColor( + ui->RedSpinBox->text().toInt(), + ui->GreenSpinBox->text().toInt(), + ui->BlueSpinBox->text().toInt() + ); + + device->modes[selected_mode].colors[index] = color; + + device->UpdateMode(); + } + break; + } +} + +void Ui::OpenRGBDevicePage::on_SelectAllLEDsButton_clicked() +{ + if(device->modes[device->active_mode].color_mode == MODE_COLORS_PER_LED) + { + ui->LEDBox->setCurrentIndex(0); + on_LEDBox_currentIndexChanged(0); + } +} diff --git a/qt/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage.h index b471e766f..a13223d10 100644 --- a/qt/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage.h @@ -55,6 +55,10 @@ private slots: void on_ModeSpecificCheck_clicked(); void on_ResizeButton_clicked(); + void on_ApplyColorsButton_clicked(); + + void on_SelectAllLEDsButton_clicked(); + private: Ui::OpenRGBDevicePageUi *ui; RGBController *device; diff --git a/qt/OpenRGBDevicePage.ui b/qt/OpenRGBDevicePage.ui index c31cd5f62..5acbed140 100644 --- a/qt/OpenRGBDevicePage.ui +++ b/qt/OpenRGBDevicePage.ui @@ -14,82 +14,58 @@ Frame - - + + + + + + - + - - - - 255 - - - - - + + - Dir: + R: - - + + - Zone: + Colors: - - - - Set All Devices - - - - + - - - - 255 - - - - + - - - - Resize + + + + 255 - - + + - LED: + Apply Colors - - - - Qt::Horizontal - - - - - + + - Speed: + @@ -109,150 +85,188 @@ - - - - - - - - - - - H: - - - - + Mode: - - - - Per-LED + + + + Qt::Horizontal - - - - - - - - - - - Colors: - - - - - - - 255 - - - - - - - - - - - - - - 359 - - - - - - - - - - 255 - - - - - - - 255 - - - - - - - V: - - - - - - - R: - - - - - - - Random - - - - + S: - - + + + + Set All Devices + + + + + + + LED: + + + + + - - - - B: + + + + 255 - + + + + 255 + + + + + + + V: + + + + + + + Dir: + + + + Mode-Specific - + - + + + + 255 + + + + + + + H: + + + + G: - + + + + 359 + + + + + + + Random + + + + + + + Speed: + + + + + + + Per-LED + + + + + + + + + + + + + + 255 + + + + + + + B: + + + + + + + + + + Select All + + + + + + + Resize + + + + + + + Zone: + + + + + + + @@ -282,8 +296,6 @@ - ZoneBox - ResizeButton LEDBox SetAllButton ModeBox