Commits

Benjamin Wohlwend committed 5b45b39

* move everything into the same settings file
* allow access to the internal QSettings instance in the Settings class
* save and restore the state of the icon_view splitter

  • Participants
  • Parent commits de02385

Comments (0)

Files changed (3)

File src/underCover.py

 
 from undercover.gui.mainwindow import UnderCover
 from undercover.util import ProxyConfigurator, check_appdir
+from undercover.util.settings import settings
 
 if __name__ == "__main__":
     check_appdir()
     app = QtGui.QApplication(sys.argv)
-    the_settings = QtCore.QSettings(QtCore.QSettings.IniFormat, 
-                                QtCore.QSettings.UserScope, 
-                                'piquadrat.ch', 'underCover')
     
     window = UnderCover()
-    pos = the_settings.value("window_pos", QtCore.QVariant(QtCore.QPoint(30, 30))).toPoint();
-    size = the_settings.value("window_size", QtCore.QVariant(QtCore.QSize(700, 500))).toSize();
-    is_maximized = the_settings.value('window_maximized', QtCore.QVariant(False)).toBool()
+    pos = settings.value("layout/window_pos", QtCore.QVariant(QtCore.QPoint(30, 30))).toPoint();
+    size = settings.value("layout/window_size", QtCore.QVariant(QtCore.QSize(700, 500))).toSize();
+    is_maximized = settings.value('layout/window_maximized', QtCore.QVariant(False)).toBool()
     window.move(pos)
     window.resize(size)
     status = None

File src/undercover/gui/mainwindow.py

         self.export_dialog = ExportDialog(self)
         if settings['main/covers_view'] < self.ui.stacked_views.count():
             self.ui.stacked_views.setCurrentIndex(settings['main/covers_view'])
+        if settings.contains("layout/icon_splitter"):
+            self.ui.icon_splitter.restoreState(settings.value("layout/icon_splitter").toByteArray())
         
         
         self.the_actions = {}
             settings['main/covers_view'] = 0
     
     def closeEvent(self, event):
-        the_settings = QtCore.QSettings(QtCore.QSettings.IniFormat, 
-                                    QtCore.QSettings.UserScope, 
-                                    'piquadrat.ch', 'underCover')
         if self.isMaximized():
-            the_settings.setValue("window_maximized", QtCore.QVariant(True))
+            settings.setValue("layout/window_maximized", QtCore.QVariant(True))
         else:
-            the_settings.setValue("window_pos", QtCore.QVariant(self.pos()))
-            the_settings.setValue("window_size", QtCore.QVariant(self.size()))
-            the_settings.setValue("window_maximized", QtCore.QVariant(False))
+            settings.setValue("layout/window_pos", QtCore.QVariant(self.pos()))
+            settings.setValue("layout/window_size", QtCore.QVariant(self.size()))
+            settings.setValue("layout/window_maximized", QtCore.QVariant(False))
+        settings.setValue("layout/icon_splitter", QtCore.QVariant(self.ui.icon_splitter.saveState()))
         QtGui.QMainWindow.closeEvent(self, event)

File src/undercover/util/settings.py

     def __haskey__(self, key):
         return self.__settings.contains(key) or key in self.__default_settings
     
+    def setValue(self, key, value):
+        '''
+        Direct access to the internal QSettings instance
+        '''
+        self.__settings.setValue(key, value)
+    
+    def value(self, key, default=QVariant()):
+        '''
+        Direct access to the internal QSettings instance
+        '''
+        return self.__settings.value(key, default)
+    
+    def contains(self, key):
+        '''
+        Direct access to the internal QSettings instance
+        '''
+        return self.__settings.contains(key)        
     def typeof(self, key):
         '''
         Returns the type of the key. Does not handle KeyErrors