mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-23 12:46:15 +01:00
Fix #4811 (E-book viewer toolbar resets position)
This commit is contained in:
parent
b3e7309c53
commit
2e8abd963d
1 changed files with 19 additions and 1 deletions
|
|
@ -5,7 +5,7 @@
|
|||
from functools import partial
|
||||
from threading import Thread
|
||||
|
||||
from PyQt4.Qt import QApplication, Qt, QIcon, QTimer, SIGNAL, \
|
||||
from PyQt4.Qt import QApplication, Qt, QIcon, QTimer, SIGNAL, QByteArray, \
|
||||
QDesktopServices, QDoubleSpinBox, QLabel, QTextBrowser, \
|
||||
QPainter, QBrush, QColor, QStandardItemModel, QPalette, \
|
||||
QStandardItem, QUrl, QRegExpValidator, QRegExp, QLineEdit, \
|
||||
|
|
@ -161,6 +161,8 @@ def clear_to_help_mode(self):
|
|||
|
||||
class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
|
||||
STATE_VERSION = 1
|
||||
|
||||
def __init__(self, pathtoebook=None, debug_javascript=False):
|
||||
MainWindow.__init__(self, None)
|
||||
self.setupUi(self)
|
||||
|
|
@ -265,6 +267,22 @@ def __init__(self, pathtoebook=None, debug_javascript=False):
|
|||
ca = self.view.copy_action
|
||||
ca.setShortcut(QKeySequence.Copy)
|
||||
self.addAction(ca)
|
||||
self.restore_state()
|
||||
|
||||
def closeEvent(self, e):
|
||||
self.save_state()
|
||||
return MainWindow.closeEvent(self, e)
|
||||
|
||||
def save_state(self):
|
||||
state = str(self.saveState(self.STATE_VERSION))
|
||||
dynamic['viewer_toolbar_state'] = state
|
||||
|
||||
def restore_state(self):
|
||||
state = dynamic.get('viewer_toolbar_state', None)
|
||||
if state is not None:
|
||||
state = QByteArray(state)
|
||||
self.restoreState(state, self.STATE_VERSION)
|
||||
|
||||
|
||||
def lookup(self, word):
|
||||
self.dictionary_view.setHtml('<html><body><p>'+ \
|
||||
|
|
|
|||
Loading…
Reference in a new issue