Merge branch 'master' of https://github.com/dae/anki into CorrectBranchInCardPreview

This commit is contained in:
Arthur-Milchior 2019-02-17 19:33:05 +01:00
commit 95a475472c
7 changed files with 93 additions and 64 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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))

View file

@ -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:

View file

@ -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):

View file

@ -18,11 +18,26 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<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>
</widget>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
@ -36,12 +51,21 @@
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>112</height>
<width>80</width>
<height>470</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<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>
@ -66,15 +90,6 @@
</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>
</item>
<item>

View file

@ -4,3 +4,4 @@ pyaudio
requests
decorator
markdown
psutil; sys_platform == "win32"