mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 23:27:12 -05:00
Merge branch 'master' of https://github.com/dae/anki into CorrectBranchInCardPreview
This commit is contained in:
commit
95a475472c
7 changed files with 93 additions and 64 deletions
|
|
@ -28,7 +28,7 @@ pyqt5-dev-tools) as well.
|
|||
If you're on another platform or your distro has the wrong Qt version, you
|
||||
can install PyQt with pip:
|
||||
|
||||
$ pip3 install sip pyqt5
|
||||
$ pip3 install PyQt5 PyQtWebEngine
|
||||
|
||||
To use the development version:
|
||||
|
||||
|
|
|
|||
|
|
@ -474,6 +474,7 @@ class ConfigEditor(QDialog):
|
|||
self.form.setupUi(self)
|
||||
restore = self.form.buttonBox.button(QDialogButtonBox.RestoreDefaults)
|
||||
restore.clicked.connect(self.onRestoreDefaults)
|
||||
self.setupFonts()
|
||||
self.updateHelp()
|
||||
self.updateText(self.conf)
|
||||
self.show()
|
||||
|
|
@ -482,6 +483,10 @@ class ConfigEditor(QDialog):
|
|||
default_conf = self.mgr.addonConfigDefaults(self.addon)
|
||||
self.updateText(default_conf)
|
||||
|
||||
def setupFonts(self):
|
||||
font_mono = QFontDatabase.systemFont(QFontDatabase.FixedFont)
|
||||
self.form.editor.setFont(font_mono)
|
||||
|
||||
def updateHelp(self):
|
||||
txt = self.mgr.addonConfigHelp(self.addon)
|
||||
if txt:
|
||||
|
|
|
|||
|
|
@ -380,7 +380,6 @@ def setupApkgImport(mw, importer):
|
|||
if not full:
|
||||
# adding
|
||||
return True
|
||||
backup = re.match("backup-.*\\.apkg", base)
|
||||
if not mw.restoringBackup and not askUser(_("""\
|
||||
This will delete your existing collection and replace it with the data in \
|
||||
the file you're importing. Are you sure?"""), msgfunc=QMessageBox.warning,
|
||||
|
|
@ -389,7 +388,7 @@ the file you're importing. Are you sure?"""), msgfunc=QMessageBox.warning,
|
|||
# schedule replacement; don't do it immediately as we may have been
|
||||
# called as part of the startup routine
|
||||
mw.progress.timer(
|
||||
100, lambda mw=mw, f=importer.file: replaceWithApkg(mw, f, backup), False)
|
||||
100, lambda mw=mw, f=importer.file: replaceWithApkg(mw, f, mw.restoringBackup), False)
|
||||
|
||||
def replaceWithApkg(mw, file, backup):
|
||||
mw.unloadCollection(lambda: _replaceWithApkg(mw, file, backup))
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from anki.utils import isWin, isMac
|
|||
from PyQt5.Qt import *
|
||||
# trigger explicit message in case of missing libraries
|
||||
# instead of silently failing to import
|
||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
||||
from PyQt5.QtWebEngineWidgets import *
|
||||
try:
|
||||
from PyQt5 import sip
|
||||
except ImportError:
|
||||
|
|
|
|||
21
aqt/utils.py
21
aqt/utils.py
|
|
@ -325,13 +325,22 @@ def ensureWidgetInScreenBoundaries(widget):
|
|||
aqt.mw.progress.timer(50, lambda: ensureWidgetInScreenBoundaries(widget), False)
|
||||
return
|
||||
|
||||
# ensure qt has restored the window within the screen's bounds,
|
||||
# and at least 50px from bottom right
|
||||
# ensure widget is smaller than screen bounds
|
||||
geom = handle.screen().availableGeometry()
|
||||
pos = widget.pos()
|
||||
x = min(max(geom.x(), pos.x()), geom.width()+geom.x()-50)
|
||||
y = min(max(geom.y(), pos.y()), geom.height()+geom.y()-50)
|
||||
if pos.x() != x or pos.y() != y:
|
||||
wsize = widget.size()
|
||||
cappedWidth = min(geom.width(), wsize.width())
|
||||
cappedHeight = min(geom.height(), wsize.height())
|
||||
if cappedWidth > wsize.width() or cappedHeight > wsize.height():
|
||||
widget.resize(QSize(cappedWidth, cappedHeight))
|
||||
|
||||
# ensure widget is inside top left
|
||||
wpos = widget.pos()
|
||||
x = max(geom.x(), wpos.x())
|
||||
y = max(geom.y(), wpos.y())
|
||||
# and bottom right
|
||||
x = min(x, geom.width()+geom.x()-cappedWidth)
|
||||
y = min(y, geom.height()+geom.y()-cappedHeight)
|
||||
if x != wpos.x() or y != wpos.y():
|
||||
widget.move(x, y)
|
||||
|
||||
def saveState(widget, key):
|
||||
|
|
|
|||
|
|
@ -18,63 +18,78 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>607</width>
|
||||
<height>112</height>
|
||||
</rect>
|
||||
<widget class="QPlainTextEdit" name="editor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="editor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>3</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>80</width>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ pyaudio
|
|||
requests
|
||||
decorator
|
||||
markdown
|
||||
psutil; sys_platform == "win32"
|
||||
|
|
|
|||
Loading…
Reference in a new issue