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()
27 self._connectSignals()
30 self.pageContent.warningLabel.setVisible(False)
32 def _initializeAttributes(self):
33 self._project_name = ""
34 self._destination_folder = os.path.expanduser("~")
35 self.pageContent.directoryEdit.setText(self._destination_folder)
37 def _connectSignals(self):
38 self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self._nameChanged)
39 self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self._directoryChanged)
40 self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self._selectDirectory)
42 def _nameChanged(self, name):
43 self._project_name = str(name).replace(" ", "_")
44 self._setProjectPath()
46 def _directoryChanged(self, directory):
47 self._destination_folder = str(QDir.toNativeSeparators(directory))
48 self._setProjectPath()
50 def _setProjectPath(self):
51 if self._destination_folder != "" and self._project_name <> "":
52 if not self._destination_folder.endswith(os.sep):
53 self._destination_folder += "/"
54 self.pageContent.projectPath.setText(QDir.toNativeSeparators(self._destination_folder + self._project_name))
55 if os.path.exists(self._destination_folder + self._project_name):
56 self.pageContent.warningLabel.setVisible(True)
57 self.pageContent.warningLabel.setText(self.tr("<font color='#FF0000'>Warning: the selected directory exists, \
58 it will be destroyed with all contained subdirectories and files...</font>"))
60 self.pageContent.warningLabel.setVisible(False)
61 self.pageContent.warningLabel.setText("")
63 self.pageContent.projectPath.setText("None")
64 self.pageContent.warningLabel.setVisible(False)
65 self.pageContent.warningLabel.setText("")
66 self.emit(SIGNAL("completeChanged()"))
68 def _selectDirectory(self):
69 directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly))
70 if len(directory) > 0:
71 self.pageContent.directoryEdit.setText(directory)
74 if self.pageContent.projectPath.text() != "None":
75 self._projectInfoStore("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))