Commit 73a317f0 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

add isDirty in ElisaConfigurationDialog to enable apply button

parent 1ea3875f
......@@ -35,8 +35,7 @@ ElisaConfigurationDialog::ElisaConfigurationDialog(QObject* parent)
setRootPath(Elisa::ElisaConfiguration::rootPath());
Elisa::ElisaConfiguration::setRootPath(mRootPath);
Elisa::ElisaConfiguration::self()->save();
save();
mConfigFileWatcher.addPath(Elisa::ElisaConfiguration::self()->config()->name());
}
......@@ -78,12 +77,18 @@ void ElisaConfigurationDialog::setRootPath(const QStringList &rootPath)
}
Q_EMIT rootPathChanged(mRootPath);
mIsDirty = true;
Q_EMIT isDirtyChanged();
}
void ElisaConfigurationDialog::save()
{
Elisa::ElisaConfiguration::setRootPath(mRootPath);
Elisa::ElisaConfiguration::self()->save();
mIsDirty = false;
Q_EMIT isDirtyChanged();
}
void ElisaConfigurationDialog::configChanged()
......
......@@ -33,6 +33,10 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject
WRITE setRootPath
NOTIFY rootPathChanged)
Q_PROPERTY(bool isDirty
READ isDirty
NOTIFY isDirtyChanged)
public:
explicit ElisaConfigurationDialog(QObject *parent = nullptr);
......@@ -41,10 +45,17 @@ public:
QStringList rootPath() const;
bool isDirty() const
{
return mIsDirty;
}
Q_SIGNALS:
void rootPathChanged(const QStringList &rootPath);
void isDirtyChanged();
public Q_SLOTS:
void setRootPath(const QStringList &rootPath);
......@@ -61,6 +72,8 @@ private:
QFileSystemWatcher mConfigFileWatcher;
bool mIsDirty = false;
};
#endif
......@@ -117,7 +117,22 @@ Window {
DialogButtonBox {
Layout.fillWidth: true
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Apply | DialogButtonBox.Cancel
Button {
text: i18n("OK")
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
Button {
text: i18n("Apply")
DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole
enabled: config.isDirty
}
Button {
text: i18n("Cancel")
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
}
onAccepted: {
config.save()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment