Need Help on populating user colors with Stylesheet change.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Need Help on populating user colors with Stylesheet change.
The #1 tech support complaint i get with my ProDark theme is User color clashes that a FreeCAD designer has no control of. Proposing a Designer with a Stylesheet accessible Mod or script that would populate User colors. Any ideas or contributions?
Re: Need Help on populating user colors with Stylesheet change.
It seems like we need a functionality that is a layer above the stylesheets: something that can operate on a bundled package of QSS stylesheet, user colors preferences, Start page CSS stylesheet, and whatever else constitutes the look-and-feel of the program. So a style author provides this whole package of data, and the user just hits "Apply" and it all gets pushed to where it needs to go. It could be done with a Macro, or baked into the core.
Re: Need Help on populating user colors with Stylesheet change.
Exactly! If it is a Macro it shouldn't be hard or burried deeply in menus for the User to access. I was trying to prepopulate User.cfg and System.cfg but doesn't work properly.chennes wrote: ↑Wed Mar 31, 2021 8:26 pm It seems like we need a functionality that is a layer above the stylesheets: something that can operate on a bundled package of QSS stylesheet, user colors preferences, Start page CSS stylesheet, and whatever else constitutes the look-and-feel of the program. So a style author provides this whole package of data, and the user just hits "Apply" and it all gets pushed to where it needs to go. It could be done with a Macro, or baked into the core.
Re: Need Help on populating user colors with Stylesheet change.
Well, rather than a macro, I'd love to see this as a first-class feature in FreeCAD - maybe called something like "Themes", that encompass the QSS, CSS, and user preference colors and fonts in an extensible way.
My thinking is that we use a file format for the themes that is analogous to the main FreeCAD FCStd file format ("*.FCTheme"?): just a zipped directory that contains each of the required components. The QSS and CSS are simple. We'd have to decide on a format for the rest, but probably make it match the user preferences files, maybe with a separate file per mod so it's easy to add new ones as a theme author's time allows. If there is an unrecognized mod in there it's just ignored, and any mod that doesn't have an entry is just left alone. Maybe also have an XML file with some descriptive information about the theme itself (Author, url, contact info, short description, screenshot(s)?) . This gives us some extensibility to add a Theme Manager analogous to the AddOn manager at some point in the future.
Within FreeCAD we could implement this as a "Set Theme..." button in the User Preferences or something along those lines.
My thinking is that we use a file format for the themes that is analogous to the main FreeCAD FCStd file format ("*.FCTheme"?): just a zipped directory that contains each of the required components. The QSS and CSS are simple. We'd have to decide on a format for the rest, but probably make it match the user preferences files, maybe with a separate file per mod so it's easy to add new ones as a theme author's time allows. If there is an unrecognized mod in there it's just ignored, and any mod that doesn't have an entry is just left alone. Maybe also have an XML file with some descriptive information about the theme itself (Author, url, contact info, short description, screenshot(s)?) . This gives us some extensibility to add a Theme Manager analogous to the AddOn manager at some point in the future.
Within FreeCAD we could implement this as a "Set Theme..." button in the User Preferences or something along those lines.
Re: Need Help on populating user colors with Stylesheet change.
mpetrikas is working on a prototype for altering user.cfg file:
https://github.com/StudioPetrikas/FC_Ve ... eeCAD4K.py
https://github.com/StudioPetrikas/FC_Ve ... eeCAD4K.py
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
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
Re: Need Help on populating user colors with Stylesheet change.
Interesting -- if we are running from within FreeCAD, though, we'd just handle the user preferences using the normal FreeCAD.ParamGet() and FreeCAD.ParamSet() functions, right?
Re: Need Help on populating user colors with Stylesheet change.
I reckon he didn't know that but would have used that. If our API was a little bit more reader friendly,
Edit: but it could also be that he didn't intend for it to run only with in FC
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
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
Re: Need Help on populating user colors with Stylesheet change.
Good ideas. The .FCTheme zipped folder makes alot of sense. The "Set Theme button" would populate from whatever .FCThemes are currently avaailable. Does FreeCAD.ParamGet() and FreeCAD.ParamSet() allow for changing icons? Cause i know somebody will want to change these.chennes wrote: ↑Wed Mar 31, 2021 9:40 pm Well, rather than a macro, I'd love to see this as a first-class feature in FreeCAD - maybe called something like "Themes", that encompass the QSS, CSS, and user preference colors and fonts in an extensible way.
My thinking is that we use a file format for the themes that is analogous to the main FreeCAD FCStd file format ("*.FCTheme"?): just a zipped directory that contains each of the required components. The QSS and CSS are simple. We'd have to decide on a format for the rest, but probably make it match the user preferences files, maybe with a separate file per mod so it's easy to add new ones as a theme author's time allows. If there is an unrecognized mod in there it's just ignored, and any mod that doesn't have an entry is just left alone. Maybe also have an XML file with some descriptive information about the theme itself (Author, url, contact info, short description, screenshot(s)?) . This gives us some extensibility to add a Theme Manager analogous to the AddOn manager at some point in the future.
Within FreeCAD we could implement this as a "Set Theme..." button in the User Preferences or something along those lines.
Re: Need Help on populating user colors with Stylesheet change.
No, those functions are just the programmatic way of accessing user preferences via Python. If changing icons is on the radar we'll need a different way of doing it, and as far as I am aware right now it's not straightforward. I suggest we keep that in mind as a future expansion, but for now focus only on the things that can be changed by users already. I'd at least like to see a way for a theme to declare itself as "light" or "dark" and have the icons adjust as necessary to accommodate, but again I think that's for v2. Or v0.02. Or whatever.
Re: Need Help on populating user colors with Stylesheet change.
Purely technical coding question for the devs reading this: I think it would be a good idea for the package to have some kind of descriptive file in it. I'm thinking it should contain information about the author, the theme's name, etc. Is there a general preference between using XML or JSON for that sort of thing? Obviously XML is pretty heavy-weight for such a simple thing, but FreeCAD already supports XML for its own main file type, so there's no extra library requirement, etc.
I'm thinking of something like:
Each one of the user_preference files contains what is in essence a list of preferences entries, typically colors and fonts. The Start CSS stylesheet can also be specified in there, since it's just another user preference. If someday we support things besides setting user preferences, that's supported within the same file format. The reader can be coded to ignore entries it doesn't recognize so we have forwards and backwards compatibility.
I'm thinking of something like:
Code: Select all
<theme themefileversion="1.0">
<name>Pro Dark</name>
<author>turn211</author>
<url>https://github.com/turn211/prodark</url>
<updated>2021-03-31</updated>
<description>The greatest theme in the history of FreeCAD themes.</description>
<type>dark</type>
<screenshots>
<image>screenshot1.png</image>
<image>screenshot2.png</image>
</screenshots>
<stylesheet>prodark.qss</stylesheet>
<components>
<module name="Part">
<user_preferences>part_colors.xml</user_preferences>
</module>
<module name="Start">
<user_preferences>start_preferences.xml</user_preferences>
</module>
</components>
<theme>