Skip to content

Commit 0731d5f

Browse files
authored
feat(cpn): customisable simulator button clicked colour (#7178)
1 parent fdafeaa commit 0731d5f

5 files changed

Lines changed: 337 additions & 240 deletions

File tree

companion/src/apppreferencesdialog.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ void AppPreferencesDialog::accept()
182182
profile.splashFile(ui->SplashFileName->text());
183183
profile.runSDSync(ui->chkPromptSDSync->isChecked());
184184
profile.radioSimCaseColor(ui->lblRadioColorSample->palette().button().color());
185+
profile.simBtnClickedUseOSTheme(ui->chkSimBtnClickedUseOSTheme->isChecked());
186+
profile.simBtnClickedColor(ui->lblSimBtnClickedColorSample->palette().button().color());
185187
profile.useSavedSettings(ui->chkUseSavedSettingsProfile->isChecked());
186188

187189
// The profile name may NEVER be empty
@@ -380,6 +382,16 @@ void AppPreferencesDialog::initSettings()
380382
ui->lblGeneralSettings->setText(hwSettings);
381383
ui->chkPromptSDSync->setChecked(profile.runSDSync());
382384
ui->lblRadioColorSample->setPalette(QPalette(profile.radioSimCaseColor()));
385+
ui->chkSimBtnClickedUseOSTheme->setChecked(profile.simBtnClickedUseOSTheme());
386+
ui->lblSimBtnClickedColorSample->setPalette(QPalette(profile.simBtnClickedColor()));
387+
388+
if (ui->chkSimBtnClickedUseOSTheme->isChecked()) {
389+
ui->lblSimBtnClickedColorSample->setVisible(false);
390+
ui->btnSimBtnClickedColor->setEnabled(false);
391+
} else {
392+
ui->lblSimBtnClickedColorSample->setVisible(true);
393+
ui->btnSimBtnClickedColor->setEnabled(true);
394+
}
383395

384396
QString currType = QStringList(profile.fwType().split('-').mid(0, 2)).join('-');
385397
foreach(Firmware * firmware, Firmware::getRegisteredFirmwares()) {
@@ -907,3 +919,21 @@ void AppPreferencesDialog::onProfileBackupPathEditingFinished()
907919
ui->profileBackupEnable->setEnabled(false);
908920
}
909921
}
922+
void AppPreferencesDialog::on_chkSimBtnClickedUseOSTheme_stateChanged()
923+
{
924+
if (ui->chkSimBtnClickedUseOSTheme->isChecked()) {
925+
ui->lblSimBtnClickedColorSample->setVisible(false);
926+
ui->btnSimBtnClickedColor->setEnabled(false);
927+
} else {
928+
ui->lblSimBtnClickedColorSample->setVisible(true);
929+
ui->btnSimBtnClickedColor->setEnabled(true);
930+
}
931+
}
932+
933+
void AppPreferencesDialog::on_btnSimBtnClickedColor_clicked()
934+
{
935+
QColorDialog *dlg = new QColorDialog(this);
936+
QColor color = dlg->getColor(g.currentProfile().simBtnClickedColor(), this);
937+
ui->lblSimBtnClickedColorSample->setPalette(QPalette(color));
938+
ui->lblSimBtnClickedColorSample->repaint();
939+
}

companion/src/apppreferencesdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class AppPreferencesDialog : public QDialog
8080
#endif
8181

8282
void on_btnRadioColor_clicked();
83+
void on_chkSimBtnClickedUseOSTheme_stateChanged();
84+
void on_btnSimBtnClickedColor_clicked();
8385
void onBackupPathEditingFinished();
8486
void onProfileBackupPathEditingFinished();
8587

0 commit comments

Comments
 (0)