def _apply_style(self, app: QApplication) -> None: buf = "" if is_win and platform.release() == "10": # day mode is missing a bottom border; background must be # also set for border to apply buf += f""" QMenuBar {{ border-bottom: 1px solid {self.color(colors.BORDER)}; background: {self.color(colors.WINDOW_BG) if self.night_mode else "white"}; }} """ # qt bug? setting the above changes the browser sidebar # to white as well, so set it back buf += f""" QTreeWidget {{ background: {self.color(colors.WINDOW_BG)}; }} """ if self.night_mode: buf += """ QToolTip { border: 0; } """ if not self.macos_dark_mode(): buf += """ QScrollBar {{ background-color: {}; }} QScrollBar::handle {{ background-color: {}; border-radius: 5px; }} QScrollBar:horizontal {{ height: 12px; }} QScrollBar::handle:horizontal {{ min-width: 50px; }} QScrollBar:vertical {{ width: 12px; }} QScrollBar::handle:vertical {{ min-height: 50px; }} QScrollBar::add-line {{ border: none; background: none; }} QScrollBar::sub-line {{ border: none; background: none; }} QTabWidget {{ background-color: {}; }} """.format( self.color(colors.WINDOW_BG), # fushion-button-hover-bg "#656565", self.color(colors.WINDOW_BG), ) # allow addons to modify the styling buf = gui_hooks.style_did_init(buf) app.setStyleSheet(buf)
def _apply_style(self, app: QApplication) -> None: buf = "" if isWin and platform.release() == "10" and not self.night_mode: # add missing bottom border to menubar buf += """ QMenuBar { border-bottom: 1px solid #aaa; background: white; } """ # qt bug? setting the above changes the browser sidebar # to white as well, so set it back buf += """ QTreeWidget { background: #eee; } """ if self.night_mode: buf += """ QToolTip { border: 0; } QGroupBox { padding-top: 0px; } """ # allow addons to modify the styling buf = gui_hooks.style_did_init(buf) app.setStyleSheet(buf)
def _apply_style(self, app: QApplication) -> None: buf = "" if isWin and platform.release() == "10" and not self.night_mode: # add missing bottom border to menubar buf += """ QMenuBar { border-bottom: 1px solid #aaa; background: white; } """ # qt bug? setting the above changes the browser sidebar # to white as well, so set it back buf += """ QTreeWidget { background: #eee; } """ if self.night_mode: buf += """ QToolTip { border: 0; } """ if not self.macos_dark_mode(): buf += """ QScrollBar { background-color: %s; } QScrollBar::handle { background-color: %s; border-radius: 5px; } QScrollBar:horizontal { height: 12px; } QScrollBar::handle:horizontal { min-width: 50px; } QScrollBar:vertical { width: 12px; } QScrollBar::handle:vertical { min-height: 50px; } QScrollBar::add-line { border: none; background: none; } QScrollBar::sub-line { border: none; background: none; } QTabWidget { background-color: %s; } """ % ( self.color(colors.WINDOW_BG), # fushion-button-hover-bg "#656565", self.color(colors.WINDOW_BG), ) # allow addons to modify the styling buf = gui_hooks.style_did_init(buf) app.setStyleSheet(buf)
def _apply_palette(self, app: QApplication) -> None: if not self.night_mode: return if not self.macos_dark_mode(): app.setStyle(QStyleFactory.create("fusion")) # type: ignore palette = QPalette() text_fg = self.qcolor(colors.TEXT_FG) palette.setColor(QPalette.ColorRole.WindowText, text_fg) palette.setColor(QPalette.ColorRole.ToolTipText, text_fg) palette.setColor(QPalette.ColorRole.Text, text_fg) palette.setColor(QPalette.ColorRole.ButtonText, text_fg) hlbg = self.qcolor(colors.HIGHLIGHT_BG) hlbg.setAlpha(64) palette.setColor( QPalette.ColorRole.HighlightedText, self.qcolor(colors.HIGHLIGHT_FG) ) palette.setColor(QPalette.ColorRole.Highlight, hlbg) window_bg = self.qcolor(colors.WINDOW_BG) palette.setColor(QPalette.ColorRole.Window, window_bg) palette.setColor(QPalette.ColorRole.AlternateBase, window_bg) palette.setColor(QPalette.ColorRole.Button, QColor("#454545")) frame_bg = self.qcolor(colors.FRAME_BG) palette.setColor(QPalette.ColorRole.Base, frame_bg) palette.setColor(QPalette.ColorRole.ToolTipBase, frame_bg) disabled_color = self.qcolor(colors.DISABLED) palette.setColor(QPalette.ColorRole.PlaceholderText, disabled_color) palette.setColor( QPalette.ColorGroup.Disabled, QPalette.ColorRole.Text, disabled_color ) palette.setColor( QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, disabled_color ) palette.setColor( QPalette.ColorGroup.Disabled, QPalette.ColorRole.HighlightedText, disabled_color, ) palette.setColor(QPalette.ColorRole.Link, self.qcolor(colors.LINK)) palette.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red) app.setPalette(palette)
def _apply_palette(self, app: QApplication) -> None: if not self.night_mode: return if not self.macos_dark_mode(): app.setStyle(QStyleFactory.create("fusion")) # type: ignore palette = QPalette() text_fg = self.qcolor("text-fg") palette.setColor(QPalette.WindowText, text_fg) palette.setColor(QPalette.ToolTipText, text_fg) palette.setColor(QPalette.Text, text_fg) palette.setColor(QPalette.ButtonText, text_fg) hlbg = self.qcolor("highlight-bg") hlbg.setAlpha(64) palette.setColor(QPalette.HighlightedText, self.qcolor("highlight-fg")) palette.setColor(QPalette.Highlight, hlbg) window_bg = self.qcolor("window-bg") palette.setColor(QPalette.Window, window_bg) palette.setColor(QPalette.AlternateBase, window_bg) palette.setColor(QPalette.Button, QColor(colors.get("fusion-button-base-bg"))) frame_bg = self.qcolor("frame-bg") palette.setColor(QPalette.Base, frame_bg) palette.setColor(QPalette.ToolTipBase, frame_bg) disabled_color = self.qcolor("disabled") palette.setColor(QPalette.Disabled, QPalette.Text, disabled_color) palette.setColor(QPalette.Disabled, QPalette.ButtonText, disabled_color) palette.setColor(QPalette.Disabled, QPalette.HighlightedText, disabled_color) palette.setColor(QPalette.Link, self.qcolor("link")) palette.setColor(QPalette.BrightText, Qt.red) app.setPalette(palette)
def apply_style(self, app: QApplication) -> None: self.default_palette = app.style().standardPalette() self._apply_palette(app) self._apply_style(app)