// find all descendants that should be considered auto widgets
// we need to climb the QObject tree recursively
findAutoWidgets(this, &_autoWidgets);
foreach(QObject *widget, _autoWidgets) {
// find all descendants that should be considered auto widgets
// we need to climb the QObject tree recursively
findAutoWidgets(this, &_autoWidgets);
foreach(QObject *widget, _autoWidgets) {
- if(widget->inherits("QAbstractButton") || widget->inherits("QGroupBox"))
+ if(widget->inherits("ColorButton"))
+ connect(widget, SIGNAL(colorChanged(QColor)), SLOT(autoWidgetHasChanged()));
+ else if(widget->inherits("QAbstractButton") || widget->inherits("QGroupBox"))
connect(widget, SIGNAL(toggled(bool)), SLOT(autoWidgetHasChanged()));
else if(widget->inherits("QLineEdit") || widget->inherits("QTextEdit"))
connect(widget, SIGNAL(textChanged(const QString &)), SLOT(autoWidgetHasChanged()));
connect(widget, SIGNAL(toggled(bool)), SLOT(autoWidgetHasChanged()));
else if(widget->inherits("QLineEdit") || widget->inherits("QTextEdit"))
connect(widget, SIGNAL(textChanged(const QString &)), SLOT(autoWidgetHasChanged()));
connect(widget, SIGNAL(currentIndexChanged(int)), SLOT(autoWidgetHasChanged()));
else if(widget->inherits("QSpinBox"))
connect(widget, SIGNAL(valueChanged(int)), SLOT(autoWidgetHasChanged()));
connect(widget, SIGNAL(currentIndexChanged(int)), SLOT(autoWidgetHasChanged()));
else if(widget->inherits("QSpinBox"))
connect(widget, SIGNAL(valueChanged(int)), SLOT(autoWidgetHasChanged()));
void SettingsPage::findAutoWidgets(QObject *parent, QObjectList *autoList) const {
foreach(QObject *child, parent->children()) {
void SettingsPage::findAutoWidgets(QObject *parent, QObjectList *autoList) const {
foreach(QObject *child, parent->children()) {
QString SettingsPage::autoWidgetSettingsKey(QObject *widget) const {
QString key = widget->property("settingsKey").toString();
QString SettingsPage::autoWidgetSettingsKey(QObject *widget) const {
QString key = widget->property("settingsKey").toString();
void SettingsPage::load() {
UiSettings s("");
foreach(QObject *widget, _autoWidgets) {
void SettingsPage::load() {
UiSettings s("");
foreach(QObject *widget, _autoWidgets) {
- QVariant val = s.value(autoWidgetSettingsKey(widget), widget->property("defaultValue"));
+ QString key = autoWidgetSettingsKey(widget);
+ QVariant val;
+ if(key.isEmpty())
+ val = loadAutoWidgetValue(widget->objectName());
+ else
+ val = s.value(key, QVariant());
+ if(!val.isValid())
+ val = widget->property("defaultValue");
widget->setProperty(autoWidgetPropertyName(widget), val);
widget->setProperty("storedValue", val);
}
widget->setProperty(autoWidgetPropertyName(widget), val);
widget->setProperty("storedValue", val);
}
void SettingsPage::save() {
UiSettings s("");
foreach(QObject *widget, _autoWidgets) {
void SettingsPage::save() {
UiSettings s("");
foreach(QObject *widget, _autoWidgets) {
QVariant val = widget->property(autoWidgetPropertyName(widget));
widget->setProperty("storedValue", val);
QVariant val = widget->property(autoWidgetPropertyName(widget));
widget->setProperty("storedValue", val);
+
+QVariant SettingsPage::loadAutoWidgetValue(const QString &widgetName) {
+ qWarning() << "Could not load value for SettingsPage widget" << widgetName;
+ return QVariant();
+}
+
+void SettingsPage::saveAutoWidgetValue(const QString &widgetName, const QVariant &) {
+ qWarning() << "Could not save value for SettingsPage widget" << widgetName;
+}
+