Turning Zolko's theme in to a Preference Pack

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Turning Zolko's theme in to a Preference Pack

Post by chennes »

drmacro wrote: Fri Aug 19, 2022 2:47 pm

Code: Select all

...
        <FCParamGroup Name="General">
          <FCText Name="AutoloadModule">SMWorkbench</FCText>
        </FCParamGroup>
        <FCParamGroup Name="MacMods">
          <FCText Name="MacString">Test MacModString</FCText>
        </FCParamGroup>
      </FCParamGroup>
 ...
 

SMWorkbench is what is currently set in the preferences.
But, the value specified in the .cfg was PartDesignWorkbench

This seems anomalous behaviour.
What do you have your current "AutoloadModule" set to, when you save your pack? It will only use the default value from the template file if you have no setting of your own for that variable.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: Turning Zolko's theme in to a Preference Pack

Post by drmacro »

chennes wrote: Fri Aug 19, 2022 3:18 pm
drmacro wrote: Fri Aug 19, 2022 2:47 pm

Code: Select all

...
        <FCParamGroup Name="General">
          <FCText Name="AutoloadModule">SMWorkbench</FCText>
        </FCParamGroup>
        <FCParamGroup Name="MacMods">
          <FCText Name="MacString">Test MacModString</FCText>
        </FCParamGroup>
      </FCParamGroup>
 ...
 

SMWorkbench is what is currently set in the preferences.
But, the value specified in the .cfg was PartDesignWorkbench

This seems anomalous behaviour.
What do you have your current "AutoloadModule" set to, when you save your pack? It will only use the default value from the template file if you have no setting of your own for that variable.
This is all just testing and getting acquainted with this pack stuff.

So, in the above, the idea was to have the pack specify what the autoload was to be (i.e. override the current setting). The current setting was SMWorkbench and I wanted, when the pack is applied, to set it to PartDesignWorkbench. So, PartDesignWorkbench was specified in the Mod/../...cfg file. Above it shows the Save new saved the current version.

From your description, I'm thinking this would be something to handle in a post macro?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Turning Zolko's theme in to a Preference Pack

Post by chennes »

I think you are still getting mixed up between the template files and the preference packs. Let me try another way: from an end-user perspective, the ultimate goal is that when you click "Save new pack", the resulting preference pack is a copy of your current preferences. The idea being that if for example you totally bork your preferences file somehow, then re-applying that preference pack will take you back to the way you were before. From a user's perspective, there is no such thing as a "template" file -- that's just internal mechanics, with no bearing on your desired outcome.

So a user should never care what is in a template file: those files only exist to ensure that when saving a preference pack, all appropriate preferences are getting saved, as the user currently has them set. They are just an internal mechanism for making sure that the end goal of saving all of a user's preferences is actually met. The reason they have to have a default value is so that that default value actually gets written into the final config file, if (and only if) the user has not set that particular configuration parameter. If that didn't happen, then anything that the user had left at its default value wouldn't be in the pack, so then couldn't overwrite a non-default setting when the pack was applied.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: Turning Zolko's theme in to a Preference Pack

Post by drmacro »

So, the template file defines a set of additional parameters to save with a Save new. And only non-standard values are taken from the template and system values specified in the file take the current value in params. (If the later is true, why put a value for system params in the file?) At least that is what I think I saw happen.

Aside from that, maybe I should explain the intent of my questions.

I'm trying to understand what is required to provide a set of preference packs.

I'm trying to understand what needs to be there as minimum and to what extent a pack can modify the setup. (For example, can it set the AutoloadWorkbench, how to change location of toolbars, stylesheets, etc.) (Earlier I did figure out how to set the AutoLoadWorkbench via pre.FCMacro, is it the right way...not sure.) (Also, how to install workbenches so a pref pack can adjust what workbenches might constitute, for example, a "Basic Mechanical" that might offer only PD, Part, TechDraw, and Manipulator. (Just an example, it might include many other benches.)

