mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Add an option to hide the toolbars in the viewer window (Preferences->Miscellaneous->Show controls in the viewr preferences). You can unhide them by right clicking in the viewer window.
This commit is contained in:
parent
81667b3253
commit
30595b6bf0
@ -70,6 +70,7 @@ def config(defaults=None):
|
||||
c.add_opt('bottom_margin', default=20)
|
||||
c.add_opt('text_color', default=None)
|
||||
c.add_opt('background_color', default=None)
|
||||
c.add_opt('show_controls', default=True)
|
||||
|
||||
fonts = c.add_group('FONTS', _('Font options'))
|
||||
fonts('serif_family', default='Times New Roman' if iswindows else 'Liberation Serif',
|
||||
@ -221,6 +222,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
for x in ('text', 'background'):
|
||||
setattr(self, 'current_%s_color'%x, getattr(opts, '%s_color'%x))
|
||||
self.update_sample_colors()
|
||||
self.opt_show_controls.setChecked(opts.show_controls)
|
||||
|
||||
def change_color(self, which, reset=False):
|
||||
if reset:
|
||||
@ -292,6 +294,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
self.opt_override_book_margins.isChecked())
|
||||
c.set('text_color', self.current_text_color)
|
||||
c.set('background_color', self.current_background_color)
|
||||
c.set('show_controls', self.opt_show_controls.isChecked())
|
||||
for x in ('top', 'bottom', 'side'):
|
||||
c.set(x+'_margin', int(getattr(self, 'opt_%s_margin'%x).value()))
|
||||
|
||||
|
@ -347,8 +347,8 @@ QToolBox::tab:hover {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>811</width>
|
||||
<height>352</height>
|
||||
<width>352</width>
|
||||
<height>176</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -573,8 +573,8 @@ QToolBox::tab:hover {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>352</width>
|
||||
<height>123</height>
|
||||
<width>811</width>
|
||||
<height>352</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -605,20 +605,27 @@ QToolBox::tab:hover {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_remember_window_size">
|
||||
<property name="text">
|
||||
<string>Remember last used &window size and layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_remember_current_page">
|
||||
<property name="text">
|
||||
<string>Remember the &current page when quitting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_show_controls">
|
||||
<property name="text">
|
||||
<string>Show &controls in the viewer window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -33,6 +33,7 @@ class Document(QWebPage): # {{{
|
||||
|
||||
page_turn = pyqtSignal(object)
|
||||
mark_element = pyqtSignal(QWebElement)
|
||||
settings_changed = pyqtSignal()
|
||||
|
||||
def set_font_settings(self, opts):
|
||||
settings = self.settings()
|
||||
@ -57,6 +58,7 @@ class Document(QWebPage): # {{{
|
||||
self.set_font_settings(opts)
|
||||
self.set_user_stylesheet(opts)
|
||||
self.misc_config(opts)
|
||||
self.settings_changed.emit()
|
||||
self.after_load()
|
||||
|
||||
def __init__(self, shortcuts, parent=None, debug_javascript=False):
|
||||
@ -153,6 +155,7 @@ class Document(QWebPage): # {{{
|
||||
self.cols_per_screen = opts.cols_per_screen
|
||||
self.side_margin = opts.side_margin
|
||||
self.top_margin, self.bottom_margin = opts.top_margin, opts.bottom_margin
|
||||
self.show_controls = opts.show_controls
|
||||
|
||||
def fit_images(self):
|
||||
if self.do_fit_images and not self.in_paged_mode:
|
||||
@ -676,7 +679,7 @@ class DocumentView(QWebView): # {{{
|
||||
|
||||
if not text and img.isNull() and self.manager is not None:
|
||||
menu.addSeparator()
|
||||
if self.document.in_fullscreen_mode and self.manager is not None:
|
||||
if (not self.document.show_controls or self.document.in_fullscreen_mode) and self.manager is not None:
|
||||
menu.addAction(self.manager.toggle_toolbar_action)
|
||||
menu.addAction(self.manager.action_full_screen)
|
||||
|
||||
|
@ -303,6 +303,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
self.toggle_toolbar_action = QAction(_('Show/hide controls'), self)
|
||||
self.toggle_toolbar_action.setCheckable(True)
|
||||
self.toggle_toolbar_action.triggered.connect(self.toggle_toolbars)
|
||||
self.toolbar_hidden = None
|
||||
self.addAction(self.toggle_toolbar_action)
|
||||
self.full_screen_label_anim = QPropertyAnimation(
|
||||
self.full_screen_label, 'size')
|
||||
@ -359,7 +360,10 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
# continue to function even when the toolbars are hidden
|
||||
self.addAction(action)
|
||||
|
||||
self.view.document.settings_changed.connect(self.settings_changed)
|
||||
|
||||
self.restore_state()
|
||||
self.settings_changed()
|
||||
self.action_toggle_paged_mode.toggled[bool].connect(self.toggle_paged_mode)
|
||||
if (start_in_fullscreen or self.view.document.start_in_fullscreen):
|
||||
self.action_full_screen.trigger()
|
||||
@ -373,6 +377,11 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
if at_start: return
|
||||
self.reload()
|
||||
|
||||
def settings_changed(self):
|
||||
for x in ('', '2'):
|
||||
x = getattr(self, 'tool_bar'+x)
|
||||
x.setVisible(self.view.document.show_controls)
|
||||
|
||||
def reload(self):
|
||||
if hasattr(self, 'current_index') and self.current_index > -1:
|
||||
self.view.document.page_position.save(overwrite=False)
|
||||
@ -575,8 +584,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
self.vertical_scrollbar.setVisible(True)
|
||||
self.window_mode_changed = 'normal'
|
||||
self.esc_full_screen_action.setEnabled(False)
|
||||
self.tool_bar.setVisible(True)
|
||||
self.tool_bar2.setVisible(True)
|
||||
self.settings_changed()
|
||||
self.full_screen_label.setVisible(False)
|
||||
if hasattr(self, '_original_frame_margins'):
|
||||
om = self._original_frame_margins
|
||||
|
Loading…
x
Reference in New Issue
Block a user