[Solved] Macro editor background colour

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Sam
Posts: 177
Joined: Sun Mar 20, 2016 6:19 pm

[Solved] Macro editor background colour

Post by Sam »

A while ago I started a thread about this over at Macro editor background colour, but if I'm going to do anything about it then this is probably a better place to discuss it.

I was having a sniff around src/Gui/DlgEditorImp.cpp to see how hard it'd be to add a preference for a background that's a bit more (less?) contrasty/less blindy. Totally achievable.

Then I had a look in PythonConsole.cpp and I see that the colours used there are hard coded. Admittedly I haven't thought too hard about this, but wouldn't the editor colours be appropriate for the Python console too?

And the Output window/Report view would need a similar preference. And the tree view. Combo view... Maybe a global background preference?

Does anyone have any opinions about this?
Last edited by Sam on Mon Sep 18, 2017 8:38 am, edited 1 time in total.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Macro editor background colour

Post by sgrogan »

Sam wrote: Tue Sep 12, 2017 11:47 pm Does anyone have any opinions about this?
As a user (KUbuntu 14.4 and Win7) with default desktop I don't have a problem. But FreeCAD is a very configurable app. We have 7 mouse models after all. So I think if you don't change the default, go for it. It could be a preferences option, or in the parameter editor if it's considered too intrusive.
"fight the good fight"
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Macro editor background colour

Post by triplus »

Have you tried if the result you are after is achievable by using a custom stylesheet?
Sam
Posts: 177
Joined: Sun Mar 20, 2016 6:19 pm

Re: Macro editor background colour

Post by Sam »

triplus wrote: Wed Sep 13, 2017 11:21 am Have you tried if the result you are after is achievable by using a custom stylesheet?
That'd probably work. I haven't seen anywhere the background colour is explicitly set.

I'm out of action for a few days, but I'll report results when I can.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Macro editor background colour

Post by triplus »

Under Edit -> Preferences ... -> General -> Style sheet you already have some options available. If you don't want to use a full stylesheet you can crate a file:

Code: Select all

.FreeCAD/Gui/Stylesheets/custom.qss
And use for example:

Code: Select all

QPlainTextEdit {
    background-color: gray;
}
More reference:

https://github.com/FreeCAD/FreeCAD/tree ... tylesheets
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Macro editor background colour

Post by pablogil »

This is something I have wondered a few times while developing the Dark and Light styles: I use just a set of colours and repeat them for each Qt element; it would be great if I can create an special stylesheet where I place colour variables which are then configurable by users inside FreeCAD preferences...
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Macro editor background colour

Post by Kunda1 »

pablogil wrote: Sat Sep 16, 2017 10:21 pm This is something I have wondered a few times while developing the Dark and Light styles: I use just a set of colours and repeat them for each Qt element; it would be great if I can create an special stylesheet where I place colour variables which are then configurable by users inside FreeCAD preferences...
That would be a UI gamechanger. +1

Edit:
Did a cursory search on this possibility and found this: http://wiki.qt.io/Dynamic_Properties_and_Stylesheets
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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Macro editor background colour

Post by Kunda1 »

We could even potentially test it with a code snippet pasted in to the python console (but I don't know how to modify the snippet to do that yet :oops: )
https://stackoverflow.com/a/27160435

Code: Select all

from PySide import QtCore, QtGui

class Window(QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.edit = QtGui.QLineEdit(self)
        self.edit.setProperty('warning', False)
        self.edit.setStyleSheet("""
           /* other rules go here */
           QLineEdit[warning="true"] {background-color: yellow};
           QLineEdit[warning="false"] {background-color: palette(base)};
            """)
        self.button = QtGui.QPushButton('Test', self)
        self.button.clicked.connect(self.handleButton)
        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(self.edit)
        layout.addWidget(self.button)

    def handleButton(self):
        self.edit.setProperty(
            'warning', not self.edit.property('warning'))
        self.edit.style().unpolish(self.edit)
        self.edit.style().polish(self.edit)

if __name__ == '__main__':

    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())
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
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: Macro editor background colour

Post by pablogil »

Well, it's not exactly what we need here, with dynamic properties you can switch from one property to other but you cannot have a real variable inside the values...

In any case I would need a programmer that codes it because I don't know C++ so if anyone wants to collaborate I'll be happy to modify the stylesheets in other to introduce the variables. ;)
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Sam
Posts: 177
Joined: Sun Mar 20, 2016 6:19 pm

Re: Macro editor background colour

Post by Sam »

triplus wrote: Thu Sep 14, 2017 10:24 pm Under Edit -> Preferences ... -> General -> Style sheet you already have some options available.
You told me where it was and I still had to look three times to notice it.

That is just the ticket. Thank you.
Post Reply