Add option to reset all config values to their default

Closes network/neochat#504
This commit is contained in:
James Graham
2024-08-23 09:20:09 +00:00
parent f2c561bd15
commit 32fd62c484
3 changed files with 24 additions and 0 deletions

View File

@@ -414,4 +414,11 @@ bool Controller::csSupported() const
#endif
}
void Controller::revertToDefaultConfig()
{
const auto config = NeoChatConfig::self();
config->setDefaults();
config->save();
}
#include "moc_controller.cpp"

View File

@@ -108,6 +108,14 @@ public:
bool csSupported() const;
/**
* @brief Revert all configuration values to their default.
*
* The parameters along with their defaults are specified in the config file
* neochatconfig.kcfg.
*/
Q_INVOKABLE void revertToDefaultConfig();
private:
explicit Controller(QObject *parent = nullptr);

View File

@@ -246,4 +246,13 @@ FormCard.FormCardPage {
});
}
}
FormCard.FormHeader {
title: i18nc("@title", "Default Settings")
}
FormCard.FormCard {
FormCard.FormButtonDelegate {
text: i18nc("@action:button", "Reset all configuration values to their default")
onClicked: Controller.revertToDefaultConfig()
}
}
}