Merge from trunk

This commit is contained in:
Charles Haley 2011-01-13 17:19:19 +00:00
commit d95fccbd16
7 changed files with 56 additions and 13 deletions

View File

@ -705,9 +705,9 @@ class ActionTweakEpub(InterfaceActionBase):
name = 'Tweak ePub' name = 'Tweak ePub'
actual_plugin = 'calibre.gui2.actions.tweak_epub:TweakEpubAction' actual_plugin = 'calibre.gui2.actions.tweak_epub:TweakEpubAction'
class ActionMoveSelection(InterfaceActionBase): class ActionNextMatch(InterfaceActionBase):
name = 'Edit Metadata' name = 'Next Match'
actual_plugin = 'calibre.gui2.actions.move_selection:MoveSelectionAction' actual_plugin = 'calibre.gui2.actions.next_match:NextMatchAction'
plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog, plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
ActionConvert, ActionDelete, ActionEditMetadata, ActionView, ActionConvert, ActionDelete, ActionEditMetadata, ActionView,
@ -715,7 +715,7 @@ plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
ActionRestart, ActionOpenFolder, ActionConnectShare, ActionRestart, ActionOpenFolder, ActionConnectShare,
ActionSendToDevice, ActionHelp, ActionPreferences, ActionSimilarBooks, ActionSendToDevice, ActionHelp, ActionPreferences, ActionSimilarBooks,
ActionAddToLibrary, ActionEditCollections, ActionChooseLibrary, ActionAddToLibrary, ActionEditCollections, ActionChooseLibrary,
ActionCopyToLibrary, ActionTweakEpub, ActionMoveSelection] ActionCopyToLibrary, ActionTweakEpub, ActionNextMatch]
# }}} # }}}

View File

@ -111,6 +111,9 @@ class InterfaceAction(QObject):
action.setWhatsThis(text) action.setWhatsThis(text)
action.setAutoRepeat(False) action.setAutoRepeat(False)
if shortcut: if shortcut:
if isinstance(shortcut, list):
action.setShortcuts(shortcut)
else:
action.setShortcut(shortcut) action.setShortcut(shortcut)
setattr(self, attr, action) setattr(self, attr, action)
return action return action
@ -170,6 +173,14 @@ class InterfaceAction(QObject):
''' '''
pass pass
def gui_layout_complete(self):
'''
Called once per action when the layout of the main GUI is
completed. If your action needs to make changes to the layout, they
should be done here, rather than in :meth:`initialization_complete`.
'''
pass
def initialization_complete(self): def initialization_complete(self):
''' '''
Called once per action when the initialization of the main GUI is Called once per action when the initialization of the main GUI is

View File

@ -7,10 +7,10 @@ __docformat__ = 'restructuredtext en'
from calibre.gui2.actions import InterfaceAction from calibre.gui2.actions import InterfaceAction
class MoveSelectionAction(InterfaceAction): class NextMatchAction(InterfaceAction):
name = 'Move selection in library' name = 'Move to next highlighted book'
action_spec = (_('Move to next item'), 'arrow-down.png', action_spec = (_('Move to next match'), 'arrow-down.png',
_('Move to next highlighted item'), 'n') _('Move to next highlighted match'), [_('N'), _('F3')])
dont_add_to = frozenset(['toolbar-device', 'context-menu-device']) dont_add_to = frozenset(['toolbar-device', 'context-menu-device'])
action_type = 'current' action_type = 'current'
@ -23,21 +23,34 @@ class MoveSelectionAction(InterfaceAction):
self.can_move = None self.can_move = None
self.qaction.triggered.connect(self.move_forward) self.qaction.triggered.connect(self.move_forward)
self.create_action(spec=(_('Move to previous item'), 'arrow-up.png', self.create_action(spec=(_('Move to previous item'), 'arrow-up.png',
_('Move to previous highlighted item'), 'F3'), attr='p_action') _('Move to previous highlighted item'), [_('Shift+N'),
_('Shift+F3')]), attr='p_action')
self.gui.addAction(self.p_action) self.gui.addAction(self.p_action)
self.p_action.triggered.connect(self.move_backward) self.p_action.triggered.connect(self.move_backward)
def gui_layout_complete(self):
self.gui.search_highlight_only.setVisible(True)
def location_selected(self, loc): def location_selected(self, loc):
self.can_move = loc == 'library' self.can_move = loc == 'library'
try:
self.gui.search_highlight_only.setVisible(self.can_move)
except:
import traceback
traceback.print_exc()
def move_forward(self): def move_forward(self):
if self.can_move is None: if self.can_move is None:
self.can_move = self.gui.current_view() is self.gui.library_view self.can_move = self.gui.current_view() is self.gui.library_view
self.gui.search_highlight_only.setVisible(self.can_move)
if self.can_move: if self.can_move:
self.gui.current_view().move_highlighted_row(forward=True) self.gui.current_view().move_highlighted_row(forward=True)
def move_backward(self): def move_backward(self):
if self.can_move is None: if self.can_move is None:
self.can_move = self.gui.current_view() is self.gui.library_view self.can_move = self.gui.current_view() is self.gui.library_view
self.gui.search_highlight_only.setVisible(self.can_move)
if self.can_move: if self.can_move:
self.gui.current_view().move_highlighted_row(forward=False) self.gui.current_view().move_highlighted_row(forward=False)

