src/eric7/Plugins/VcsPlugins/vcsMercurial/HgNewProjectOptionsDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
24 class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog): 24 class HgNewProjectOptionsDialog(QDialog, Ui_HgNewProjectOptionsDialog):
25 """ 25 """
26 Class implementing the Options Dialog for a new project from the 26 Class implementing the Options Dialog for a new project from the
27 repository. 27 repository.
28 """ 28 """
29
29 def __init__(self, vcs, parent=None): 30 def __init__(self, vcs, parent=None):
30 """ 31 """
31 Constructor 32 Constructor
32 33
33 @param vcs reference to the version control object 34 @param vcs reference to the version control object
34 @param parent parent widget (QWidget) 35 @param parent parent widget (QWidget)
35 """ 36 """
36 super().__init__(parent) 37 super().__init__(parent)
37 self.setupUi(self) 38 self.setupUi(self)
38 39
39 self.vcsProjectDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 40 self.vcsProjectDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
40 41
41 self.__vcs = vcs 42 self.__vcs = vcs
42 43
43 vcsUrlHistory = self.__vcs.getPlugin().getPreferences( 44 vcsUrlHistory = self.__vcs.getPlugin().getPreferences("RepositoryUrlHistory")
44 "RepositoryUrlHistory")
45 self.vcsUrlPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 45 self.vcsUrlPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
46 self.vcsUrlPicker.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop) 46 self.vcsUrlPicker.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop)
47 self.vcsUrlPicker.setSizeAdjustPolicy( 47 self.vcsUrlPicker.setSizeAdjustPolicy(
48 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) 48 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon
49 )
49 self.vcsUrlPicker.setPathsList(vcsUrlHistory) 50 self.vcsUrlPicker.setPathsList(vcsUrlHistory)
50 self.vcsUrlClearHistoryButton.setIcon( 51 self.vcsUrlClearHistoryButton.setIcon(UI.PixmapCache.getIcon("editDelete"))
51 UI.PixmapCache.getIcon("editDelete"))
52 self.vcsUrlPicker.setText("") 52 self.vcsUrlPicker.setText("")
53 53
54 ipath = ( 54 ipath = Preferences.getMultiProject("Workspace") or Utilities.getHomeDir()
55 Preferences.getMultiProject("Workspace") or
56 Utilities.getHomeDir()
57 )
58 self.__initPaths = [ 55 self.__initPaths = [
59 Utilities.fromNativeSeparators(ipath), 56 Utilities.fromNativeSeparators(ipath),
60 Utilities.fromNativeSeparators(ipath) + "/", 57 Utilities.fromNativeSeparators(ipath) + "/",
61 ] 58 ]
62 self.vcsProjectDirPicker.setText(self.__initPaths[0]) 59 self.vcsProjectDirPicker.setText(self.__initPaths[0])
63 60
64 self.lfNoteLabel.setVisible( 61 self.lfNoteLabel.setVisible(self.__vcs.isExtensionActive("largefiles"))
65 self.__vcs.isExtensionActive("largefiles")) 62 self.largeCheckBox.setVisible(self.__vcs.isExtensionActive("largefiles"))
66 self.largeCheckBox.setVisible( 63
67 self.__vcs.isExtensionActive("largefiles")) 64 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
68 65
69 self.buttonBox.button(
70 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
71
72 msh = self.minimumSizeHint() 66 msh = self.minimumSizeHint()
73 self.resize(max(self.width(), msh.width()), msh.height()) 67 self.resize(max(self.width(), msh.width()), msh.height())
74 68
75 @pyqtSlot(str) 69 @pyqtSlot(str)
76 def on_vcsProjectDirPicker_textChanged(self, txt): 70 def on_vcsProjectDirPicker_textChanged(self, txt):
77 """ 71 """
78 Private slot to handle a change of the project directory. 72 Private slot to handle a change of the project directory.
79 73
80 @param txt name of the project directory (string) 74 @param txt name of the project directory (string)
81 """ 75 """
82 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( 76 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
83 bool(txt) and 77 bool(txt) and Utilities.fromNativeSeparators(txt) not in self.__initPaths
84 Utilities.fromNativeSeparators(txt) not in self.__initPaths) 78 )
85 79
86 @pyqtSlot(str) 80 @pyqtSlot(str)
87 def on_vcsUrlPicker_textChanged(self, txt): 81 def on_vcsUrlPicker_textChanged(self, txt):
88 """ 82 """
89 Private slot to handle changes of the URL. 83 Private slot to handle changes of the URL.
90 84
91 @param txt current text of the line edit (string) 85 @param txt current text of the line edit (string)
92 """ 86 """
93 url = QUrl.fromUserInput(txt) 87 url = QUrl.fromUserInput(txt)
94 enable = url.isValid() and url.scheme() in ConfigHgSchemes 88 enable = url.isValid() and url.scheme() in ConfigHgSchemes
95 self.buttonBox.button( 89 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
96 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) 90
97 91 self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file" or len(txt) == 0)
98 self.vcsUrlPicker.setPickerEnabled(url.scheme() == "file" or 92
99 len(txt) == 0)
100
101 @pyqtSlot() 93 @pyqtSlot()
102 def on_vcsUrlClearHistoryButton_clicked(self): 94 def on_vcsUrlClearHistoryButton_clicked(self):
103 """ 95 """
104 Private slot to clear the history of entered repository URLs. 96 Private slot to clear the history of entered repository URLs.
105 """ 97 """
106 currentVcsUrl = self.vcsUrlPicker.text() 98 currentVcsUrl = self.vcsUrlPicker.text()
107 self.vcsUrlPicker.clear() 99 self.vcsUrlPicker.clear()
108 self.vcsUrlPicker.setText(currentVcsUrl) 100 self.vcsUrlPicker.setText(currentVcsUrl)
109 101
110 self.__saveHistory() 102 self.__saveHistory()
111 103
112 def getData(self): 104 def getData(self):
113 """ 105 """
114 Public slot to retrieve the data entered into the dialog and to 106 Public slot to retrieve the data entered into the dialog and to
115 save the history of entered repository URLs. 107 save the history of entered repository URLs.
116 108
117 @return a tuple of a string (project directory) and a dictionary 109 @return a tuple of a string (project directory) and a dictionary
118 containing the data entered. 110 containing the data entered.
119 """ 111 """
120 self.__saveHistory() 112 self.__saveHistory()
121 113
122 url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/")) 114 url = QUrl.fromUserInput(self.vcsUrlPicker.text().replace("\\", "/"))
123 vcsdatadict = { 115 vcsdatadict = {
124 "url": url.toString(QUrl.UrlFormattingOption.None_), 116 "url": url.toString(QUrl.UrlFormattingOption.None_),
125 "revision": self.vcsRevisionEdit.text(), 117 "revision": self.vcsRevisionEdit.text(),
126 "largefiles": self.largeCheckBox.isChecked(), 118 "largefiles": self.largeCheckBox.isChecked(),
127 } 119 }
128 return (self.vcsProjectDirPicker.text(), vcsdatadict) 120 return (self.vcsProjectDirPicker.text(), vcsdatadict)
129 121
130 def __saveHistory(self): 122 def __saveHistory(self):
131 """ 123 """
132 Private method to save the repository URL history. 124 Private method to save the repository URL history.
133 """ 125 """
134 url = self.vcsUrlPicker.text() 126 url = self.vcsUrlPicker.text()
135 vcsUrlHistory = self.vcsUrlPicker.getPathItems() 127 vcsUrlHistory = self.vcsUrlPicker.getPathItems()
136 if url not in vcsUrlHistory: 128 if url not in vcsUrlHistory:
137 vcsUrlHistory.insert(0, url) 129 vcsUrlHistory.insert(0, url)
138 130
139 # max. list sizes is hard coded to 20 entries 131 # max. list sizes is hard coded to 20 entries
140 newVcsUrlHistory = [url for url in vcsUrlHistory if url] 132 newVcsUrlHistory = [url for url in vcsUrlHistory if url]
141 if len(newVcsUrlHistory) > 20: 133 if len(newVcsUrlHistory) > 20:
142 newVcsUrlHistory = newVcsUrlHistory[:20] 134 newVcsUrlHistory = newVcsUrlHistory[:20]
143 135
144 self.__vcs.getPlugin().setPreferences( 136 self.__vcs.getPlugin().setPreferences("RepositoryUrlHistory", newVcsUrlHistory)
145 "RepositoryUrlHistory", newVcsUrlHistory)

eric ide

mercurial