Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py

changeset 5548
95b188f96d3d
parent 5389
9b1c800daff3
child 5549
fa21bfab0a29
diff -r 971f5ab7429c -r 95b188f96d3d Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py
--- a/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py	Wed Feb 22 19:25:07 2017 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py	Thu Feb 23 18:44:25 2017 +0100
@@ -10,15 +10,13 @@
 
 from __future__ import unicode_literals
 
-import os
-
-from PyQt5.QtCore import pyqtSlot, QDir
+from PyQt5.QtCore import pyqtSlot, QUrl
 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
 
 from E5Gui.E5PathPicker import E5PathPickerModes
 
 from .Ui_HgNewProjectOptionsDialog import Ui_HgNewProjectOptionsDialog
-from .Config import ConfigHgProtocols
+from .Config import ConfigHgSchemes
 
 import Utilities
 import Preferences
@@ -42,18 +40,6 @@
         self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode)
         self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode)
         
-        self.protocolCombo.addItems(ConfigHgProtocols)
-        
-        hd = Utilities.toNativeSeparators(QDir.homePath())
-        hd = os.path.join(hd, 'hgroot')
-        self.vcsUrlPicker.setText(hd)
-        
-        self.vcs = vcs
-        
-        self.localPath = hd
-        self.networkPath = "localhost/"
-        self.localProtocol = True
-        
         ipath = Preferences.getMultiProject("Workspace") or \
             Utilities.getHomeDir()
         self.__initPaths = [
@@ -62,10 +48,8 @@
         ]
         self.vcsProjectDirPicker.setText(self.__initPaths[0])
         
-        self.lfNoteLabel.setVisible(self.vcs.isExtensionActive("largefiles"))
-        self.largeCheckBox.setVisible(self.vcs.isExtensionActive("largefiles"))
-        
-        self.resize(self.width(), self.minimumSizeHint().height())
+        self.lfNoteLabel.setVisible(vcs.isExtensionActive("largefiles"))
+        self.largeCheckBox.setVisible(vcs.isExtensionActive("largefiles"))
         
         self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
         
@@ -84,32 +68,17 @@
             Utilities.fromNativeSeparators(txt) not in self.__initPaths)
     
     @pyqtSlot(str)
-    def on_protocolCombo_activated(self, protocol):
-        """
-        Private slot to switch the status of the directory selection button.
-        
-        @param protocol name of the selected protocol (string)
-        """
-        self.vcsUrlPicker.setPickerEnabled(protocol == "file://")
-        if protocol == "file://":
-            self.networkPath = self.vcsUrlPicker.text()
-            self.vcsUrlPicker.setText(self.localPath)
-            self.localProtocol = True
-        else:
-            if self.localProtocol:
-                self.localPath = self.vcsUrlPicker.text()
-                self.vcsUrlPicker.setText(self.networkPath)
-                self.localProtocol = False
-    
-    @pyqtSlot(str)
     def on_vcsUrlPicker_textChanged(self, txt):
         """
         Private slot to handle changes of the URL.
         
         @param txt current text of the line edit (string)
         """
-        enable = "://" not in txt
+        url = QUrl.fromUserInput(txt)
+        enable = url.isValid() and url.scheme() in ConfigHgSchemes
         self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
+        
+        self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file")
     
     def getData(self):
         """
@@ -118,12 +87,9 @@
         @return a tuple of a string (project directory) and a dictionary
             containing the data entered.
         """
-        scheme = self.protocolCombo.currentText()
-        url = self.vcsUrlPicker.text()
-        if scheme == "file://" and url[0] not in ["\\", "/"]:
-            url = "/{0}".format(url)
+        url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/"))
         vcsdatadict = {
-            "url": '{0}{1}'.format(scheme, url),
+            "url": url.toString(QUrl.None_),
             "revision": self.vcsRevisionEdit.text(),
             "largefiles": self.largeCheckBox.isChecked(),
         }

eric ide

mercurial