Hidden Line pref disregarded if language is French

Discussions about the development of the TechDraw workbench
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Hidden Line pref disregarded if language is French

Postby NormandC » Sat Mar 10, 2018 7:11 pm

There is something really weird going on with TechDraw preferences. Or maybe it is with language switching within the preferences.

I was trying to troubleshoot why views created in TechDraw would refuse to show hidden lines, even when I set the "Hard Hidden" and "Smooth Hidden" properties of TD views to true.

Starting from a fresh .FreeCAD folder, I load TechDraw then I go to Edit --> Preferences --> TechDraw. What I see is this:
FC017_TD_Prefs_bug_01.png
FC017_TD_Prefs_bug_01.png (72.38 KiB) Viewed 841 times
So Hidden Line type is set to "Solide" (Solid) by default. Which seems odd to me.

But, before changing this setting, I go to General then switches the language to English; then I go back to TechDraw. And now, here's what it shows:
FC017_TD_Prefs_bug_02.png
FC017_TD_Prefs_bug_02.png (41.83 KiB) Viewed 841 times
Uh. It's now set to "NeverShow", and I never touched it.

So I change it to "Dash", click Apply, then switch back to General, change language back to French, Apply, go back to TechDraw prefs, and now the setting is... "ToujoursCacher", which is NeverShow!

:?
wandererfan
Posts: 3080
Joined: Tue Nov 06, 2012 5:42 pm

Re: Hidden Line pref disregarded if language is French

Postby wandererfan » Sat Mar 10, 2018 8:56 pm

NormandC wrote:
Sat Mar 10, 2018 7:11 pm
There is something really weird going on with TechDraw preferences. Or maybe it is with language switching within the preferences.
It happens here too, if Preferences>General and Preferences>TechDraw are both in the sidebar. If TechDraw isn't in the sidebar then it doesn't happen.

If I change language from French to English, the TD hidden line parameter in user.cfg changes from solide(1) to neverDraw(0).

Code: Select all

            <FCParamGroup Name="General">
              <FCInt Name="HiddenLine" Value="1"/>
              <FCInt Name="ProjectionAngle" Value="0"/>
              ...

Code: Select all

            <FCParamGroup Name="General">
              <FCInt Name="HiddenLine" Value="0"/>
              <FCInt Name="ProjectionAngle" Value="0"/>
              ...


Can't make it change the other way from ToujoursCache to Solide by changing language.
The only common thing I can find is that both parameters are in a subgroup called "General".
wmayer
Site Admin
Posts: 14892
Joined: Thu Feb 19, 2009 10:32 am

Re: Hidden Line pref disregarded if language is French

Postby wmayer » Sat Mar 10, 2018 9:04 pm

The point is that when changing the language a preference page receives an event and to call a function translateUi. This function is generated by Qt's uic compiler and always clears combo boxes. So, developers must take special care about this behaviour and explicitly save & restore the current index.
wandererfan
Posts: 3080
Joined: Tue Nov 06, 2012 5:42 pm

Re: Hidden Line pref disregarded if language is French

Postby wandererfan » Sun Mar 11, 2018 1:08 am

wmayer wrote:
Sat Mar 10, 2018 9:04 pm
developers must take special care about this behaviour and explicitly save & restore the current index.
Is this what you mean? Does it only apply to comboBox derived widgets?

Code: Select all

void DlgPrefsTechDrawImp::changeEvent(QEvent *e)
{
    if (e->type() == QEvent::LanguageChange) {
        saveAllTheComboBoxIndices();
        retranslateUi(this);
        restoreAllTheComboBoxIndices();
    }
    else {
I don't think this is well known. The preference code I copied from didn't do this.
wmayer
Site Admin
Posts: 14892
Joined: Thu Feb 19, 2009 10:32 am

Re: Hidden Line pref disregarded if language is French

Postby wmayer » Sun Mar 11, 2018 9:49 am

Does it only apply to comboBox derived widgets?
Yes, I think so. But e.g. the font combo box is not affected which is more or less obvious as there is nothing to translate.
wandererfan
Posts: 3080
Joined: Tue Nov 06, 2012 5:42 pm

Re: Hidden Line pref disregarded if language is French

Postby wandererfan » Sun Mar 11, 2018 10:53 pm

This should be fixed by git commit 9d26fe05.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Hidden Line pref disregarded if language is French

Postby NormandC » Sun Mar 11, 2018 10:55 pm

Thanks!
wandererfan
Posts: 3080
Joined: Tue Nov 06, 2012 5:42 pm

Re: Hidden Line pref disregarded if language is French

Postby wandererfan » Mon Mar 12, 2018 12:01 pm

NormandC wrote:
Sun Mar 11, 2018 10:55 pm
Thanks!
de rien, mon ami.

The problem may occur with other preference pages - I've seen a few without save/restore around the retranslate(), but I've never inspected them to see if the page has comboBoxes.