From e3fb184a84c0f2db163bb75985c16d46bcce40d0 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 24 Jan 2020 07:55:14 +1000 Subject: [PATCH] fix night mode tooltips --- qt/aqt/theme.py | 12 ++++++++++-- qt/aqt/utils.py | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index c806b45b2..d568dfd6f 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -89,6 +89,13 @@ QTreeWidget { } """ + if self.night_mode: + buf += """ +QToolTip { + border: 0; +} + """ + # allow addons to modify the styling buf = gui_hooks.style_did_init(buf) @@ -104,7 +111,6 @@ QTreeWidget { text_fg = self.qcolor("text-fg") palette.setColor(QPalette.WindowText, text_fg) - palette.setColor(QPalette.ToolTipBase, text_fg) palette.setColor(QPalette.ToolTipText, text_fg) palette.setColor(QPalette.Text, text_fg) palette.setColor(QPalette.ButtonText, text_fg) @@ -119,7 +125,9 @@ QTreeWidget { palette.setColor(QPalette.AlternateBase, window_bg) palette.setColor(QPalette.Button, window_bg) - palette.setColor(QPalette.Base, self.qcolor("frame-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) diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 6c316bd5d..2691b4b4f 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -11,6 +11,7 @@ import aqt from anki.lang import _ from anki.utils import invalidFilename, isMac, isWin, noBundledLibs, versionWithBuild from aqt.qt import * +from aqt.theme import theme_manager def aqt_data_folder() -> str: @@ -551,10 +552,11 @@ def tooltip(msg, period=3000, parent=None): lab.setFrameStyle(QFrame.Panel) lab.setLineWidth(2) lab.setWindowFlags(Qt.ToolTip) - p = QPalette() - p.setColor(QPalette.Window, QColor("#feffc4")) - p.setColor(QPalette.WindowText, QColor("#000000")) - lab.setPalette(p) + if not theme_manager.night_mode: + p = QPalette() + p.setColor(QPalette.Window, QColor("#feffc4")) + p.setColor(QPalette.WindowText, QColor("#000000")) + lab.setPalette(p) lab.move(aw.mapToGlobal(QPoint(0, -100 + aw.height()))) lab.show() _tooltipTimer = aqt.mw.progress.timer(