Fix Set All Devices being slow and crashing on certain setups. It was sending the update multiple times
This commit is contained in:
parent
ad4e198aea
commit
f108515a6e
4 changed files with 67 additions and 10 deletions
|
|
@ -1266,8 +1266,6 @@ void RGBController::SetLED(unsigned int led, RGBColor color)
|
|||
if(led < colors.size())
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateSingleLED(led);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1277,8 +1275,6 @@ void RGBController::SetAllLEDs(RGBColor color)
|
|||
{
|
||||
SetAllZoneLEDs(zone_idx, color);
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
|
|
@ -1287,8 +1283,6 @@ void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
|
|||
{
|
||||
zones[zone].colors[color_idx] = color;
|
||||
}
|
||||
|
||||
UpdateZoneLEDs(zone);
|
||||
}
|
||||
|
||||
int RGBController::GetMode()
|
||||
|
|
|
|||
|
|
@ -642,13 +642,72 @@ void Ui::OpenRGBDevicePage::UpdateDevice()
|
|||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::SetCustomMode()
|
||||
void Ui::OpenRGBDevicePage::SetCustomMode(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the selected mode to the custom mode and update UI|
|
||||
\*-----------------------------------------------------*/
|
||||
device->SetCustomMode();
|
||||
ui->ModeBox->blockSignals(true);
|
||||
ui->ModeBox->setCurrentIndex(device->active_mode);
|
||||
ui->ModeBox->blockSignals(false);
|
||||
UpdateModeUi();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the color boxes |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdatingColor = true;
|
||||
ui->RedSpinBox->setValue(red);
|
||||
ui->GreenSpinBox->setValue(green);
|
||||
ui->BlueSpinBox->setValue(blue);
|
||||
UpdatingColor = false;
|
||||
updateHSV();
|
||||
updateWheel();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read selected mode |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex();
|
||||
|
||||
switch(device->modes[selected_mode].color_mode)
|
||||
{
|
||||
case MODE_COLORS_PER_LED:
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set all device LEDs to the current color |
|
||||
\*-----------------------------------------------------*/
|
||||
RGBColor color = ToRGBColor(
|
||||
ui->RedSpinBox->text().toInt(),
|
||||
ui->GreenSpinBox->text().toInt(),
|
||||
ui->BlueSpinBox->text().toInt()
|
||||
);
|
||||
|
||||
device->SetAllLEDs(color);
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set all device LEDs to the current color |
|
||||
\*-----------------------------------------------------*/
|
||||
RGBColor color = ToRGBColor(
|
||||
ui->RedSpinBox->text().toInt(),
|
||||
ui->GreenSpinBox->text().toInt(),
|
||||
ui->BlueSpinBox->text().toInt()
|
||||
);
|
||||
|
||||
for(std::size_t i = 0; i < device->modes[selected_mode].colors.size(); i++)
|
||||
{
|
||||
device->modes[selected_mode].colors[i] = color;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Apply mode and colors |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
|
|
@ -673,6 +732,8 @@ void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked()
|
|||
);
|
||||
|
||||
device->SetAllLEDs(color);
|
||||
|
||||
device->UpdateLEDs();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -729,6 +790,7 @@ void Ui::OpenRGBDevicePage::on_SetZoneButton_clicked()
|
|||
);
|
||||
|
||||
device->SetAllZoneLEDs(index, color);
|
||||
device->UpdateZoneLEDs(index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -761,12 +823,14 @@ void Ui::OpenRGBDevicePage::on_SetLEDButton_clicked()
|
|||
if(selected_zone == 0)
|
||||
{
|
||||
device->SetLED(index, color);
|
||||
device->UpdateSingleLED(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
selected_zone = selected_zone - 1;
|
||||
|
||||
device->SetLED(device->zones[selected_zone].start_idx + index, color);
|
||||
device->UpdateSingleLED(device->zones[selected_zone].start_idx + index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
~OpenRGBDevicePage();
|
||||
|
||||
void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetCustomMode();
|
||||
void SetCustomMode(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void UpdateDevice();
|
||||
void UpdateMode();
|
||||
void UpdateModeUi();
|
||||
|
|
|
|||
|
|
@ -405,8 +405,7 @@ void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, un
|
|||
{
|
||||
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
|
||||
{
|
||||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetCustomMode();
|
||||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetDevice(red, green, blue);
|
||||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetCustomMode(red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue