Shortcut for grid view

This commit is contained in:
Kovid Goyal 2013-08-01 12:55:36 +05:30
parent 3d7b8b939e
commit 0889f6f0c6

View File

@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
import functools import functools
from PyQt4.Qt import (Qt, QApplication, QStackedWidget, QMenu, QTimer, from PyQt4.Qt import (Qt, QApplication, QStackedWidget, QMenu, QTimer,
QSize, QSizePolicy, QStatusBar, QLabel, QFont) QSize, QSizePolicy, QStatusBar, QLabel, QFont, QAction)
from calibre.utils.config import prefs, tweaks from calibre.utils.config import prefs, tweaks
from calibre.constants import (isosx, __appname__, preferred_encoding, from calibre.constants import (isosx, __appname__, preferred_encoding,
@ -243,6 +243,20 @@ class StatusBar(QStatusBar): # {{{
# }}} # }}}
class GridViewButton(LayoutButton): # {{{
def __init__(self, gui):
sc = _('Shift+Alt+G')
LayoutButton.__init__(self, I('grid.png'), _('Cover Grid'), parent=gui, shortcut=sc)
self.set_state_to_show()
self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self)
gui.addAction(self.action_toggle)
gui.keyboard.register_shortcut('grid view toggle' + self.label, unicode(self.action_toggle.text()),
default_keys=(sc,), action=self.action_toggle)
self.action_toggle.triggered.connect(self.toggle)
# }}}
class LayoutMixin(object): # {{{ class LayoutMixin(object): # {{{
def __init__(self): def __init__(self):
@ -278,8 +292,7 @@ class LayoutMixin(object): # {{{
self.status_bar = StatusBar(self) self.status_bar = StatusBar(self)
stylename = unicode(self.style().objectName()) stylename = unicode(self.style().objectName())
self.grid_view_button = LayoutButton(I('grid.png'), _('Cover Grid'), parent=self, shortcut=_('Shift+Alt+G')) self.grid_view_button = GridViewButton(self)
self.grid_view_button.set_state_to_show()
for x in button_order: for x in button_order:
button = self.grid_view_button if x == 'gv' else getattr(self, x+'_splitter').button button = self.grid_view_button if x == 'gv' else getattr(self, x+'_splitter').button