If no BeRTOS version is selected the Wizard automatically select the latest
[bertos.git] / wizard / BFolderPage.py
index 2628aa668d74fbb7f7f6727ec4d0bec08d972b61..0539c62b5f5ba137e420dbb0b0fabeeda2d3fffb 100644 (file)
@@ -4,7 +4,7 @@
 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
 # All rights reserved.
 #
-# $Id:$
+# $Id$
 #
 # Author: Lorenzo Berni <duplo@develer.com>
 #
@@ -34,6 +34,7 @@ class BFolderPage(BWizardPage):
         """
         Overload of the QWizardPage isComplete method.
         """
+        self.setDefaultFolder(self._destination_folder)
         if self.pageContent.projectPath.text() != "None":
             self.setProjectInfo("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))
             return True
@@ -80,7 +81,7 @@ class BFolderPage(BWizardPage):
         """
         Slot called when the project folder is changed using the file dialog.
         """
-        directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly))
+        directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), self.pageContent.directoryEdit.text(), QFileDialog.ShowDirsOnly))
         if len(directory) > 0:
             self.pageContent.directoryEdit.setText(directory)
 
@@ -91,7 +92,16 @@ class BFolderPage(BWizardPage):
         Initializes the page attributes to the default values.
         """
         self._project_name = ""
-        self._destination_folder = os.path.expanduser("~")
+        stored_folder = self.defaultFolder()
+        if stored_folder != "":
+            self._destination_folder = stored_folder
+        elif os.name == "nt":
+            from win32com.shell import shell, shellcon
+            self._destination_folder = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, 0, 0)
+            del shell
+            del shellcon
+        else:
+            self._destination_folder = os.path.expanduser("~")
         self.pageContent.directoryEdit.setText(self._destination_folder)
     
     def setProjectPath(self):
@@ -100,7 +110,7 @@ class BFolderPage(BWizardPage):
         """
         if self._destination_folder != "" and self._project_name <> "":
             if not self._destination_folder.endswith(os.sep):
-                self._destination_folder += "/"
+                self._destination_folder += os.sep
             self.pageContent.projectPath.setText(QDir.toNativeSeparators(self._destination_folder + self._project_name))
             if os.path.exists(self._destination_folder + self._project_name):
                 self.pageContent.warningLabel.setVisible(True)
@@ -113,4 +123,4 @@ class BFolderPage(BWizardPage):
             self.pageContent.projectPath.setText("None")
             self.pageContent.warningLabel.setVisible(False)
             self.pageContent.warningLabel.setText("")
-        self.emit(SIGNAL("completeChanged()"))
\ No newline at end of file
+        self.emit(SIGNAL("completeChanged()"))