Add apply and select all buttons.

Select all button and some minor rework by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
k1-801
2020-08-21 21:32:13 +04:00
committed by Adam Honse
parent b03fce33ca
commit 1598fc8de4
3 changed files with 273 additions and 192 deletions

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -14,82 +14,58 @@
<string>Frame</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="ZoneBox"/>
<item row="12" column="8">
<widget class="QPushButton" name="ButtonCyan">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1" colspan="4">
<item row="7" column="1" colspan="4">
<widget class="QComboBox" name="ModeBox"/>
</item>
<item row="6" column="9" colspan="2">
<widget class="QSpinBox" name="SatSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="DirectionLabel">
<item row="7" column="5">
<widget class="QLabel" name="RedLabel">
<property name="text">
<string>Dir:</string>
<string>R:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="ZoneLabel">
<item row="8" column="0">
<widget class="QLabel" name="ColorLabel">
<property name="text">
<string>Zone:</string>
<string>Colors:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="4">
<widget class="QPushButton" name="SetAllButton">
<property name="text">
<string>Set All Devices</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="4">
<item row="12" column="1" colspan="4">
<widget class="QComboBox" name="DirectionBox"/>
</item>
<item row="7" column="9" colspan="2">
<widget class="QSpinBox" name="ValSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="10" column="9">
<item row="12" column="9">
<widget class="QPushButton" name="ButtonBlue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="ResizeButton">
<property name="text">
<string>Resize</string>
<item row="7" column="6" colspan="2">
<widget class="QSpinBox" name="RedSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="LEDLabel">
<item row="4" column="1" colspan="4">
<widget class="QPushButton" name="ApplyColorsButton">
<property name="text">
<string>LED:</string>
<string>Apply Colors</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="4">
<widget class="QSlider" name="SpeedSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="SpeedLabel">
<item row="12" column="6">
<widget class="QPushButton" name="ButtonYellow">
<property name="text">
<string>Speed:</string>
<string/>
</property>
</widget>
</item>
@@ -109,150 +85,188 @@
</property>
</widget>
</item>
<item row="10" column="6">
<widget class="QPushButton" name="ButtonYellow">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="8">
<widget class="QLabel" name="HueLabel">
<property name="text">
<string>H:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="ModeLabel">
<property name="text">
<string>Mode:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QRadioButton" name="PerLEDCheck">
<property name="text">
<string>Per-LED</string>
<item row="9" column="1" colspan="4">
<widget class="QSlider" name="SpeedSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="7">
<widget class="QPushButton" name="ButtonGreen">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="ColorLabel">
<property name="text">
<string>Colors:</string>
</property>
</widget>
</item>
<item row="6" column="6" colspan="2">
<widget class="QSpinBox" name="GreenSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="10" column="5">
<widget class="QPushButton" name="ButtonRed">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="9" colspan="2">
<widget class="QSpinBox" name="HueSpinBox">
<property name="maximum">
<number>359</number>
</property>
</widget>
</item>
<item row="2" column="1" colspan="4">
<widget class="QComboBox" name="LEDBox"/>
</item>
<item row="7" column="6" colspan="2">
<widget class="QSpinBox" name="BlueSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="5" column="6" colspan="2">
<widget class="QSpinBox" name="RedSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="7" column="8">
<widget class="QLabel" name="ValLabel">
<property name="text">
<string>V:</string>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QLabel" name="RedLabel">
<property name="text">
<string>R:</string>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QRadioButton" name="RandomCheck">
<property name="text">
<string>Random</string>
</property>
</widget>
</item>
<item row="6" column="8">
<item row="8" column="8">
<widget class="QLabel" name="SatLabel">
<property name="text">
<string>S:</string>
</property>
</widget>
</item>
<item row="10" column="8">
<widget class="QPushButton" name="ButtonCyan">
<item row="5" column="1" colspan="4">
<widget class="QPushButton" name="SetAllButton">
<property name="text">
<string>Set All Devices</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="LEDLabel">
<property name="text">
<string>LED:</string>
</property>
</widget>
</item>
<item row="12" column="5">
<widget class="QPushButton" name="ButtonRed">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="5">
<widget class="QLabel" name="BlueLabel">
<property name="text">
<string>B:</string>
<item row="8" column="6" colspan="2">
<widget class="QSpinBox" name="GreenSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<item row="9" column="6" colspan="2">
<widget class="QSpinBox" name="BlueSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="9" column="8">
<widget class="QLabel" name="ValLabel">
<property name="text">
<string>V:</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="DirectionLabel">
<property name="text">
<string>Dir:</string>
</property>
</widget>
</item>
<item row="8" column="2" colspan="2">
<widget class="QRadioButton" name="ModeSpecificCheck">
<property name="text">
<string>Mode-Specific</string>
</property>
</widget>
</item>
<item row="10" column="10">
<item row="12" column="10">
<widget class="QPushButton" name="ButtonMagenta">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="5">
<item row="8" column="9" colspan="2">
<widget class="QSpinBox" name="SatSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="7" column="8">
<widget class="QLabel" name="HueLabel">
<property name="text">
<string>H:</string>
</property>
</widget>
</item>
<item row="8" column="5">
<widget class="QLabel" name="GreenLabel">
<property name="text">
<string>G:</string>
</property>
</widget>
</item>
<item row="1" column="5" rowspan="3" colspan="6">
<item row="7" column="9" colspan="2">
<widget class="QSpinBox" name="HueSpinBox">
<property name="maximum">
<number>359</number>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QRadioButton" name="RandomCheck">
<property name="text">
<string>Random</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="SpeedLabel">
<property name="text">
<string>Speed:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QRadioButton" name="PerLEDCheck">
<property name="text">
<string>Per-LED</string>
</property>
</widget>
</item>
<item row="12" column="7">
<widget class="QPushButton" name="ButtonGreen">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="9" colspan="2">
<widget class="QSpinBox" name="ValSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="9" column="5">
<widget class="QLabel" name="BlueLabel">
<property name="text">
<string>B:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="LEDBox"/>
</item>
<item row="3" column="4">
<widget class="QPushButton" name="SelectAllLEDsButton">
<property name="text">
<string>Select All</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="ResizeButton">
<property name="text">
<string>Resize</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="ZoneLabel">
<property name="text">
<string>Zone:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="ZoneBox"/>
</item>
<item row="2" column="5" rowspan="4" colspan="6">
<widget class="ColorWheel" name="ColorWheelBox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -282,8 +296,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>ZoneBox</tabstop>
<tabstop>ResizeButton</tabstop>
<tabstop>LEDBox</tabstop>
<tabstop>SetAllButton</tabstop>
<tabstop>ModeBox</tabstop>