Need Help on populating user colors with Stylesheet change.

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
obelisk79
Veteran
Posts: 1063
Joined: Thu Sep 24, 2020 9:01 pm

Re: Need Help on populating user colors with Stylesheet change.

Post by obelisk79 »

I'm not sure it would qualify as a 'theme' per-se, but what about also having an option to save interface element layout? IE which tool bars/panels are enabled along with relative positioning.

Would doing something like that make sense or even be practical?
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Need Help on populating user colors with Stylesheet change.

Post by chennes »

It's completely practical, insofar as all of that information is stored as a user preference. Themes can technically store anything that's in user.cfg (even non-user-interface elements, if you really wanted to). To enable it either the theme author would have to manually add those items to the theme's CFG file, or we'd have to add a template for "UI layout" or something, the way I've proposed we have templates for color and font information.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
bleber
Posts: 259
Joined: Thu Jun 30, 2016 5:12 pm

Re: Need Help on populating user colors with Stylesheet change.

Post by bleber »

Maybe an off-topic or not...
A list of themes at Freecad start are useful, like templates to start Freecad in different scenarios.
a template for work in inches
a template to work in mm
a template to work mechanical objects
a template to work architecture
.......
......
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Need Help on populating user colors with Stylesheet change.

Post by chennes »

The basic architecture of the Theme Manager supports that kind of use: in an abstract sense, a theme is just a collection of user preferences that can be applied together as a set. The first way this will get exposed to end users right now is via the "Theme" preference that allows them to apply sets of visual customizations. But the same code can potentially be used elsewhere to create other types of preferences sets.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Need Help on populating user colors with Stylesheet change.

Post by Kunda1 »

Petrikas wrote: Sat Mar 13, 2021 6:30 pm
@Petrikas take a look at this thread
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
Petrikas
Posts: 122
Joined: Sat Dec 05, 2020 8:05 pm

Re: Need Help on populating user colors with Stylesheet change.

Post by Petrikas »

Kunda1 wrote: Wed Apr 21, 2021 6:15 pm @Petrikas take a look at this thread
Hey, thanks for tagging me in! This is a very interesting development, I'm happy to see this in progress already.

The code I wrote is very crude, it literally finds lines in the user.cfg file and replaces (or appends new lines) as necessary. The app had to be external, because I needed to access the Windows Registry where some of the QT information is stored.

I also planned on making an app that could extract the User colour information in separate xml files and load them back in, but it was more of a workaround to the current process than an actual improvement to the software.

Glad you guys are pushing this forwards the proper way!
I sometimes make FreeCAD Tutorials | VertUI | MidnightUI
User avatar
turn211
Posts: 162
Joined: Mon Feb 01, 2021 11:37 pm

Re: Need Help on populating user colors with Stylesheet change.

Post by turn211 »

chennes wrote: Tue Apr 20, 2021 3:53 pm To enable this, we need "template" *.cfg files, listing out the things that get saved in the theme: in the above example, there are a whole bunch of templates, which get read in and presented to the user as checkable boxes. All of this is pretty straightforward. And for external workbenches, the storage location of those cfg files is obvious. But what about for internal stuff? Where should those configuration template files go?
My Development machine is still dead in the water with all the chip shortages but when you get something I can populate let me know. That way I can find if anything is missing.
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Need Help on populating user colors with Stylesheet change.

Post by chennes »

turn211 wrote: Fri Apr 23, 2021 3:24 am when you get something I can populate let me know
The list I posted here: https://forum.freecadweb.org/viewtopic. ... 30#p497808 is what I am using right now, though I have since broken it up into multiple files so the user can choose subsets to save when using the "Save as theme..." option, but those are the options I have right now. I should be able to commit the real files sometime today, but I have to do some actual work here at the office for a bit, and one of the metadata constructors is giving me grief.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Need Help on populating user colors with Stylesheet change.

Post by chennes »

OK, I got the Theme template reader working now. You can see the templates in:
https://github.com/chennes/FreeCAD/tree ... eTemplates

ETA: I should also note that Mod authors can include theme templates in their mods and they'll be listed in the GUI when the user goes to save a new theme. Any file in a mod subdirectory that ends in "_theme_template.cfg" will be found automatically, and all of those preferences sets will get listed in their own sub-tree, like this:
Screenshot 2021-04-23 132048.png
Screenshot 2021-04-23 132048.png (57.95 KiB) Viewed 2506 times
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
mnesarco
Posts: 447
Joined: Thu Mar 26, 2020 8:52 pm

Re: Need Help on populating user colors with Stylesheet change.

Post by mnesarco »

chennes wrote: Fri Apr 23, 2021 6:14 pm Any file in a mod subdirectory that ends in "_theme_template.cfg" will be found automatically, and all of those preferences sets will get listed in their own sub-tree, like this:
Sounds great. Is the file name pattern hardcoded or referenced from the metadata? There is no problem if is hardcoded but it should be documented somewhere.

Anything referenced in metadata can be indexed and displayed in extension managers before install. While file name conventions require deep search into the extension package once installed. I don't know if it is important in this case, but just to take into account.
Post Reply