Skip to content

[Feature Request] [Core] [Preferences] [UI/UX] Buttons to reset default values of Pages/Groups#10688

Merged
chennes merged 3 commits intoFreeCAD:masterfrom
CalligaroV:preferences-defaultButtons
Oct 2, 2023
Merged

[Feature Request] [Core] [Preferences] [UI/UX] Buttons to reset default values of Pages/Groups#10688
chennes merged 3 commits intoFreeCAD:masterfrom
CalligaroV:preferences-defaultButtons

Conversation

@CalligaroV
Copy link
Contributor

Fixes #10161

Forum discussion
https://forum.freecad.org/viewtopic.php?t=80253

Allows to reset the default values of a Preferences Page, as for the title of the issue, and also adds another button to reset all the Preference Pages of the chosen Group.

@github-actions github-actions bot added the Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Sep 14, 2023
@luzpaz
Copy link
Contributor

luzpaz commented Sep 18, 2023

Can you copy image into the OP to show what the final outcome of the PR looks like in the GUI ?

@CalligaroV
Copy link
Contributor Author

Not sure if you asked me to put it on my first post here or to put it in the forum topic but in the meantime I paste it here 😉

Don't know if this will be the final version but it takes into account the tips from other users on the forum

preferencesDefaultButtons

@chennes chennes self-assigned this Sep 18, 2023
Comment on lines 233 to 234
ui->buttonResetGroup->setText(tr(std::string("Reset Group\n" + group.toStdString()).c_str()));
ui->buttonResetTab->setText(tr(std::string("Reset Tab " + tabWidget->tabText(tabIndex).toStdString()).c_str()));
Copy link
Member

@chennes chennes Sep 18, 2023

Choose a reason for hiding this comment

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

What you need here is to use the QString arg function to construct your string, so that translators see the right thing. It will looks like tr("Reset Group %1").arg(groupName). I wouldn't include the "\n" either, that will only work in English. So tell the button to wrap the text (you'll have to use a QToolButton), or something along those lines.

@FEA-eng
Copy link
Contributor

FEA-eng commented Sep 18, 2023

Looks great to me :-) It's a very nice enhancement.

@luzpaz luzpaz added the Topic: User Interface Issue related UI / UX label Sep 19, 2023
@CalligaroV
Copy link
Contributor Author

@FEA-eng Thank you very much for the appreciation! 😄

@chennes Thanks for the suggestions!
About the arg usage I have no other questions ATM, most likely I will apply it in my next commit.

About the QToolButton, I'm not sure I understood your suggestion.
Could you please share an example from other parts of FreeCAD or from other software?

@chennes
Copy link
Member

chennes commented Sep 19, 2023

About the QToolButton, I'm not sure I understood your suggestion.

You have included a \n in the text of that button to manually wrap the line: that isn't going to work well in translated text. So I am proposing that you switch from using a QPushButton (which does not support text wrapping, as far as I remember) to a QToolButton, which does.

…or Group

 * reformatted texts for better translations
 * Morphed buttons from QPushButton to QToolButton
 * added code to resize items list and buttons on language change

Signed-off-by: CalligaroV <[email protected]>
@CalligaroV
Copy link
Contributor Author

I see, so it's just to get rid of \n, not for particular features of the QToolButton.

However, how is the text wrapping enabled?
I did some searches and found that one method used is suggested here https://stackoverflow.com/questions/8960233/subclassing-qlabel-to-show-native-mouse-hover-button-indicator/8960548#8960548
Do you know easier ways? I'd prefer to remove the code I had to add to obtain the text wrapping

Besides that, I applied your other suggestion about the arg function, hope it's correct now.

I also noticed that, after changing the language, the entries in the groups list lose the vertical alignment so I added some lines of code to fix that too

@yorikvanhavre
Copy link
Member

@CalligaroV
Copy link
Contributor Author

https://stackoverflow.com/questions/8969086/is-there-a-way-to-enable-word-wrapping-of-text-on-some-simple-widgets-like-qpush

Yes, this is one of the pages I found while searching and it's indeed the code I added (basically create a label, set word wrap, add a layout to the button, insert the label into the layout)

Looks like that's the most common way to have the word wrap ATM.

Thanks @yorikvanhavre!

@FEA-eng
Copy link
Contributor

FEA-eng commented Oct 2, 2023

@CalligaroV Is this PR ready to merge?

@CalligaroV
Copy link
Contributor Author

CalligaroV commented Oct 2, 2023

@FEA-eng by now I can see only 2 reasons for not merging:

  1. Haven't yet figured out how to handle the settings added in "non standard ways" (see my Side Note in the forum post https://forum.freecad.org/viewtopic.php?p=703098#p703098)
  2. Don't know if someone else tested it

If this two items aren't an issue then for me it's ok to merge!

@chennes
Copy link
Member

chennes commented Oct 2, 2023

I had planned on merging it at this morning merge meeting, but then I couldn't make the meeting... sorry for the delay.

