This means that SettingsPages can now handle both FontSelector and ColorButton automatically and
don't have to worry about tracking/saving/loading them. This should save us several hundred lines
of boilerplate code, and also some cute kittens.
I must reiterate that Qt's property system is worth a ton of bacon. At least.
findAutoWidgets(this, &_autoWidgets);
foreach(QObject *widget, _autoWidgets) {
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()));
+ else if(widget->inherits("FontSelector"))
+ connect(widget, SIGNAL(fontChanged(QFont)), SLOT(autoWidgetHasChanged()));
else
qWarning() << "SettingsPage::init(): Unknown autoWidget type" << widget->metaObject()->className();
}
else
qWarning() << "SettingsPage::init(): Unknown autoWidget type" << widget->metaObject()->className();
}
QByteArray SettingsPage::autoWidgetPropertyName(QObject *widget) const {
QByteArray prop;
QByteArray SettingsPage::autoWidgetPropertyName(QObject *widget) const {
QByteArray prop;
- if(widget->inherits("QAbstractButton") || widget->inherits("QGroupBox"))
+ if(widget->inherits("ColorButton"))
+ prop = "color";
+ else if(widget->inherits("QAbstractButton") || widget->inherits("QGroupBox"))
prop = "checked";
else if(widget->inherits("QLineEdit") || widget->inherits("QTextEdit"))
prop = "text";
prop = "checked";
else if(widget->inherits("QLineEdit") || widget->inherits("QTextEdit"))
prop = "text";
prop = "currentIndex";
else if(widget->inherits("QSpinBox"))
prop = "value";
prop = "currentIndex";
else if(widget->inherits("QSpinBox"))
prop = "value";
+ else if(widget->inherits("FontSelector"))
+ prop = "selectedFont";
else
qWarning() << "SettingsPage::autoWidgetPropertyName(): Unhandled widget type for" << widget;
else
qWarning() << "SettingsPage::autoWidgetPropertyName(): Unhandled widget type for" << widget;