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!
hyarion
Posts: 139
Joined: Fri Jun 26, 2020 6:08 pm

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

Post by hyarion »

turn211 wrote: Fri Apr 02, 2021 7:11 pm
chennes wrote: Thu Apr 01, 2021 2:41 pm The UI for this is pretty straightforward: here's a first take on it...
ETA: The "Apply" button becomes "Reapply" once a theme has been applied.
It would be nice to have a Please restart FreeCAD popup after changing themes or Style Sheet as Qss code in ProDark Theme (might be others) cannot update certain elements without restarting (i.e. url link colors)
Wouldn't it be better to fix the issues instead?
It would be nice if you could put the issues you find in a list that we can go through and fix :)
User avatar
chennes
Veteran
Posts: 3879
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 »

Agreed - it's easy enough to have FreeCAD restart, but a better solution is to make the restart unnecessary. This bug feels fixable to me (it might not be, but it's worth a look).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
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 »

hyarion wrote: Fri Apr 02, 2021 10:13 pm
turn211 wrote: Fri Apr 02, 2021 7:11 pm
chennes wrote: Thu Apr 01, 2021 2:41 pm The UI for this is pretty straightforward: here's a first take on it...
ETA: The "Apply" button becomes "Reapply" once a theme has been applied.
It would be nice to have a Please restart FreeCAD popup after changing themes or Style Sheet as Qss code in ProDark Theme (might be others) cannot update certain elements without restarting (i.e. url link colors)
Wouldn't it be better to fix the issues instead?
It would be nice if you could put the issues you find in a list that we can go through and fix :)
True. The below code won't work without a restart
QLabel[haslink="true"] {
color: #55aaff;
}

Gui--UrlLabel {
color: #55aaff;
}
Also all Undocked QPushButtons don't get updated without restart. They inherit previous sizes even swiching to no stylesheet. I might be able to fix this one.
User avatar
chennes
Veteran
Posts: 3879
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 »

Kunda1 wrote: Thu Apr 01, 2021 12:36 am
chennes wrote: Thu Apr 01, 2021 12:11 am Purely technical coding question for the devs reading this
There was/is an ongoing discussion about this regarding Addons. This would qualify as an addon, per se.
https://github.com/FreeCAD/FreeCAD-addo ... -303949382
Was any progress made on this front? I'm happy to use that QGIS metadata.txt file format, but it doesn't look like it's actually used anywhere in FreeCAD. We use JSON in a couple of places (Arch and Path use it, but I think this would be its first use in the core), and of course XML is used in the core, but has the disadvantage of being huge overkill for this use.
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 »

chennes wrote: Fri Apr 02, 2021 11:34 pm
Kunda1 wrote: Thu Apr 01, 2021 12:36 am There was/is an ongoing discussion about this regarding Addons. This would qualify as an addon, per se.
https://github.com/FreeCAD/FreeCAD-addo ... -303949382
Was any progress made on this front? I'm happy to use that QGIS metadata.txt file format, but it doesn't look like it's actually used anywhere in FreeCAD. We use JSON in a couple of places (Arch and Path use it, but I think this would be its first use in the core), and of course XML is used in the core, but has the disadvantage of being huge overkill for this use.
Maybe some of the macros are using it? I don't remember specifically right now. Honestly I don't think FC is married to the metadata format. If you made a stronger proposal for something else it could be utilized instead just because as you can see it's not widely embraced. Maybe beneficial to check with the Extension manager dev and see how far he got with it?
mnesarco wrote::bell:
@mnesarco does extension manager parse add-on metadata?
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: 3879
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 poked at this a little today. Here's my proposed Metadata class -- the idea is that calling C++ code would just instantiate this class with a file path, and they'd get back a "dictionary" of whatever metadata that file contained. Purely string-based to keep things as simple as possible:

Code: Select all

namespace Base {

