diff --git a/OpenRGB.pro b/OpenRGB.pro index a3ca4287..b3e54a1b 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -72,6 +72,7 @@ SOURCES += \ qt/OpenRGBProfileSaveDialog.cpp \ qt/OpenRGBSoftwareInfoPage.cpp \ qt/OpenRGBSystemInfoPage.cpp \ + qt/OpenRGBZoneResizeDialog.cpp \ qt/hsv.cpp \ serial_port/serial_port.cpp \ super_io/super_io.cpp \ @@ -161,6 +162,7 @@ HEADERS += \ qt/OpenRGBProfileSaveDialog.h \ qt/OpenRGBSoftwareInfoPage.h \ qt/OpenRGBSystemInfoPage.h \ + qt/OpenRGBZoneResizeDialog.h \ serial_port/find_usb_serial_port.h \ serial_port/serial_port.h \ super_io/super_io.h \ @@ -223,7 +225,8 @@ FORMS += \ qt/OpenRGBDialog2.ui \ qt/OpenRGBProfileSaveDialog.ui \ qt/OpenRGBSoftwareInfoPage.ui \ - qt/OpenRGBSystemInfoPage.ui + qt/OpenRGBSystemInfoPage.ui \ + qt/OpenRGBZoneResizeDialog.ui #----------------------------------------------- # Windows specific project configuration diff --git a/RGBController/RGBController.h b/RGBController/RGBController.h index 253f662a..48197ef7 100644 --- a/RGBController/RGBController.h +++ b/RGBController/RGBController.h @@ -120,6 +120,8 @@ typedef struct zone_type type; /* Zone type */ std::vector> map; /* LED index map */ + unsigned int leds_min; + unsigned int leds_max; } zone; class RGBController diff --git a/RGBController/RGBController_CorsairNodePro.cpp b/RGBController/RGBController_CorsairNodePro.cpp index aed25f92..5b8d2a99 100644 --- a/RGBController/RGBController_CorsairNodePro.cpp +++ b/RGBController/RGBController_CorsairNodePro.cpp @@ -183,9 +183,11 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl char ch_idx_string[2]; sprintf(ch_idx_string, "%d", channel_idx + 1); - new_zone->name = "Corsair Channel "; + new_zone->name = "Corsair Channel "; new_zone->name.append(ch_idx_string); - new_zone->type = ZONE_TYPE_LINEAR; + new_zone->type = ZONE_TYPE_LINEAR; + new_zone->leds_min = 0; + new_zone->leds_max = 40; std::vector *new_zone_map = new std::vector(); diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index 5595ee40..86aef1a2 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -1,4 +1,5 @@ #include "OpenRGBDevicePage.h" +#include "OpenRGBZoneResizeDialog.h" #include "hsv.h" using namespace Ui; @@ -108,6 +109,8 @@ void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int /*index*/) { ui->LEDBox->addItem(device->leds[i].name.c_str()); } + + ui->ResizeButton->setEnabled(false); } else { @@ -120,6 +123,15 @@ void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int /*index*/) ui->LEDBox->addItem(device->leds[device->zones[selected_zone].map[y][x]].name.c_str()); } } + + if(device->zones[selected_zone].leds_min == device->zones[selected_zone].leds_max) + { + ui->ResizeButton->setEnabled(false); + } + else + { + ui->ResizeButton->setEnabled(true); + } } ui->LEDBox->setCurrentIndex(0); @@ -441,6 +453,8 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() ui->LEDBox->blockSignals(true); ui->LEDBox->clear(); ui->LEDBox->blockSignals(false); + + ui->ResizeButton->setEnabled(false); break; case MODE_COLORS_PER_LED: @@ -477,6 +491,15 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() ui->LEDBox->blockSignals(true); ui->LEDBox->clear(); + if(device->modes[selected_mode].colors_min == device->modes[selected_mode].colors_max) + { + ui->ResizeButton->setEnabled(false); + } + else + { + ui->ResizeButton->setEnabled(true); + } + for (std::size_t i = 0; i < device->modes[selected_mode].colors.size(); i++) { char id_buf[32]; @@ -932,3 +955,44 @@ void Ui::OpenRGBDevicePage::on_SetAllButton_clicked() emit SetAllDevices(red, green, blue); } + +void Ui::OpenRGBDevicePage::on_ResizeButton_clicked() +{ + switch(device->modes[device->active_mode].color_mode) + { + case MODE_COLORS_PER_LED: + { + int selected_zone = ui->ZoneBox->currentIndex(); + + selected_zone -= 1; + + if(device->zones[selected_zone].type == ZONE_TYPE_LINEAR) + { + OpenRGBZoneResizeDialog dlg(device->zones[selected_zone].leds_min, + device->zones[selected_zone].leds_max, + device->zones[selected_zone].map[0].size()); + + int new_size = dlg.show(); + } + } + break; + + case MODE_COLORS_MODE_SPECIFIC: + { + OpenRGBZoneResizeDialog dlg(device->modes[device->active_mode].colors_min, + device->modes[device->active_mode].colors_max, + device->modes[device->active_mode].colors.size()); + + int new_size = dlg.show(); + + if(new_size > 0) + { + device->modes[device->active_mode].colors.resize(new_size); + } + + UpdateModeUi(); + UpdateMode(); + } + break; + } +} diff --git a/qt/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage.h index 6945b154..3a692c0f 100644 --- a/qt/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage.h @@ -56,6 +56,8 @@ private slots: void on_ModeSpecificCheck_clicked(); + void on_ResizeButton_clicked(); + private: Ui::OpenRGBDevicePageUi *ui; RGBController *device; diff --git a/qt/OpenRGBDevicePage.ui b/qt/OpenRGBDevicePage.ui index 0f281a9c..2db3bf42 100644 --- a/qt/OpenRGBDevicePage.ui +++ b/qt/OpenRGBDevicePage.ui @@ -14,131 +14,6 @@ Frame - - - - - - - 255 - - - - - - - - - - - - - - - - - - - - - S: - - - - - - - Mode: - - - - - - - 255 - - - - - - - LED: - - - - - - - 255 - - - - - - - R: - - - - - - - Dir: - - - - - - - Qt::Horizontal - - - - - - - Zone: - - - - - - - B: - - - - - - - Set: - - - - - - - V: - - - - - - - - - - 255 - - - - - - - 359 - - - @@ -146,89 +21,20 @@ - - - - 255 - - - - - - - - - - - + - - - - - - - Speed: - - - - - - - - - - H: - - - - - - - Zone - - - - + - - - - Set All Devices - - - - - - - G: - - - - - - - LED - - - - - - - - - - @@ -236,17 +42,27 @@ - - + + + + 255 + + + + + + + + - Mode-Specific + S: - + - Random + Mode-Specific @@ -257,6 +73,197 @@ + + + + + + + + + + + + + + B: + + + + + + + Speed: + + + + + + + Set All Devices + + + + + + + V: + + + + + + + Dir: + + + + + + + + + + R: + + + + + + + LED + + + + + + + G: + + + + + + + + + + + + + + Zone + + + + + + + 255 + + + + + + + Qt::Horizontal + + + + + + + H: + + + + + + + + + + + + + + + + + + + + + Set: + + + + + + + LED: + + + + + + + 359 + + + + + + + 255 + + + + + + + Random + + + + + + + 255 + + + + + + + 255 + + + + + + + Zone: + + + + + + + Mode: + + + + + + + + + + Resize + + + diff --git a/qt/OpenRGBZoneResizeDialog.cpp b/qt/OpenRGBZoneResizeDialog.cpp new file mode 100644 index 00000000..d3aeca7c --- /dev/null +++ b/qt/OpenRGBZoneResizeDialog.cpp @@ -0,0 +1,53 @@ +#include "OpenRGBZoneResizeDialog.h" + +using namespace Ui; + +OpenRGBZoneResizeDialog::OpenRGBZoneResizeDialog(int size_min, int size_max, int size_current, QWidget *parent) : + QDialog(parent), + ui(new Ui::OpenRGBZoneResizeDialogUi) +{ + ui->setupUi(this); + + ui->ResizeSlider->setRange(size_min, size_max); + ui->ResizeBox->setRange(size_min, size_max); + + ui->ResizeSlider->setValue(size_current); + ui->ResizeBox->setValue(size_current); +} + +OpenRGBZoneResizeDialog::~OpenRGBZoneResizeDialog() +{ + delete ui; +} + +void Ui::OpenRGBZoneResizeDialog::on_ResizeSlider_valueChanged(int value) +{ + ui->ResizeBox->blockSignals(true); + ui->ResizeBox->setValue(value); + ui->ResizeBox->blockSignals(false); +} + +void Ui::OpenRGBZoneResizeDialog::on_ResizeBox_valueChanged(int value) +{ + ui->ResizeSlider->blockSignals(true); + ui->ResizeSlider->setValue(value); + ui->ResizeSlider->blockSignals(false); +} + +int Ui::OpenRGBZoneResizeDialog::show() +{ + int ret_val = 0; + + int result = this->exec(); + + if(result == QDialog::Rejected) + { + ret_val = -1; + } + else + { + ret_val = ui->ResizeBox->value(); + } + + return(ret_val); +} diff --git a/qt/OpenRGBZoneResizeDialog.h b/qt/OpenRGBZoneResizeDialog.h new file mode 100644 index 00000000..300c389f --- /dev/null +++ b/qt/OpenRGBZoneResizeDialog.h @@ -0,0 +1,30 @@ +#ifndef OPENRGBZONERESIZEDIALOG_H +#define OPENRGBZONERESIZEDIALOG_H + +#include +#include "ui_OpenRGBZoneResizeDialog.h" + +namespace Ui { +class OpenRGBZoneResizeDialog; +} + +class Ui::OpenRGBZoneResizeDialog : public QDialog +{ + Q_OBJECT + +public: + explicit OpenRGBZoneResizeDialog(int size_min, int size_max, int size_current, QWidget *parent = nullptr); + ~OpenRGBZoneResizeDialog(); + + int show(); + +private slots: + void on_ResizeSlider_valueChanged(int value); + + void on_ResizeBox_valueChanged(int arg1); + +private: + Ui::OpenRGBZoneResizeDialogUi *ui; +}; + +#endif // OPENRGBZONERESIZEDIALOG_H diff --git a/qt/OpenRGBZoneResizeDialog.ui b/qt/OpenRGBZoneResizeDialog.ui new file mode 100644 index 00000000..c7e427b1 --- /dev/null +++ b/qt/OpenRGBZoneResizeDialog.ui @@ -0,0 +1,91 @@ + + + OpenRGBZoneResizeDialogUi + + + + 0 + 0 + 400 + 180 + + + + Resize Zone + + + + + 30 + 140 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 20 + 20 + 361 + 22 + + + + Qt::Horizontal + + + + + + 260 + 80 + 121 + 22 + + + + + + + + buttonBox + accepted() + OpenRGBZoneResizeDialogUi + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + OpenRGBZoneResizeDialogUi + reject() + + + 316 + 260 + + + 286 + 274 + + + + +