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!
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by pablogil »

easyw-fc wrote: Hi @pablogil
I'm porting my macro and I'm trying to use QT layout
I have a part of the macro using this code:

Code: Select all

   pal = QtGui.QPalette()
   bgc = QtGui.QColor(shape_col[0]*255,shape_col[1]*255, shape_col[2]*255)
   pal.setColor(QtGui.QPalette.Base, bgc)
   ui.plainTextEdit.viewport().setPalette(pal)
when used in standard FC basic configuration (no style applied) the code works fine
colored boxes.png
but using a stylesheet theme the boxes became transparent
colored boxes-themed1.png
Is there a way to have a box colored inside also when using theme stylesheet?
Thank you
Maurice
I guess you are using the last stylesheet included into vanilla FreeCAD 0.16 and not this v1.8a version, doesn't it?

Anyway it is a clearly a bug, in order to help me fixing it, could you share with me this macro so that I'm able to reproduce the error (popup window with QPalette)?
Thanks

PS - Other thing that could help me: could you tell me the hierarchy you have used to create the QT GUI?
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by easyw-fc »

pablogil wrote:
easyw-fc wrote: Hi @pablogil
I'm porting my macro and I'm trying to use QT layout
I have a part of the macro using this code:

Code: Select all

   pal = QtGui.QPalette()
   bgc = QtGui.QColor(shape_col[0]*255,shape_col[1]*255, shape_col[2]*255)
   pal.setColor(QtGui.QPalette.Base, bgc)
   ui.plainTextEdit.viewport().setPalette(pal)
when used in standard FC basic configuration (no style applied) the code works fine
colored boxes.png
but using a stylesheet theme the boxes became transparent
colored boxes-themed1.png
Is there a way to have a box colored inside also when using theme stylesheet?
Thank you
Maurice
I guess you are using the last stylesheet included into vanilla FreeCAD 0.16 and not this v1.8a version, doesn't it?

Anyway it is a clearly a bug, in order to help me fixing it, could you share with me this macro so that I'm able to reproduce the error (popup window with QPalette)?
Thanks

PS - Other thing that could help me: could you tell me the hierarchy you have used to create the QT GUI?
Hi, the macro is kicad-StepUp-tools.FCMacro inside the demo here
https://sourceforge.net/projects/kicads ... t/download
To activate the colored box just create a cube in Part Design, select it and click on the button "Export to kicad" with 'wrl mat' ticked
export-wrl.png
export-wrl.png (135.31 KiB) Viewed 4026 times
Please note that the main Window is still not built using the QT Layout (that will take longer :) )
I tested it both on FreeCAD 0.17 8443 and FC 0.16 6706

thank you
Maurice
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by pablogil »

@easyw-fc
OK, tested and I could arrive to the problematic place, I will try to solve the issue.
Anyway, I see your GUI still has layout problems, do you still place the buttons by XY coordinates?
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by easyw-fc »

pablogil wrote:@easyw-fc
OK, tested and I could arrive to the problematic place, I will try to solve the issue.
thanks :D
pablogil wrote: Anyway, I see your GUI still has layout problems, do you still place the buttons by XY coordinates?
I know :oops:
I'm working on that, but it will take some time to re-write all the main window and check all working functions...

Maurice
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by easyw-fc »

pablogil wrote:@easyw-fc
OK, tested and I could arrive to the problematic place, I will try to solve the issue.
Anyway, I see your GUI still has layout problems, do you still place the buttons by XY coordinates?
Hi, is there a way to set geometry appearance as in standard (no-stylesheet) GUI?
I mean when I switch from no-stylesheet to i.e. Dark-blue theme Text inside the buttons get cropped...
tc.png
tc.png (174.38 KiB) Viewed 3971 times
I know I can insert some style inside the app i.e.
self.RotateX.setStyleSheet('QPushButton {right: 2px; color: red;}')
but I don't know which style should I apply to reset the geometry to the one applied in the standard (no-stylesheets) GUI...
Thank you
Maurice
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by pablogil »

