Plugins/VcsPlugins/vcsPySvn/SvnNewProjectOptionsDialog.py

changeset 4597
46be8d9c4dd8
parent 4021
195a471c327b
child 4631
5c1a96925da4
equal deleted inserted replaced
4595:f0e48b3e31d4 4597:46be8d9c4dd8
13 import os 13 import os
14 14
15 from PyQt5.QtCore import QDir, pyqtSlot 15 from PyQt5.QtCore import QDir, pyqtSlot
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
17 17
18 from E5Gui.E5Completers import E5DirCompleter 18 from E5Gui.E5PathPicker import E5PathPickerModes
19 from E5Gui import E5FileDialog
20 19
21 from .Ui_SvnNewProjectOptionsDialog import Ui_SvnNewProjectOptionsDialog 20 from .Ui_SvnNewProjectOptionsDialog import Ui_SvnNewProjectOptionsDialog
22 from .Config import ConfigSvnProtocols 21 from .Config import ConfigSvnProtocols
23 22
24 import Utilities 23 import Utilities
25 import Preferences 24 import Preferences
26 import UI.PixmapCache
27 25
28 26
29 class SvnNewProjectOptionsDialog(QDialog, Ui_SvnNewProjectOptionsDialog): 27 class SvnNewProjectOptionsDialog(QDialog, Ui_SvnNewProjectOptionsDialog):
30 """ 28 """
31 Class implementing the Options Dialog for a new project from the 29 Class implementing the Options Dialog for a new project from the
39 @param parent parent widget (QWidget) 37 @param parent parent widget (QWidget)
40 """ 38 """
41 super(SvnNewProjectOptionsDialog, self).__init__(parent) 39 super(SvnNewProjectOptionsDialog, self).__init__(parent)
42 self.setupUi(self) 40 self.setupUi(self)
43 41
44 self.vcsUrlButton.setIcon(UI.PixmapCache.getIcon("open.png")) 42 self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode)
45 self.projectDirButton.setIcon(UI.PixmapCache.getIcon("open.png")) 43 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode)
46
47 self.vcsDirectoryCompleter = E5DirCompleter(self.vcsUrlEdit)
48 self.vcsProjectDirCompleter = E5DirCompleter(self.vcsProjectDirEdit)
49 44
50 self.protocolCombo.addItems(ConfigSvnProtocols) 45 self.protocolCombo.addItems(ConfigSvnProtocols)
51 46
52 hd = Utilities.toNativeSeparators(QDir.homePath()) 47 hd = Utilities.toNativeSeparators(QDir.homePath())
53 hd = os.path.join(hd, 'subversionroot') 48 hd = os.path.join(hd, 'subversionroot')
54 self.vcsUrlEdit.setText(hd) 49 self.vcsUrlPicker.setText(hd)
55 50
56 self.vcs = vcs 51 self.vcs = vcs
57 52
58 self.localPath = hd 53 self.localPath = hd
59 self.networkPath = "localhost/" 54 self.networkPath = "localhost/"
63 Utilities.getHomeDir() 58 Utilities.getHomeDir()
64 self.__initPaths = [ 59 self.__initPaths = [
65 Utilities.fromNativeSeparators(ipath), 60 Utilities.fromNativeSeparators(ipath),
66 Utilities.fromNativeSeparators(ipath) + "/", 61 Utilities.fromNativeSeparators(ipath) + "/",
67 ] 62 ]
68 self.vcsProjectDirEdit.setText( 63 self.vcsProjectDirPicker.setText(self.__initPaths[0])
69 Utilities.toNativeSeparators(self.__initPaths[0]))
70 64
71 self.resize(self.width(), self.minimumSizeHint().height()) 65 self.resize(self.width(), self.minimumSizeHint().height())
72 66
73 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 67 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
74 68
75 msh = self.minimumSizeHint() 69 msh = self.minimumSizeHint()
76 self.resize(max(self.width(), msh.width()), msh.height()) 70 self.resize(max(self.width(), msh.width()), msh.height())
77 71
78 @pyqtSlot(str) 72 @pyqtSlot(str)
79 def on_vcsProjectDirEdit_textChanged(self, txt): 73 def on_vcsProjectDirPicker_textChanged(self, txt):
80 """ 74 """
81 Private slot to handle a change of the project directory. 75 Private slot to handle a change of the project directory.
82 76
83 @param txt name of the project directory (string) 77 @param txt name of the project directory (string)
84 """ 78 """
85 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( 79 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
86 bool(txt) and 80 bool(txt) and
87 Utilities.fromNativeSeparators(txt) not in self.__initPaths) 81 Utilities.fromNativeSeparators(txt) not in self.__initPaths)
88 82
89 @pyqtSlot() 83 @pyqtSlot()
90 def on_vcsUrlButton_clicked(self): 84 def on_vcsUrlPicker_pickerButtonClicked(self):
91 """ 85 """
92 Private slot to display a selection dialog. 86 Private slot to display a repository browser dialog.
93 """ 87 """
94 if self.protocolCombo.currentText() == "file://": 88 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog
95 directory = E5FileDialog.getExistingDirectory( 89 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self)
96 self, 90 dlg.start(
97 self.tr("Select Repository-Directory"), 91 self.protocolCombo.currentText() + self.vcsUrlPicker.text())
98 self.vcsUrlEdit.text(), 92 if dlg.exec_() == QDialog.Accepted:
99 E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) 93 url = dlg.getSelectedUrl()
100 94 if url:
101 if directory: 95 protocol = url.split("://")[0]
102 self.vcsUrlEdit.setText( 96 path = url.split("://")[1]
103 Utilities.toNativeSeparators(directory)) 97 self.protocolCombo.setCurrentIndex(
104 else: 98 self.protocolCombo.findText(protocol + "://"))
105 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog 99 self.vcsUrlPicker.setText(path)
106 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self)
107 dlg.start(
108 self.protocolCombo.currentText() + self.vcsUrlEdit.text())
109 if dlg.exec_() == QDialog.Accepted:
110 url = dlg.getSelectedUrl()
111 if url:
112 protocol = url.split("://")[0]
113 path = url.split("://")[1]
114 self.protocolCombo.setCurrentIndex(
115 self.protocolCombo.findText(protocol + "://"))
116 self.vcsUrlEdit.setText(path)
117
118 @pyqtSlot()
119 def on_projectDirButton_clicked(self):
120 """
121 Private slot to display a directory selection dialog.
122 """
123 directory = E5FileDialog.getExistingDirectory(
124 self,
125 self.tr("Select Project Directory"),
126 self.vcsProjectDirEdit.text(),
127 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
128
129 if directory:
130 self.vcsProjectDirEdit.setText(
131 Utilities.toNativeSeparators(directory))
132 100
133 def on_layoutCheckBox_toggled(self, checked): 101 def on_layoutCheckBox_toggled(self, checked):
134 """ 102 """
135 Private slot to handle the change of the layout checkbox. 103 Private slot to handle the change of the layout checkbox.
136 104
147 Private slot to switch the status of the directory selection button. 115 Private slot to switch the status of the directory selection button.
148 116
149 @param protocol name of the selected protocol (string) 117 @param protocol name of the selected protocol (string)
150 """ 118 """
151 if protocol == "file://": 119 if protocol == "file://":
152 self.networkPath = self.vcsUrlEdit.text() 120 self.networkPath = self.vcsUrlPicker.text()
153 self.vcsUrlEdit.setText(self.localPath) 121 self.vcsUrlPicker.setText(self.localPath)
154 self.vcsUrlLabel.setText(self.tr("Pat&h:")) 122 self.vcsUrlLabel.setText(self.tr("Pat&h:"))
155 self.localProtocol = True 123 self.localProtocol = True
124 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode)
156 else: 125 else:
157 if self.localProtocol: 126 if self.localProtocol:
158 self.localPath = self.vcsUrlEdit.text() 127 self.localPath = self.vcsUrlPicker.text()
159 self.vcsUrlEdit.setText(self.networkPath) 128 self.vcsUrlPicker.setText(self.networkPath)
160 self.vcsUrlLabel.setText(self.tr("&URL:")) 129 self.vcsUrlLabel.setText(self.tr("&URL:"))
161 self.localProtocol = False 130 self.localProtocol = False
131 self.vcsUrlPicker.setMode(E5PathPickerModes.CustomMode)
162 132
163 @pyqtSlot(str) 133 @pyqtSlot(str)
164 def on_vcsUrlEdit_textChanged(self, txt): 134 def on_vcsUrlPicker_textChanged(self, txt):
165 """ 135 """
166 Private slot to handle changes of the URL. 136 Private slot to handle changes of the URL.
167 137
168 @param txt current text of the line edit (string) 138 @param txt current text of the line edit (string)
169 """ 139 """
176 146
177 @return a tuple of a string (project directory) and a dictionary 147 @return a tuple of a string (project directory) and a dictionary
178 containing the data entered. 148 containing the data entered.
179 """ 149 """
180 scheme = self.protocolCombo.currentText() 150 scheme = self.protocolCombo.currentText()
181 url = self.vcsUrlEdit.text() 151 url = self.vcsUrlPicker.text()
182 vcsdatadict = { 152 vcsdatadict = {
183 "url": '{0}{1}'.format(scheme, url), 153 "url": '{0}{1}'.format(scheme, url),
184 "tag": self.vcsTagEdit.text(), 154 "tag": self.vcsTagEdit.text(),
185 "standardLayout": self.layoutCheckBox.isChecked(), 155 "standardLayout": self.layoutCheckBox.isChecked(),
186 } 156 }
187 return (self.vcsProjectDirEdit.text(), vcsdatadict) 157 return (self.vcsProjectDirPicker.text(), vcsdatadict)

eric ide

mercurial