Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferences: Remember which tab was last open within a session #24678

Closed
2 tasks done
avvvvve opened this issue Sep 12, 2024 · 7 comments · Fixed by #24999
Closed
2 tasks done

Preferences: Remember which tab was last open within a session #24678

avvvvve opened this issue Sep 12, 2024 · 7 comments · Fixed by #24999
Assignees
Labels
community Issues particularly suitable for community contributors to work on feature request Used to suggest improvements or new capabilities

Comments

@avvvvve
Copy link

avvvvve commented Sep 12, 2024

Your idea

The Preferences window currently always opens to the 'General' tab. If I switch to a different tab, close the window, and reopen it, it should open to the last tab I had open.

If I quit and reopen MuseScore Studio, it should start back on the 'General' tab.

Problem to be solved

This would remove the extra step of pointing and clicking back to where you were if you're trying to stay focused on one area of preferences (i.e. setting up a bunch of shortcuts or changing appearance).

Prior art

No response

Additional context

No response

Checklist

  • This request follows the guidelines for reporting issues
  • I have verified that this feature request has not been logged before, by searching the issue tracker for similar requests
@muse-bot muse-bot added the feature request Used to suggest improvements or new capabilities label Sep 12, 2024
@avvvvve avvvvve changed the title Preferences: Remember which tab was open within a session Preferences: Remember which tab was last open within a session Sep 12, 2024
@avvvvve avvvvve added the community Issues particularly suitable for community contributors to work on label Sep 12, 2024
@pacebes
Copy link
Contributor

pacebes commented Sep 29, 2024

Hi

I volunteer to try to implement this issue with help.

I have been looking into the code and if I'm right:

  • PreferencesDialog.xml creates the window and "on completed" calls preferencesModel.load(root.currentPageId). If you change property string currentPageId: "" to property string currentPageId: "canvas" Preference windows will be opened on this tab
  • preferencesmodel.cpp: void PreferencesModel::load(const QString& currentPageId) could be used to set the initial tab

But, it seems Preference window is created and destroyed (PreferencesModel::~PreferencesModel())every time the user asks for it. Then currentPageId is forgotten.

Are there within MuseScore any method to store key Values that last while the application is running ?. That could be a way to store the PreferenceCurrentPageId keyValue and restore within PreferencesModel::load if currentPageId is empty

Kind Regards

@avvvvve
Copy link
Author

avvvvve commented Sep 30, 2024

@pacebes I can't find a specific code example for you (I am but a humble UX designer), but the code for the Format > Style... dialog might be helpful to look at. That dialog remembers the last "tab" that was open from the list on the left when you close and open it.

image

@cbjeukendrup
Copy link
Contributor

@pacebes The (I)AppShellConfiguration class lives for the entire session. You could use that to store the ID of the last opened page. Most method from that class return values from settings(), but since the page ID does not need to be preserved between sessions, you can simply store this value in a member field of AppShellConfiguration. Then, in PreferencesModel::load, you can replace "general" with configuration()->preferencesDialogLastOpenedPageId(), where preferencesDialogLastOpenedPageId would be the name of the newly created method.

@pacebes
Copy link
Contributor

pacebes commented Oct 1, 2024

Hi

Thanks @cbjeukendrup, I have a working version with the following changes (Just to check if they are "acceptable").

If you assign this issue to me I can create a pull request on the current version.

diff --git a/src/appshell/iappshellconfiguration.h b/src/appshell/iappshellconfiguration.h
index ed0bb20e18..6044863f53 100644
--- a/src/appshell/iappshellconfiguration.h
+++ b/src/appshell/iappshellconfiguration.h
@@ -58,6 +58,14 @@ public:

     virtual std::string museScoreVersion() const = 0;
     virtual std::string museScoreRevision() const = 0;
+
+    virtual QString preferencesDialogLastOpenedPageId() const = 0;
+    virtual void setpreferencesDialogLastOpenedPageId(QString lastOpenedPageId) = 0;
+
+

     virtual bool isNotationNavigatorVisible() const = 0;
     virtual void setIsNotationNavigatorVisible(bool visible) const = 0;

diff --git a/src/appshell/internal/appshellconfiguration.cpp b/src/appshell/internal/appshellconfiguration.cpp
index 6387abf93c..1984d84763 100644
--- a/src/appshell/internal/appshellconfiguration.cpp
+++ b/src/appshell/internal/appshellconfiguration.cpp
@@ -153,6 +153,16 @@ std::string AppShellConfiguration::musicXMLLicenseDeedUrl() const
     return MUSICXML_LICENSE_DEED_URL;
 }

