From 5b3e3e420f47d567c33627857eb84e2896bb9c1f Mon Sep 17 00:00:00 2001 From: NoDRM Date: Sun, 2 Jan 2022 21:18:13 +0100 Subject: [PATCH] Make plugin work in Calibre 6 (Qt 6) --- DeDRM_plugin/adobekey.py | 2 +- DeDRM_plugin/config.py | 10 ++++++++-- DeDRM_plugin/standalone/remove_drm.py | 8 ++++---- Obok_plugin/config.py | 8 +++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/DeDRM_plugin/adobekey.py b/DeDRM_plugin/adobekey.py index d8e68d8..6155cff 100644 --- a/DeDRM_plugin/adobekey.py +++ b/DeDRM_plugin/adobekey.py @@ -136,7 +136,7 @@ if iswindows: if os.path.isfile(os.path.join(p, "libcrypto-1_1.dll")): return os.path.join(p, "libcrypto-1_1.dll") if os.path.isfile(os.path.join(p, "libeay32.dll")): - return os.path.join(p, "libeay.dll") + return os.path.join(p, "libeay32.dll") return None def _load_crypto_libcrypto(): diff --git a/DeDRM_plugin/config.py b/DeDRM_plugin/config.py index 40f645b..b3d924c 100755 --- a/DeDRM_plugin/config.py +++ b/DeDRM_plugin/config.py @@ -327,7 +327,13 @@ class ManageKeysDialog(QDialog): self.export_key_button.setIcon(QIcon(I('save.png'))) self.export_key_button.clicked.connect(self.export_key) button_layout.addWidget(self.export_key_button) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + try: + # QT 6 + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Policy.Minimum, QtGui.QSizePolicy.Policy.Expanding) + except AttributeError: + # QT 5 + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + button_layout.addItem(spacerItem) if self.wineprefix is not None: @@ -811,7 +817,7 @@ class AddBandNKeyDialog(QDialog): self.cbType.addItem("Extract passhashes from Adobe Digital Editions") self.cbType.addItem("Extract key from Nook Windows application") self.cbType.addItem("Extract key from Nook Android application") - self.cbType.currentIndexChanged.connect(self.update_form, self.cbType.currentIndex()) + self.cbType.currentIndexChanged.connect(lambda: self.update_form(self.cbType.currentIndex())) self.layout.addWidget(self.cbType) self.button_box = QDialogButtonBox(QDialogButtonBox.Cancel) diff --git a/DeDRM_plugin/standalone/remove_drm.py b/DeDRM_plugin/standalone/remove_drm.py index 5ab5f33..8273b97 100644 --- a/DeDRM_plugin/standalone/remove_drm.py +++ b/DeDRM_plugin/standalone/remove_drm.py @@ -142,7 +142,7 @@ def perform_action(params, files): return 0 if overwrite_original and (output is not None or outputdir is not None): - print("Can't use --overwrite together with --output or --outputdir.") + print("Can't use --overwrite together with --output or --outputdir.", file=sys.stderr) return 1 if output is not None and os.path.isfile(output) and not force: @@ -155,8 +155,8 @@ def perform_action(params, files): return 1 if outputdir is not None and output is not None and os.path.isabs(output): - print("--output parameter is absolute path despite --outputdir being set.") - print("Remove --outputdir, or give a relative path to --output.") + print("--output parameter is absolute path despite --outputdir being set.", file=sys.stderr) + print("Remove --outputdir, or give a relative path to --output.", file=sys.stderr) return 1 @@ -166,7 +166,7 @@ def perform_action(params, files): file = os.path.abspath(file) if not os.path.isfile(file): - print("Skipping file " + file + " - not found.") + print("Skipping file " + file + " - not found.", file=sys.stderr) continue if overwrite_original: diff --git a/Obok_plugin/config.py b/Obok_plugin/config.py index deb29f9..9a637f3 100644 --- a/Obok_plugin/config.py +++ b/Obok_plugin/config.py @@ -118,7 +118,13 @@ class ManageKeysDialog(QDialog): self._delete_key_button.clicked.connect(self.delete_key) button_layout.addWidget(self._delete_key_button) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + try: + # QT 6 + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Policy.Minimum, QtGui.QSizePolicy.Policy.Expanding) + except AttributeError: + # QT 5 + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + button_layout.addItem(spacerItem) layout.addSpacing(5)