mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-22 09:19:55 +06:00
Fix Python2 bugs in GUI code
This commit is contained in:
parent
69329fe09a
commit
7e9153e294
@ -9,7 +9,13 @@
|
|||||||
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.actions import menu_action_unique_name
|
from calibre.gui2.actions import menu_action_unique_name
|
||||||
from PyQt5.QtGui import QMenu, QToolButton
|
try:
|
||||||
|
from PyQt5.QtGui import QMenu, QToolButton
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
from PyQt5.QtWidgets import QMenu, QToolButton
|
||||||
|
except ImportError:
|
||||||
|
from PyQt4.Qt import QMenu, QToolButton
|
||||||
|
|
||||||
|
|
||||||
#@@CALIBRE_COMPAT_CODE@@
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
@ -61,13 +67,19 @@ class ActualACSMInputGUIExtension(InterfaceAction):
|
|||||||
# Text, icon, tooltip, keyboard shortcut
|
# Text, icon, tooltip, keyboard shortcut
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
print("Genesis!")
|
print("ACSM Input: GUI Plugin Genesis!")
|
||||||
self.menu = QMenu(self.gui)
|
self.menu = QMenu(self.gui)
|
||||||
|
|
||||||
self.rebuild_menus()
|
self.rebuild_menus()
|
||||||
|
|
||||||
self.qaction.setMenu(self.menu)
|
self.qaction.setMenu(self.menu)
|
||||||
icon = get_icons('acsm_logo_2.png', "ACSM Input Plugin")
|
try:
|
||||||
|
# Py3
|
||||||
|
icon = get_icons('acsm_logo_2.png', "ACSM Input Plugin")
|
||||||
|
except TypeError:
|
||||||
|
# Py2
|
||||||
|
icon = get_icons('acsm_logo_2.png')
|
||||||
|
|
||||||
self.qaction.setIcon(icon)
|
self.qaction.setIcon(icon)
|
||||||
#self.qaction.triggered.connect(self.trigger_config_dialog)
|
#self.qaction.triggered.connect(self.trigger_config_dialog)
|
||||||
|
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from calibre.customize import InterfaceActionBase # type: ignore
|
from calibre.customize import InterfaceActionBase # type: ignore
|
||||||
from calibre.customize import PluginInstallationType
|
try:
|
||||||
|
from calibre.customize import PluginInstallationType
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -25,8 +28,12 @@ class ACSMInputGUIExtension(InterfaceActionBase):
|
|||||||
type = "File type"
|
type = "File type"
|
||||||
# Just so that the GUI extension shows up at the same place as the actual ACSM Input plugin.
|
# Just so that the GUI extension shows up at the same place as the actual ACSM Input plugin.
|
||||||
|
|
||||||
installation_type = PluginInstallationType.EXTERNAL
|
try:
|
||||||
# Mark this as user-installed so it shows up in the plugin list by default.
|
installation_type = PluginInstallationType.EXTERNAL
|
||||||
|
# Mark this as user-installed so it shows up in the plugin list by default.
|
||||||
|
except:
|
||||||
|
# Setting the Installation type doesn't always work on Calibre 4 and below.
|
||||||
|
pass
|
||||||
|
|
||||||
actual_plugin = "calibre_plugins.deacsm.gui_main:ActualACSMInputGUIExtension"
|
actual_plugin = "calibre_plugins.deacsm.gui_main:ActualACSMInputGUIExtension"
|
||||||
|
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
|
|
||||||
|
|
||||||
from calibre.customize import InterfaceActionBase # type: ignore
|
from calibre.customize import InterfaceActionBase # type: ignore
|
||||||
from calibre.customize import PluginInstallationType
|
try:
|
||||||
|
from calibre.customize import PluginInstallationType
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DeACSMMigrationPlugin(InterfaceActionBase):
|
class DeACSMMigrationPlugin(InterfaceActionBase):
|
||||||
@ -28,8 +31,12 @@ class DeACSMMigrationPlugin(InterfaceActionBase):
|
|||||||
type = "File type"
|
type = "File type"
|
||||||
# Just so that the GUI extension shows up at the same place as the actual ACSM Input plugin.
|
# Just so that the GUI extension shows up at the same place as the actual ACSM Input plugin.
|
||||||
|
|
||||||
installation_type = PluginInstallationType.EXTERNAL
|
try:
|
||||||
# Mark this as user-installed so it shows up in the plugin list by default.
|
installation_type = PluginInstallationType.EXTERNAL
|
||||||
|
# Mark this as user-installed so it shows up in the plugin list by default.
|
||||||
|
except:
|
||||||
|
# Setting the Installation type doesn't always work on Calibre 4 and below.
|
||||||
|
pass
|
||||||
|
|
||||||
actual_plugin = "calibre_plugins.deacsm.migration:ActualMigrationPlugin"
|
actual_plugin = "calibre_plugins.deacsm.migration:ActualMigrationPlugin"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user