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):
22 Initial page of the wizard. Permit to select the project name and the directory
23 where the project will be created.
27 BWizardPage.__init__(self, UI_LOCATION + "/dir_select.ui")
28 self.setTitle(self.tr("Select the project name"))
29 self.initializeAttributes()
31 ## Overloaded QWizardPage methods ##
35 Overload of the QWizardPage isComplete method.
37 if self.pageContent.projectPath.text() != "None":
38 self.setProjectInfo("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))
45 ## Overloaded BWizardPage methods ##
49 Overload of the BWizardPage setupUi method.
51 self.pageContent.warningLabel.setVisible(False)
53 def connectSignals(self):
55 Overload of the BWizardPage connectSignals method.
57 self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self.nameChanged)
58 self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self.directoryChanged)
59 self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self.selectDirectory)
65 def nameChanged(self, name):
67 Slot called when the project name is changed manually by the user.
69 self._project_name = str(name).replace(" ", "_")
72 def directoryChanged(self, directory):
74 Slot called when the project folder is changed manually by the user.
76 self._destination_folder = str(QDir.toNativeSeparators(directory))
79 def selectDirectory(self):
81 Slot called when the project folder is changed using the file dialog.
83 directory = unicode(QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly))
84 if len(directory) > 0:
85 self.pageContent.directoryEdit.setText(directory)
89 def initializeAttributes(self):
91 Initializes the page attributes to the default values.
93 self._project_name = ""
94 self._destination_folder = os.path.expanduser("~")
95 self.pageContent.directoryEdit.setText(self._destination_folder)
97 def setProjectPath(self):
99 Analyzes the page attributes and generates the path string.
101 if self._destination_folder != "" and self._project_name <> "":
102 if not self._destination_folder.endswith(os.sep):
103 self._destination_folder += os.sep
104 self.pageContent.projectPath.setText(QDir.toNativeSeparators(self._destination_folder + self._project_name))
105 if os.path.exists(self._destination_folder + self._project_name):
106 self.pageContent.warningLabel.setVisible(True)
107 self.pageContent.warningLabel.setText(self.tr("<font color='#FF0000'>Warning: the selected directory exists, \
108 it will be destroyed with all contained subdirectories and files...</font>"))
110 self.pageContent.warningLabel.setVisible(False)
111 self.pageContent.warningLabel.setText("")
113 self.pageContent.projectPath.setText("None")
114 self.pageContent.warningLabel.setVisible(False)
115 self.pageContent.warningLabel.setText("")
116 self.emit(SIGNAL("completeChanged()"))