feat(cpn): customisable simulator button clicked colour (#7178)

This commit is contained in:
Neil Horne
2026-03-18 12:19:18 +10:00
committed by GitHub
parent fdafeaaa5a
commit 0731d5f685
5 changed files with 351 additions and 254 deletions
+30
View File
@@ -182,6 +182,8 @@ void AppPreferencesDialog::accept()
profile.splashFile(ui->SplashFileName->text());
profile.runSDSync(ui->chkPromptSDSync->isChecked());
profile.radioSimCaseColor(ui->lblRadioColorSample->palette().button().color());
profile.simBtnClickedUseOSTheme(ui->chkSimBtnClickedUseOSTheme->isChecked());
profile.simBtnClickedColor(ui->lblSimBtnClickedColorSample->palette().button().color());
profile.useSavedSettings(ui->chkUseSavedSettingsProfile->isChecked());
// The profile name may NEVER be empty
@@ -380,6 +382,16 @@ void AppPreferencesDialog::initSettings()
ui->lblGeneralSettings->setText(hwSettings);
ui->chkPromptSDSync->setChecked(profile.runSDSync());
ui->lblRadioColorSample->setPalette(QPalette(profile.radioSimCaseColor()));
ui->chkSimBtnClickedUseOSTheme->setChecked(profile.simBtnClickedUseOSTheme());
ui->lblSimBtnClickedColorSample->setPalette(QPalette(profile.simBtnClickedColor()));
if (ui->chkSimBtnClickedUseOSTheme->isChecked()) {
ui->lblSimBtnClickedColorSample->setVisible(false);
ui->btnSimBtnClickedColor->setEnabled(false);
} else {
ui->lblSimBtnClickedColorSample->setVisible(true);
ui->btnSimBtnClickedColor->setEnabled(true);
}
QString currType = QStringList(profile.fwType().split('-').mid(0, 2)).join('-');
foreach(Firmware * firmware, Firmware::getRegisteredFirmwares()) {
@@ -907,3 +919,21 @@ void AppPreferencesDialog::onProfileBackupPathEditingFinished()
ui->profileBackupEnable->setEnabled(false);
}
}
void AppPreferencesDialog::on_chkSimBtnClickedUseOSTheme_stateChanged()
{
if (ui->chkSimBtnClickedUseOSTheme->isChecked()) {
ui->lblSimBtnClickedColorSample->setVisible(false);
ui->btnSimBtnClickedColor->setEnabled(false);
} else {
ui->lblSimBtnClickedColorSample->setVisible(true);
ui->btnSimBtnClickedColor->setEnabled(true);
}
}
void AppPreferencesDialog::on_btnSimBtnClickedColor_clicked()
{
QColorDialog *dlg = new QColorDialog(this);
QColor color = dlg->getColor(g.currentProfile().simBtnClickedColor(), this);
ui->lblSimBtnClickedColorSample->setPalette(QPalette(color));
ui->lblSimBtnClickedColorSample->repaint();
}
+2
View File
@@ -80,6 +80,8 @@ class AppPreferencesDialog : public QDialog
#endif
void on_btnRadioColor_clicked();
void on_chkSimBtnClickedUseOSTheme_stateChanged();
void on_btnSimBtnClickedColor_clicked();
void onBackupPathEditingFinished();
void onProfileBackupPathEditingFinished();
+311 -239
View File
@@ -26,6 +26,16 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
@@ -35,48 +45,26 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="profileTab">
<attribute name="title">
<string>Radio Profile</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0,0">
<item row="6" column="0" colspan="5">
<widget class="Line" name="splashSeparator">
<item row="14" column="2">
<widget class="QLabel" name="lblGeneralSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="20" column="0" colspan="5">
<widget class="Line" name="line_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="label_25">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Updates</string>
<string notr="true">Radio Settings Label</string>
</property>
</widget>
</item>
@@ -134,8 +122,8 @@ Mode 4:
</item>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="stickmodeLabel">
<item row="4" column="0">
<widget class="QLabel" name="langLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -143,20 +131,7 @@ Mode 4:
</sizepolicy>
</property>
<property name="text">
<string>Default Stick Mode</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="sdPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SD Structure path</string>
<string>Language</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
@@ -179,53 +154,7 @@ Mode 4:
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Default Int. Module</string>
</property>
</widget>
</item>
<item row="26" column="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="10" column="2">
<widget class="QLineEdit" name="profileBackupPath">
<property name="toolTip">
<string>If set it will override the application general setting</string>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="24" column="2">
<widget class="QCheckBox" name="burnFirmware">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Prompt to write firmware to radio after update</string>
</property>
</widget>
</item>
<item row="22" column="2">
<item row="23" column="2">
<widget class="QCheckBox" name="profileBackupEnable">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -241,92 +170,37 @@ Mode 4:
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Options</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
</widget>
</item>
<item row="19" column="3">
<widget class="QPushButton" name="btnRadioColor">
<property name="text">
<string>Select Colour</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="langLabel">
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Language</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="19" column="2">
<widget class="QLabel" name="lblRadioColorSample">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="profileNameLE"/>
</item>
<item row="14" column="2">
<widget class="QLabel" name="lblGeneralSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Radio Settings Label</string>
</property>
</widget>
</item>
<item row="15" column="2">
<widget class="QComboBox" name="defaultInternalModuleCB"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Profile Name</string>
<string>Radio Type</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="25" column="2">
<widget class="QCheckBox" name="burnFirmware">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Prompt to write firmware to radio after update</string>
</property>
</widget>
</item>
@@ -466,24 +340,24 @@ Mode 4:
</item>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="boardCB">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_24">
<item row="9" column="3" colspan="2">
<widget class="QPushButton" name="sdPathButton">
<property name="text">
<string>Simulator Case Colour</string>
<string>Select Folder</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<item row="16" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>External Module</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -494,10 +368,99 @@ Mode 4:
</font>
</property>
<property name="text">
<string>Radio Type</string>
<string>Profile Name</string>
</property>
</widget>
</item>
<item row="10" column="3" colspan="2">
<widget class="QPushButton" name="profileBackupPathButton">
<property name="toolTip">
<string>The profile specific folder, if set, will override general Backup folder</string>
</property>
<property name="text">
<string>Select Folder</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Options</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
</widget>
</item>
<item row="27" column="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Radio Settings</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Simulator Button Clicked Colour</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="Line" name="line_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QLineEdit" name="profileBackupPath">
<property name="toolTip">
<string>If set it will override the application general setting</string>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="26" column="2">
<widget class="QCheckBox" name="chkPromptSDSync">
<property name="text">
<string>Prompt to run SD Sync after update</string>
</property>
</widget>
</item>
@@ -531,22 +494,25 @@ Mode 4:
</layout>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="Line" name="line_8">
<item row="15" column="2">
<widget class="QComboBox" name="defaultInternalModuleCB"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="sdPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<property name="text">
<string>SD Structure path</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="16" column="2">
<widget class="QComboBox" name="externalModuleSizeCB"/>
</item>
<item row="7" column="0" colspan="5">
<widget class="QWidget" name="widget_splashImage" native="true">
<layout class="QGridLayout" name="gridLayout_5">
@@ -663,6 +629,25 @@ Mode 4:
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="profileNameLE"/>
</item>
<item row="9" column="2">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0" colspan="5">
<widget class="QLabel" name="label">
<property name="sizePolicy">
@@ -681,24 +666,33 @@ Mode 4:
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
<item row="6" column="0" colspan="5">
<widget class="Line" name="splashSeparator">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_4">
<item row="23" column="0">
<widget class="QLabel" name="label_25">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Updates</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="stickmodeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -706,21 +700,7 @@ Mode 4:
</sizepolicy>
</property>
<property name="text">
<string>Radio Settings</string>
</property>
</widget>
</item>
<item row="9" column="3" colspan="2">
<widget class="QPushButton" name="sdPathButton">
<property name="text">
<string>Select Folder</string>
</property>
</widget>
</item>
<item row="25" column="2">
<widget class="QCheckBox" name="chkPromptSDSync">
<property name="text">
<string>Prompt to run SD Sync after update</string>
<string>Default Stick Mode</string>
</property>
</widget>
</item>
@@ -740,20 +720,40 @@ Mode 4:
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_18">
<item row="15" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>External Module</string>
<string>Default Int. Module</string>
</property>
</widget>
</item>
<item row="10" column="3" colspan="2">
<widget class="QPushButton" name="profileBackupPathButton">
<property name="toolTip">
<string>The profile specific folder, if set, will override general Backup folder</string>
<item row="16" column="2">
<widget class="QComboBox" name="externalModuleSizeCB"/>
</item>
<item row="21" column="0" colspan="5">
<widget class="Line" name="line_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Select Folder</string>
<string>Simulator Radio Case Colour</string>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QCheckBox" name="chkUseSavedSettingsProfile">
<property name="text">
<string>Use settings backup for new models and settings files</string>
</property>
</widget>
</item>
@@ -767,10 +767,92 @@ Mode 4:
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QCheckBox" name="chkUseSavedSettingsProfile">
<item row="2" column="2">
<widget class="QComboBox" name="boardCB">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="20" column="3">
<widget class="QPushButton" name="btnSimBtnClickedColor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use settings backup for new models and settings files</string>
<string>Select Colour</string>
</property>
</widget>
</item>
<item row="20" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="chkSimBtnClickedUseOSTheme">
<property name="text">
<string>Operating System theme</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblSimBtnClickedColorSample">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::Box</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_29">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="19" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="lblRadioColorSample">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::Box</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_27">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_28">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="19" column="3">
<widget class="QPushButton" name="btnRadioColor">
<property name="text">
<string>Select Colour</string>
</property>
</widget>
</item>
@@ -1717,16 +1799,6 @@ Mode 4:
</widget>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
@@ -23,6 +23,7 @@
#include "radiouiaction.h"
#include "radiokeywidget.h"
#include "appdata.h"
#include <QWidget>
#include <QtGui>
@@ -69,22 +70,12 @@ class ButtonsWidget : public QWidget
connect(pushbtn, &QPushButton::pressed, rkw, &RadioKeyWidget::press);
connect(pushbtn, &QPushButton::released, rkw, &RadioKeyWidget::release);
if (action) {
if (action && !g.currentProfile().simBtnClickedUseOSTheme()) {
// blink push button on click or matching key(s) press
connect(action, static_cast<void (RadioUiAction::*)(void)>(&RadioUiAction::pushed), [this, pushbtn] (void) {
// TODO: use a palette colors
// set to default -> blink -> default
QString csssave = pushbtn->styleSheet();
QString blnkcol = "background-color: rgb(239, 41, 41)";
// pressing the same key in rapid seccession can affect the order of the events see TODO
if (csssave != blnkcol) {
pushbtn->setStyleSheet(blnkcol);
QTimer * tim = new QTimer(this);
tim->setSingleShot(true);
connect(tim, &QTimer::timeout, [pushbtn, csssave]() { pushbtn->setStyleSheet(csssave); });
tim->start(300);
}
});
pushbtn->setStyleSheet(QString(
"QPushButton:pressed {background-color: %1; border-style: inset;}")
.arg(QVariant(g.currentProfile().simBtnClickedColor()).toString())
);
}
return rkw;
+2
View File
@@ -504,6 +504,8 @@ class Profile: public CompStoreObj
PROPERTY(bool, telemSimPauseOnHide, true)
PROPERTY(bool, telemSimResetRssiOnStop, false)
PROPERTY(QColor, radioSimCaseColor, QColor(Qt::black))
PROPERTY(bool, simBtnClickedUseOSTheme, true)
PROPERTY(QColor, simBtnClickedColor, QColor(Qt::red))
// General settings
PROPERTYQBA(generalSettings)