PluginRefactoringRope.py

branch
eric7
changeset 413
a4cba20ad7ab
parent 412
6fa5892b9097
child 414
af1d72eccf91
equal deleted inserted replaced
412:6fa5892b9097 413:a4cba20ad7ab
9 9
10 import contextlib 10 import contextlib
11 import os 11 import os
12 12
13 from PyQt6.QtCore import QCoreApplication, QObject, Qt, QTranslator 13 from PyQt6.QtCore import QCoreApplication, QObject, Qt, QTranslator
14 from PyQt6.QtGui import QPalette
14 15
15 from eric7 import Preferences, Utilities 16 from eric7 import Preferences, Utilities
16 from eric7.EricWidgets.EricApplication import ericApp 17 from eric7.EricWidgets.EricApplication import ericApp
17 18
18 # Start-Of-Header 19 # Start-Of-Header
37 error = "" 38 error = ""
38 39
39 refactoringRopePluginObject = None 40 refactoringRopePluginObject = None
40 41
41 42
42 def createAutoCompletionPage(configDlg): 43 def createAutoCompletionPage(configDlg): # noqa: U100
43 """ 44 """
44 Module function to create the autocompletion configuration page. 45 Module function to create the autocompletion configuration page.
45 46
46 @param configDlg reference to the configuration dialog 47 @param configDlg reference to the configuration dialog
47 @type ConfigurationWidget 48 @type ConfigurationWidget
48 @return reference to the configuration page 49 @return reference to the configuration page
49 @rtype AutoCompletionRopePage 50 @rtype AutoCompletionRopePage
50 """ 51 """
51 global refactoringRopePluginObject
52 from RefactoringRope.ConfigurationPage.AutoCompletionRopePage import ( 52 from RefactoringRope.ConfigurationPage.AutoCompletionRopePage import (
53 AutoCompletionRopePage, 53 AutoCompletionRopePage,
54 ) 54 )
55 55
56 global refactoringRopePluginObject
57
56 page = AutoCompletionRopePage(refactoringRopePluginObject) 58 page = AutoCompletionRopePage(refactoringRopePluginObject)
57 return page 59 return page
58 60
59 61
60 def createCallTipsPage(configDlg): 62 def createCallTipsPage(configDlg): # noqa: U100
61 """ 63 """
62 Module function to create the calltips configuration page. 64 Module function to create the calltips configuration page.
63 65
64 @param configDlg reference to the configuration dialog 66 @param configDlg reference to the configuration dialog
65 @type ConfigurationWidget 67 @type ConfigurationWidget
66 @return reference to the configuration page 68 @return reference to the configuration page
67 @rtype CallTipsRopePage 69 @rtype CallTipsRopePage
68 """ 70 """
71 from RefactoringRope.ConfigurationPage.CallTipsRopePage import CallTipsRopePage
72
69 global refactoringRopePluginObject 73 global refactoringRopePluginObject
70 from RefactoringRope.ConfigurationPage.CallTipsRopePage import CallTipsRopePage
71 74
72 page = CallTipsRopePage(refactoringRopePluginObject) 75 page = CallTipsRopePage(refactoringRopePluginObject)
73 return page 76 return page
74 77
75 78
76 def createMouseClickHandlerPage(configDlg): 79 def createMouseClickHandlerPage(configDlg): # noqa: U100
77 """ 80 """
78 Module function to create the mouse click handler configuration page. 81 Module function to create the mouse click handler configuration page.
79 82
80 @param configDlg reference to the configuration dialog 83 @param configDlg reference to the configuration dialog
81 @type ConfigurationWidget 84 @type ConfigurationWidget
82 @return reference to the configuration page 85 @return reference to the configuration page
83 @rtype MouseClickHandlerRopePage 86 @rtype MouseClickHandlerRopePage
84 """ 87 """
85 global refactoringRopePluginObject
86 from RefactoringRope.ConfigurationPage.MouseClickHandlerRopePage import ( 88 from RefactoringRope.ConfigurationPage.MouseClickHandlerRopePage import (
87 MouseClickHandlerRopePage, 89 MouseClickHandlerRopePage,
88 ) 90 )
89 91
92 global refactoringRopePluginObject
93
90 page = MouseClickHandlerRopePage(refactoringRopePluginObject) 94 page = MouseClickHandlerRopePage(refactoringRopePluginObject)
91 return page 95 return page
92 96
93 97
94 def getConfigData(): 98 def getConfigData():
99 @rtype dict 103 @rtype dict
100 """ 104 """
101 try: 105 try:
102 usesDarkPalette = ericApp().usesDarkPalette() 106 usesDarkPalette = ericApp().usesDarkPalette()
103 except AttributeError: 107 except AttributeError:
104 from PyQt6.QtGui import QPalette
105
106 palette = ericApp().palette() 108 palette = ericApp().palette()
107 lightness = palette.color(QPalette.Window).lightness() 109 lightness = palette.color(QPalette.Window).lightness()
108 usesDarkPalette = lightness <= 128 110 usesDarkPalette = lightness <= 128
109 iconSuffix = "dark" if usesDarkPalette else "light" 111 iconSuffix = "dark" if usesDarkPalette else "light"
110 112
205 Public method to activate this plugin. 207 Public method to activate this plugin.
206 208
207 @return tuple of None and activation status 209 @return tuple of None and activation status
208 @rtype tuple of (None, bool) 210 @rtype tuple of (None, bool)
209 """ 211 """
212 from RefactoringRope.CodeAssistServer import CodeAssistServer
213 from RefactoringRope.RefactoringServer import RefactoringServer
214
210 global refactoringRopePluginObject 215 global refactoringRopePluginObject
211 refactoringRopePluginObject = self 216 refactoringRopePluginObject = self
212 217
213 ericApp().getObject("PluginManager").shutdown.connect(self.__shutdown) 218 ericApp().getObject("PluginManager").shutdown.connect(self.__shutdown)
214 219
215 from RefactoringRope.CodeAssistServer import CodeAssistServer
216
217 self.__codeAssistServer = CodeAssistServer(self, self.__ui) 220 self.__codeAssistServer = CodeAssistServer(self, self.__ui)
218 self.__codeAssistServer.activate() 221 self.__codeAssistServer.activate()
219
220 from RefactoringRope.RefactoringServer import RefactoringServer
221 222
222 self.__refactoringServer = RefactoringServer(self, self.__ui) 223 self.__refactoringServer = RefactoringServer(self, self.__ui)
223 self.__refactoringServer.activate() 224 self.__refactoringServer.activate()
224 225
225 ericApp().getObject("PluginManager").shutdown.connect(self.__shutdown) 226 ericApp().getObject("PluginManager").shutdown.connect(self.__shutdown)
536 except ImportError: 537 except ImportError:
537 pipInstall(["rope"]) 538 pipInstall(["rope"])
538 539
539 540
540 # 541 #
541 # eflag: noqa = M801 542 # eflag: noqa = M801, U200

eric ide

mercurial