easyw-fc wrote: Hi, is there a way to set geometry appearance as in standard (no-stylesheet) GUI?
I mean when I switch from no-stylesheet to i.e. Dark-blue theme Text inside the buttons get cropped...
tc.png
I know I can insert some style inside the app i.e.
self.RotateX.setStyleSheet('QPushButton {right: 2px; color: red;}')
but I don't know which style should I apply to reset the geometry to the one applied in the standard (no-stylesheets) GUI...
Thank you
Maurice
The easiest way is to add your custom code to the buttons, but I don't know if it will override the stylesheet... just try.
I guess the code you have to override is:

Code: Select all

QPushButton {
    padding: 0px;
    margin: 0px;
}
Let me know
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by easyw-fc »

pablogil wrote: The easiest way is to add your custom code to the buttons, but I don't know if it will override the stylesheet... just try.
I guess the code you have to override is:

Code: Select all

QPushButton {
    padding: 0px;
    margin: 0px;
}
Let me know
Hi, I tried to add just

Code: Select all

KSUWidget.setStyleSheet('QPushButton { padding: 0px;margin: 0px;}
but the buttons don't behave very well ... they just miss all the other values
I added more parameters...

Code: Select all

KSUWidget.setStyleSheet('QPushButton { border: 1px solid #5a5a5a;border-radius: 0px;min-width: 50px;min-height: 20px;padding: 1px 2px;}')
but there were the hover functionality missing...
to add that one I would need to know the default values from the standard theme...
I tried applying i.e. the one of the Dark-blue

Code: Select all

KSUWidget.setStyleSheet('QPushButton:hover,QPushButton:focus { color: white; border-color: #3874f2; background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5e90fa, stop:1 #3874f2);}')
and they work, but what I would need as behavior would be to just set

Code: Select all

border-radius: 0px;min-width: 50px;min-height: 20px;padding: 1px 2px;
and have the others as from the adopted theme.... :?:
Do you think it would be possible?
My need comes from the fact that I have many buttons with quite text inside that will be cropped when leaving the standard theme...
thank you again
Maurice
PS I managed to solve the other issue (color for TextEdit background) reworking my code and not using Palette
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by pablogil »

easyw-fc wrote: Do you think it would be possible?
My need comes from the fact that I have many buttons with quite text inside that will be cropped when leaving the standard theme...
thank you again
Maurice
Umm, I don't think so is possible, anyway I'm not a C++ coder so I don't know if there is a way to do it as you suggest.
Anyway, I think you should learn how to create QT layouts, you will find there are not difficult and your GUI will behave much better than your actual one.

Just guessing, do you think setting a longer X size for buttons would work? I mean, if you set the button width big enough to show all the text inside then you don't need to bother about custom stylesheets...
easyw-fc wrote: PS I managed to solve the other issue (color for TextEdit background) reworking my code and not using Palette
OK, that's great, then I won't try it, better if you solved it with your code.
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by easyw-fc »

pablogil wrote:
easyw-fc wrote: My need comes from the fact that I have many buttons with quite text inside that will be cropped when leaving the standard theme...
Umm, I don't think so is possible, anyway I'm not a C++ coder so I don't know if there is a way to do it as you suggest.
What I need is just a way to acquire style values for i.e. QtPushButton in the actual theme, then I can apply all the values, changing only what I need...
pablogil wrote: Anyway, I think you should learn how to create QT layouts, you will find there are not difficult and your GUI will behave much better than your actual one.
this is not a problem, I've already ported the GUI just using QT Layout and Grid Layout
pablogil wrote: Just guessing, do you think setting a longer X size for buttons would work? I mean, if you set the button width big enough to show all the text inside then you don't need to bother about custom stylesheets...
but, as I have many buttons, with large text inside, changing to your themes, the buttons would need to be too much bigger and so the GUI getting a big size of the working area....
Is there a way to acquire the style values from the current theme usingPySide?
thank you again
Maurice
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Dark and Light FreeCAD stylesheets (v1.8a)

Post by pablogil »

easyw-fc wrote:but, as I have many buttons, with large text inside, changing to your themes, the buttons would need to be too much bigger and so the GUI getting a big size of the working area....
Is there a way to acquire the style values from the current theme usingPySide?
I don't know, I just know how to style QT, I'm not C++ or Python coder... :(
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Post Reply