1
0
Fork 0
flightgear/src/GUI/SettingsSectionQML.hxx

73 lines
1.8 KiB
C++
Raw Normal View History

2017-02-21 11:01:06 +00:00
#ifndef SETTINGSSECTIONQML_HXX
#define SETTINGSSECTIONQML_HXX
2017-04-10 13:37:18 +00:00
#include "SettingsSection.hxx"
2017-02-21 11:01:06 +00:00
#include <QQmlListProperty>
class SettingsControl;
class SettingsSectionQML : public SettingsSection
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QObject> controls READ qmlControls)
Q_PROPERTY(QString summary READ summary WRITE setSummary NOTIFY qmlSummaryChanged)
2017-04-10 13:37:18 +00:00
2017-02-21 11:01:06 +00:00
Q_CLASSINFO("DefaultProperty", "controls")
public:
SettingsSectionQML();
QQmlListProperty<QObject> qmlControls();
QList<SettingsControl*> controls() const;
void saveState(QSettings& settings) const override;
void restoreState(QSettings& settings) override;
void doApply() override;
virtual QString summary() const override;
Q_INVOKABLE void saveSetting(QString key, QVariant value);
Q_INVOKABLE QVariant restoreSetting(QString key);
bool showAdvanced() const override;
2017-02-21 11:01:06 +00:00
public slots:
void setSummary(QString summary);
void setSearchTerm(QString search);
2017-02-21 11:01:06 +00:00
signals:
void controlsChanged();
/**
* @brief apply - change the launch configuration according to the values
* in this settings section.
*/
void apply();
void save();
void restore();
void qmlSummaryChanged(QString summary);
private:
static void controls_append( QQmlListProperty<QObject>* prop,
QObject* item );
static void controls_clear( QQmlListProperty<QObject>* prop );
static int controls_count( QQmlListProperty<QObject>* prop );
static QObject* control_at( QQmlListProperty<QObject>* prop, int index );
void internalUpdateAdvanced() override;
void updateShowAdvanced() override;
QString m_summary;
QObjectList m_controls;
bool m_forceShowAdvanced; ///< overrides show-advanced when searching
2017-02-21 11:01:06 +00:00
};
#endif // SETTINGSSECTIONQML_HXX