mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Add a toolbar with buttons to control the preview panel
This commit is contained in:
parent
f77fc9493e
commit
6df507a962
1566
imgsrc/view-refresh.svg
Normal file
1566
imgsrc/view-refresh.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 57 KiB |
BIN
resources/images/auto-reload.png
Normal file
BIN
resources/images/auto-reload.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
BIN
resources/images/view-refresh.png
Normal file
BIN
resources/images/view-refresh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
@ -876,6 +876,7 @@ class Application(QApplication):
|
||||
'MessageBoxWarning': u'dialog_warning.png',
|
||||
'MessageBoxCritical': u'dialog_error.png',
|
||||
'MessageBoxQuestion': u'dialog_question.png',
|
||||
'BrowserReload': u'view-refresh.png',
|
||||
# These two are used to calculate the sizes for the doc widget
|
||||
# title bar buttons, therefore, they have to exist. The actual
|
||||
# icon is not used.
|
||||
|
@ -12,7 +12,7 @@ from Queue import Queue, Empty
|
||||
|
||||
from PyQt4.Qt import (
|
||||
QWidget, QVBoxLayout, QApplication, QSize, QNetworkAccessManager,
|
||||
QNetworkReply, QTimer, QNetworkRequest, QUrl, Qt, QNetworkDiskCache)
|
||||
QNetworkReply, QTimer, QNetworkRequest, QUrl, Qt, QNetworkDiskCache, QToolBar)
|
||||
from PyQt4.QtWebKit import QWebView
|
||||
|
||||
from calibre import prints
|
||||
@ -20,7 +20,7 @@ from calibre.constants import iswindows
|
||||
from calibre.ebooks.oeb.polish.parsing import parse
|
||||
from calibre.ebooks.oeb.base import serialize, OEB_DOCS
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre.gui2.tweak_book import current_container, editors, tprefs
|
||||
from calibre.gui2.tweak_book import current_container, editors, tprefs, actions
|
||||
from calibre.gui2.viewer.documentview import apply_settings
|
||||
from calibre.gui2.viewer.config import config
|
||||
from calibre.utils.ipc.simple_worker import offload_worker
|
||||
@ -269,6 +269,19 @@ class Preview(QWidget):
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
self.view = WebView(self)
|
||||
l.addWidget(self.view)
|
||||
self.bar = QToolBar(self)
|
||||
l.addWidget(self.bar)
|
||||
|
||||
ac = actions['auto-reload-preview']
|
||||
ac.setCheckable(True)
|
||||
ac.setChecked(True)
|
||||
ac.toggled.connect(self.auto_reload_toggled)
|
||||
self.auto_reload_toggled(ac.isChecked())
|
||||
self.bar.addAction(ac)
|
||||
|
||||
ac = actions['reload-preview']
|
||||
ac.triggered.connect(self.refresh)
|
||||
self.bar.addAction(ac)
|
||||
|
||||
self.current_name = None
|
||||
self.last_sync_request = None
|
||||
@ -301,7 +314,13 @@ class Preview(QWidget):
|
||||
self.view.clear()
|
||||
|
||||
def start_refresh_timer(self):
|
||||
self.refresh_timer.start(tprefs['preview_refresh_time'] * 1000)
|
||||
if actions['auto-reload-preview'].isChecked():
|
||||
self.refresh_timer.start(tprefs['preview_refresh_time'] * 1000)
|
||||
|
||||
def stop_refresh_timer(self):
|
||||
self.refresh_timer.stop()
|
||||
|
||||
def auto_reload_toggled(self, checked):
|
||||
actions['auto-reload-preview'].setToolTip(_(
|
||||
'Auto reload preview when text changes in editor') if not checked else _(
|
||||
'Disable auto reload of preview'))
|
||||
|
@ -141,7 +141,8 @@ class Main(MainWindow):
|
||||
def reg(icon, text, target, sid, keys, description):
|
||||
ac = actions[sid] = QAction(QIcon(I(icon)), text, self)
|
||||
ac.setObjectName('action-' + sid)
|
||||
ac.triggered.connect(target)
|
||||
if target is not None:
|
||||
ac.triggered.connect(target)
|
||||
if isinstance(keys, type('')):
|
||||
keys = (keys,)
|
||||
self.keyboard.register_shortcut(
|
||||
@ -193,6 +194,10 @@ class Main(MainWindow):
|
||||
'smarten-punctuation.png', _('&Smarten punctuation'), partial(
|
||||
self.boss.polish, 'smarten_punctuation', _('Smarten punctuation')), 'smarten-punctuation', (), _('Smarten punctuation'))
|
||||
|
||||
# Preview actions
|
||||
self.action_auto_reload_preview = reg('auto-reload.png', _('Auto reload preview'), None, 'auto-reload-preview', (), _('Auto reload preview'))
|
||||
self.action_reload_preview = reg('view-refresh.png', _('Refresh preview'), None, 'reload-preview', (), _('Refresh preview'))
|
||||
|
||||
def create_menubar(self):
|
||||
b = self.menuBar()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user