83 |
83 |
84 |
84 |
85 def displayString(): |
85 def displayString(): |
86 """ |
86 """ |
87 Public function to get the display string. |
87 Public function to get the display string. |
88 |
88 |
89 @return display string (string) |
89 @return display string (string) |
90 """ |
90 """ |
91 try: |
91 try: |
92 import pysvn # __IGNORE_WARNING__ |
92 import pysvn # __IGNORE_WARNING__ |
93 return QCoreApplication.translate('VcsPySvnPlugin', |
93 |
94 'Subversion (pysvn)') |
94 return QCoreApplication.translate("VcsPySvnPlugin", "Subversion (pysvn)") |
95 except ImportError: |
95 except ImportError: |
96 return "" |
96 return "" |
97 |
97 |
|
98 |
98 subversionCfgPluginObject = None |
99 subversionCfgPluginObject = None |
99 |
100 |
100 |
101 |
101 def createConfigurationPage(configDlg): |
102 def createConfigurationPage(configDlg): |
102 """ |
103 """ |
103 Module function to create the configuration page. |
104 Module function to create the configuration page. |
104 |
105 |
105 @param configDlg reference to the configuration dialog (QDialog) |
106 @param configDlg reference to the configuration dialog (QDialog) |
106 @return reference to the configuration page |
107 @return reference to the configuration page |
107 """ |
108 """ |
108 global subversionCfgPluginObject |
109 global subversionCfgPluginObject |
109 from VcsPlugins.vcsPySvn.ConfigurationPage.SubversionPage import ( |
110 from VcsPlugins.vcsPySvn.ConfigurationPage.SubversionPage import SubversionPage |
110 SubversionPage |
111 |
111 ) |
|
112 if subversionCfgPluginObject is None: |
112 if subversionCfgPluginObject is None: |
113 subversionCfgPluginObject = VcsPySvnPlugin(None) |
113 subversionCfgPluginObject = VcsPySvnPlugin(None) |
114 page = SubversionPage(subversionCfgPluginObject) |
114 page = SubversionPage(subversionCfgPluginObject) |
115 return page |
115 return page |
116 |
116 |
117 |
117 |
118 def getConfigData(): |
118 def getConfigData(): |
119 """ |
119 """ |
120 Module function returning data as required by the configuration dialog. |
120 Module function returning data as required by the configuration dialog. |
121 |
121 |
122 @return dictionary with key "zzz_subversionPage" containing the relevant |
122 @return dictionary with key "zzz_subversionPage" containing the relevant |
123 data |
123 data |
124 """ |
124 """ |
125 return { |
125 return { |
126 "zzz_subversionPage": |
126 "zzz_subversionPage": [ |
127 [QCoreApplication.translate("VcsPySvnPlugin", "Subversion"), |
127 QCoreApplication.translate("VcsPySvnPlugin", "Subversion"), |
128 os.path.join("VcsPlugins", "vcsPySvn", "icons", |
128 os.path.join( |
129 "preferences-subversion.svg"), |
129 "VcsPlugins", "vcsPySvn", "icons", "preferences-subversion.svg" |
130 createConfigurationPage, "vcsPage", None], |
130 ), |
|
131 createConfigurationPage, |
|
132 "vcsPage", |
|
133 None, |
|
134 ], |
131 } |
135 } |
132 |
136 |
133 |
137 |
134 def prepareUninstall(): |
138 def prepareUninstall(): |
135 """ |
139 """ |
136 Module function to prepare for an uninstallation. |
140 Module function to prepare for an uninstallation. |
137 """ |
141 """ |
138 if not ericApp().getObject("PluginManager").isPluginLoaded( |
142 if not ericApp().getObject("PluginManager").isPluginLoaded("PluginVcsSubversion"): |
139 "PluginVcsSubversion"): |
|
140 Preferences.getSettings().remove("Subversion") |
143 Preferences.getSettings().remove("Subversion") |
141 |
144 |
142 |
145 |
143 class VcsPySvnPlugin(QObject): |
146 class VcsPySvnPlugin(QObject): |
144 """ |
147 """ |
145 Class implementing the PySvn version control plugin. |
148 Class implementing the PySvn version control plugin. |
146 """ |
149 """ |
|
150 |
147 def __init__(self, ui): |
151 def __init__(self, ui): |
148 """ |
152 """ |
149 Constructor |
153 Constructor |
150 |
154 |
151 @param ui reference to the user interface object (UI.UserInterface) |
155 @param ui reference to the user interface object (UI.UserInterface) |
152 """ |
156 """ |
153 super().__init__(ui) |
157 super().__init__(ui) |
154 self.__ui = ui |
158 self.__ui = ui |
155 |
159 |
156 self.__subversionDefaults = { |
160 self.__subversionDefaults = { |
157 "StopLogOnCopy": 1, |
161 "StopLogOnCopy": 1, |
158 "LogLimit": 20, |
162 "LogLimit": 20, |
159 } |
163 } |
160 |
164 |
161 from VcsPlugins.vcsPySvn.ProjectHelper import PySvnProjectHelper |
165 from VcsPlugins.vcsPySvn.ProjectHelper import PySvnProjectHelper |
|
166 |
162 self.__projectHelperObject = PySvnProjectHelper(None, None) |
167 self.__projectHelperObject = PySvnProjectHelper(None, None) |
163 with contextlib.suppress(KeyError): |
168 with contextlib.suppress(KeyError): |
164 ericApp().registerPluginObject( |
169 ericApp().registerPluginObject( |
165 pluginTypename, self.__projectHelperObject, pluginType) |
170 pluginTypename, self.__projectHelperObject, pluginType |
|
171 ) |
166 readShortcuts(pluginName=pluginTypename) |
172 readShortcuts(pluginName=pluginTypename) |
167 |
173 |
168 def getProjectHelper(self): |
174 def getProjectHelper(self): |
169 """ |
175 """ |
170 Public method to get a reference to the project helper object. |
176 Public method to get a reference to the project helper object. |
171 |
177 |
172 @return reference to the project helper object |
178 @return reference to the project helper object |
173 """ |
179 """ |
174 return self.__projectHelperObject |
180 return self.__projectHelperObject |
175 |
181 |
176 def initToolbar(self, ui, toolbarManager): |
182 def initToolbar(self, ui, toolbarManager): |
177 """ |
183 """ |
178 Public slot to initialize the VCS toolbar. |
184 Public slot to initialize the VCS toolbar. |
179 |
185 |
180 @param ui reference to the main window (UserInterface) |
186 @param ui reference to the main window (UserInterface) |
181 @param toolbarManager reference to a toolbar manager object |
187 @param toolbarManager reference to a toolbar manager object |
182 (EricToolBarManager) |
188 (EricToolBarManager) |
183 """ |
189 """ |
184 if self.__projectHelperObject: |
190 if self.__projectHelperObject: |
185 self.__projectHelperObject.initToolbar(ui, toolbarManager) |
191 self.__projectHelperObject.initToolbar(ui, toolbarManager) |
186 |
192 |
187 def activate(self): |
193 def activate(self): |
188 """ |
194 """ |
189 Public method to activate this plugin. |
195 Public method to activate this plugin. |
190 |
196 |
191 @return tuple of reference to instantiated viewmanager and |
197 @return tuple of reference to instantiated viewmanager and |
192 activation status (boolean) |
198 activation status (boolean) |
193 """ |
199 """ |
194 from VcsPlugins.vcsPySvn.subversion import Subversion |
200 from VcsPlugins.vcsPySvn.subversion import Subversion |
|
201 |
195 self.__object = Subversion(self, self.__ui) |
202 self.__object = Subversion(self, self.__ui) |
196 |
203 |
197 tb = self.__ui.getToolbar("vcs")[1] |
204 tb = self.__ui.getToolbar("vcs")[1] |
198 tb.setVisible(False) |
205 tb.setVisible(False) |
199 tb.setEnabled(False) |
206 tb.setEnabled(False) |
200 |
207 |
201 tb = self.__ui.getToolbar("pysvn")[1] |
208 tb = self.__ui.getToolbar("pysvn")[1] |
202 tb.setVisible(Preferences.getVCS("ShowVcsToolbar")) |
209 tb.setVisible(Preferences.getVCS("ShowVcsToolbar")) |
203 tb.setEnabled(True) |
210 tb.setEnabled(True) |
204 |
211 |
205 return self.__object, True |
212 return self.__object, True |
206 |
213 |
207 def deactivate(self): |
214 def deactivate(self): |
208 """ |
215 """ |
209 Public method to deactivate this plugin. |
216 Public method to deactivate this plugin. |
210 """ |
217 """ |
211 self.__object = None |
218 self.__object = None |
212 |
219 |
213 tb = self.__ui.getToolbar("pysvn")[1] |
220 tb = self.__ui.getToolbar("pysvn")[1] |
214 tb.setVisible(False) |
221 tb.setVisible(False) |
215 tb.setEnabled(False) |
222 tb.setEnabled(False) |
216 |
223 |
217 tb = self.__ui.getToolbar("vcs")[1] |
224 tb = self.__ui.getToolbar("vcs")[1] |
218 tb.setVisible(Preferences.getVCS("ShowVcsToolbar")) |
225 tb.setVisible(Preferences.getVCS("ShowVcsToolbar")) |
219 tb.setEnabled(True) |
226 tb.setEnabled(True) |
220 |
227 |
221 def getPreferences(self, key): |
228 def getPreferences(self, key): |
222 """ |
229 """ |
223 Public method to retrieve the various settings. |
230 Public method to retrieve the various settings. |
224 |
231 |
225 @param key the key of the value to get |
232 @param key the key of the value to get |
226 @return the requested refactoring setting |
233 @return the requested refactoring setting |
227 """ |
234 """ |
228 if key in ["StopLogOnCopy"]: |
235 if key in ["StopLogOnCopy"]: |
229 return Preferences.toBool(Preferences.getSettings().value( |
236 return Preferences.toBool( |
230 "Subversion/" + key, self.__subversionDefaults[key])) |
237 Preferences.getSettings().value( |
|
238 "Subversion/" + key, self.__subversionDefaults[key] |
|
239 ) |
|
240 ) |
231 elif key in ["LogLimit"]: |
241 elif key in ["LogLimit"]: |
232 return int(Preferences.getSettings().value( |
242 return int( |
233 "Subversion/" + key, |
243 Preferences.getSettings().value( |
234 self.__subversionDefaults[key])) |
244 "Subversion/" + key, self.__subversionDefaults[key] |
|
245 ) |
|
246 ) |
235 elif key in ["Commits"]: |
247 elif key in ["Commits"]: |
236 return Preferences.toList(Preferences.getSettings().value( |
248 return Preferences.toList( |
237 "Subversion/" + key)) |
249 Preferences.getSettings().value("Subversion/" + key) |
|
250 ) |
238 else: |
251 else: |
239 return Preferences.getSettings().value("Subversion/" + key) |
252 return Preferences.getSettings().value("Subversion/" + key) |
240 |
253 |
241 def setPreferences(self, key, value): |
254 def setPreferences(self, key, value): |
242 """ |
255 """ |
243 Public method to store the various settings. |
256 Public method to store the various settings. |
244 |
257 |
245 @param key the key of the setting to be set |
258 @param key the key of the setting to be set |
246 @param value the value to be set |
259 @param value the value to be set |
247 """ |
260 """ |
248 Preferences.getSettings().setValue("Subversion/" + key, value) |
261 Preferences.getSettings().setValue("Subversion/" + key, value) |
249 |
262 |
250 def getServersPath(self): |
263 def getServersPath(self): |
251 """ |
264 """ |
252 Public method to get the filename of the servers file. |
265 Public method to get the filename of the servers file. |
253 |
266 |
254 @return filename of the servers file (string) |
267 @return filename of the servers file (string) |
255 """ |
268 """ |
256 return getServersPath() |
269 return getServersPath() |
257 |
270 |
258 def getConfigPath(self): |
271 def getConfigPath(self): |
259 """ |
272 """ |
260 Public method to get the filename of the config file. |
273 Public method to get the filename of the config file. |
261 |
274 |
262 @return filename of the config file (string) |
275 @return filename of the config file (string) |
263 """ |
276 """ |
264 return getConfigPath() |
277 return getConfigPath() |
265 |
278 |
266 def prepareUninstall(self): |
279 def prepareUninstall(self): |
267 """ |
280 """ |
268 Public method to prepare for an uninstallation. |
281 Public method to prepare for an uninstallation. |
269 """ |
282 """ |
270 ericApp().unregisterPluginObject(pluginTypename) |
283 ericApp().unregisterPluginObject(pluginTypename) |
271 |
284 |
272 def prepareUnload(self): |
285 def prepareUnload(self): |
273 """ |
286 """ |
274 Public method to prepare for an unload. |
287 Public method to prepare for an unload. |
275 """ |
288 """ |
276 if self.__projectHelperObject: |
289 if self.__projectHelperObject: |
277 self.__projectHelperObject.removeToolbar( |
290 self.__projectHelperObject.removeToolbar( |
278 self.__ui, ericApp().getObject("ToolbarManager")) |
291 self.__ui, ericApp().getObject("ToolbarManager") |
|
292 ) |
279 ericApp().unregisterPluginObject(pluginTypename) |
293 ericApp().unregisterPluginObject(pluginTypename) |