	/**
	 * \class Metadata 
	 * \brief Reads data from a metadata file. 
	 * 
	 * All metadata is treated as strings: no processing is done on it. Any 
	 * metadata names are supported by the class, but one has special meaning: 
	 * "description" is allowed to be multiple lines. All others are single-line 
	 * only. Typical metadata contains:
	 *   * name
	 *   * author
	 *   * version
	 *   * date
	 *   * description (multiline supported, end with two blank lines)
	 *   * homepage_url
	 *   * tracker_url
	 *   * git_repository_url
	 *   * screenshot_filename
	 * 
	 * No guarantee is made that calling code must use any of this data, and there 
	 * is no in-code requirement that any or all of this data exists. Calling code 
	 * may request metadata of any name: if it does not exist, an empty string is 
	 * returned.
	 *   
	 * With the exception of "description", blank lines are ignored, and anything 
	 * following a semicolon ';' on a line is ignored.
	 */
	class Metadata {
	public:
		explicit Metadata(const boost::filesystem::path& metadataFile);
		~Metadata() = default;
 
		/**
		 * Get named metadata item, or an empty string if that key does not exist.
		 */
		std::string operator[] (const std::string& key) const;

	private:
		std::map<std::string, std::string> _metadata;

	};

}
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 »

LGTM
Yorik should weigh in on this for sure.
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
hyarion
Posts: 139
Joined: Fri Jun 26, 2020 6:08 pm

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

Post by hyarion »

chennes wrote: Sat Apr 03, 2021 9:31 pm OK, I poked at this a little today. Here's my proposed Metadata class -- the idea is that calling C++ code would just instantiate this class with a file path, and they'd get back a "dictionary" of whatever metadata that file contained. Purely string-based to keep things as simple as possible
It might be simple now, but I suspect it will be extended with time, so I'm not sure it's a good idea to invent a new file format for this.
As everything else is xml based I think this should be too. Perhaps we could deprecate metadata.txt and introduce a new metadata.xml instead?
User avatar
chennes
Veteran
Posts: 3879
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 »

hyarion wrote: Sun Apr 04, 2021 12:44 pm It might be simple now, but I suspect it will be extended with time, so I'm not sure it's a good idea to invent a new file format for this.
Well, we are inventing a new format regardless (unless we use the QGIS format, but it's not like that's some kind of official standard). So whether the underlying framework is XML, JSON, or something else, the schema will be something new.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
mnesarco
Posts: 446
Joined: Thu Mar 26, 2020 8:52 pm

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

Post by mnesarco »

Hello Friends, I am sorry for beign late to the discussion, but the real problem with the metadata is not the wire format but the content specification. Today there is no standar defined for extensions metadata and each extension developer invents its own to cover its needs.

For the wire format, anything like yaml, json, ini or even xml will work.

Last time we discussed this i saw two big problems:

1. Apparently it will be hard to convince extension developers to upgrade to a defined standard and we will end up with just another metadata format in the wild.

2. Standarization requires some kind of process a little different than how things are done in FreeCAD community. Here there are very minimal restrictions on what to do and how, so we have a wild ecosystem. That lead to things like ModernUI, ExtMan, LinkStage3... Great things but hard to integrate.

Creating standars is hard, but necesary to improve quality, and at the same time we need to be sure to no stop innovation and flexibility.

It is required to:

1. Start with a proposal: Something not perfect for sure but a start.
2. Stablish a process to develop the proposed standar, probably a cometee or something like PEP (Python Enhancement Proposals)
3. Identify all the areas that require standardization (only the bare minimum to maintain flexibility but boost compatibility)
4. Define a roadmap (inception, proposal0, meetings..., alpha, beta, rc.., release) all of this is about the standar not the implementation.
5. Define an implementation plan and compatibility levels matching freecad versions.
6. Maintain the standard and the process

Personally I feel that this kind of processes are very hard to achieve in the FreeCAD community. The usual process here is to discuss somthing ad infinitum and somethimes someone takes the torch and start something in solo.
Post Reply