@chennes chennes merged commit d8636dd into FreeCAD:master Oct 2, 2023
@wwmayer
Copy link
Contributor

wwmayer commented Oct 2, 2023

  • Morphed buttons from QPushButton to QToolButton

Why? The height of a tool button is different to the height of a push button and this makes the dialog looking bad. Also the behaviour when hovering or pressing a tool button is very different and this makes it more inconsistent.

Having three Reset buttons now is very confusing, IMO. The buttons are somehow related but are located at very different places which makes it even more confusing.

I think a better and more polished way is to switch back to a single reset button which when clicking on it opens a sub-widget with the 3 options.

@CalligaroV
Copy link
Contributor Author

@chennes, thanks for merging!

@wwmayer, thanks for the feedback!

Why? The height of a tool button is different to the height of a push button and this makes the dialog looking bad. Also the behaviour when hovering or pressing a tool button is very different and this makes it more inconsistent.

I saw some differences in the height of those buttons but in my case those differences were small enough to not make it an issue for me.
If you think it's better to fix it I'll apply the modifications needed.

About the hovering behavior, have you experienced something strange because of that or are you foreseeing potential issues?
I tried again right now but haven't spotted anything

Having three Reset buttons now is very confusing, IMO. The buttons are somehow related but are located at very different places which makes it even more confusing.

I can understand your argument and I somehow agree.
The current implementation takes into account the requests/suggestions from other forum users.
If you think this point is worth of further discussion I can write a post about that on the forum!

I think a better and more polished way is to switch back to a single reset button which when clicking on it opens a sub-widget with the 3 options.

I like this idea!
This may give yet another reason for using QToolButton.

At this point, if you agree, I'll expose these last two point on the forum.

@chennes
Copy link
Member

chennes commented Oct 3, 2023

FYI there is a UI/UX working group forming right now (details to come once the organizers have a preliminary meeting) and I know that they are planning on working on the Preferences dialog. So you might want to reach out to @obelisk79, who is organizing that effort.

@obelisk79
Copy link
Contributor

Use of QPushButton is more logical unless the QToolButton with dropdown is implemented. I would like to see the preferences dialog get a complete review and reorganization prior to the next full release, which is one of the reasons why I'll be eventually leading a discussion with the working group. But that will be a little bit further down the road.

@wwmayer
Copy link
Contributor

wwmayer commented Oct 4, 2023

If you think it's better to fix it I'll apply the modifications needed.

It's not only the height but its visual appearance. If you use the default desktop theme it's not that obvious but as soon as you activate one of the style sheets e.g. to Dark then the push buttons are flat and look like a label while the push buttons are raised. With other style sheets like "Behave-dark" it looks even worse because a tool button has a linear gradient while a push button hasn't it.

About the hovering behavior, have you experienced something strange because of that or are you foreseeing potential issues?

No issues but visual appearance only. But IMO this change contradicts to the efforts (e.g. from paddle) to make the UI more user friendly and consistent.

I like this idea!
This may give yet another reason for using QToolButton.

I don't mind what buttons you use for this sub-panel.

But IMO three reset buttons are way too prominent and this isn't something a user uses all the time.

At this point, if you agree, I'll expose these last two point on the forum.

OK.

Btw, I have tested this function and doesn't work in 100% of all cases because not all setting pages use "PrefWidgets" but get and set the parameters by accessing the parameter groups via the Application. Some example where it fails are:

  • DlgSettingsGeneral
  • DlgSettingsWorkbench
  • DlgSettingsTheme
  • DlgSettingsEditor

The class DlgPreferencesImp isn't able to handle all eventualities and thus I think there should be a way to let a concrete settings class override the default behaviour. I can think of two alternatives to achieve this:

  • Move restorePageDefaults to PreferencePage and make it virtual. Then a subclass can override the method and handle the tricky cases (or disallow to reset any parameters in case this makes sense anywhere)
  • The DlgPreferencesImp class could check if the settings class has a slot function of the name restoreDefaults and if yes call it, otherwise use restorePageDefaults

The first option is more OOP and thus probably the better choice.

@CalligaroV
Copy link
Contributor Author

@chennes thanks for the info!

@obelisk79 I'm sorry I couldn't attend the meeting. Is the next one already scheduled?
About the dialog reorganization, you mean Kadet's the proposal of forum topic https://forum.freecad.org/viewtopic.php?t=81609?

@wwmayer, I just saw you already opened a pull request to restore the single reset button layout. Thanks!
About moving restorePageDefaults, I think I got your idea but I'd like to confirm:
by doing so the pages with all the parameters defined using Pref* Widgets will use that function but pages such as the ones you mentioned must be modified redefining restorePageDefaults, correct?

p.s. for everyone: sorry for the late reply!

@CalligaroV CalligaroV deleted the preferences-defaultButtons branch October 14, 2023 18:30
@wwmayer
Copy link
Contributor

wwmayer commented Oct 14, 2023

correct?

Correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD Topic: User Interface Issue related UI / UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Reset tab button in Preferences (only reset preferences in the active tab)

7 participants