|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the About plugin. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import QObject |
|
11 from PyQt6.QtGui import QAction |
|
12 |
|
13 import UI.Info |
|
14 import UI.PixmapCache |
|
15 |
|
16 from EricGui.EricAction import EricAction |
|
17 from EricWidgets import EricMessageBox |
|
18 |
|
19 # Start-Of-Header |
|
20 name = "About Plugin" |
|
21 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
|
22 autoactivate = True |
|
23 deactivateable = True |
|
24 version = UI.Info.VersionOnly |
|
25 className = "AboutPlugin" |
|
26 packageName = "__core__" |
|
27 shortDescription = "Show the About dialogs." |
|
28 longDescription = """This plugin shows the About dialogs.""" |
|
29 pyqtApi = 2 |
|
30 # End-Of-Header |
|
31 |
|
32 error = "" |
|
33 |
|
34 |
|
35 class AboutPlugin(QObject): |
|
36 """ |
|
37 Class implementing the About plugin. |
|
38 """ |
|
39 def __init__(self, ui): |
|
40 """ |
|
41 Constructor |
|
42 |
|
43 @param ui reference to the user interface object (UI.UserInterface) |
|
44 """ |
|
45 super().__init__(ui) |
|
46 self.__ui = ui |
|
47 |
|
48 self.__aboutDialog = None |
|
49 |
|
50 def activate(self): |
|
51 """ |
|
52 Public method to activate this plugin. |
|
53 |
|
54 @return tuple of None and activation status (boolean) |
|
55 """ |
|
56 self.__initActions() |
|
57 self.__initMenu() |
|
58 |
|
59 return None, True |
|
60 |
|
61 def deactivate(self): |
|
62 """ |
|
63 Public method to deactivate this plugin. |
|
64 """ |
|
65 menu = self.__ui.getMenu("help") |
|
66 if menu: |
|
67 menu.removeAction(self.aboutAct) |
|
68 menu.removeAction(self.aboutQtAct) |
|
69 acts = [self.aboutAct, self.aboutQtAct] |
|
70 self.__ui.removeEricActions(acts, 'ui') |
|
71 |
|
72 def __initActions(self): |
|
73 """ |
|
74 Private method to initialize the actions. |
|
75 """ |
|
76 acts = [] |
|
77 |
|
78 self.aboutAct = EricAction( |
|
79 self.tr('About {0}').format(UI.Info.Program), |
|
80 UI.PixmapCache.getIcon("helpAbout"), |
|
81 self.tr('&About {0}').format(UI.Info.Program), |
|
82 0, 0, self, 'about_eric') |
|
83 self.aboutAct.setStatusTip(self.tr( |
|
84 'Display information about this software')) |
|
85 self.aboutAct.setWhatsThis(self.tr( |
|
86 """<b>About {0}</b>""" |
|
87 """<p>Display some information about this software.</p>""" |
|
88 ).format(UI.Info.Program)) |
|
89 self.aboutAct.triggered.connect(self.__about) |
|
90 self.aboutAct.setMenuRole(QAction.MenuRole.AboutRole) |
|
91 acts.append(self.aboutAct) |
|
92 |
|
93 self.aboutQtAct = EricAction( |
|
94 self.tr('About Qt'), |
|
95 UI.PixmapCache.getIcon("helpAboutQt"), |
|
96 self.tr('About &Qt'), 0, 0, self, 'about_qt') |
|
97 self.aboutQtAct.setStatusTip( |
|
98 self.tr('Display information about the Qt toolkit')) |
|
99 self.aboutQtAct.setWhatsThis(self.tr( |
|
100 """<b>About Qt</b>""" |
|
101 """<p>Display some information about the Qt toolkit.</p>""" |
|
102 )) |
|
103 self.aboutQtAct.triggered.connect(self.__aboutQt) |
|
104 self.aboutQtAct.setMenuRole(QAction.MenuRole.AboutQtRole) |
|
105 acts.append(self.aboutQtAct) |
|
106 |
|
107 self.__ui.addEricActions(acts, 'ui') |
|
108 |
|
109 def __initMenu(self): |
|
110 """ |
|
111 Private method to add the actions to the right menu. |
|
112 """ |
|
113 menu = self.__ui.getMenu("help") |
|
114 if menu: |
|
115 act = self.__ui.getMenuAction("help", "show_versions") |
|
116 if act: |
|
117 menu.insertAction(act, self.aboutAct) |
|
118 menu.insertAction(act, self.aboutQtAct) |
|
119 else: |
|
120 menu.addAction(self.aboutAct) |
|
121 menu.addAction(self.aboutQtAct) |
|
122 |
|
123 def __about(self): |
|
124 """ |
|
125 Private slot to handle the About dialog. |
|
126 """ |
|
127 from AboutPlugin.AboutDialog import AboutDialog |
|
128 if self.__aboutDialog is None: |
|
129 self.__aboutDialog = AboutDialog(self.__ui) |
|
130 self.__aboutDialog.show() |
|
131 |
|
132 def __aboutQt(self): |
|
133 """ |
|
134 Private slot to handle the About Qt dialog. |
|
135 """ |
|
136 EricMessageBox.aboutQt(self.__ui, UI.Info.Program) |