fix inconsistently sized buttons and add platform classes
This commit is contained in:
parent
3acf926fb0
commit
4a25853c57
@ -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."
|
||||
|
@ -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 }
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user