mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-01-03 14:43:29 +01:00
Fix for cal2.10 kybd shortcuts change, minor obscure bug fixes.
This commit is contained in:
parent
1ecfb68fb2
commit
efeb1017ac
3 changed files with 14 additions and 15 deletions
|
|
@ -520,7 +520,7 @@ class UserPassDialog(QDialog):
|
|||
self.l = QGridLayout()
|
||||
self.setLayout(self.l)
|
||||
|
||||
if exception.passwdonly:
|
||||
if exception and exception.passwdonly:
|
||||
self.setWindowTitle(_('Password'))
|
||||
self.l.addWidget(QLabel(_("Author requires a password for this story(%s).")%exception.url),0,0,1,2)
|
||||
# user isn't used, but it's easier to still have it for
|
||||
|
|
|
|||
|
|
@ -128,9 +128,8 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
|
|||
|
||||
# Assign our menu to this action
|
||||
self.menu = QMenu(self.gui)
|
||||
self.old_actions_unique_map = {}
|
||||
# menu_actions is just to keep a live reference to the menu
|
||||
# items to prevent GC removing it.
|
||||
# menu_actions is to keep a live reference to the menu items
|
||||
# to prevent GC removing it and so rebuild_menus has a list
|
||||
self.menu_actions = []
|
||||
self.qaction.setMenu(self.menu)
|
||||
self.menus_lock = threading.RLock()
|
||||
|
|
@ -238,8 +237,15 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
|
|||
#self.qaction.setText("FFDL")
|
||||
do_user_config = self.interface_action_base_plugin.do_user_config
|
||||
self.menu.clear()
|
||||
self.actions_unique_map = {}
|
||||
|
||||
for action in self.menu_actions:
|
||||
self.gui.keyboard.unregister_shortcut(action.calibre_shortcut_unique_name)
|
||||
# starting in calibre 2.10.0, actions are registers at
|
||||
# the top gui level for OSX' benefit.
|
||||
if calibre_version >= (2,10,0):
|
||||
self.gui.removeAction(action)
|
||||
self.menu_actions = []
|
||||
|
||||
self.add_action = self.create_menu_item_ex(self.menu, _('&Add New from URL(s)'), image='plus.png',
|
||||
unique_name='Add New FanFiction Book(s) from URL(s)',
|
||||
shortcut_name=_('Add New FanFiction Book(s) from URL(s)'),
|
||||
|
|
@ -325,11 +331,6 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
|
|||
shortcut_name=_('About FanFictionDownLoader'),
|
||||
triggered=self.about)
|
||||
|
||||
# Before we finalize, make sure we delete any actions for menus that are no longer displayed
|
||||
for menu_id, unique_name in self.old_actions_unique_map.iteritems():
|
||||
if menu_id not in self.actions_unique_map:
|
||||
self.gui.keyboard.unregister_shortcut(unique_name)
|
||||
self.old_actions_unique_map = self.actions_unique_map
|
||||
self.gui.keyboard.finalize()
|
||||
|
||||
def about(self):
|
||||
|
|
@ -352,7 +353,6 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
|
|||
#print("create_menu_item_ex before %s"%menu_text)
|
||||
ac = create_menu_action_unique(self, parent_menu, menu_text, image, tooltip,
|
||||
shortcut, triggered, is_checked, shortcut_name, unique_name)
|
||||
self.actions_unique_map[ac.calibre_shortcut_unique_name] = ac.calibre_shortcut_unique_name
|
||||
self.menu_actions.append(ac)
|
||||
#print("create_menu_item_ex after %s"%menu_text)
|
||||
return ac
|
||||
|
|
|
|||
|
|
@ -311,15 +311,14 @@ class FanFictionNetSiteAdapter(BaseSiteAdapter):
|
|||
|
||||
# some ancient stories have body tags inside them that cause
|
||||
# soup parsing to discard the content. For story text we
|
||||
# don't care about anything before "<div class='storytextp"
|
||||
# (there's a space after storytextp, so no close quote(')) and
|
||||
# don't care about anything before "<div role='main'" and
|
||||
# this kills any body tags.
|
||||
divstr = "<div role='main'"
|
||||
if divstr not in data:
|
||||
raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
|
||||
else:
|
||||
data = data[data.index(divstr):]
|
||||
data.replace("<body","<notbody").replace("<BODY","<NOTBODY")
|
||||
data = data[data.index(divstr):]
|
||||
data = data.replace("<body","<notbody").replace("<BODY","<NOTBODY")
|
||||
|
||||
soup = bs.BeautifulSoup(data)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue