From 4acebfdf52fd6756415c085f9144908155f7882c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 14 Feb 2019 13:47:44 +1000 Subject: [PATCH 1/7] ensure full window is on screen when restoring --- aqt/utils.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/aqt/utils.py b/aqt/utils.py index 942f3fecf..1221ce8b7 100644 --- a/aqt/utils.py +++ b/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): From 8e944c6a02882530b4a0934a85dfda65bde121db Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 14 Feb 2019 15:22:57 +1000 Subject: [PATCH 2/7] fix schema not being modified on backup import --- aqt/importing.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/aqt/importing.py b/aqt/importing.py index 4b429d92d..fb63bd029 100644 --- a/aqt/importing.py +++ b/aqt/importing.py @@ -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)) From a7c27b08eb59bf20a246a61569dc732aeb8247e9 Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Fri, 15 Feb 2019 13:51:57 +0100 Subject: [PATCH 3/7] Update pip command for PyQt packaging changes PyQtWebEngine is now shipped separately, and PyQ5-sip is automatically installed as a dependency of PyQt5. --- README.development | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.development b/README.development index 299bb3937..d597b32ad 100644 --- a/README.development +++ b/README.development @@ -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: From ff74c51d9fe62049310c1c10780092a25a0a4327 Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Fri, 15 Feb 2019 13:55:35 +0100 Subject: [PATCH 4/7] Explicitly import all QtWebEngineWidgets Seems to be necessary for pyqt 5.12+ builds from pypi. --- aqt/qt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aqt/qt.py b/aqt/qt.py index fea2d26c3..4936c300a 100644 --- a/aqt/qt.py +++ b/aqt/qt.py @@ -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: From 6c982ac05bdc17a2435f1cacee6c9b34952d973b Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Fri, 15 Feb 2019 14:15:22 +0100 Subject: [PATCH 5/7] Switch to a horizontal, qsplitter-based layout for editor and help text Also: Disable text wrapping in the editor area to reduce the likelihood of users performing syntax errors. --- designer/addonconf.ui | 123 +++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 54 deletions(-) diff --git a/designer/addonconf.ui b/designer/addonconf.ui index e2a688d63..0ad52e196 100644 --- a/designer/addonconf.ui +++ b/designer/addonconf.ui @@ -18,63 +18,78 @@ - - - - 0 - 1 - + + + Qt::Horizontal - - QFrame::NoFrame - - - true - - - - - 0 - 0 - 607 - 112 - + + + + 3 + 0 + + + + QPlainTextEdit::NoWrap - - - 0 - - - - - - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - - - - - - - - - 0 - 3 - - + + + + 1 + 0 + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 80 + 470 + + + + + 4 + + + 0 + + + 0 + + + 0 + + + + + + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + + + + From 11f3d77eb1938310f51f6553cc3ebd0f3af391db Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Fri, 15 Feb 2019 14:15:54 +0100 Subject: [PATCH 6/7] Switch to the system default monospaced font for the config editor area --- aqt/addons.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aqt/addons.py b/aqt/addons.py index 2bc108dfc..5a3868245 100644 --- a/aqt/addons.py +++ b/aqt/addons.py @@ -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: From a7ee142b7f6a2ecfde3875746ef1b2473b87220a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 16 Feb 2019 13:03:16 +1000 Subject: [PATCH 7/7] require psutil on win32 https://github.com/dae/anki/pull/277 --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 09d11657b..58c98a64d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ pyaudio requests decorator markdown +psutil; sys_platform == "win32"