Add save to device support to RGBController

This commit is contained in:
Adam Honse 2021-07-04 16:32:18 -05:00
parent c2a353ec6f
commit eade8fea1a
5 changed files with 53 additions and 0 deletions

View file

@ -1523,6 +1523,11 @@ void RGBController::UpdateMode()
CallFlag_UpdateMode = true;
}
void RGBController::SaveMode()
{
DeviceSaveMode();
}
void RGBController::DeviceUpdateLEDs()
{
@ -1557,6 +1562,13 @@ void RGBController::DeviceCallThreadFunction()
}
}
void RGBController::DeviceSaveMode()
{
/*-------------------------------------------------*\
| If not implemented by controller, does nothing |
\*-------------------------------------------------*/
}
std::string device_type_to_str(device_type type)
{
switch(type)

View file

@ -37,6 +37,8 @@ enum
MODE_FLAG_HAS_PER_LED_COLOR = (1 << 5), /* Mode has per-LED colors */
MODE_FLAG_HAS_MODE_SPECIFIC_COLOR = (1 << 6), /* Mode has mode specific colors */
MODE_FLAG_HAS_RANDOM_COLOR = (1 << 7), /* Mode has random color option */
MODE_FLAG_MANUAL_SAVE = (1 << 8), /* Mode can manually be saved */
MODE_FLAG_AUTOMATIC_SAVE = (1 << 9), /* Mode automatically saves */
};
/*------------------------------------------------------------------*\
@ -194,6 +196,7 @@ public:
//virtual void UpdateSingleLED(int led) = 0;
virtual void UpdateMode() = 0;
virtual void SaveMode() = 0;
virtual void DeviceCallThreadFunction() = 0;
@ -209,6 +212,7 @@ public:
virtual void UpdateSingleLED(int led) = 0;
virtual void DeviceUpdateMode() = 0;
virtual void DeviceSaveMode() = 0;
virtual void SetCustomMode() = 0;
};
@ -273,6 +277,7 @@ public:
//void UpdateSingleLED(int led);
void UpdateMode();
void SaveMode();
void DeviceCallThreadFunction();
@ -288,6 +293,7 @@ public:
virtual void UpdateSingleLED(int led) = 0;
virtual void DeviceUpdateMode() = 0;
void DeviceSaveMode();
virtual void SetCustomMode() = 0;

View file

@ -459,6 +459,8 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
bool mode_specific = device->modes[selected_mode].color_mode == MODE_COLORS_MODE_SPECIFIC;
bool random = device->modes[selected_mode].color_mode == MODE_COLORS_RANDOM;
unsigned int dir = device->modes[selected_mode].direction;
bool manual_save = ( device->modes[selected_mode].flags & MODE_FLAG_MANUAL_SAVE );
bool automatic_save = ( device->modes[selected_mode].flags & MODE_FLAG_AUTOMATIC_SAVE );
if(supports_speed)
{
@ -633,6 +635,22 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
ui->RandomCheck->setAutoExclusive(true);
}
if(automatic_save)
{
ui->DeviceSaveButton->setText("Saved To Device");
ui->DeviceSaveButton->setEnabled(false);
}
else if(manual_save)
{
ui->DeviceSaveButton->setText("Save To Device");
ui->DeviceSaveButton->setEnabled(true);
}
else
{
ui->DeviceSaveButton->setText("Saving Not Supported");
ui->DeviceSaveButton->setEnabled(false);
}
/*-----------------------------------------------------*\
| Fill in the zone box based on color mode |
\*-----------------------------------------------------*/
@ -1311,3 +1329,11 @@ void Ui::OpenRGBDevicePage::on_SelectAllLEDsButton_clicked()
ui->DeviceViewBox->repaint();
}
}
void Ui::OpenRGBDevicePage::on_DeviceSaveButton_clicked()
{
if(device->modes[device->active_mode].flags & MODE_FLAG_MANUAL_SAVE)
{
device->SaveMode();
}
}

View file

@ -57,6 +57,8 @@ private slots:
void on_SelectAllLEDsButton_clicked();
void on_DeviceSaveButton_clicked();
private:
Ui::OpenRGBDevicePageUi *ui;
RGBController *device;

View file

@ -254,6 +254,13 @@
</property>
</widget>
</item>
<item row="10" column="5" colspan="6">
<widget class="QPushButton" name="DeviceSaveButton">
<property name="text">
<string>Save To Device</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>