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: 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: 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)) 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: 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): 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 + + + + + + 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"