mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add keyboard shortcuts to show/hide the Tag Browser, Book details and Cover Browser panels. Hover your mouse over the buttons that toggle them to see the shortcuts.
This commit is contained in:
parent
fee01926b2
commit
2d79d42b9f
@ -166,7 +166,8 @@ class LibraryWidget(Splitter): # {{{
|
|||||||
I('cover_flow.svg'),
|
I('cover_flow.svg'),
|
||||||
orientation=orientation, parent=parent,
|
orientation=orientation, parent=parent,
|
||||||
connect_button=not config['separate_cover_flow'],
|
connect_button=not config['separate_cover_flow'],
|
||||||
side_index=idx, initial_side_size=size, initial_show=False)
|
side_index=idx, initial_side_size=size, initial_show=False,
|
||||||
|
shortcut=_('Shift+Alt+B'))
|
||||||
parent.library_view = BooksView(parent)
|
parent.library_view = BooksView(parent)
|
||||||
parent.library_view.setObjectName('library_view')
|
parent.library_view.setObjectName('library_view')
|
||||||
self.addWidget(parent.library_view)
|
self.addWidget(parent.library_view)
|
||||||
@ -181,7 +182,8 @@ class Stack(QStackedWidget): # {{{
|
|||||||
self.tb_widget = TagBrowserWidget(parent)
|
self.tb_widget = TagBrowserWidget(parent)
|
||||||
parent.tb_splitter = Splitter('tag_browser_splitter',
|
parent.tb_splitter = Splitter('tag_browser_splitter',
|
||||||
_('Tag Browser'), I('tags.svg'),
|
_('Tag Browser'), I('tags.svg'),
|
||||||
parent=parent, side_index=0, initial_side_size=200)
|
parent=parent, side_index=0, initial_side_size=200,
|
||||||
|
shortcut=_('Shift+Alt+T'))
|
||||||
parent.tb_splitter.addWidget(self.tb_widget)
|
parent.tb_splitter.addWidget(self.tb_widget)
|
||||||
parent.tb_splitter.addWidget(parent.cb_splitter)
|
parent.tb_splitter.addWidget(parent.cb_splitter)
|
||||||
parent.tb_splitter.setCollapsible(parent.tb_splitter.other_index, False)
|
parent.tb_splitter.setCollapsible(parent.tb_splitter.other_index, False)
|
||||||
@ -274,7 +276,8 @@ class LayoutMixin(object): # {{{
|
|||||||
self.stack = Stack(self)
|
self.stack = Stack(self)
|
||||||
self.bd_splitter = Splitter('book_details_splitter',
|
self.bd_splitter = Splitter('book_details_splitter',
|
||||||
_('Book Details'), I('book.svg'),
|
_('Book Details'), I('book.svg'),
|
||||||
orientation=Qt.Vertical, parent=self, side_index=1)
|
orientation=Qt.Vertical, parent=self, side_index=1,
|
||||||
|
shortcut=_('Alt+D'))
|
||||||
self.bd_splitter.addWidget(self.stack)
|
self.bd_splitter.addWidget(self.stack)
|
||||||
self.bd_splitter.addWidget(self.book_details)
|
self.bd_splitter.addWidget(self.book_details)
|
||||||
self.bd_splitter.setCollapsible(self.bd_splitter.other_index, False)
|
self.bd_splitter.setCollapsible(self.bd_splitter.other_index, False)
|
||||||
@ -283,7 +286,8 @@ class LayoutMixin(object): # {{{
|
|||||||
else: # wide {{{
|
else: # wide {{{
|
||||||
self.bd_splitter = Splitter('book_details_splitter',
|
self.bd_splitter = Splitter('book_details_splitter',
|
||||||
_('Book Details'), I('book.svg'), initial_side_size=200,
|
_('Book Details'), I('book.svg'), initial_side_size=200,
|
||||||
orientation=Qt.Horizontal, parent=self, side_index=1)
|
orientation=Qt.Horizontal, parent=self, side_index=1,
|
||||||
|
shortcut=_('Shift+Alt+D'))
|
||||||
self.stack = Stack(self)
|
self.stack = Stack(self)
|
||||||
self.bd_splitter.addWidget(self.stack)
|
self.bd_splitter.addWidget(self.stack)
|
||||||
self.book_details = BookDetails(True, self)
|
self.book_details = BookDetails(True, self)
|
||||||
|
@ -5,7 +5,7 @@ Miscellaneous widgets used in the GUI
|
|||||||
'''
|
'''
|
||||||
import re, os, traceback
|
import re, os, traceback
|
||||||
|
|
||||||
from PyQt4.Qt import QIcon, QFont, QLabel, QListWidget, \
|
from PyQt4.Qt import QIcon, QFont, QLabel, QListWidget, QAction, \
|
||||||
QListWidgetItem, QTextCharFormat, QApplication, \
|
QListWidgetItem, QTextCharFormat, QApplication, \
|
||||||
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
||||||
QPixmap, QSplitterHandle, QToolButton, \
|
QPixmap, QSplitterHandle, QToolButton, \
|
||||||
@ -855,7 +855,7 @@ class SplitterHandle(QSplitterHandle):
|
|||||||
|
|
||||||
class LayoutButton(QToolButton):
|
class LayoutButton(QToolButton):
|
||||||
|
|
||||||
def __init__(self, icon, text, splitter, parent=None):
|
def __init__(self, icon, text, splitter, parent=None, shortcut=None):
|
||||||
QToolButton.__init__(self, parent)
|
QToolButton.__init__(self, parent)
|
||||||
self.label = text
|
self.label = text
|
||||||
self.setIcon(QIcon(icon))
|
self.setIcon(QIcon(icon))
|
||||||
@ -864,18 +864,21 @@ class LayoutButton(QToolButton):
|
|||||||
self.splitter = splitter
|
self.splitter = splitter
|
||||||
splitter.state_changed.connect(self.update_state)
|
splitter.state_changed.connect(self.update_state)
|
||||||
self.setCursor(Qt.PointingHandCursor)
|
self.setCursor(Qt.PointingHandCursor)
|
||||||
|
self.shortcut = ''
|
||||||
|
if shortcut:
|
||||||
|
self.shortcut = shortcut
|
||||||
|
|
||||||
def set_state_to_show(self, *args):
|
def set_state_to_show(self, *args):
|
||||||
self.setChecked(False)
|
self.setChecked(False)
|
||||||
label =_('Show')
|
label =_('Show')
|
||||||
self.setText(label + ' ' + self.label)
|
self.setText(label + ' ' + self.label + ' ' + self.shortcut)
|
||||||
self.setToolTip(self.text())
|
self.setToolTip(self.text())
|
||||||
self.setStatusTip(self.text())
|
self.setStatusTip(self.text())
|
||||||
|
|
||||||
def set_state_to_hide(self, *args):
|
def set_state_to_hide(self, *args):
|
||||||
self.setChecked(True)
|
self.setChecked(True)
|
||||||
label = _('Hide')
|
label = _('Hide')
|
||||||
self.setText(label + ' ' + self.label)
|
self.setText(label + ' ' + self.label+ ' ' + self.shortcut)
|
||||||
self.setToolTip(self.text())
|
self.setToolTip(self.text())
|
||||||
self.setStatusTip(self.text())
|
self.setStatusTip(self.text())
|
||||||
|
|
||||||
@ -891,7 +894,7 @@ class Splitter(QSplitter):
|
|||||||
|
|
||||||
def __init__(self, name, label, icon, initial_show=True,
|
def __init__(self, name, label, icon, initial_show=True,
|
||||||
initial_side_size=120, connect_button=True,
|
initial_side_size=120, connect_button=True,
|
||||||
orientation=Qt.Horizontal, side_index=0, parent=None):
|
orientation=Qt.Horizontal, side_index=0, parent=None, shortcut=None):
|
||||||
QSplitter.__init__(self, parent)
|
QSplitter.__init__(self, parent)
|
||||||
self.resize_timer = QTimer(self)
|
self.resize_timer = QTimer(self)
|
||||||
self.resize_timer.setSingleShot(True)
|
self.resize_timer.setSingleShot(True)
|
||||||
@ -906,10 +909,21 @@ class Splitter(QSplitter):
|
|||||||
self.initial_side_size = initial_side_size
|
self.initial_side_size = initial_side_size
|
||||||
self.initial_show = initial_show
|
self.initial_show = initial_show
|
||||||
self.splitterMoved.connect(self.splitter_moved, type=Qt.QueuedConnection)
|
self.splitterMoved.connect(self.splitter_moved, type=Qt.QueuedConnection)
|
||||||
self.button = LayoutButton(icon, label, self)
|
self.button = LayoutButton(icon, label, self, shortcut=shortcut)
|
||||||
if connect_button:
|
if connect_button:
|
||||||
self.button.clicked.connect(self.double_clicked)
|
self.button.clicked.connect(self.double_clicked)
|
||||||
|
|
||||||
|
if shortcut is not None:
|
||||||
|
self.action_toggle = QAction(QIcon(icon), _('Toggle') + ' ' + label,
|
||||||
|
self)
|
||||||
|
self.action_toggle.triggered.connect(self.toggle_triggered)
|
||||||
|
self.action_toggle.setShortcut(shortcut)
|
||||||
|
if parent is not None:
|
||||||
|
parent.addAction(self.action_toggle)
|
||||||
|
|
||||||
|
def toggle_triggered(self, *args):
|
||||||
|
self.toggle_side_pane()
|
||||||
|
|
||||||
def createHandle(self):
|
def createHandle(self):
|
||||||
return SplitterHandle(self.orientation(), self)
|
return SplitterHandle(self.orientation(), self)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user