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 *
18 class BFolderPage(BWizardPage):
21 BWizardPage.__init__(self, "dir_select.ui")
22 self.setTitle(self.tr("Select the project name"))
23 self._initializeAttributes()
24 self._connectSignals()
26 def _initializeAttributes(self):
27 self._projectName = ""
28 self._destinationFolder = os.path.expanduser("~")
29 self.pageContent.directoryEdit.setText(self._destinationFolder)
31 def _connectSignals(self):
32 self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self._nameChanged)
33 self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self._directoryChanged)
34 self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self._selectDirectory)
36 def _nameChanged(self, name):
37 self._projectName = str(name).replace(" ", "_")
38 self._setProjectPath()
40 def _directoryChanged(self, directory):
41 self._destinationFolder = str(directory)
42 self._setProjectPath()
44 def _setProjectPath(self):
45 if self._destinationFolder != "" and self._projectName <> "":
46 if not self._destinationFolder.endswith(os.sep):
47 self._destinationFolder += os.sep
48 self.pageContent.projectPath.setText(self._destinationFolder + self._projectName + "/")
50 self.pageContent.projectPath.setText("None")
51 self.emit(SIGNAL("completeChanged()"))
53 def _selectDirectory(self):
54 directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly))
55 if len(directory) == "":
56 self.pageContent.directoryEdit.setText(directory)
59 if self.pageContent.projectPath.text() != "None":
60 self._projectInfoStore("PROJECT_PATH", self.pageContent.projectPath.text())