+ BWizardPage.__init__(self, UI_LOCATION + "/dir_select.ui")
+ self.setTitle(self.tr("Select the project name"))
+ self.initializeAttributes()
+
+ ## Overloaded QWizardPage methods ##
+
+ def isComplete(self):
+ """
+ Overload of the QWizardPage isComplete method.
+ """
+ self.setDefaultFolder(self._destination_folder)
+ if self.pageContent.projectPath.text() != "None":
+ self.setProjectInfo("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))
+ return True
+ else:
+ return False
+
+ ####
+
+ ## Overloaded BWizardPage methods ##
+
+ def setupUi(self):
+ """
+ Overload of the BWizardPage setupUi method.
+ """
+ self.pageContent.warningLabel.setVisible(False)
+
+ def connectSignals(self):
+ """
+ Overload of the BWizardPage connectSignals method.
+ """
+ self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self.nameChanged)
+ self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self.directoryChanged)
+ self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self.selectDirectory)
+
+ ####
+
+ ## Slots ##
+
+ def nameChanged(self, name):
+ """
+ Slot called when the project name is changed manually by the user.
+ """
+ try:
+ name = unicode(name).encode("ascii")
+ except UnicodeEncodeError:
+ name = self._project_name
+ self.pageContent.nameEdit.setText(name)
+ self._project_name = unicode(name).replace(" ", "_")
+ self.setProjectPath()
+
+ def directoryChanged(self, directory):
+ """
+ Slot called when the project folder is changed manually by the user.
+ """
+ self._destination_folder = unicode(QDir.toNativeSeparators(directory))
+ self.setProjectPath()
+
+ def selectDirectory(self):
+ """
+ Slot called when the project folder is changed using the file dialog.
+ """
+ directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), self.pageContent.directoryEdit.text(), QFileDialog.ShowDirsOnly))
+ if len(directory) > 0:
+ self.pageContent.directoryEdit.setText(directory)
+
+ ####