Plugins/VcsPlugins/vcsMercurial/HgAddSubrepositoryDialog.py

changeset 4593
cc745fa6c914
parent 4021
195a471c327b
child 4631
5c1a96925da4
--- a/Plugins/VcsPlugins/vcsMercurial/HgAddSubrepositoryDialog.py	Sun Nov 29 17:25:42 2015 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgAddSubrepositoryDialog.py	Sun Nov 29 19:29:34 2015 +0100
@@ -14,10 +14,10 @@
 from PyQt5.QtCore import pyqtSlot
 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
 
-from E5Gui import E5FileDialog, E5MessageBox
+from E5Gui import E5MessageBox
+from E5Gui.E5PathPicker import E5PathPickerModes
 
 import Utilities
-import UI.PixmapCache
 
 from .Ui_HgAddSubrepositoryDialog import Ui_HgAddSubrepositoryDialog
 
@@ -36,12 +36,13 @@
         super(HgAddSubrepositoryDialog, self).__init__(parent)
         self.setupUi(self)
         
-        self.pathButton.setIcon(UI.PixmapCache.getIcon("open.png"))
+        self.pathPicker.setMode(E5PathPickerModes.DirectoryMode)
+        self.pathPicker.setDefaultDirectory(projectPath)
         
         self.__ok = self.buttonBox.button(QDialogButtonBox.Ok)
         self.__ok.setEnabled(False)
         
-        self.__projectPath = projectPath
+        self.__projectPath = Utilities.toNativeSeparators(projectPath)
         
         self.typeCombo.addItem("Mercurial", "hg")
         self.typeCombo.addItem("GIT", "git")
@@ -54,7 +55,7 @@
         """
         Private slot to update the state of the OK button.
         """
-        path = self.pathEdit.text()
+        path = self.pathPicker.text()
         url = self.urlEdit.text()
         
         self.__ok.setEnabled(
@@ -64,7 +65,7 @@
         )
     
     @pyqtSlot(str)
-    def on_pathEdit_textChanged(self, p0):
+    def on_pathPicker_textChanged(self, p0):
         """
         Private slot to handle the update of the path.
         
@@ -81,30 +82,24 @@
         """
         self.__updateOk()
     
-    @pyqtSlot()
-    def on_pathButton_clicked(self):
-        """
-        Private slot to handle the path selection via a directory selection
-        dialog.
+    @pyqtSlot(str)
+    def on_pathPicker_pathSelected(self, path):
         """
-        path = E5FileDialog.getExistingDirectory(
-            self,
-            self.tr("Add Sub-repository"),
-            os.path.join(self.__projectPath, self.pathEdit.text()),
-            E5FileDialog.Options(E5FileDialog.Option(0)))
+        Private slot handling the selection of a subrepository path.
         
-        if path:
-            path = Utilities.toNativeSeparators(path)
-            if path.startswith(self.__projectPath):
-                path = path.replace(self.__projectPath, "")[1:]
-                self.pathEdit.setText(path)
-            else:
-                E5MessageBox.critical(
-                    self,
-                    self.tr("Add Sub-repository"),
-                    self.tr("""The sub-repository path must be inside"""
-                            """ the project."""))
-                return
+        @param path path of the subrepository
+        @type str
+        """
+        if path.startswith(self.__projectPath + os.sep):
+            path = path.replace(self.__projectPath + os.sep, "")
+            self.pathPicker.setText(path)
+        else:
+            E5MessageBox.critical(
+                self,
+                self.tr("Add Sub-repository"),
+                self.tr("""The sub-repository path must be inside"""
+                        """ the project."""))
+            self.pathPicker.setText("")
     
     def getData(self):
         """
@@ -115,7 +110,7 @@
             string)
         """
         return (
-            self.pathEdit.text(),
+            self.pathPicker.text(),
             self.typeCombo.itemData(self.typeCombo.currentIndex()),
             self.urlEdit.text()
         )

eric ide

mercurial