Add the project editing functionality
[bertos.git] / wizard / BOpenPage.py
diff --git a/wizard/BOpenPage.py b/wizard/BOpenPage.py
new file mode 100644 (file)
index 0000000..b35a965
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+import os
+import pickle
+
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+
+from BWizardPage import *
+import bertos_utils
+
+from const import *
+
+class BOpenPage(BWizardPage):
+    """
+    Initial page of the wizard. Permit to select the project name and the directory
+    where the project will be created.
+    """
+    
+    def __init__(self):
+        BWizardPage.__init__(self, UI_LOCATION + "/project_select.ui")
+        self.setTitle(self.tr("Open an existing BeRTOS project"))
+    
+    ## Overloaded BWizardPage methods ##
+    
+    def reloadData(self):
+        project = unicode(QFileDialog.getOpenFileName(self, self.tr("Open project file"), os.path.expanduser("~"), self.tr("Project file (project.bertos)")))
+        if project == "":
+            QApplication.instance().quit()
+        else:
+            QApplication.instance().project = pickle.loads(open(project, "r").read())
+            self.pageContent.nameLabel.setText(os.path.basename(project.replace(os.sep + "project.bertos", "")))
+            self.pageContent.dirLabel.setText(project)
+    
+    ####
+