Hidden Line pref disregarded if language is French

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Hidden Line pref disregarded if language is French

Post by NormandC »

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 2448 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 2448 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!

:?
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hidden Line pref disregarded if language is French

Post by wandererfan »

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
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Hidden Line pref disregarded if language is French

Post by wmayer »

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.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hidden Line pref disregarded if language is French

Post by wandererfan »

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
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Hidden Line pref disregarded if language is French

Post by wmayer »

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.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hidden Line pref disregarded if language is French

Post by wandererfan »

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

Re: Hidden Line pref disregarded if language is French

Post by NormandC »

Thanks!
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hidden Line pref disregarded if language is French

Post by wandererfan »

NormandC wrote: Sun Mar 11, 2018 10:55 pmThanks!
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.
Post Reply