fix: clear settings should wipe the state file too
This commit is contained in:
parent
13c5655976
commit
0baecf3fa7
5 changed files with 19 additions and 3 deletions
|
|
@ -60,6 +60,12 @@ void Settings::setStateFile(const QString &stateFile)
|
|||
qInfo().noquote() << "state file changed:" << instance()->m_stateSettings->fileName();
|
||||
}
|
||||
|
||||
void Settings::clearState()
|
||||
{
|
||||
instance()->m_stateSettings->clear();
|
||||
instance()->m_stateSettings->sync();
|
||||
}
|
||||
|
||||
Settings::Settings(QObject *parent) : QObject(parent), m_settingsWatcher{new QFileSystemWatcher(this)}
|
||||
{
|
||||
QString fileToLoad;
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ public:
|
|||
static Settings *instance();
|
||||
static void setSettingsFile(const QString &settingsFile = QString());
|
||||
static void setStateFile(const QString &stateFile = QString());
|
||||
static void clearState();
|
||||
static void setValue(const QString &key = QString(), const QVariant &value = QVariant());
|
||||
static QVariant value(const QString &key = QString());
|
||||
static void restoreDefaultSettings();
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ void clearSettings(bool enableRestart)
|
|||
{
|
||||
qDebug("clearing settings");
|
||||
Settings::proxy().clear();
|
||||
|
||||
// Reset the windowGeometry
|
||||
Settings::setValue(Settings::Gui::WindowGeometry);
|
||||
Settings::clearState();
|
||||
|
||||
// save but do not emit saving signal which will prevent the current state of
|
||||
// the app config and server configs from being applied.
|
||||
|
|
|
|||
|
|
@ -101,4 +101,14 @@ void SettingsTests::checkCleanScreenName_LongName()
|
|||
QCOMPARE(Settings::value(Settings::Core::ComputerName).toString(), expected);
|
||||
}
|
||||
|
||||
void SettingsTests::checkClearState()
|
||||
{
|
||||
Settings::setValue(Settings::Gui::WindowGeometry, QRect(1, 2, 3, 4));
|
||||
QVERIFY(Settings::value(Settings::Gui::WindowGeometry).toRect().isValid());
|
||||
|
||||
Settings::clearState();
|
||||
|
||||
QVERIFY(!Settings::value(Settings::Gui::WindowGeometry).toRect().isValid());
|
||||
}
|
||||
|
||||
QTEST_MAIN(SettingsTests)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ private Q_SLOTS:
|
|||
void checkValidSettings();
|
||||
void checkCleanScreenName();
|
||||
void checkCleanScreenName_LongName();
|
||||
void checkClearState();
|
||||
|
||||
private:
|
||||
inline static const QString m_settingsPathTemp = QStringLiteral("tmp/test");
|
||||
|
|
|
|||
Loading…
Reference in a new issue