I'm trying to understand how close to the final product Save new gets me.

I'm trying to understand how to test the lot while I'm learning.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Turning Zolko's theme in to a Preference Pack

Post by chennes »

drmacro wrote: Fri Aug 19, 2022 9:31 pm And only non-standard values are taken from the template and system values specified in the file take the current value in params.
No, the opposite: the template only provides the standard value. Maybe an example will help: imagine you have a perfectly clean install of FreeCAD, never before run. Run it, it creates a user.cfg file: that file is nearly empty, because almost all values are at their defaults, and not that much stuff gets set automatically. Now, imagine you really like the default color scheme, and you want to save the current state of things to a new preference pack. So you click "Save new pack" and tell FreeCAD to save everything by checking all the boxes.

Then you start changing colors, etc. And it's awful, and you want to get back to the ones you saved in the preference pack. Well, if there were no such thing as template files, then when you saved the pack originally, all that would have been written into the pack would have been basically a copy of the default user.cfg file, which contains no color information (because they are at their defaults). So when you apply the saved preference pack, the colors are left alone (a preference pack can't delete a preference setting, only change or add one). So your colors don't get fixed. This is the problem the Template files address: when you tell FreeCAD to save a preference pack, it saves values for EVERYTHING in the template files, even if the user has not set it. The stuff the user hasn't set gets set to the default found in the template. If the user set it, then the default isn't needed, and their setting is stored.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: Turning Zolko's theme in to a Preference Pack

Post by drmacro »

chennes wrote: Fri Aug 19, 2022 9:53 pm
drmacro wrote: Fri Aug 19, 2022 9:31 pm And only non-standard values are taken from the template and system values specified in the file take the current value in params.
No, the opposite: the template only provides the standard value. Maybe an example will help: imagine you have a perfectly clean install of FreeCAD, never before run. Run it, it creates a user.cfg file: that file is nearly empty, because almost all values are at their defaults, and not that much stuff gets set automatically. Now, imagine you really like the default color scheme, and you want to save the current state of things to a new preference pack. So you click "Save new pack" and tell FreeCAD to save everything by checking all the boxes.

...
I think I saw the following:

I created MyWonky.cfg that specified a random parameter (myrand set to "bogus") and a known parameter (AutoloadWorkbench set to "PartDesignWorkbench").

Save new produced the dialog as expected with an additiona checkbox named MyWonky.

myrand doesn't exist in params at this point, but AutoloadWorkbench is set to SMWorkbench

The template contained myrand set to bogus and AutoloadWorkbench set to SMWorkbench (this is expected based on what you said.)

Another question: where is the shape of the various panes persisited? I did a diff before and after changing the the size of the report view and it was nowhere...
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Turning Zolko's theme in to a Preference Pack

Post by chennes »

Various things about the main window, including (I believe) the size of various dock windows, are stored using QSettings, and is not in our config file. Qt stores those things in different ways, depending on the OS.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: Turning Zolko's theme in to a Preference Pack

Post by drmacro »

chennes wrote: Sat Aug 20, 2022 10:35 pm Various things about the main window, including (I believe) the size of various dock windows, are stored using QSettings, and is not in our config file. Qt stores those things in different ways, depending on the OS.
After posting I did find a diff in the FreeCAD.cfg in a section named [Qt...].

It is byte data in hex.

Guessing that is what QSettings is accessing?

Wonder if QSettings is exposed so it ca be gotten to from Python?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Turning Zolko's theme in to a Preference Pack

Post by Kunda1 »

drmacro wrote: Sat Aug 20, 2022 11:03 pm It is byte data in hex.
Nice sleuthing!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Turning Zolko's theme in to a Preference Pack

Post by chennes »

drmacro wrote: Sat Aug 20, 2022 11:03 pm Wonder if QSettings is exposed so it ca be gotten to from Python?
Yes: https://doc.qt.io/qtforpython-5/PySide2 ... tings.html
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply