Edit Book: Saved searches window: Remember the last used values for where to search and search direction

This commit is contained in:
Kovid Goyal 2014-10-07 17:44:32 +05:30
parent 2f300b1ae8
commit 6d1139ba2d
2 changed files with 16 additions and 0 deletions

View File

@ -753,6 +753,20 @@ class SavedSearches(QWidget):
self.searches.setFocus(Qt.OtherFocusReason)
@dynamic_property
def state(self):
def fget(self):
return {'wrap':self.wrap, 'direction':self.direction, 'where':self.where}
def fset(self, val):
self.wrap, self.where, self.direction = val['wrap'], val['where'], val['direction']
return property(fget=fget, fset=fset)
def save_state(self):
tprefs['saved_seaches_state'] = self.state
def restore_state(self):
self.state = tprefs.get('saved_seaches_state', SearchWidget.DEFAULT_STATE)
def has_focus(self):
if self.hasFocus():
return True

View File

@ -703,6 +703,7 @@ class Main(MainWindow):
tprefs.set('main_window_geometry', bytearray(self.saveGeometry()))
tprefs.set('main_window_state', bytearray(self.saveState(self.STATE_VERSION)))
self.central.save_state()
self.saved_searches.save_state()
self.check_book.save_state()
def restore_state(self):
@ -713,6 +714,7 @@ class Main(MainWindow):
if state is not None:
self.restoreState(state, self.STATE_VERSION)
self.central.restore_state()
self.saved_searches.restore_state()
def contextMenuEvent(self, ev):
ev.ignore()