+ 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)
+ # self.connect(self.pageContent.customButton, SIGNAL("toggled(bool)"), self.isComplete)
+
+ ####
+
+ ## 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.
+ """
+ try:
+ directory = unicode(directory).encode("ascii")
+ except UnicodeEncodeError:
+ directory = self._destination_folder
+ self.pageContent.directoryEdit.setText(directory)
+ self._destination_folder = 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(QDir.toNativeSeparators(directory))
+
+ ####
+
+ def initializeAttributes(self):
+ """
+ Initializes the page attributes to the default values.
+ """
+ self._project_name = ""
+ stored_folder = self.defaultFolder()
+ if stored_folder != "":
+ self._destination_folder = stored_folder
+ elif os.name == "nt":
+ def _winGetSpecialFolder(csidl):
+ from ctypes import windll, create_unicode_buffer
+ MAX_PATH = 4096
+ buf = create_unicode_buffer(MAX_PATH)
+ if not windll.shell32.SHGetSpecialFolderPathW(0, buf, csidl, False):
+ raise WindowsError("cannot get special folder location")
+ return buf.value
+ CSIDL_PERSONAL = 5
+ self._destination_folder = _winGetSpecialFolder(CSIDL_PERSONAL)
+ else:
+ self._destination_folder = os.path.expanduser("~")
+ self.pageContent.directoryEdit.setText(self._destination_folder)
+
+ def setProjectPath(self):
+ """
+ Analyzes the page attributes and generates the path string.
+ """
+ if self._destination_folder != "" and self._project_name <> "":
+ if not self._destination_folder.endswith(os.sep):
+ self._destination_folder += os.sep
+ self.pageContent.projectPath.setText(QDir.toNativeSeparators(self._destination_folder + self._project_name))
+ if os.path.exists(self._destination_folder + self._project_name):
+ self.pageContent.warningLabel.setVisible(True)
+ self.pageContent.warningLabel.setText(self.tr("<font color='#FF0000'>Warning: the selected directory exists, \
+ it will be destroyed with all contained subdirectories and files...</font>"))
+ else:
+ self.pageContent.warningLabel.setVisible(False)
+ self.pageContent.warningLabel.setText("")
+ else:
+ self.pageContent.projectPath.setText("None")
+ self.pageContent.warningLabel.setVisible(False)
+ self.pageContent.warningLabel.setText("")
+ self.emit(SIGNAL("completeChanged()"))