mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Consolidate all the layout buttons in the status bar into a single button
This commit is contained in:
parent
6106b2f654
commit
ae3b5a00c2
@ -8,11 +8,11 @@ __docformat__ = 'restructuredtext en'
|
||||
import functools
|
||||
|
||||
from PyQt5.Qt import (Qt, QApplication, QStackedWidget, QMenu, QTimer,
|
||||
QSize, QSizePolicy, QStatusBar, QLabel, QFont, QAction, QTabBar,
|
||||
QVBoxLayout, QWidget, QSplitter)
|
||||
QSizePolicy, QStatusBar, QLabel, QFont, QAction, QTabBar,
|
||||
QVBoxLayout, QWidget, QSplitter, QToolButton, QIcon)
|
||||
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.icu import sort_key, primary_sort_key
|
||||
from calibre.constants import (isosx, __appname__, preferred_encoding,
|
||||
get_version)
|
||||
from calibre.gui2 import config, is_widescreen, gprefs, error_dialog
|
||||
@ -340,8 +340,7 @@ class SearchBarButton(LayoutButton): # {{{
|
||||
gprefs['search bar visible'] = bool(self.isChecked())
|
||||
|
||||
def restore_state(self):
|
||||
if gprefs.get('search bar visible', True):
|
||||
self.toggle()
|
||||
self.setChecked(gprefs.get('search bar visible', True))
|
||||
|
||||
|
||||
# }}}
|
||||
@ -535,22 +534,40 @@ class LayoutMixin(object): # {{{
|
||||
self.grid_view_button.toggled.connect(self.toggle_grid_view)
|
||||
self.search_bar_button.toggled.connect(self.toggle_search_bar)
|
||||
|
||||
self.layout_buttons = []
|
||||
for x in button_order:
|
||||
if hasattr(self, x + '_splitter'):
|
||||
button = getattr(self, x + '_splitter').button
|
||||
else:
|
||||
button = self.grid_view_button if x == 'gv' else self.search_bar_button
|
||||
button.setIconSize(QSize(24, 24))
|
||||
self.layout_buttons.append(button)
|
||||
button.setVisible(False)
|
||||
if isosx and stylename != u'Calibre':
|
||||
button.setStyleSheet('''
|
||||
QToolButton { background: none; border:none; padding: 0px; }
|
||||
QToolButton:checked { background: rgba(0, 0, 0, 25%); }
|
||||
''')
|
||||
self.status_bar.addPermanentWidget(button)
|
||||
self.layout_button = b = QToolButton(self)
|
||||
b.setAutoRaise(True), b.setCursor(Qt.PointingHandCursor)
|
||||
b.setPopupMode(b.InstantPopup)
|
||||
b.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
|
||||
b.setText(_('Layout')), b.setIcon(QIcon(I('config.png')))
|
||||
b.setMenu(QMenu()), b.menu().aboutToShow.connect(self.populate_layout_menu)
|
||||
b.setToolTip(_(
|
||||
'Show and hide various parts of the calibre main window'))
|
||||
self.status_bar.addPermanentWidget(b)
|
||||
self.status_bar.addPermanentWidget(self.jobs_button)
|
||||
self.setStatusBar(self.status_bar)
|
||||
self.status_bar.update_label.linkActivated.connect(self.update_link_clicked)
|
||||
|
||||
def populate_layout_menu(self):
|
||||
m = self.layout_button.menu()
|
||||
m.clear()
|
||||
buttons = sorted(self.layout_buttons, key=lambda b:primary_sort_key(b.label))
|
||||
for b in buttons:
|
||||
m.addAction(b.icon(), b.text(), b.click)
|
||||
|
||||
def finalize_layout(self):
|
||||
self.status_bar.initialize(self.system_tray_icon)
|
||||
self.book_details.show_book_info.connect(self.iactions['Show Book Details'].show_book_info)
|
||||
|
@ -497,7 +497,6 @@ class SearchBoxMixin(object): # {{{
|
||||
self.library_view.model().set_highlight_only(config['highlight_search_matches'])
|
||||
|
||||
def focus_search_box(self, *args):
|
||||
self.search_bar_button.setChecked(True)
|
||||
self.search.setFocus(Qt.OtherFocusReason)
|
||||
self.search.lineEdit().selectAll()
|
||||
|
||||
|
@ -971,16 +971,13 @@ class LayoutButton(QToolButton):
|
||||
|
||||
def set_state_to_show(self, *args):
|
||||
self.setChecked(False)
|
||||
self.setText(_('Show %(label)s [%(shortcut)s]')%dict(label=self.label, shortcut=self.shortcut) + '\n\n' +
|
||||
_('Right click to configure'))
|
||||
self.setText(_('Show {}'.format(self.label) + '\t' + self.shortcut))
|
||||
self.setToolTip(self.text())
|
||||
self.setStatusTip(self.text())
|
||||
|
||||
def set_state_to_hide(self, *args):
|
||||
self.setChecked(True)
|
||||
self.setText(_('Hide %(label)s [%(shortcut)s]')%dict(
|
||||
label=self.label, shortcut=self.shortcut) + '\n\n' +
|
||||
_('Right click to configure'))
|
||||
self.setText(_('Hide {}'.format(self.label) + '\t' + self.shortcut))
|
||||
self.setToolTip(self.text())
|
||||
self.setStatusTip(self.text())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user