Skip to content

Commit

Permalink
feat: save and reload app settings when opening a project
Browse files Browse the repository at this point in the history
Saving only takes place if it's applicable.
  • Loading branch information
Cuperino committed Mar 3, 2025
1 parent f64c4f3 commit ac2de57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/core/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ Settings::Settings(Mode mode, QObject *parent)
Q_ASSERT(m_instance == nullptr);
m_instance = this;

loadKnutSettings();
if (!isTesting()) // Only load if not testing
loadUserSettings();
loadBaseSettings();

m_saveTimer->callOnTimeout(this, &Settings::saveSettings);
m_saveTimer->setSingleShot(true);
Expand All @@ -63,6 +61,13 @@ Settings::~Settings()
m_instance = nullptr;
}

void Settings::loadBaseSettings()
{
loadKnutSettings();
if (!isTesting()) // Only load if not testing
loadUserSettings();
}

Settings *Settings::instance()
{
Q_ASSERT(m_instance);
Expand All @@ -85,6 +90,9 @@ void Settings::loadUserSettings()

void Settings::loadProjectSettings(const QString &rootDir)
{
saveOnExit();
loadBaseSettings();

m_projectPath = rootDir;

const QString fileName = projectFilePath();
Expand Down
1 change: 1 addition & 0 deletions src/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public slots:

void loadKnutSettings();
void loadUserSettings();
void loadBaseSettings();
void updatePaths(const QString &path, const std::string &json_path, bool add);
void saveSettings();
void saveOnExit();
Expand Down

0 comments on commit ac2de57

Please sign in to comment.