Fixed details window geometry save/restore which sometimes caused the dialog to appear in inconvenient places (partially out of the screen).

This commit is contained in:
Virgil Dupras 2012-03-19 15:09:44 -04:00
parent b500b34ef1
commit fa547bb95e
2 changed files with 10 additions and 6 deletions

View File

@ -17,8 +17,10 @@ class DetailsDialog(QDialog):
self.app = app
self.model = app.model.details_panel
self._setupUi()
if self.app.prefs.detailsWindowRect is not None:
self.setGeometry(self.app.prefs.detailsWindowRect)
# To avoid saving uninitialized geometry on appWillSavePrefs, we track whether our dialog
# has been shown. If it has, we know that our geometry should be saved.
self._shown_once = False
self.app.prefs.restoreGeometry('DetailsWindowRect', self)
self.tableModel = DetailsModel(self.model)
# tableView is defined in subclasses
self.tableView.setModel(self.tableModel)
@ -29,9 +31,14 @@ class DetailsDialog(QDialog):
def _setupUi(self): # Virtual
pass
def show(self):
self._shown_once = True
QDialog.show(self)
#--- Events
def appWillSavePrefs(self):
self.app.prefs.detailsWindowRect = self.geometry()
if self._shown_once:
self.app.prefs.saveGeometry('DetailsWindowRect', self)
#--- model --> view
def refresh(self):

View File

@ -33,7 +33,6 @@ class Preferences(PreferencesBase):
self.tableFontSize = get('TableFontSize', self.tableFontSize)
self.resultWindowIsMaximized = get('ResultWindowIsMaximized', self.resultWindowIsMaximized)
self.resultWindowRect = self.get_rect('ResultWindowRect', self.resultWindowRect)
self.detailsWindowRect = self.get_rect('DetailsWindowRect', self.detailsWindowRect)
self.directoriesWindowRect = self.get_rect('DirectoriesWindowRect', self.directoriesWindowRect)
self.recentResults = get('RecentResults', self.recentResults)
self.recentFolders = get('RecentFolders', self.recentFolders)
@ -58,7 +57,6 @@ class Preferences(PreferencesBase):
self.tableFontSize = QApplication.font().pointSize()
self.resultWindowIsMaximized = False
self.resultWindowRect = None
self.detailsWindowRect = None
self.directoriesWindowRect = None
self.recentResults = []
self.recentFolders = []
@ -84,7 +82,6 @@ class Preferences(PreferencesBase):
set_('TableFontSize', self.tableFontSize)
set_('ResultWindowIsMaximized', self.resultWindowIsMaximized)
self.set_rect('ResultWindowRect', self.resultWindowRect)
self.set_rect('DetailsWindowRect', self.detailsWindowRect)
self.set_rect('DirectoriesWindowRect', self.directoriesWindowRect)
set_('RecentResults', self.recentResults)
set_('RecentFolders', self.recentFolders)