mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-10 03:42:09 +08:00
ui: handle two dynamic toggle icon cases (#26517)
handles two cases old-commit-hash: 797c626984080e1ff17206b99e67a11bba87992f
This commit is contained in:
@@ -153,15 +153,10 @@ public:
|
||||
if (!confirm || confirmed || !state || dialog.exec()) {
|
||||
if (store_confirm && state) params.putBool(key + "Confirmed", true);
|
||||
params.putBool(key, state);
|
||||
setIcon(state);
|
||||
} else {
|
||||
toggle.togglePosition();
|
||||
}
|
||||
|
||||
if (state && !active_icon_pixmap.isNull()) {
|
||||
icon_label->setPixmap(active_icon_pixmap);
|
||||
} else if (!icon_pixmap.isNull()) {
|
||||
icon_label->setPixmap(icon_pixmap);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,8 +170,10 @@ public:
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (params.getBool(key) != toggle.on) {
|
||||
bool state = params.getBool(key);
|
||||
if (state != toggle.on) {
|
||||
toggle.togglePosition();
|
||||
setIcon(state);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,6 +182,14 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
void setIcon(bool state) {
|
||||
if (state && !active_icon_pixmap.isNull()) {
|
||||
icon_label->setPixmap(active_icon_pixmap);
|
||||
} else if (!icon_pixmap.isNull()) {
|
||||
icon_label->setPixmap(icon_pixmap);
|
||||
}
|
||||
};
|
||||
|
||||
std::string key;
|
||||
Params params;
|
||||
QPixmap active_icon_pixmap;
|
||||
|
||||
Reference in New Issue
Block a user