21 # Start-Of-Header |
21 # Start-Of-Header |
22 name = "Color String Plug-in" |
22 name = "Color String Plug-in" |
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.0.0" |
26 version = "2.0.1" |
27 className = "ColorStringPlugin" |
27 className = "ColorStringPlugin" |
28 packageName = "ColorString" |
28 packageName = "ColorString" |
29 shortDescription = "Insert color as string" |
29 shortDescription = "Insert color as string" |
30 longDescription = \ |
30 longDescription = \ |
31 """This plug-in implements a tool to select a color via a""" \ |
31 """This plug-in implements a tool to select a color via a""" \ |
155 act = menu.addSeparator() |
155 act = menu.addSeparator() |
156 self.__editors[editor].append(act) |
156 self.__editors[editor].append(act) |
157 act = menu.addMenu(self.__menu) |
157 act = menu.addMenu(self.__menu) |
158 self.__menu.setEnabled(True) |
158 self.__menu.setEnabled(True) |
159 self.__editors[editor].append(act) |
159 self.__editors[editor].append(act) |
|
160 editor.showMenu.connect(self.__editorShowMenu) |
160 |
161 |
161 def __editorClosed(self, editor): |
162 def __editorClosed(self, editor): |
162 """ |
163 """ |
163 Private slot called, when an editor was closed. |
164 Private slot called, when an editor was closed. |
164 |
165 |
168 del self.__editors[editor] |
169 del self.__editors[editor] |
169 if not self.__editors: |
170 if not self.__editors: |
170 self.__menu.setEnabled(False) |
171 self.__menu.setEnabled(False) |
171 except KeyError: |
172 except KeyError: |
172 pass |
173 pass |
|
174 |
|
175 def __editorShowMenu(self, menuName, menu, editor): |
|
176 """ |
|
177 Private slot called, when the the editor context menu or a submenu is |
|
178 about to be shown. |
|
179 |
|
180 @param menuName name of the menu to be shown (string) |
|
181 @param menu reference to the menu (QMenu) |
|
182 @param editor reference to the editor |
|
183 """ |
|
184 if menuName == "Tools": |
|
185 if self.__menu.menuAction() not in menu.actions(): |
|
186 # Re-add our menu |
|
187 self.__editors[editor] = [] |
|
188 if not menu.isEmpty(): |
|
189 act = menu.addSeparator() |
|
190 self.__editors[editor].append(act) |
|
191 act = menu.addMenu(self.__menu) |
|
192 self.__editors[editor].append(act) |
173 |
193 |
174 def __isHexString(self, text): |
194 def __isHexString(self, text): |
175 """ |
195 """ |
176 Private method to check, if a given text is a hex string. |
196 Private method to check, if a given text is a hex string. |
177 |
197 |