Skip to content

Commit cb2b32e

Browse files
committed
correct toolbar for better visibility when using a dark theme
1 parent 40661a9 commit cb2b32e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cq_editor/main_window.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
from PyQt5.QtGui import QPalette, QColor
34
from PyQt5.QtWidgets import (QLabel, QMainWindow, QToolBar, QDockWidget, QAction)
45

56
import cadquery as cq
@@ -30,6 +31,9 @@ def __init__(self,parent=None):
3031
super(MainWindow,self).__init__(parent)
3132
MainMixin.__init__(self)
3233

34+
self.toolbar = None
35+
self.status_label = None
36+
3337
self.setWindowIcon(icon('app'))
3438

3539
self.viewer = OCCViewer(self)
@@ -189,7 +193,13 @@ def prepare_menubar_component(self,menus,comp_menu_dict):
189193

190194
def prepare_toolbar(self):
191195

192-
self.toolbar = QToolBar('Main toolbar',self,objectName='Main toolbar')
196+
self.toolbar = QToolBar('Main toolbar', self, objectName='Main toolbar')
197+
198+
p = self.toolbar.palette()
199+
if p.color(QPalette.Background).lightnessF() < 0.5: # dark theme is active
200+
p.setColor(QPalette.Button, QColor(120, 120, 120))
201+
p.setColor(QPalette.Background, QColor(170, 170, 170))
202+
self.toolbar.setPalette(p)
193203

194204
for c in self.components.values():
195205
add_actions(self.toolbar,c.toolbarActions())
@@ -325,6 +335,3 @@ def cq_documentation(self):
325335

326336
open_url('https://cadquery.readthedocs.io/en/latest/')
327337

328-
if __name__ == "__main__":
329-
330-
pass

0 commit comments

Comments
 (0)