PluginAssistantEric.py

changeset 30
8f4d794d8ee0
parent 26
b48e3ff07482
child 32
68ef15fe34c3
equal deleted inserted replaced
29:402d146da2f1 30:8f4d794d8ee0
21 # Start-Of-Header 21 # Start-Of-Header
22 name = "Assistant Eric Plugin" 22 name = "Assistant Eric Plugin"
23 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 23 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
24 autoactivate = True 24 autoactivate = True
25 deactivateable = True 25 deactivateable = True
26 version = "2.1.2" 26 version = "2.2.0"
27 className = "AssistantEricPlugin" 27 className = "AssistantEricPlugin"
28 packageName = "AssistantEric" 28 packageName = "AssistantEric"
29 shortDescription = "Alternative autocompletion and calltips provider." 29 shortDescription = "Alternative autocompletion and calltips provider."
30 longDescription = """This plugin implements an alternative autocompletion and""" \ 30 longDescription = """This plugin implements an alternative autocompletion and""" \
31 """ calltips provider.""" 31 """ calltips provider."""
35 35
36 error = "" 36 error = ""
37 37
38 assistantEricPluginObject = None 38 assistantEricPluginObject = None
39 39
40
40 def createAutoCompletionPage(configDlg): 41 def createAutoCompletionPage(configDlg):
41 """ 42 """
42 Module function to create the autocompletion configuration page. 43 Module function to create the autocompletion configuration page.
43 44
44 @return reference to the configuration page 45 @return reference to the configuration page
47 from AssistantEric.ConfigurationPages.AutoCompletionEricPage \ 48 from AssistantEric.ConfigurationPages.AutoCompletionEricPage \
48 import AutoCompletionEricPage 49 import AutoCompletionEricPage
49 page = AutoCompletionEricPage(assistantEricPluginObject) 50 page = AutoCompletionEricPage(assistantEricPluginObject)
50 return page 51 return page
51 52
53
52 def createCallTipsPage(configDlg): 54 def createCallTipsPage(configDlg):
53 """ 55 """
54 Module function to create the calltips configuration page. 56 Module function to create the calltips configuration page.
55 57
56 @return reference to the configuration page 58 @return reference to the configuration page
59 from AssistantEric.ConfigurationPages.CallTipsEricPage \ 61 from AssistantEric.ConfigurationPages.CallTipsEricPage \
60 import CallTipsEricPage 62 import CallTipsEricPage
61 page = CallTipsEricPage(assistantEricPluginObject) 63 page = CallTipsEricPage(assistantEricPluginObject)
62 return page 64 return page
63 65
66
64 def getConfigData(): 67 def getConfigData():
65 """ 68 """
66 Module function returning data as required by the configuration dialog. 69 Module function returning data as required by the configuration dialog.
67 70
68 @return dictionary containing the relevant data 71 @return dictionary containing the relevant data
69 """ 72 """
70 return { 73 return {
71 "ericAutoCompletionPage" : \ 74 "ericAutoCompletionPage": \
72 [QApplication.translate("AssistantEricPlugin", "Eric"), 75 [QApplication.translate("AssistantEricPlugin", "Eric"),
73 os.path.join("AssistantEric", "ConfigurationPages", 76 os.path.join("AssistantEric", "ConfigurationPages",
74 "eric.png"), 77 "eric.png"),
75 createAutoCompletionPage, "editorAutocompletionPage", None], 78 createAutoCompletionPage, "editorAutocompletionPage", None],
76 "ericCallTipsPage" : \ 79 "ericCallTipsPage": \
77 [QApplication.translate("AssistantEricPlugin", "Eric"), 80 [QApplication.translate("AssistantEricPlugin", "Eric"),
78 os.path.join("AssistantEric", "ConfigurationPages", 81 os.path.join("AssistantEric", "ConfigurationPages",
79 "eric.png"), 82 "eric.png"),
80 createCallTipsPage, "editorCalltipsPage", None], 83 createCallTipsPage, "editorCalltipsPage", None],
81 } 84 }
82 85
86
83 def prepareUninstall(): 87 def prepareUninstall():
84 """ 88 """
85 Module function to prepare for an uninstallation. 89 Module function to prepare for an uninstallation.
86 """ 90 """
87 assistant = AssistantEricPlugin(None) 91 assistant = AssistantEricPlugin(None)
88 assistant.prepareUninstall() 92 assistant.prepareUninstall()
89 93
94
90 class AssistantEricPlugin(QObject): 95 class AssistantEricPlugin(QObject):
91 """ 96 """
92 Class implementing the Eric assistant plugin. 97 Class implementing the Eric assistant plugin.
93 """ 98 """
94 def __init__(self, ui): 99 def __init__(self, ui):
99 """ 104 """
100 QObject.__init__(self, ui) 105 QObject.__init__(self, ui)
101 self.__ui = ui 106 self.__ui = ui
102 self.__initialize() 107 self.__initialize()
103 108
104 self.__newStyle = ui.versionIsNewer("5.0.99", "20100811")
105
106 self.__defaults = { 109 self.__defaults = {
107 "AutoCompletionEnabled" : False, 110 "AutoCompletionEnabled": False,
108 "AutoCompletionSource" : AcsAPIs | AcsProject, 111 "AutoCompletionSource": AcsAPIs | AcsProject,
109 "CalltipsEnabled" : False, 112 "CalltipsEnabled": False,
110 "CallTipsContextShown" : 1, 113 "CallTipsContextShown": 1,
111 } 114 }
112 115
113 self.__translator = None 116 self.__translator = None
114 self.__loadTranslator() 117 self.__loadTranslator()
115 118
116 def __initialize(self): 119 def __initialize(self):
117 """ 120 """
118 Private slot to (re)initialize the plugin. 121 Private slot to (re)initialize the plugin.
119 """ 122 """
120 self.__object = None 123 self.__object = None
124
125 def __checkUiVersion(self):
126 """
127 Private method to check, if the IDE has a suitable version.
128
129 @return flag indicating a suitable version (boolean)
130 """
131 global error
132
133 suitable = self.__ui.versionIsNewer("5.0.99", "20100811")
134 if not suitable:
135 error = self.trUtf8("Your version of eric5 is not supported.")
136 return suitable
121 137
122 def __checkQSql(self): 138 def __checkQSql(self):
123 """ 139 """
124 Private method to perform some checks on QSql. 140 Private method to perform some checks on QSql.
125 141
147 @return tuple of None and activation status (boolean) 163 @return tuple of None and activation status (boolean)
148 """ 164 """
149 global error 165 global error
150 error = "" # clear previous error 166 error = "" # clear previous error
151 167
152 if not self.__checkQSql(): 168 if not self.__checkUiVersion() or \
169 not self.__checkQSql():
153 return None, False 170 return None, False
154 171
155 global assistantEricPluginObject 172 global assistantEricPluginObject
156 assistantEricPluginObject = self 173 assistantEricPluginObject = self
157 174
158 from AssistantEric.Assistant import Assistant 175 from AssistantEric.Assistant import Assistant
159 176
160 self.__object = Assistant(self, self.__newStyle, self.__ui) 177 self.__object = Assistant(self, self.__ui)
161 e5App().registerPluginObject("AssistantEric", self.__object) 178 e5App().registerPluginObject("AssistantEric", self.__object)
162 179
163 self.__object.activate() 180 self.__object.activate()
164 181
165 return None, True 182 return None, True

eric ide

mercurial