Dark and Light FreeCAD stylesheets (v1.8a)

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by wmayer »

Here is something for how to style a push button and this also works on a ColorButton:

Code: Select all

 QPushButton {
     border: 5px solid #8f8f91;
     border-radius: 6px;
     background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                       stop: 0 #f6f7fa, stop: 1 #dadbde);
     min-width: 80px;
 }

 QPushButton:pressed {
     background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                       stop: 0 #dadbde, stop: 1 #f6f7fa);
 }

 QPushButton:flat {
     border: none; /* no border for a flat push button */
 }

 QPushButton:default {
     border-color: navy; /* make the default button prominent */
 }
(taken from the Qt docs and a bit modified)
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by pablogil »

Yes, I know but there are two issues:
  • the ColorButton is not fully stylable, it only appears to change its size but they are not controlled by the QPushButton. I mean, if I make QPushButtons big the ColorButton goes big (and making QPushButtons small it lowers the ColorButton but not with same proportions or size so it results in a non controllable parameter. And, as said, the ColorButton does not allow to change it border color, border radius, margins, padding, etc. (reading the code links you shared with me it seems that the buttons is hardly coded, creating a "Rect" and applying sizes and color from QPalette...
  • it's desirable to separate QPushButton styling to ColorButton one because they are different elements. With the actual configuration there are no possibility to do it. It would be great to have something like the following in order to separate the styling of both:

Code: Select all

QPushButton {
    /* the style here */
}
ColorButton {
    /* the style here */
}
Or maybe like:

Code: Select all

QPushButton {
    /* the style here */
}
QPushButton.ColorButton {
    /* the style here */
}
At this point, what I think is that it would need work from a coder to allow accesibility of all these parameters from a stylesheet as it happens with the "Task panel" that by now is not stylable...
If any of you want to collaborate with me we can make them stylable, I don't know how to code but I can help testing it and making sure it works as expected from the point of view of the graphical designer. So, if you know anyone that would like to do it let me know =)
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by wmayer »

This is the syntax to make it different for ColorButtons. However, I don't know how to make sub-elements stylable for custom widgets.

Code: Select all

QPushButton
{
    /* the style here */
}
Gui--ColorButton
{
    /* the style here */
}
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by pablogil »

That's great wmayer!

This way I have some kind of control: the rectangle inside the ColorButton is still not stylable but with your solution I'm able to create a nice style:
colors_styled.png
colors_styled.png (12.54 KiB) Viewed 2543 times
Is possible to have a similar syntax to reach the "Task panel" elements?
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by wmayer »

The class names are iisIconLabel, iisTaskBox, iisTaskGroup, iisTaskHeader, iisTaskPanel. But not sure if you can customize this much.
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by pablogil »

I have tried:

Code: Select all

Gui--issTaskBox {
     /* here the style */
}
and so on, and it didn't work... any idea?
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by wmayer »

Remove the "Gui--" prefix. I tried it and it works to set borders but not colours.
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by pablogil »

Yes, it worked but as you said it only applies to issTaskBox and only border property... The rest of them are not stylable...
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by pablogil »

As I told you, if any coder has the time to include a solution so that it can be fully stylable I then will be glad to update the stylesheets and then FreeCAD will have a fully stylable GUI.
Here I found what seems to be no just a solution but some (I guess you should choose the one you prefer): http://stackoverflow.com/questions/7276 ... tom-widget
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.3)

Post by pablogil »

It can also be related with this file: https://code.google.com/p/qsint/source/ ... scheme.cpp

I don't know how to override it... have tried some options but can't change any property.
I would say that the stylesheet should override everything because it's loaded at "the end", doesn't it?
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Post Reply