mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a setting to control toolbar visibility
This commit is contained in:
parent
8bfe1b2598
commit
47fc7c20b9
@ -22,6 +22,8 @@ class ToolBar(QToolBar):
|
||||
QToolBar.__init__(self, parent)
|
||||
self.shortcut_actions = {}
|
||||
self.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||
self.setVisible(False)
|
||||
self.setAllowedAreas(Qt.AllToolBarAreas)
|
||||
|
||||
def create_shortcut_action(self, icon, text, sc):
|
||||
a = QAction(QIcon(I(icon)), text, self)
|
||||
@ -39,13 +41,14 @@ class ActionsToolBar(ToolBar):
|
||||
def __init__(self, parent=None):
|
||||
ToolBar.__init__(self, parent)
|
||||
self.setObjectName('actions_toolbar')
|
||||
self.setAllowedAreas(Qt.AllToolBarAreas)
|
||||
self.update_visibility()
|
||||
|
||||
def initialize(self, web_view):
|
||||
shortcut_action = self.create_shortcut_action
|
||||
self.action_triggered.connect(web_view.trigger_shortcut)
|
||||
page = web_view.page()
|
||||
web_view.paged_mode_changed.connect(self.update_mode_action)
|
||||
web_view.standalone_misc_settings_changed.connect(self.update_visibility)
|
||||
|
||||
self.back_action = page.action(QWebEnginePage.Back)
|
||||
self.back_action.setIcon(QIcon(I('back.png')))
|
||||
@ -129,3 +132,6 @@ class ActionsToolBar(ToolBar):
|
||||
elided_text(entry['title'], pos='right', width=250),
|
||||
elided_text(os.path.basename(path), width=250))).triggered.connect(partial(
|
||||
self.open_book_at_path.emit, path))
|
||||
|
||||
def update_visibility(self):
|
||||
self.setVisible(bool(get_session_pref('show_actions_toolbar', default=False)))
|
||||
|
@ -102,7 +102,6 @@ class EbookViewer(MainWindow):
|
||||
self.actions_toolbar = at = ActionsToolBar(self)
|
||||
at.open_book_at_path.connect(self.ask_for_open)
|
||||
self.addToolBar(Qt.LeftToolBarArea, at)
|
||||
at.setVisible(False)
|
||||
try:
|
||||
os.makedirs(annotations_dir)
|
||||
except EnvironmentError:
|
||||
|
@ -402,6 +402,7 @@ class WebView(RestartingWebEngineView):
|
||||
print_book = pyqtSignal()
|
||||
shortcuts_changed = pyqtSignal(object)
|
||||
paged_mode_changed = pyqtSignal()
|
||||
standalone_misc_settings_changed = pyqtSignal(object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
self._host_widget = None
|
||||
@ -532,6 +533,7 @@ class WebView(RestartingWebEngineView):
|
||||
vprefs['session_data'] = {}
|
||||
apply_font_settings(self._page)
|
||||
self.paged_mode_changed.emit()
|
||||
self.standalone_misc_settings_changed.emit()
|
||||
elif key != '*':
|
||||
sd = vprefs['session_data']
|
||||
sd[key] = val
|
||||
@ -540,6 +542,8 @@ class WebView(RestartingWebEngineView):
|
||||
apply_font_settings(self._page)
|
||||
elif key == 'read_mode':
|
||||
self.paged_mode_changed.emit()
|
||||
elif key == 'standalone_misc_settings':
|
||||
self.standalone_misc_settings_changed.emit(val)
|
||||
|
||||
def set_local_storage(self, key, val):
|
||||
if key == '*' and val is None:
|
||||
|
@ -15,6 +15,7 @@ CONTAINER = unique_id('standalone-misc-settings')
|
||||
DEFAULTS = {
|
||||
'remember_window_geometry': False,
|
||||
'remember_last_read': True,
|
||||
'show_actions_toolbar': False,
|
||||
'save_annotations_in_ebook': True,
|
||||
'singleinstance': False,
|
||||
}
|
||||
@ -44,6 +45,7 @@ def create_misc_panel(container, apply_func, cancel_func):
|
||||
return E.div(style='margin-top:1ex', E.label(ans, '\xa0' + text))
|
||||
|
||||
container.append(cb('remember_window_geometry', _('Remember last used window size and position')))
|
||||
container.append(cb('show_actions_toolbar', _('Show a toolbar with the most useful actions')))
|
||||
container.append(cb('remember_last_read', _('Remember current page when quitting')))
|
||||
container.append(cb('save_annotations_in_ebook', _('Keep a copy of annotations/bookmarks in the e-book file, for easy sharing')))
|
||||
container.append(cb('singleinstance', _('Allow only a single instance of the viewer (needs restart)')))
|
||||
|
Loading…
x
Reference in New Issue
Block a user