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!
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: Wed Aug 17, 2022 12:31 pm Would it be possible to add workbenches (for example, making a custom setup that could be chosen for a specific type of work, say that needed the Curves workbench) ?
yes, that-one would be really nice to have. PreferencePacks limited to a choice of colours are not very useful, but if they can handle the entire work environment, including additional Addons to be installed, that would open the door to many use-cases : Architecture, 3D-printing, FEM ...
try the Assembly4 workbench for FreCAD — tutorials here and here
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 »

@Zolko

How did you configure the status bar?

How did the draft snap and scale get added to the navigation and 3d view size?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
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: Wed Aug 17, 2022 3:29 pm How did the draft snap and scale get added to the navigation and 3d view size?
I don't see those things on my system. I think it's your config that does it
try the Assembly4 workbench for FreCAD — tutorials here and here
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 »

Zolko wrote: Wed Aug 17, 2022 5:28 pm
drmacro wrote: Wed Aug 17, 2022 3:29 pm How did the draft snap and scale get added to the navigation and 3d view size?
I don't see those things on my system. I think it's your config that does it
Yes, my bad. I had Draft WB selected.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
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 »

Zolko wrote: Wed Aug 17, 2022 9:37 am Also, in the new config directory (~/.config/FreeCAD/) there is a new file FreeCAD.conf which seems to contain Qt version specific data in clear text and byte-array format, which might contain this position info.
yes but that file already existed and was already placed there before FreeCAD adopted the XDG standard since Qt has been using it for a long time apparently. On windows these are stored in the registry, not sure on macOS.
Same remark for toolbars, they don't seem to be controlled by the PreferencePack, at least not their position.
The toolbars I'm not so sure, I think the global toolbars are controlled at the qt level but workbench toolbars positions are supposed to be remembered by FreeCAD too, in very old versions these where not saved and required an addon that was eventually integrated into FreeCAD I believe. There might be some sort of conflict or overlap between what qt stores and what FreeCAD stores though.
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 »

adrianinsaval wrote: Wed Aug 17, 2022 7:09 pm that file already existed and was already placed there before FreeCAD adopted the XDG standard since Qt has been using it for a long time apparently. On windows these are stored in the registry, not sure on macOS.
OK, but then, how do you save and restore them in a PreferencePack ?
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
chennes
Veteran
Posts: 3878
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 don't know how the position of the toolbars is stored, so I'm not much help on that front.

Preference Packs can absolutely set preferences for external workbenches: literally anything that can be set in user.cfg can be set in a preference pack, and Addon developers can even include Preference Pack template files as part of their Addon. In fact, you could create an entire addon that was nothing but Preference Pack template files! In addition, when you apply a preference pack it runs an optional FCMacro file, so you can use that file to do things that can't be done via the config file (e.g. if it turns out you can't set the location of the toolbars in user.cfg, you can write a short Python script to do it instead.
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: Wed Aug 17, 2022 9:57 pm I don't know how the position of the toolbars is stored, so I'm not much help on that front.

Preference Packs can absolutely set preferences for external workbenches: literally anything that can be set in user.cfg can be set in a preference pack, and Addon developers can even include Preference Pack template files as part of their Addon. In fact, you could create an entire addon that was nothing but Preference Pack template files! In addition, when you apply a preference pack it runs an optional FCMacro file, so you can use that file to do things that can't be done via the config file (e.g. if it turns out you can't set the location of the toolbars in user.cfg, you can write a short Python script to do it instead.
Hmm...to experiment with PP templates in my mind I seem to have a chicken or egg scenario.

If I open FreeCAD and do a Save new, in ~/.local/share/FreeCAD/SavedPreferencePacks/ I get a package.xml and a directory with the saved .cfg. (This .cfg file is the current state of user.cfg, including only the set that was checked in the Save dialog?).

To add custom parameters, then create a ~/.local/share/FreeCAD/SavedPreferencePacks/PreferencePackTemplates and add <custom name>.cfg files in this directory.

If the parameters specified in these custom cfg files don't exist they are created (with the specified defaults) when the PP is applied? So, a custom cfg that addresses, say parameters for a specific workbench would need to have the parameter tree that know that workbench parameter tree? If the workbench hasn't been installed are these values going to be over written if it then installed? As for completely custom params, do they just get created? (I'm off to experiment...)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3878
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 »

Most workbenches don't actively overwrite their known parameters on installation (actually I don't know of any that do, I don't know how it would work). So you can happily set whatever config parameters you want: if no code ever checks them that's fine. If later on a WB gets installed that uses them, then they are there. Does that answer that part of your question?

The template files exist because there is no way to know what parameters are available, and what their default files are: FreeCAD is completely freeform in this regard. A developer can add a new parameter by simply using it in their code. There is no central repository, etc., and FreeCAD doesn't even keep track of which parameters are asked for: if a param isn't in the config file, its default value is returned, but no record is kept of that transaction. So those template files were my way of making such a repository, at least for variables that I figured might be used most commonly in preference packs. I started with just color info (because that seemed obvious), and we've been adding things ever since.
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 »

Pursuant to my previous post.

I did a save new.

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
With 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="MacMods">
          <FCText Name="MacString">Test MacModString</FCText>
        </FCParamGroup>
      </FCParamGroup>
    </FCParamGroup>
  </FCParamGroup>

</FCParameters>

I then applied the pack, but MacMods is not created in the Param tree.

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...)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply