PluginExtensionIrc.py

changeset 11
d1af35d0bcc6
parent 9
bd9ede602f1c
equal deleted inserted replaced
10:f98d019645f9 11:d1af35d0bcc6
14 from PyQt6.QtGui import QIcon, QKeySequence, QPixmap 14 from PyQt6.QtGui import QIcon, QKeySequence, QPixmap
15 15
16 from eric7 import EricUtilities, Preferences 16 from eric7 import EricUtilities, Preferences
17 from eric7.EricGui import EricPixmapCache 17 from eric7.EricGui import EricPixmapCache
18 from eric7.EricGui.EricAction import EricAction 18 from eric7.EricGui.EricAction import EricAction
19 from eric7.EricWidgets import EricMessageBox
19 from eric7.EricWidgets.EricApplication import ericApp 20 from eric7.EricWidgets.EricApplication import ericApp
20 from eric7.UI.UserInterface import UserInterfaceSide 21 from eric7.UI.UserInterface import UserInterfaceSide
21 22
22 # Start-Of-Header 23 # Start-Of-Header
23 __header__ = { 24 __header__ = {
24 "name": "IRC Extension Plugin", 25 "name": "IRC Extension Plugin",
25 "author": "Detlev Offenbach <detlev@die-offenbachs.de>", 26 "author": "Detlev Offenbach <detlev@die-offenbachs.de>",
26 "autoactivate": True, 27 "autoactivate": True,
27 "deactivateable": True, 28 "deactivateable": True,
28 "version": "10.0.1", 29 "version": "10.0.2",
29 "className": "IrcExtensionPlugin", 30 "className": "IrcExtensionPlugin",
30 "packageName": "ExtensionIrc", 31 "packageName": "ExtensionIrc",
31 "shortDescription": "This plug-in adds a widget to communicate via IRC messa", 32 "shortDescription": "This plug-in adds a widget to communicate via IRC messa",
32 "longDescription": ( 33 "longDescription": (
33 "This plug-in adds a widget to communicate via IRC messages. It replaces" 34 "This plug-in adds a widget to communicate via IRC messages. It replaces"
85 Preferences.getSettings().remove(IrcExtensionPlugin.PreferencesKey) 86 Preferences.getSettings().remove(IrcExtensionPlugin.PreferencesKey)
86 87
87 88
88 class IrcExtensionPlugin(QObject): 89 class IrcExtensionPlugin(QObject):
89 """ 90 """
90 Class documentation goes here. 91 Class implementing a plug-in providing IRC communication capability.
91 """ 92 """
92 93
93 PreferencesKey = "IRC" 94 PreferencesKey = "IRC"
94 95
95 def __init__(self, ui): 96 def __init__(self, ui):
166 """ 167 """
167 global error, ircExtensionPluginObject 168 global error, ircExtensionPluginObject
168 error = "" # clear previous error 169 error = "" # clear previous error
169 ircExtensionPluginObject = self 170 ircExtensionPluginObject = self
170 171
171 # Create the IRC user interface 172 if self.__ui.versionIsNewer("25.4"):
172 logging.getLogger(__name__).debug("Creating IRC Widget...") 173 # Create the IRC user interface
173 from ExtensionIrc.IrcWidget import IrcWidget # noqa: I-101, I-102 174 logging.getLogger(__name__).debug("Creating IRC Widget...")
174 175 from ExtensionIrc.IrcWidget import IrcWidget # noqa: I-101, I-102
175 usesDarkPalette = ericApp().usesDarkPalette() 176
176 self.__iconType = "dark" if usesDarkPalette else "light" 177 usesDarkPalette = ericApp().usesDarkPalette()
177 178 self.__iconType = "dark" if usesDarkPalette else "light"
178 self.__irc = IrcWidget(plugin=self) 179
179 iconName = "sbIrc96" if self.__ui.getLayoutType() == "Sidebars" else "irc" 180 self.__irc = IrcWidget(plugin=self)
180 self.__ui.addSideWidget( 181 iconName = "sbIrc96" if self.__ui.getLayoutType() == "Sidebars" else "irc"
181 UserInterfaceSide.Right, 182 self.__ui.addSideWidget(
182 self.__irc, 183 UserInterfaceSide.Right,
183 self.getIcon(iconName), 184 self.__irc,
184 self.tr("IRC"), 185 self.getIcon(iconName),
185 ) 186 self.tr("IRC"),
186 187 )
187 self.__activateAct = EricAction( 188
188 self.tr("IRC"), 189 self.__activateAct = EricAction(
189 self.tr("&IRC"), 190 self.tr("IRC"),
190 QKeySequence(self.tr("Ctrl+Alt+Shift+I")), 191 self.tr("&IRC"),
191 0, 192 QKeySequence(self.tr("Ctrl+Alt+Shift+I")),
192 self, 193 0,
193 "irc_widget_activate", 194 self,
194 ) 195 "irc_widget_activate",
195 self.__activateAct.setStatusTip( 196 )
196 self.tr("Switch the input focus to the IRC window.") 197 self.__activateAct.setStatusTip(
197 ) 198 self.tr("Switch the input focus to the IRC window.")
198 self.__activateAct.setWhatsThis( 199 )
199 self.tr( 200 self.__activateAct.setWhatsThis(
200 """<b>Activate IRC</b>""" 201 self.tr(
201 """<p>This switches the input focus to the IRC window.</p>""" 202 """<b>Activate IRC</b>"""
202 ) 203 """<p>This switches the input focus to the IRC window.</p>"""
203 ) 204 )
204 self.__activateAct.triggered.connect(self.__activateWidget) 205 )
205 206 self.__activateAct.triggered.connect(self.__activateWidget)
206 self.__ui.addEricActions([self.__activateAct], "ui") 207
207 menu = self.__ui.getMenu("subwindow") 208 self.__ui.addEricActions([self.__activateAct], "ui")
208 menu.addAction(self.__activateAct) 209 menu = self.__ui.getMenu("subwindow")
209 210 menu.addAction(self.__activateAct)
210 ericApp().getObject("PluginManager").shutdown.connect(self.__irc.shutdown) 211
211 212 ericApp().getObject("PluginManager").shutdown.connect(self.__irc.shutdown)
212 self.__irc.autoConnected.connect(self.__activateWidget) 213
213 self.__irc.autoConnect() 214 self.__irc.autoConnected.connect(self.__activateWidget)
214 215 self.__irc.autoConnect()
215 return None, True 216
217 return None, True
218 else:
219 EricMessageBox.warning(
220 self.__ui,
221 self.tr("IRC Extension"),
222 self.tr(
223 "The IRC extension cannot be activated because it requires eric7"
224 " 25.5 or newer."
225 ),
226 )
227 error = self.tr(
228 "The IRC extension cannot be activated because it requires eric7 25.5"
229 " or newer."
230 )
231
232 return None, False
216 233
217 def deactivate(self): 234 def deactivate(self):
218 """ 235 """
219 Public method to deactivate this plug-in. 236 Public method to deactivate this plug-in.
220 """ 237 """
298 ) 315 )
299 print("Using default.") # noqa: M-801 316 print("Using default.") # noqa: M-801
300 317
301 def __activateWidget(self): 318 def __activateWidget(self):
302 """ 319 """
303 Private slot to handle the activation of the MQTT Monitor. 320 Private slot to handle the activation of the IRC widget.
304 """ 321 """
305 uiLayoutType = self.__ui.getLayoutType() 322 uiLayoutType = self.__ui.getLayoutType()
306 323
307 if uiLayoutType == "Toolboxes": 324 if uiLayoutType == "Toolboxes":
308 self.__ui.rToolboxDock.show() 325 self.__ui.rToolboxDock.show()

eric ide

mercurial