eric6/Plugins/PluginAbout.py

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

eric ide

mercurial