Move the .ui files in the ui directory
[bertos.git] / wizard / BFolderPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
5 # All rights reserved.
6 #
7 # $Id:$
8 #
9 # Author: Lorenzo Berni <duplo@develer.com>
10 #
11
12 import os
13
14 from PyQt4.QtGui import *
15 from BWizardPage import *
16 import bertos_utils
17
18 from const import *
19
20 class BFolderPage(BWizardPage):
21     
22     def __init__(self):
23         BWizardPage.__init__(self, UI_LOCATION + "/dir_select.ui")
24         self.setTitle(self.tr("Select the project name"))
25         self._initializeAttributes()
26         self._connectSignals()
27
28     def _initializeAttributes(self):
29         self._projectName = ""
30         self._destinationFolder = os.path.expanduser("~")
31         self.pageContent.directoryEdit.setText(self._destinationFolder)
32     
33     def _connectSignals(self):
34         self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self._nameChanged)
35         self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self._directoryChanged)
36         self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self._selectDirectory)
37     
38     def _nameChanged(self, name):
39         self._projectName = str(name).replace(" ", "_")
40         self._setProjectPath()
41     
42     def _directoryChanged(self, directory):
43         self._destinationFolder = str(directory)
44         self._setProjectPath()
45     
46     def _setProjectPath(self):
47         if self._destinationFolder != "" and self._projectName <> "":
48             if not self._destinationFolder.endswith(os.sep):
49                 self._destinationFolder += os.sep
50             self.pageContent.projectPath.setText(self._destinationFolder + self._projectName)
51         else:
52             self.pageContent.projectPath.setText("None")
53         self.emit(SIGNAL("completeChanged()"))
54     
55     def _selectDirectory(self):
56         directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly))
57         if len(directory) == "":
58             self.pageContent.directoryEdit.setText(directory)
59     
60     def isComplete(self):
61         if self.pageContent.projectPath.text() != "None":
62             self._projectInfoStore("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))
63             return True
64         else:
65             return False