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
Final code review fix
  • Loading branch information
pacebes authored and cbjeukendrup committed Oct 1, 2024
1 parent 0512822 commit 1b9f9a5
Show file tree
Hide file tree
Showing 4 changed files with 25 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 const QString& preferencesDialogLastOpenedPageId() const = 0;
virtual void setPreferencesDialogLastOpenedPageId(const 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));
}

const QString& AppShellConfiguration::preferencesDialogLastOpenedPageId() const
{
return m_preferencesDialogCurrentPageId;
}

void AppShellConfiguration::setPreferencesDialogLastOpenedPageId(const QString& lastOpenedPageId)
{
m_preferencesDialogCurrentPageId = 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;

const QString& preferencesDialogLastOpenedPageId() const override;
void setPreferencesDialogLastOpenedPageId(const 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_preferencesDialogCurrentPageId;
};
}

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

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

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

Expand Down

0 comments on commit 1b9f9a5

Please sign in to comment.