View File

@ -196,9 +196,11 @@ class SearchBar(QWidget): # {{{
x = parent.search_highlight_only = QCheckBox() x = parent.search_highlight_only = QCheckBox()
x.setText(_('&Highlight')) x.setText(_('&Highlight'))
x.setToolTip(_('Highlight matched books in the book list, instead ' x.setToolTip('<p>'+_('When searching, highlight matched books, instead '
'of restricting the book list to the matches.')) 'of restricting the book list to the matches.<p> You can use the '
'N or F3 keys to go to the next match.'))
l.addWidget(x) l.addWidget(x)
x.setVisible(False)
x = parent.saved_search = SavedSearchBox(self) x = parent.saved_search = SavedSearchBox(self)
x.setMaximumSize(QSize(150, 16777215)) x.setMaximumSize(QSize(150, 16777215))

View File

@ -34,6 +34,9 @@ path_to_ebook to the database.
help=_('Log debugging information to console')) help=_('Log debugging information to console'))
parser.add_option('--no-update-check', default=False, action='store_true', parser.add_option('--no-update-check', default=False, action='store_true',
help=_('Do not check for updates')) help=_('Do not check for updates'))
parser.add_option('--ignore-plugins', default=False, action='store_true',
help=_('Ignore custom plugins, useful if you installed a plugin'
' that is preventing calibre from starting'))
return parser return parser
def init_qt(args): def init_qt(args):

View File

@ -103,6 +103,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.gui_debug = gui_debug self.gui_debug = gui_debug
acmap = OrderedDict() acmap = OrderedDict()
for action in interface_actions(): for action in interface_actions():
if opts.ignore_plugins and action.plugin_path is not None:
continue
try: try:
ac = action.load_actual_plugin(self) ac = action.load_actual_plugin(self)
except: except:
@ -256,6 +258,14 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.height()) self.height())
self.resize(self.width(), self._calculated_available_height) self.resize(self.width(), self._calculated_available_height)
for ac in self.iactions.values():
try:
ac.gui_layout_complete()
except:
import traceback
traceback.print_exc()
if ac.plugin_path is None:
raise
if config['autolaunch_server']: if config['autolaunch_server']:
self.start_content_server() self.start_content_server()

View File

@ -478,6 +478,10 @@ Calibre has several keyboard shortcuts to save you time and mouse movement. Thes
- Focus the search bar - Focus the search bar
* - :kbd:`Shift+Ctrl+F` * - :kbd:`Shift+Ctrl+F`
- Open the advanced search dialog - Open the advanced search dialog
* - :kbd:`N or F3`
- Find the next book that matches the current search (only works if the highlight checkbox next to the search bar is checked)
* - :kbd:`Shift+N or Shift+F3`
- Find the next book that matches the current search (only works if the highlight checkbox next to the search bar is checked)
* - :kbd:`Ctrl+D` * - :kbd:`Ctrl+D`
- Download metadata and shortcuts - Download metadata and shortcuts
* - :kbd:`Ctrl+R` * - :kbd:`Ctrl+R`