Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py

changeset 5554
c477ae02bf5f
parent 5549
fa21bfab0a29
child 6048
82ad8ec9548c
equal deleted inserted replaced
5553:d0e3207d1e8f 5554:c477ae02bf5f
9 """ 9 """
10 10
11 from __future__ import unicode_literals 11 from __future__ import unicode_literals
12 12
13 from PyQt5.QtCore import pyqtSlot, QUrl 13 from PyQt5.QtCore import pyqtSlot, QUrl
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox
15 15
16 from E5Gui.E5PathPicker import E5PathPickerModes 16 from E5Gui.E5PathPicker import E5PathPickerModes
17 17
18 from .Ui_HgNewProjectOptionsDialog import Ui_HgNewProjectOptionsDialog 18 from .Ui_HgNewProjectOptionsDialog import Ui_HgNewProjectOptionsDialog
19 from .Config import ConfigHgSchemes 19 from .Config import ConfigHgSchemes
20 20
21 import Utilities 21 import Utilities
22 import Preferences 22 import Preferences
23 import UI.PixmapCache
23 24
24 25
25 class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog): 26 class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog):
26 """ 27 """
27 Class implementing the Options Dialog for a new project from the 28 Class implementing the Options Dialog for a new project from the
36 """ 37 """
37 super(HgNewProjectOptionsDialog, self).__init__(parent) 38 super(HgNewProjectOptionsDialog, self).__init__(parent)
38 self.setupUi(self) 39 self.setupUi(self)
39 40
40 self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode) 41 self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode)
42
43 self.__vcs = vcs
44
45 vcsUrlHistory = self.__vcs.getPlugin().getPreferences(
46 "RepositoryUrlHistory")
41 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode) 47 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode)
48 self.vcsUrlPicker.setInsertPolicy(QComboBox.InsertAtTop)
49 self.vcsUrlPicker.setSizeAdjustPolicy(
50 QComboBox.AdjustToMinimumContentsLength)
51 self.vcsUrlPicker.setPathsList(vcsUrlHistory)
52 self.vcsUrlClearHistoryButton.setIcon(
53 UI.PixmapCache.getIcon("editDelete.png"))
54 self.vcsUrlPicker.setText("")
42 55
43 ipath = Preferences.getMultiProject("Workspace") or \ 56 ipath = Preferences.getMultiProject("Workspace") or \
44 Utilities.getHomeDir() 57 Utilities.getHomeDir()
45 self.__initPaths = [ 58 self.__initPaths = [
46 Utilities.fromNativeSeparators(ipath), 59 Utilities.fromNativeSeparators(ipath),
47 Utilities.fromNativeSeparators(ipath) + "/", 60 Utilities.fromNativeSeparators(ipath) + "/",
48 ] 61 ]
49 self.vcsProjectDirPicker.setText(self.__initPaths[0]) 62 self.vcsProjectDirPicker.setText(self.__initPaths[0])
50 63
51 self.lfNoteLabel.setVisible(vcs.isExtensionActive("largefiles")) 64 self.lfNoteLabel.setVisible(
52 self.largeCheckBox.setVisible(vcs.isExtensionActive("largefiles")) 65 self.__vcs.isExtensionActive("largefiles"))
66 self.largeCheckBox.setVisible(
67 self.__vcs.isExtensionActive("largefiles"))
53 68
54 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 69 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
55 70
56 msh = self.minimumSizeHint() 71 msh = self.minimumSizeHint()
57 self.resize(max(self.width(), msh.width()), msh.height()) 72 self.resize(max(self.width(), msh.width()), msh.height())
79 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) 94 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
80 95
81 self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file" or 96 self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file" or
82 len(txt) == 0) 97 len(txt) == 0)
83 98
99 @pyqtSlot()
100 def on_vcsUrlClearHistoryButton_clicked(self):
101 """
102 Private slot to clear the history of entered repository URLs.
103 """
104 currentVcsUrl = self.vcsUrlPicker.text()
105 self.vcsUrlPicker.clear()
106 self.vcsUrlPicker.setText(currentVcsUrl)
107
108 self.__saveHistory()
109
84 def getData(self): 110 def getData(self):
85 """ 111 """
86 Public slot to retrieve the data entered into the dialog. 112 Public slot to retrieve the data entered into the dialog and to
113 save the history of entered repository URLs.
87 114
88 @return a tuple of a string (project directory) and a dictionary 115 @return a tuple of a string (project directory) and a dictionary
89 containing the data entered. 116 containing the data entered.
90 """ 117 """
118 self.__saveHistory()
119
91 url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/")) 120 url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/"))
92 vcsdatadict = { 121 vcsdatadict = {
93 "url": url.toString(QUrl.None_), 122 "url": url.toString(QUrl.None_),
94 "revision": self.vcsRevisionEdit.text(), 123 "revision": self.vcsRevisionEdit.text(),
95 "largefiles": self.largeCheckBox.isChecked(), 124 "largefiles": self.largeCheckBox.isChecked(),
96 } 125 }
97 return (self.vcsProjectDirPicker.text(), vcsdatadict) 126 return (self.vcsProjectDirPicker.text(), vcsdatadict)
127
128 def __saveHistory(self):
129 """
130 Private method to save the repository URL history.
131 """
132 url = self.vcsUrlPicker.text()
133 vcsUrlHistory = self.vcsUrlPicker.getPathItems()
134 if url not in vcsUrlHistory:
135 vcsUrlHistory.insert(0, url)
136
137 # max. list sizes is hard coded to 20 entries
138 newVcsUrlHistory = [url for url in vcsUrlHistory if url]
139 if len(newVcsUrlHistory) > 20:
140 newVcsUrlHistory = newVcsUrlHistory[:20]
141
142 self.__vcs.getPlugin().setPreferences(
143 "RepositoryUrlHistory", newVcsUrlHistory)

eric ide

mercurial