mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Viewer: have the toolbar actions for the docks indicate visibility
This commit is contained in:
parent
ba95c2b363
commit
4b077904c0
@ -147,11 +147,14 @@ class ActionsToolBar(ToolBar):
|
|||||||
self.next_action = shortcut_action('next')
|
self.next_action = shortcut_action('next')
|
||||||
self.previous_action = shortcut_action('previous')
|
self.previous_action = shortcut_action('previous')
|
||||||
|
|
||||||
self.toc_action = shortcut_action('toc')
|
self.toc_action = a = shortcut_action('toc')
|
||||||
self.bookmarks_action = shortcut_action('bookmarks')
|
a.setCheckable(True)
|
||||||
|
self.bookmarks_action = a = shortcut_action('bookmarks')
|
||||||
|
a.setCheckable(True)
|
||||||
self.reference_action = a = shortcut_action('reference')
|
self.reference_action = a = shortcut_action('reference')
|
||||||
a.setCheckable(True)
|
a.setCheckable(True)
|
||||||
self.lookup_action = shortcut_action('lookup')
|
self.lookup_action = a = shortcut_action('lookup')
|
||||||
|
a.setCheckable(True)
|
||||||
self.chrome_action = shortcut_action('chrome')
|
self.chrome_action = shortcut_action('chrome')
|
||||||
|
|
||||||
self.mode_action = a = shortcut_action('mode')
|
self.mode_action = a = shortcut_action('mode')
|
||||||
@ -187,6 +190,11 @@ class ActionsToolBar(ToolBar):
|
|||||||
def update_reference_mode_action(self, enabled):
|
def update_reference_mode_action(self, enabled):
|
||||||
self.reference_action.setChecked(enabled)
|
self.reference_action.setChecked(enabled)
|
||||||
|
|
||||||
|
def update_dock_actions(self, visibility_map):
|
||||||
|
for k in ('toc', 'bookmarks', 'lookup'):
|
||||||
|
ac = getattr(self, '{}_action'.format(k))
|
||||||
|
ac.setChecked(visibility_map[k])
|
||||||
|
|
||||||
def set_tooltips(self, rmap):
|
def set_tooltips(self, rmap):
|
||||||
for sc, a in iteritems(self.shortcut_actions):
|
for sc, a in iteritems(self.shortcut_actions):
|
||||||
if a.isCheckable():
|
if a.isCheckable():
|
||||||
|
@ -118,6 +118,7 @@ class EbookViewer(MainWindow):
|
|||||||
ans.setObjectName(name)
|
ans.setObjectName(name)
|
||||||
self.addDockWidget(area, ans)
|
self.addDockWidget(area, ans)
|
||||||
ans.setVisible(False)
|
ans.setVisible(False)
|
||||||
|
ans.visibilityChanged.connect(self.dock_visibility_changed)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
for dock_def in itervalues(self.dock_defs):
|
for dock_def in itervalues(self.dock_defs):
|
||||||
@ -170,6 +171,7 @@ class EbookViewer(MainWindow):
|
|||||||
self.loading_overlay = LoadingOverlay(self)
|
self.loading_overlay = LoadingOverlay(self)
|
||||||
self.restore_state()
|
self.restore_state()
|
||||||
self.actions_toolbar.update_visibility()
|
self.actions_toolbar.update_visibility()
|
||||||
|
self.dock_visibility_changed()
|
||||||
if continue_reading:
|
if continue_reading:
|
||||||
self.continue_reading()
|
self.continue_reading()
|
||||||
|
|
||||||
@ -289,6 +291,10 @@ class EbookViewer(MainWindow):
|
|||||||
md.setImageData(img)
|
md.setImageData(img)
|
||||||
md.setUrls([url])
|
md.setUrls([url])
|
||||||
QApplication.instance().clipboard().setMimeData(md)
|
QApplication.instance().clipboard().setMimeData(md)
|
||||||
|
|
||||||
|
def dock_visibility_changed(self):
|
||||||
|
vmap = {dock.objectName().partition('-')[0]: dock.toggleViewAction().isChecked() for dock in self.dock_widgets}
|
||||||
|
self.actions_toolbar.update_dock_actions(vmap)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Load book {{{
|
# Load book {{{
|
||||||
@ -307,8 +313,12 @@ class EbookViewer(MainWindow):
|
|||||||
from .printing import print_book
|
from .printing import print_book
|
||||||
print_book(set_book_path.pathtoebook, book_title=self.current_book_data['metadata']['title'], parent=self)
|
print_book(set_book_path.pathtoebook, book_title=self.current_book_data['metadata']['title'], parent=self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dock_widgets(self):
|
||||||
|
return self.findChildren(QDockWidget, options=Qt.FindDirectChildrenOnly)
|
||||||
|
|
||||||
def reset_interface(self):
|
def reset_interface(self):
|
||||||
for dock in self.findChildren(QDockWidget):
|
for dock in self.dock_widgets:
|
||||||
dock.setFloating(False)
|
dock.setFloating(False)
|
||||||
area = self.dock_defs[dock.objectName().partition('-')[0]].initial_area
|
area = self.dock_defs[dock.objectName().partition('-')[0]].initial_area
|
||||||
self.removeDockWidget(dock)
|
self.removeDockWidget(dock)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user