Make plugin work in Calibre 6 (Qt 6)

This commit is contained in:
NoDRM 2022-01-02 21:18:13 +01:00
parent f17b255159
commit 5b3e3e420f
4 changed files with 20 additions and 8 deletions

View File

@ -136,7 +136,7 @@ if iswindows:
if os.path.isfile(os.path.join(p, "libcrypto-1_1.dll")): if os.path.isfile(os.path.join(p, "libcrypto-1_1.dll")):
return 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")): 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 return None
def _load_crypto_libcrypto(): def _load_crypto_libcrypto():

View File

@ -327,7 +327,13 @@ class ManageKeysDialog(QDialog):
self.export_key_button.setIcon(QIcon(I('save.png'))) self.export_key_button.setIcon(QIcon(I('save.png')))
self.export_key_button.clicked.connect(self.export_key) self.export_key_button.clicked.connect(self.export_key)
button_layout.addWidget(self.export_key_button) button_layout.addWidget(self.export_key_button)
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) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
button_layout.addItem(spacerItem) button_layout.addItem(spacerItem)
if self.wineprefix is not None: 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 passhashes from Adobe Digital Editions")
self.cbType.addItem("Extract key from Nook Windows application") self.cbType.addItem("Extract key from Nook Windows application")
self.cbType.addItem("Extract key from Nook Android 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.layout.addWidget(self.cbType)
self.button_box = QDialogButtonBox(QDialogButtonBox.Cancel) self.button_box = QDialogButtonBox(QDialogButtonBox.Cancel)

View File

@ -142,7 +142,7 @@ def perform_action(params, files):
return 0 return 0
if overwrite_original and (output is not None or outputdir is not None): 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 return 1
if output is not None and os.path.isfile(output) and not force: if output is not None and os.path.isfile(output) and not force:
@ -155,8 +155,8 @@ def perform_action(params, files):
return 1 return 1
if outputdir is not None and output is not None and os.path.isabs(output): 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("--output parameter is absolute path despite --outputdir being set.", file=sys.stderr)
print("Remove --outputdir, or give a relative path to --output.") print("Remove --outputdir, or give a relative path to --output.", file=sys.stderr)
return 1 return 1
@ -166,7 +166,7 @@ def perform_action(params, files):
file = os.path.abspath(file) file = os.path.abspath(file)
if not os.path.isfile(file): if not os.path.isfile(file):
print("Skipping file " + file + " - not found.") print("Skipping file " + file + " - not found.", file=sys.stderr)
continue continue
if overwrite_original: if overwrite_original:

View File

@ -118,7 +118,13 @@ class ManageKeysDialog(QDialog):
self._delete_key_button.clicked.connect(self.delete_key) self._delete_key_button.clicked.connect(self.delete_key)
button_layout.addWidget(self._delete_key_button) button_layout.addWidget(self._delete_key_button)
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) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
button_layout.addItem(spacerItem) button_layout.addItem(spacerItem)
layout.addSpacing(5) layout.addSpacing(5)