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
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

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

Post by Zolko »

drmacro wrote: Thu Aug 18, 2022 1:09 pm On another note (probably because of how I initially got got this particular cfg). Every time I apply a pack I get the following warning:

Code: Select all

keyboard shortcut 3 disabled: because conflicting with Std_ViewRight
I've not been able to figure out where this is (I know where shortcuts are defined, just not which category is trying to assign 3...)
I have a similar message, and I don't know what is causing it:

Code: Select all

Recent macros : keyboard shortcut 1 disabled because conflicting with Std_ViewFront
Recent macros : keyboard shortcut 2 disabled because conflicting with Std_ViewTop
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

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

Post by adrianinsaval »

drmacro wrote: Thu Aug 18, 2022 1:09 pm Every time I apply a pack I get the following warning:

Code: Select all

keyboard shortcut 3 disabled: because conflicting with Std_ViewRight
I've not been able to figure out where this is (I know where shortcuts are defined, just not which category is trying to assign 3...)
I think this usually comes from the recent macros shortcuts, you need to assign some modifier to it so it doesn't try to just use number, but I think that would start with 1 not 3 so it could be something else.
User avatar
chennes
Veteran
Posts: 3877
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 »

Are you closing FreeCAD before checking the config file?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

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

Post by drmacro »

chennes wrote: Thu Aug 18, 2022 4:35 pm Are you closing FreeCAD before checking the config file?
Yes, multiple times. No go.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

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

Post by drmacro »

Further testing...descriptions of preference packs.

The wiki shows various XML that may be used in the package.xml

But, the sample package.xml says the file may be overwritten loosing edits.

But, it does not appear it is overwritten when "Save new" is used, the new pack is added and the edits are still there.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3877
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: Thu Aug 18, 2022 1:09 pm This created the following directory/file:

~/.local/share/FreeCAD/SavedPreferencePacks/TestCustomParams/

I then created a sub-directory:

~/.local/share/FreeCAD/SavedPreferencePacks/TestCustomParams/PreferencePackTemplates/

In it I placed a file: MacMods.cfg
I think there is some confusion here between the use of a template, and the use of a preference pack. You don't put a template inside a preference pack, you use a template to generate a preference pack. Templates have a couple of possible storage locations, but SavedPreferencePacks isn't one of them. FreeCAD will look in its own resource directory for the built-in packs, and then in all the subdirectories of the Mod directory. Since "SavedPreferencePacks" isn't installed as a Mod, it never looks there. So we can either change that (see e.g. line ~480 of PreferencePackManager.cpp), or you can make a folder inside Mod, and in that folder put your PreferencePackTemplates folder.

Once you've done that, your new template file should show in the list of options when saving a new preference pack.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8865
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 2:34 am
...
Then this, from the wiki, is wrong?

"To include these template files, add-on authors should create a subdirectory in their package called either "PreferencePackTemplates" or "preference_pack_templates""

I also see no specific mention of the Mod directory in the wiki.

I am apparently reading the wiki completely wrong as well. Or I'm not make a distinction between template and pack. When I do a Save new, the new pack is listed in the Edit>Preferences dialog. And can be applied. Are you (or the wiki) saying the custom parameters are not to be stored with the directory where the Save new saved it? And this new pack can't be tested without being setup up in the Addon manager?

Sorry to be so dense. :oops:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

I admit that I have abused the "Save new" function from the preferences. It created the structure and I could replace the contents of the xml file.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

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

Post by drmacro »

chrisb wrote: Fri Aug 19, 2022 12:55 pm I admit that I have abused the "Save new" function from the preferences. It created the structure and I could replace the contents of the xml file.
I just create a random named directory in the Mod directory. In it I added a directory called PreferencePackTemplates. In it I added my .cfg file.

When I tried Save new, it did find and add my .cfg to the list of params to save.

the .cfg file contents:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<FCParameters>

  <FCParamGroup Name="Root">
    <FCParamGroup Name="BaseApp">
      <FCParamGroup Name="Preferences">
        <FCParamGroup Name="General">
          <FCText Name="AutoloadModule">PartDesignWorkbench</FCText>
        </FCParamGroup>
        <FCParamGroup Name="MacMods">
          <FCText Name="MacString">Test MacModString</FCText>
        </FCParamGroup>
      </FCParamGroup>
    </FCParamGroup>
  </FCParamGroup>

</FCParameters>
The template created with this .cfg unchecked didn't include the General group or MacMods. As expected.

Creating the template with it checked produced:

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.

But, also, how would one effect the changing of parameters (since it seems the value is taken from the current state, not as specified in the .cfg.)?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3877
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 will try to explain:

The main idea behind the templates is that there is no way to know what parameters exist, or what their defaults are. This is because of the way FreeCAD deals with user preferences. As you know, they aren't all in the user.cfg file: in general, only those that are not at their default state are in that file. But when saving a pack in many cases I expect you to want to explicitly have the pack set a variable to that default state. So, the template files are lists of parameters, along with their default value. When a preference pack is saved, only parameters listed in the template file are saved, either with the default value as set in the template, or, if the user has actually set that variable, with the value the user has set it to in FreeCAD. That's because those are literally the only variables that the pref pack system knows exist. In an ideal world those templates would cover all user preferences that make sense to include in a preference pack (e.g. you probably wouldn't want your "recent files" list in there, and in most cases not your language, etc.). I started with just the appearance ones and hope I can get community help generating the rest. The ones that deal with FreeCAD's core are expected to be included with FreeCAD, and are in the main FreeCAD resources directory. I didn't include a facility whose intended purpose was extending those core preference templates because the idea is that they should be included with FreeCAD's distribution. We don't have them all yet, but we've been adding them over the past months.

What I did include was a facility for Workbench authors (not necessarily, or even generally, Preference Pack authors) to include template files to provide a centralized list of the saveable parameters that their Addon uses. These aren't really intended to address things that are core to FreeCAD, but rather are specific settings for that Addon.

Finally, all of this "save a new pack" business is only intended to provide a basic functionality for saving the beginnings of a new preference pack. Maybe sometimes that pack will actually cover exactly what someone needs, but I anticipate that authors of distributable packs will edit those saved config files to really include only the parameters they actually need, and to add the missing ones (things that weren't in the templates). They'll also want to package them up with their own package.xml file, etc., and possibly a pre.FCMacro and/or a post.FCMacro to do any final configuration.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply