Skip to content

Commit

Permalink
Fix #24678: Remember which tab was last open within a session
Browse files Browse the repository at this point in the history
  • Loading branch information
pacebes committed Oct 1, 2024
1 parent 0512822 commit 8560e29
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/appshell/iappshellconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class IAppShellConfiguration : MODULE_EXPORT_INTERFACE
virtual bool needShowSplashScreen() const = 0;
virtual void setNeedShowSplashScreen(bool show) = 0;

virtual QString preferencesDialogLastOpenedPageId() const = 0;
virtual void setPreferencesDialogLastOpenedPageId(QString lastOpenedPageId) = 0;

virtual void startEditSettings() = 0;
virtual void applySettings() = 0;
virtual void rollbackSettings() = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/appshell/internal/appshellconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ void AppShellConfiguration::setNeedShowSplashScreen(bool show)
settings()->setSharedValue(SPLASH_SCREEN_VISIBLE_KEY, Val(show));
}

QString AppShellConfiguration::preferencesDialogLastOpenedPageId() const
{
return m_preferencesDialogCurrentPageIdQString;
}

void AppShellConfiguration::setPreferencesDialogLastOpenedPageId(QString lastOpenedPageId)
{
m_preferencesDialogCurrentPageIdQString = lastOpenedPageId;
}

void AppShellConfiguration::startEditSettings()
{
settings()->beginTransaction();
Expand Down
5 changes: 5 additions & 0 deletions src/appshell/internal/appshellconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class AppShellConfiguration : public IAppShellConfiguration, public muse::Inject
bool needShowSplashScreen() const override;
void setNeedShowSplashScreen(bool show) override;

QString preferencesDialogLastOpenedPageId() const override;
void setPreferencesDialogLastOpenedPageId(QString lastOpenedPageId) override;

void startEditSettings() override;
void applySettings() override;
void rollbackSettings() override;
Expand All @@ -106,6 +109,8 @@ class AppShellConfiguration : public IAppShellConfiguration, public muse::Inject
muse::Ret writeSessionState(const QByteArray& data);

muse::io::paths_t parseSessionProjectsPaths(const QByteArray& json) const;

QString m_preferencesDialogCurrentPageIdQString = "";
};
}

Expand Down
7 changes: 6 additions & 1 deletion src/appshell/view/preferences/preferencesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ void PreferencesModel::load(const QString& currentPageId)
if (!currentPageId.isEmpty()) {
setCurrentPageId(currentPageId);
} else {
setCurrentPageId("general");
if (configuration()->preferencesDialogLastOpenedPageId().isEmpty()) {
setCurrentPageId("general");
} else {
setCurrentPageId(configuration()->preferencesDialogLastOpenedPageId());
}
}

m_rootItem = new PreferencePageItem();
Expand Down Expand Up @@ -275,6 +279,7 @@ void PreferencesModel::setCurrentPageId(QString currentPageId)
}

m_currentPageId = currentPageId;
configuration()->setPreferencesDialogLastOpenedPageId(currentPageId);
emit currentPageIdChanged(m_currentPageId);
}

Expand Down

0 comments on commit 8560e29

Please sign in to comment.