Project/PropertiesDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3359
6b6c224d67d6
child 3656
441956d8fce5
--- a/Project/PropertiesDialog.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/Project/PropertiesDialog.py	Thu Apr 03 23:05:31 2014 +0200
@@ -12,7 +12,7 @@
 import os
 
 from PyQt4.QtCore import QDir, pyqtSlot
-from PyQt4.QtGui import QDialog
+from PyQt4.QtGui import QDialog, QDialogButtonBox
 
 from E5Gui.E5Application import e5App
 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter
@@ -22,6 +22,7 @@
 
 import Utilities
 import Preferences
+import UI.PixmapCache
 
 
 class PropertiesDialog(QDialog, Ui_PropertiesDialog):
@@ -42,6 +43,9 @@
             self.setObjectName(name)
         self.setupUi(self)
         
+        self.dirButton.setIcon(UI.PixmapCache.getIcon("open.png"))
+        self.mainscriptButton.setIcon(UI.PixmapCache.getIcon("open.png"))
+        
         self.project = project
         self.newProject = new
         self.transPropertiesDlg = None
@@ -58,6 +62,13 @@
             self.projectTypeComboBox.addItem(
                 projectTypes[projectType], projectType)
         
+        ipath = Preferences.getMultiProject("Workspace") or \
+            Utilities.getHomeDir()
+        self.__initPaths = [
+            Utilities.fromNativeSeparators(ipath),
+            Utilities.fromNativeSeparators(ipath) + "/",
+        ]
+        
         if not new:
             name = os.path.splitext(self.project.pfile)[0]
             self.nameEdit.setText(os.path.basename(name))
@@ -108,13 +119,13 @@
                 except KeyError:
                     vcsSystemDisplay = "None"
                 self.vcsLabel.setText(
-                    self.trUtf8(
+                    self.tr(
                         "The project is version controlled by <b>{0}</b>.")
                     .format(vcsSystemDisplay))
                 self.vcsInfoButton.show()
             else:
                 self.vcsLabel.setText(
-                    self.trUtf8("The project is not version controlled."))
+                    self.tr("The project is not version controlled."))
                 self.vcsInfoButton.hide()
             self.vcsCheckBox.hide()
         else:
@@ -122,14 +133,17 @@
                 self.languageComboBox.findText("Python3"))
             self.projectTypeComboBox.setCurrentIndex(
                 self.projectTypeComboBox.findData("Qt4"))
-            hp = Preferences.getMultiProject("Workspace") or \
-                Utilities.getHomeDir()
-            self.dirEdit.setText(hp)
+            self.dirEdit.setText(self.__initPaths[0])
             self.versionEdit.setText('0.1')
             self.vcsLabel.hide()
             self.vcsInfoButton.hide()
             if not self.project.vcsSoftwareAvailable():
                 self.vcsCheckBox.hide()
+        
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
+            bool(self.dirEdit.text()) and
+            Utilities.fromNativeSeparators(self.dirEdit.text()) not in
+            self.__initPaths)
     
     @pyqtSlot(str)
     def on_languageComboBox_currentIndexChanged(self, language):
@@ -149,6 +163,17 @@
         self.projectTypeComboBox.setCurrentIndex(
             self.projectTypeComboBox.findData(curProjectType))
     
+    @pyqtSlot(str)
+    def on_dirEdit_textChanged(self, txt):
+        """
+        Private slot to handle a change of the project directory.
+        
+        @param txt name of the project directory (string)
+        """
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
+            bool(txt) and
+            Utilities.fromNativeSeparators(txt) not in self.__initPaths)
+    
     @pyqtSlot()
     def on_dirButton_clicked(self):
         """
@@ -156,7 +181,7 @@
         """
         directory = E5FileDialog.getExistingDirectory(
             self,
-            self.trUtf8("Select project directory"),
+            self.tr("Select project directory"),
             self.dirEdit.text(),
             E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
         
@@ -205,11 +230,11 @@
         for pattern, filetype in list(self.project.pdata["FILETYPES"].items()):
             if filetype == "SOURCES":
                 patterns.append(pattern)
-        filters = self.trUtf8("Source Files ({0});;All Files (*)")\
+        filters = self.tr("Source Files ({0});;All Files (*)")\
             .format(" ".join(patterns))
         fn = E5FileDialog.getOpenFileName(
             self,
-            self.trUtf8("Select main script file"),
+            self.tr("Select main script file"),
             dir,
             filters)
         

eric ide

mercurial