You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
67 lines
2.0 KiB
|
8 years ago
|
#ifndef QTMVVM_SETTINGSVIEWMODEL_H
|
||
|
|
#define QTMVVM_SETTINGSVIEWMODEL_H
|
||
|
|
|
||
|
|
#include <QtCore/qsettings.h>
|
||
|
|
#include <QtCore/qscopedpointer.h>
|
||
|
|
|
||
|
|
#include <QtMvvmCore/viewmodel.h>
|
||
|
8 years ago
|
#include <QtMvvmCore/message.h>
|
||
|
8 years ago
|
|
||
|
8 years ago
|
#include "QtMvvmCore/qtmvvmcore_global.h"
|
||
|
|
#include "QtMvvmCore/settingssetup.h"
|
||
|
8 years ago
|
|
||
|
|
namespace QtMvvm {
|
||
|
|
|
||
|
|
class SettingsViewModelPrivate;
|
||
|
8 years ago
|
class Q_MVVMCORE_EXPORT SettingsViewModel : public ViewModel
|
||
|
8 years ago
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
Q_PROPERTY(bool canRestoreDefaults READ canRestoreDefaults CONSTANT)
|
||
|
8 years ago
|
Q_PROPERTY(QtMvvm::MessageConfig restoreConfig READ restoreConfig CONSTANT)
|
||
|
8 years ago
|
|
||
|
|
Q_PROPERTY(QtMvvm::ISettingsSetupLoader* settingsSetupLoader READ settingsSetupLoader WRITE setSettingsSetupLoader NOTIFY settingsSetupLoaderChanged)
|
||
|
|
QTMVVM_INJECT(QtMvvm::ISettingsSetupLoader*, settingsSetupLoader)
|
||
|
|
|
||
|
|
public:
|
||
|
8 years ago
|
static const QString paramSettings;
|
||
|
|
static const QString paramSetupFile;
|
||
|
|
|
||
|
|
static QVariantHash showParams(QSettings *settings = nullptr, const QString &setupFile = {});
|
||
|
|
|
||
|
8 years ago
|
Q_INVOKABLE explicit SettingsViewModel(QObject *parent = nullptr);
|
||
|
|
~SettingsViewModel();
|
||
|
|
|
||
|
|
virtual bool canRestoreDefaults() const;
|
||
|
8 years ago
|
virtual QtMvvm::MessageConfig restoreConfig() const;
|
||
|
|
|
||
|
|
ISettingsSetupLoader* settingsSetupLoader() const;
|
||
|
8 years ago
|
SettingsElements::Setup loadSetup(const QString &frontend) const;
|
||
|
8 years ago
|
|
||
|
|
QSettings *settings() const;
|
||
|
8 years ago
|
|
||
|
8 years ago
|
Q_INVOKABLE virtual QVariant loadValue(const QString &key, const QVariant &defaultValue = {}) const;
|
||
|
|
Q_INVOKABLE virtual void saveValue(const QString &key, const QVariant &value);
|
||
|
|
Q_INVOKABLE virtual void resetValue(const QString &key);
|
||
|
8 years ago
|
|
||
|
|
public Q_SLOTS:
|
||
|
8 years ago
|
virtual void callAction(const QString &entryId, const QVariantMap ¶meters);
|
||
|
8 years ago
|
|
||
|
|
void setSettingsSetupLoader(QtMvvm::ISettingsSetupLoader* settingsSetupLoader);
|
||
|
|
|
||
|
|
Q_SIGNALS:
|
||
|
|
void settingsSetupLoaderChanged(QtMvvm::ISettingsSetupLoader* settingsSetupLoader);
|
||
|
|
|
||
|
8 years ago
|
void beginLoadSetup();
|
||
|
|
|
||
|
8 years ago
|
protected:
|
||
|
|
void onInit(const QVariantHash ¶ms) override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
QScopedPointer<SettingsViewModelPrivate> d;
|
||
|
|
};
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif // QTMVVM_SETTINGSVIEWMODEL_H
|