Add Set All Devices button

This commit is contained in:
Adam Honse
2019-12-23 16:17:00 -06:00
parent 5f786e649a
commit cbdbb71d79
6 changed files with 61 additions and 11 deletions

View File

@@ -115,6 +115,18 @@ void Ui::OpenRGBDevicePage::on_ModeBox_currentIndexChanged(int index)
device->SetMode(ui->ModeBox->currentIndex());
}
void Ui::OpenRGBDevicePage::SetDevice(unsigned char red, unsigned char green, unsigned char blue)
{
UpdatingColor = true;
ui->RedSpinBox->setValue(red);
ui->GreenSpinBox->setValue(green);
ui->BlueSpinBox->setValue(blue);
UpdatingColor = false;
updateHSV();
on_SetDeviceButton_clicked();
}
void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked()
{
/*-----------------------------------------------------*\
@@ -291,3 +303,12 @@ void Ui::OpenRGBDevicePage::on_ValSpinBox_valueChanged(int arg1)
{
updateRGB();
}
void Ui::OpenRGBDevicePage::on_SetAllButton_clicked()
{
unsigned char red = ui->RedSpinBox->value();
unsigned char green = ui->GreenSpinBox->value();
unsigned char blue = ui->BlueSpinBox->value();
emit SetAllDevices(red, green, blue);
}

View File

@@ -18,6 +18,8 @@ public:
explicit OpenRGBDevicePage(RGBController *dev, QWidget *parent = nullptr);
~OpenRGBDevicePage();
void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
private slots:
void on_ButtonRed_clicked();
void on_ButtonYellow_clicked();
@@ -38,6 +40,8 @@ private slots:
void on_BlueSpinBox_valueChanged(int arg1);
void on_ValSpinBox_valueChanged(int arg1);
void on_SetAllButton_clicked();
private:
Ui::OpenRGBDevicePageUi *ui;
RGBController *device;
@@ -47,6 +51,9 @@ private:
void updateRGB();
void updateHSV();
signals:
void SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
};
#endif // OPENRGBDEVICEPAGE_H

View File

@@ -368,6 +368,19 @@
<string>Set:</string>
</property>
</widget>
<widget class="QPushButton" name="SetAllButton">
<property name="geometry">
<rect>
<x>110</x>
<y>180</y>
<width>80</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Set All Devices</string>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@@ -25,6 +25,14 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(control[dev_idx]);
ui->DevicesTabBar->addTab(NewPage, "");
/*-----------------------------------------------------*\
| Connect the page's Set All button to the Set All slot |
\*-----------------------------------------------------*/
connect(NewPage,
SIGNAL(SetAllDevices(unsigned char, unsigned char, unsigned char)),
this,
SLOT(on_SetAllDevices(unsigned char, unsigned char, unsigned char)));
/*-----------------------------------------------------*\
| Use Qt's HTML capabilities to display both icon and |
| text in the tab label. Choose icon based on device |
@@ -148,3 +156,11 @@ void OpenRGBDialog2::show()
{
QMainWindow::show();
}
void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetDevice(red, green, blue);
}
}

View File

@@ -34,6 +34,9 @@ protected:
private:
Ui::OpenRGBDialog2Ui *ui;
private slots:
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
};
#endif // OPENRGBDIALOG2_H

View File

@@ -70,18 +70,8 @@
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</property>
<widget class="QWidget" name="TabStaticEffect">
<attribute name="title">
<string>Static</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</widget>
<widget class="QWidget" name="TabInformation">