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

11565 confirmation dialog for reset preferences and fixes #25400

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

krasko78
Copy link
Contributor

@krasko78 krasko78 commented Nov 1, 2024

Resolves: #11565

  1. Added a confirmation dialog for when the Reset preferences button on the Preferences dialog is clicked
  2. All preference pages update all of their settings to match the reset preferences after resetting the preferences.

I've added some comments below (in this PR) with more info and observations.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@krasko78
Copy link
Contributor Author

krasko78 commented Nov 1, 2024

Observations:

  • The confirmation dialog is in preferencesmodel.cpp and is pretty straight-forward. The Cancel button is the default button. Here is a screenshot:
    image

  • The changes to update each page after the reset is complete are in separate commits (much easier to review I guess). The Appearance, Folders and Shortcuts page already worked as expected so no changes were needed for them.

  • There is inconsistency in the use of .onReceive(nullptr, vs. .onReceive(this,.

  • There is also inconsistent use of ValCh vs. ValNt vs. separate channel/notification.

  • I've added a few comments to some files to explain why I had to make a specific change that might not be obvious.

@krasko78 krasko78 marked this pull request as draft November 1, 2024 19:58
//! NOTE To change the language at the moment, a restart is required
m_needRestartToApplyLanguageChange = true;
m_needRestartToApplyLanguageChange = newLanguageCode != m_activeLanguageCode;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to make the "Restart required" text go away if the user restores the language explicitly or via Reset preferences to the currently active language. Currently, once this text appears, it won't go away.

@@ -95,6 +95,13 @@ void Settings::reset(bool keepDefaultSettings, bool notifyAboutChanges)
m_settings->clear();

m_isTransactionStarted = false;

std::vector<Settings::Key> locallyAddedKeys;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made these changes because it turned out that some settings without a value are not present in m_items. If the user opens the Preferences dialog, all settings are switched to m_localSettings. If the user sets a value of a missing setting, it will be created in m_localSettings. Then, if the user resets the preferences without closing the dialog, change notifications will be sent out for the settings in m_items, i.e. any settings added in m_localSettings will be missed and thefore not updated on the dialog. Two examples of such settings are: Score -> Style for part (PART_STYLE_FILE_PATH in the code) and Import -> Style file (STYLE_FILE_IMPORT_PATH_KEY in the code).

@@ -41,7 +41,12 @@ BaseSection {
QtObject {
id: prv

property bool useStyleFile: root.styleFileImportPath !== ""
property bool useStyleFileExplicitlySet: root.styleFileImportPath !== ""
Copy link
Contributor Author

@krasko78 krasko78 Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes were needed to properly update the Styles used for import controls on the Import page and fix these two bugs:
1. Open the Preferences dialog and navigate to the Import page.
2. Change Style used for import from Built-in style to Use style file.
3. Type a file if you want or skip this step.
4. Click Reset Preferences without closing the dialog.
Result: the Use style file radiobutton remains selected.

AND:
1. Open the Preferences dialog and navigate to the Import page.
2. Change Style used for import from Built-in style to Use style file.
3. Type something in the file textbox.
4. Delete the text in the file textbox.
Result: the Built-in style radiobutton becomes selected.

@krasko78 krasko78 force-pushed the 11565-ConfirmationDialogForResetPreferencesAndFixes branch 2 times, most recently from 8f244fd to a23448e Compare November 1, 2024 23:14
@krasko78 krasko78 force-pushed the 11565-ConfirmationDialogForResetPreferencesAndFixes branch from a23448e to 628dfa7 Compare November 1, 2024 23:18
@krasko78 krasko78 marked this pull request as ready for review November 1, 2024 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MU4 Issue] "Reset preferences" doesn't reset all preferences (e.g. advanced), no confirmation
1 participant