+QString AppShellConfiguration::preferencesDialogLastOpenedPageId() const
+{
+       return (preferencesDialogCurrentPageId);
+}
+
+void AppShellConfiguration::setpreferencesDialogLastOpenedPageId(QString lastOpenedPageId)
+{
+       preferencesDialogCurrentPageId = lastOpenedPageId;
+}
+
 std::string AppShellConfiguration::museScoreVersion() const
 {
     return String(application()->version().toString() + u"." + application()->build()).toStdString();

diff --git a/src/appshell/internal/appshellconfiguration.h b/src/appshell/internal/appshellconfiguration.h
index 0b6f258952..d4e6a69856 100644
--- a/src/appshell/internal/appshellconfiguration.h
+++ b/src/appshell/internal/appshellconfiguration.h
@@ -77,6 +77,13 @@ public:

     std::string museScoreVersion() const override;
     std::string museScoreRevision() const override;
+
+    QString preferencesDialogLastOpenedPageId() const override;
+    void setpreferencesDialogLastOpenedPageId(QString lastOpenedPageId) override;
+

     bool isNotationNavigatorVisible() const override;
     void setIsNotationNavigatorVisible(bool visible) const override;
@@ -106,6 +113,8 @@ private:
     muse::Ret writeSessionState(const QByteArray& data);

     muse::io::paths_t parseSessionProjectsPaths(const QByteArray& json) const;
+
+    QString preferencesDialogCurrentPageId="";
 };
 }

diff --git a/src/appshell/view/preferences/preferencesmodel.cpp b/src/appshell/view/preferences/preferencesmodel.cpp
index 4f80474989..cbe3a41122 100644
--- a/src/appshell/view/preferences/preferencesmodel.cpp
+++ b/src/appshell/view/preferences/preferencesmodel.cpp
@@ -143,8 +143,14 @@ void PreferencesModel::load(const QString& currentPageId)
     if (!currentPageId.isEmpty()) {
         setCurrentPageId(currentPageId);
     } else {
-        setCurrentPageId("general");
-    }
+        // setCurrentPageId("general");
+               if ( configuration()->preferencesDialogLastOpenedPageId().isEmpty()) {
+                       setCurrentPageId("general");
+               } else {
+
+                       setCurrentPageId(configuration()->preferencesDialogLastOpenedPageId());
+               }
+       }

     m_rootItem = new PreferencePageItem();

@@ -276,6 +282,9 @@ void PreferencesModel::setCurrentPageId(QString currentPageId)

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

 PreferencePageItem* PreferencesModel::makeItem(const QString& id, const QString& title, muse::ui::IconCode::Code icon,


@cbjeukendrup
Copy link
Contributor

@pacebes That looks about right! There are some stylistic details, but those are easier to point out when you open the Pull Request, because then I can comment on individual lines.

In general, make sure that the indentation is correct, and that there are no multiple blank lines in a row (one is enough) and that there are no blank lines before a }.

Also, note that names of member fields should start with m_, i.e. m_preferencesDialogCurrentPageId.

For the rest I'll check it in the Pull Request itself!

@pacebes
Copy link
Contributor

pacebes commented Oct 1, 2024

Hi @cbjeukendrup

I don't know if I should ask about them here or in the pull request...

I created the pull request which failed because of "Codestyle / codestyle". I have run " tools/codestyle/uncrustify_run_file.sh" on them and then

  • git add ...(Files)
  • git commit --amend --no-edit

I have tried to push it again and I get

git push --force
fatal: The current branch 24678-rememberTabPreferencesWithinSession has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin 24678-rememberTabPreferencesWithinSession

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

But I'm not sure if this is the right option. Could you help me with that ?

Or perhaps it could be easier if you reject the previous pull request and I create a new one from the scratch

@cbjeukendrup
Copy link
Contributor

Amending the existing pull request is preferable. If you run git remote -v, then you should see that origin points to your own fork and upstream points to the musescore/MuseScore repo. If that is indeed the case, then you can run the command that Git suggests:

git push --set-upstream origin 24678-rememberTabPreferencesWithinSession

However, because it will be a force-push in this case, you need to add the -f flag:

git push --set-upstream origin 24678-rememberTabPreferencesWithinSession -f

pacebes added a commit to pacebes/MuseScore that referenced this issue Oct 1, 2024
pacebes added a commit to pacebes/MuseScore that referenced this issue Oct 1, 2024
pacebes added a commit to pacebes/MuseScore that referenced this issue Oct 1, 2024
pacebes added a commit to pacebes/MuseScore that referenced this issue Oct 1, 2024
cbjeukendrup added a commit that referenced this issue Oct 2, 2024
…thinSession

Fix #24678: Remember which tab was last open within a session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issues particularly suitable for community contributors to work on feature request Used to suggest improvements or new capabilities
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants