diff --git a/aqt/browser.py b/aqt/browser.py index 712bb4c19..dfff1175a 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -18,7 +18,7 @@ from anki.utils import fmtTimeSpan, ids2str, stripHTMLMedia, htmlToTextLine, \ isWin, intTime, \ isMac, isLin, bodyClass from aqt.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter, \ - saveHeader, restoreHeader, saveState, restoreState, applyStyles, getTag, \ + saveHeader, restoreHeader, saveState, restoreState, getTag, \ showInfo, askUser, tooltip, openHelp, showWarning, shortcut, mungeQA, \ getOnlyText, MenuList, SubMenu from anki.hooks import runHook, addHook, remHook, runFilter @@ -384,7 +384,6 @@ class Browser(QMainWindow): def __init__(self, mw): QMainWindow.__init__(self, None, Qt.Window) - applyStyles(self) self.mw = mw self.col = self.mw.col self.lastFilter = "" diff --git a/aqt/main.py b/aqt/main.py index 6d79c4134..ad46177d0 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -8,6 +8,7 @@ import zipfile import gc import time import faulthandler +import platform from threading import Thread from send2trash import send2trash @@ -15,7 +16,7 @@ from aqt.qt import * from anki import Collection from anki.utils import isWin, isMac, intTime, splitFields, ids2str, \ devMode -from anki.hooks import runHook, addHook +from anki.hooks import runHook, addHook, runFilter import aqt import aqt.progress import aqt.webview @@ -26,7 +27,7 @@ from aqt.utils import showWarning import anki.sound import anki.mpv from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \ - restoreState, getOnlyText, askUser, applyStyles, showText, tooltip, \ + restoreState, getOnlyText, askUser, showText, tooltip, \ openHelp, openLink, checkInvalidFilename, getFile import sip @@ -696,7 +697,33 @@ title="%s" %s>%s''' % ( self.form.statusbar.showMessage(text, timeout) def setupStyle(self): - applyStyles(self) + buf = "" + + if isWin and platform.release() == '10': + # 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; +} + """ + + # allow addons to modify the styling + buf = runFilter("setupStyle", buf) + + # allow users to extend styling + p = os.path.join(aqt.mw.pm.base, "style.css") + if os.path.exists(p): + buf += open(p).read() + + self.app.setStyleSheet(buf) # Key handling ########################################################################## diff --git a/aqt/utils.py b/aqt/utils.py index 456057a8b..49fbabfa2 100644 --- a/aqt/utils.py +++ b/aqt/utils.py @@ -350,11 +350,6 @@ def mungeQA(col, txt): txt = stripSounds(txt) return txt -def applyStyles(widget): - p = os.path.join(aqt.mw.pm.base, "style.css") - if os.path.exists(p): - widget.setStyleSheet(open(p).read()) - def openFolder(path): if isWin: subprocess.Popen(["explorer", "file://"+path])