Skip to content

Commit

Permalink
correct toolbar for better visibility when using a dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
mbway committed May 28, 2021
1 parent ae84083 commit 0613140
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cq_editor/main_window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys

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

import cadquery as cq
Expand Down Expand Up @@ -30,6 +31,9 @@ def __init__(self,parent=None):
super(MainWindow,self).__init__(parent)
MainMixin.__init__(self)

self.toolbar = None
self.status_label = None

self.setWindowIcon(icon('app'))

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

def prepare_toolbar(self):

self.toolbar = QToolBar('Main toolbar',self,objectName='Main toolbar')
self.toolbar = QToolBar('Main toolbar', self, objectName='Main toolbar')

p = self.toolbar.palette()
if p.color(QPalette.Background).lightnessF() < 0.5: # dark theme is active
p.setColor(QPalette.Button, QColor(120, 120, 120))
p.setColor(QPalette.Background, QColor(170, 170, 170))
self.toolbar.setPalette(p)

for c in self.components.values():
add_actions(self.toolbar,c.toolbarActions())
Expand Down

0 comments on commit 0613140

Please sign in to comment.