mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-25 12:43:53 +08:00
ui: function for setting toggle confirmation settings (#26516)
function for setting confirmation settings
This commit is contained in:
@@ -90,7 +90,7 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
};
|
||||
|
||||
for (auto &[param, title, desc, icon] : toggle_defs) {
|
||||
auto toggle = new ParamControl(param, title, desc, icon, false, this);
|
||||
auto toggle = new ParamControl(param, title, desc, icon, this);
|
||||
|
||||
bool locked = params.getBool((param + "Lock").toStdString());
|
||||
toggle->setEnabled(!locked);
|
||||
@@ -100,9 +100,8 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
}
|
||||
|
||||
// Toggles with confirmation dialogs
|
||||
toggles["ExperimentalMode"]->confirm = true;
|
||||
toggles["ExperimentalMode"]->store_confirm = true;
|
||||
toggles["ExperimentalLongitudinalEnabled"]->confirm = true;
|
||||
toggles["ExperimentalMode"]->setConfirmation(true, true);
|
||||
toggles["ExperimentalLongitudinalEnabled"]->setConfirmation(true, false);
|
||||
|
||||
connect(toggles["ExperimentalLongitudinalEnabled"], &ToggleControl::toggleFlipped, [=]() {
|
||||
updateToggles();
|
||||
|
||||
@@ -139,7 +139,7 @@ class ParamControl : public ToggleControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ParamControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon, const bool _confirm, QWidget *parent = nullptr) : confirm(_confirm), ToggleControl(title, desc, icon, false, parent) {
|
||||
ParamControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr) : ToggleControl(title, desc, icon, false, parent) {
|
||||
key = param.toStdString();
|
||||
QObject::connect(this, &ParamControl::toggleFlipped, [=](bool state) {
|
||||
QString content("<body><h2 style=\"text-align: center;\">" + title + "</h2><br>"
|
||||
@@ -156,8 +156,10 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
bool confirm = false;
|
||||
bool store_confirm = false;
|
||||
void setConfirmation(bool _confirm, bool _store_confirm) {
|
||||
confirm = _confirm;
|
||||
store_confirm = _store_confirm;
|
||||
};
|
||||
|
||||
void refresh() {
|
||||
if (params.getBool(key) != toggle.on) {
|
||||
@@ -172,6 +174,8 @@ public:
|
||||
private:
|
||||
std::string key;
|
||||
Params params;
|
||||
bool confirm = false;
|
||||
bool store_confirm = false;
|
||||
};
|
||||
|
||||
class ListWidget : public QWidget {
|
||||
|
||||
Reference in New Issue
Block a user