From 4a25853c5756620cf26fd64366c0a2c81be63a02 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 23 Jan 2020 18:05:55 +1000 Subject: [PATCH] fix inconsistently sized buttons and add platform classes --- qt/aqt/theme.py | 14 ++++++++++++-- qt/aqt/webview.py | 6 +++--- qt/ts/scss/_buttons.scss | 21 +++++++++++++++++---- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index 3d0e4e9f9..c806b45b2 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -5,6 +5,7 @@ import platform from typing import Dict +from anki.utils import isMac from aqt import QApplication, gui_hooks, isWin from aqt.colors import colors from aqt.qt import QColor, QIcon, QPalette, QPixmap, QStyleFactory, Qt @@ -32,8 +33,17 @@ class ThemeManager: return self._icon_cache.setdefault(path, icon) def body_class(self) -> str: - "Returns '' in normal mode, 'nightMode' in night mode." - return self.night_mode and "nightMode" or "" + "Returns space-separated class list for platform/theme." + classes = [] + if isWin: + classes.append("isWin") + elif isMac: + classes.append("isMac") + else: + classes.append("isLin") + if self.night_mode: + classes.append("nightMode") + return " ".join(classes) def body_classes_for_card_ord(self, card_ord: int) -> str: "Returns body classes used when showing a card." diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 2c0f28d7d..1f0e77579 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -266,14 +266,14 @@ class AnkiWebView(QWebEngineView): # type: ignore if isWin: # T: include a font for your language on Windows, eg: "Segoe UI", "MS Mincho" family = _('"Segoe UI"') - widgetspec = "button { font-size: 12px; font-family:%s; }" % family + widgetspec = "button { font-family:%s; }" % family widgetspec += "\n:focus { outline: 1px solid %s; }" % color_hl fontspec = "font-size:12px;font-family:%s;" % family elif isMac: family = "Helvetica" fontspec = 'font-size:15px;font-family:"%s";' % family widgetspec = """ -button { font-size: 13px; -webkit-appearance: none; background: #fff; border: 1px solid #ccc; +button { -webkit-appearance: none; background: #fff; border: 1px solid #ccc; border-radius:5px; font-family: Helvetica }""" else: family = self.font().family() @@ -282,7 +282,7 @@ border-radius:5px; font-family: Helvetica }""" fontspec = 'font-size:14px;font-family:"%s";' % family widgetspec = """ /* Buttons */ -button{ font-size:14px; -webkit-appearance:none; outline:0; +button{ -webkit-appearance:none; outline:0; background-color: %(color_btn)s; border:1px solid rgba(0,0,0,.2); border-radius:2px; height:24px; font-family:"%(family)s"; } button:focus{ border-color: %(color_hl)s } diff --git a/qt/ts/scss/_buttons.scss b/qt/ts/scss/_buttons.scss index a8c58d154..b91c3b7fa 100644 --- a/qt/ts/scss/_buttons.scss +++ b/qt/ts/scss/_buttons.scss @@ -13,11 +13,7 @@ border: 1px solid vars.$night-faint-border; border-radius: 3px; - height: 24px; padding: 5px; - padding-left: 10px; - padding-right: 10px; - padding-bottom: 18px; } button:hover { @@ -25,3 +21,20 @@ } } +.isWin { + button { + font-size: 12px; + } +} + +.isMac { + button { + font-size: 13px; + } +} + +.isLin { + button { + font-size: 14px; + } +}