4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
14 from PyQt4.QtGui import *
15 from BWizardPage import *
20 class BFolderPage(BWizardPage):
23 BWizardPage.__init__(self, UI_LOCATION + "/dir_select.ui")
24 self.setTitle(self.tr("Select the project name"))
25 self._initializeAttributes()
26 self._connectSignals()
28 def _initializeAttributes(self):
29 self._projectName = ""
30 self._destinationFolder = os.path.expanduser("~")
31 self.pageContent.directoryEdit.setText(self._destinationFolder)
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)
38 def _nameChanged(self, name):
39 self._projectName = str(name).replace(" ", "_")
40 self._setProjectPath()
42 def _directoryChanged(self, directory):
43 self._destinationFolder = str(directory)
44 self._setProjectPath()
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)
52 self.pageContent.projectPath.setText("None")
53 self.emit(SIGNAL("completeChanged()"))
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)
61 if self.pageContent.projectPath.text() != "None":
62 self._projectInfoStore("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))