mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
add UI scale preference
This commit is contained in:
parent
5ce3de0e98
commit
3a4f94ab86
5 changed files with 86 additions and 41 deletions
|
@ -12,7 +12,6 @@ import locale
|
||||||
import gettext
|
import gettext
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from aqt.main import AnkiQt
|
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import anki.lang
|
import anki.lang
|
||||||
from anki.consts import HELP_SITE
|
from anki.consts import HELP_SITE
|
||||||
|
@ -26,6 +25,9 @@ appDonate="http://ankisrs.net/support/"
|
||||||
appShared="https://ankiweb.net/shared/"
|
appShared="https://ankiweb.net/shared/"
|
||||||
appUpdate="https://ankiweb.net/update/desktop"
|
appUpdate="https://ankiweb.net/update/desktop"
|
||||||
appHelpSite=HELP_SITE
|
appHelpSite=HELP_SITE
|
||||||
|
|
||||||
|
from aqt.main import AnkiQt
|
||||||
|
|
||||||
mw: Optional[AnkiQt] = None # set on init
|
mw: Optional[AnkiQt] = None # set on init
|
||||||
|
|
||||||
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
||||||
|
@ -319,6 +321,9 @@ def _run(argv=None, exec=True):
|
||||||
if os.environ.get("ANKI_SOFTWAREOPENGL"):
|
if os.environ.get("ANKI_SOFTWAREOPENGL"):
|
||||||
QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL)
|
QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL)
|
||||||
|
|
||||||
|
# apply user-provided scale factor
|
||||||
|
os.environ["QT_SCALE_FACTOR"] = str(pm.uiScale())
|
||||||
|
|
||||||
# create the app
|
# create the app
|
||||||
QCoreApplication.setApplicationName("Anki")
|
QCoreApplication.setApplicationName("Anki")
|
||||||
QGuiApplication.setDesktopFileName("anki.desktop")
|
QGuiApplication.setDesktopFileName("anki.desktop")
|
||||||
|
|
|
@ -13,6 +13,7 @@ from threading import Thread
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from send2trash import send2trash
|
from send2trash import send2trash
|
||||||
from anki.collection import _Collection
|
from anki.collection import _Collection
|
||||||
|
from aqt.profiles import ProfileManager
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from anki.storage import Collection
|
from anki.storage import Collection
|
||||||
from anki.utils import isWin, isMac, intTime, splitFields, ids2str, \
|
from anki.utils import isWin, isMac, intTime, splitFields, ids2str, \
|
||||||
|
@ -33,7 +34,7 @@ from aqt.qt import sip
|
||||||
from anki.lang import _, ngettext
|
from anki.lang import _, ngettext
|
||||||
|
|
||||||
class AnkiQt(QMainWindow):
|
class AnkiQt(QMainWindow):
|
||||||
def __init__(self, app, profileManager, opts, args):
|
def __init__(self, app: QApplication, profileManager: ProfileManager, opts, args):
|
||||||
QMainWindow.__init__(self)
|
QMainWindow.__init__(self)
|
||||||
self.state = "startup"
|
self.state = "startup"
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import datetime, time
|
import datetime, time
|
||||||
|
|
||||||
|
from aqt import AnkiQt
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import anki.lang
|
import anki.lang
|
||||||
from aqt.utils import openHelp, showInfo, askUser
|
from aqt.utils import openHelp, showInfo, askUser
|
||||||
|
@ -11,7 +13,7 @@ from anki.lang import _
|
||||||
|
|
||||||
class Preferences(QDialog):
|
class Preferences(QDialog):
|
||||||
|
|
||||||
def __init__(self, mw):
|
def __init__(self, mw: AnkiQt):
|
||||||
QDialog.__init__(self, mw, Qt.Window)
|
QDialog.__init__(self, mw, Qt.Window)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.prof = self.mw.pm.profile
|
self.prof = self.mw.pm.profile
|
||||||
|
@ -216,7 +218,11 @@ Not currently enabled; click the sync button in the main window to enable."""))
|
||||||
|
|
||||||
def setupOptions(self):
|
def setupOptions(self):
|
||||||
self.form.pastePNG.setChecked(self.prof.get("pastePNG", False))
|
self.form.pastePNG.setChecked(self.prof.get("pastePNG", False))
|
||||||
|
self.form.uiScale.setValue(self.mw.pm.uiScale()*100)
|
||||||
|
|
||||||
def updateOptions(self):
|
def updateOptions(self):
|
||||||
self.prof['pastePNG'] = self.form.pastePNG.isChecked()
|
self.prof['pastePNG'] = self.form.pastePNG.isChecked()
|
||||||
|
newScale = self.form.uiScale.value()/100
|
||||||
|
if newScale != self.mw.pm.uiScale():
|
||||||
|
self.mw.pm.setUiScale(newScale)
|
||||||
|
showInfo(_("Changes will take effect when you restart Anki."))
|
||||||
|
|
|
@ -465,3 +465,12 @@ please see:
|
||||||
self.setGlMode("software")
|
self.setGlMode("software")
|
||||||
elif mode == "angle":
|
elif mode == "angle":
|
||||||
self.setGlMode("software")
|
self.setGlMode("software")
|
||||||
|
|
||||||
|
# Scale
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def uiScale(self) -> float:
|
||||||
|
return self.meta.get("uiScale", 1.0)
|
||||||
|
|
||||||
|
def setUiScale(self, scale: float) -> None:
|
||||||
|
self.meta["uiScale"] = scale
|
||||||
|
|
|
@ -137,34 +137,35 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>12</number>
|
<number>12</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="3" column="1">
|
||||||
|
<widget class="QSpinBox" name="timeLimit">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>9999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLabel" name="label_40">
|
||||||
|
<property name="text">
|
||||||
|
<string>hours past midnight</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QLabel" name="label_39">
|
||||||
|
<property name="text">
|
||||||
|
<string>mins</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_23">
|
<widget class="QLabel" name="label_23">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Next day starts at</string>
|
<string>Next day starts at</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="dayOffset">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>23</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_24">
|
|
||||||
<property name="text">
|
|
||||||
<string>Learn ahead limit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QSpinBox" name="lrnCutoff">
|
<widget class="QSpinBox" name="lrnCutoff">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -177,38 +178,60 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_29">
|
<widget class="QLabel" name="label_24">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mins</string>
|
<string>Learn ahead limit</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="dayOffset">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>23</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_30">
|
<widget class="QLabel" name="label_30">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Timebox time limit</string>
|
<string>Timebox time limit</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QSpinBox" name="timeLimit">
|
|
||||||
<property name="maximum">
|
|
||||||
<number>9999</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QLabel" name="label_39">
|
<widget class="QLabel" name="label_29">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mins</string>
|
<string>mins</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_40">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>hours past midnight</string>
|
<string>User interface size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="uiScale">
|
||||||
|
<property name="suffix">
|
||||||
|
<string>%</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>200</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -490,6 +513,7 @@
|
||||||
<tabstop>newSched</tabstop>
|
<tabstop>newSched</tabstop>
|
||||||
<tabstop>useCurrent</tabstop>
|
<tabstop>useCurrent</tabstop>
|
||||||
<tabstop>newSpread</tabstop>
|
<tabstop>newSpread</tabstop>
|
||||||
|
<tabstop>uiScale</tabstop>
|
||||||
<tabstop>dayOffset</tabstop>
|
<tabstop>dayOffset</tabstop>
|
||||||
<tabstop>lrnCutoff</tabstop>
|
<tabstop>lrnCutoff</tabstop>
|
||||||
<tabstop>timeLimit</tabstop>
|
<tabstop>timeLimit</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue