--- a/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py Fri Feb 24 18:51:36 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py Fri Feb 24 18:58:27 2017 +0100 @@ -11,7 +11,7 @@ from __future__ import unicode_literals from PyQt5.QtCore import pyqtSlot, QUrl -from PyQt5.QtWidgets import QDialog, QDialogButtonBox +from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox from E5Gui.E5PathPicker import E5PathPickerModes @@ -20,6 +20,7 @@ import Utilities import Preferences +import UI.PixmapCache class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog): @@ -38,7 +39,19 @@ self.setupUi(self) self.vcsProjectDirPicker.setMode(E5PathPickerModes.DirectoryMode) + + self.__vcs = vcs + + vcsUrlHistory = self.__vcs.getPlugin().getPreferences( + "RepositoryUrlHistory") self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode) + self.vcsUrlPicker.setInsertPolicy(QComboBox.InsertAtTop) + self.vcsUrlPicker.setSizeAdjustPolicy( + QComboBox.AdjustToMinimumContentsLength) + self.vcsUrlPicker.setPathsList(vcsUrlHistory) + self.vcsUrlClearHistoryButton.setIcon( + UI.PixmapCache.getIcon("editDelete.png")) + self.vcsUrlPicker.setText("") ipath = Preferences.getMultiProject("Workspace") or \ Utilities.getHomeDir() @@ -48,8 +61,10 @@ ] self.vcsProjectDirPicker.setText(self.__initPaths[0]) - self.lfNoteLabel.setVisible(vcs.isExtensionActive("largefiles")) - self.largeCheckBox.setVisible(vcs.isExtensionActive("largefiles")) + self.lfNoteLabel.setVisible( + self.__vcs.isExtensionActive("largefiles")) + self.largeCheckBox.setVisible( + self.__vcs.isExtensionActive("largefiles")) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) @@ -81,13 +96,27 @@ self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file" or len(txt) == 0) + @pyqtSlot() + def on_vcsUrlClearHistoryButton_clicked(self): + """ + Private slot to clear the history of entered repository URLs. + """ + currentVcsUrl = self.vcsUrlPicker.text() + self.vcsUrlPicker.clear() + self.vcsUrlPicker.setText(currentVcsUrl) + + self.__saveHistory() + def getData(self): """ - Public slot to retrieve the data entered into the dialog. + Public slot to retrieve the data entered into the dialog and to + save the history of entered repository URLs. @return a tuple of a string (project directory) and a dictionary containing the data entered. """ + self.__saveHistory() + url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/")) vcsdatadict = { "url": url.toString(QUrl.None_), @@ -95,3 +124,20 @@ "largefiles": self.largeCheckBox.isChecked(), } return (self.vcsProjectDirPicker.text(), vcsdatadict) + + def __saveHistory(self): + """ + Private method to save the repository URL history. + """ + url = self.vcsUrlPicker.text() + vcsUrlHistory = self.vcsUrlPicker.getPathItems() + if url not in vcsUrlHistory: + vcsUrlHistory.insert(0, url) + + # max. list sizes is hard coded to 20 entries + newVcsUrlHistory = [url for url in vcsUrlHistory if url] + if len(newVcsUrlHistory) > 20: + newVcsUrlHistory = newVcsUrlHistory[:20] + + self.__vcs.getPlugin().setPreferences( + "RepositoryUrlHistory", newVcsUrlHistory)