|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the About plugin. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import QObject, SIGNAL |
|
11 from PyQt4.QtGui import QMessageBox |
|
12 |
|
13 from UI.Info import * |
|
14 import UI.PixmapCache |
|
15 |
|
16 from E4Gui.E4Action import E4Action |
|
17 |
|
18 from AboutPlugin.AboutDialog import AboutDialog |
|
19 |
|
20 # Start-Of-Header |
|
21 name = "About Plugin" |
|
22 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
|
23 autoactivate = True |
|
24 deactivateable = True |
|
25 version = "5.0.0" |
|
26 className = "AboutPlugin" |
|
27 packageName = "__core__" |
|
28 shortDescription = "Show the About dialogs." |
|
29 longDescription = """This plugin shows the About dialogs.""" |
|
30 pyqtApi = 2 |
|
31 # End-Of-Header |
|
32 |
|
33 error = "" |
|
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 QObject.__init__(self, ui) |
|
46 self.__ui = ui |
|
47 |
|
48 def activate(self): |
|
49 """ |
|
50 Public method to activate this plugin. |
|
51 |
|
52 @return tuple of None and activation status (boolean) |
|
53 """ |
|
54 self.__initActions() |
|
55 self.__initMenu() |
|
56 |
|
57 return None, True |
|
58 |
|
59 def deactivate(self): |
|
60 """ |
|
61 Public method to deactivate this plugin. |
|
62 """ |
|
63 menu = self.__ui.getMenu("help") |
|
64 if menu: |
|
65 menu.removeAction(self.aboutAct) |
|
66 menu.removeAction(self.aboutQtAct) |
|
67 acts = [self.aboutAct, self.aboutQtAct] |
|
68 self.__ui.removeE4Actions(acts, 'ui') |
|
69 |
|
70 def __initActions(self): |
|
71 """ |
|
72 Private method to initialize the actions. |
|
73 """ |
|
74 acts = [] |
|
75 |
|
76 self.aboutAct = E4Action(self.trUtf8('About {0}').format(Program), |
|
77 UI.PixmapCache.getIcon("helpAbout.png"), |
|
78 self.trUtf8('&About {0}').format(Program), |
|
79 0, 0, self, 'about_eric') |
|
80 self.aboutAct.setStatusTip(self.trUtf8('Display information about this software')) |
|
81 self.aboutAct.setWhatsThis(self.trUtf8( |
|
82 """<b>About {0}</b>""" |
|
83 """<p>Display some information about this software.</p>""" |
|
84 ).format(Program)) |
|
85 self.connect(self.aboutAct, SIGNAL('triggered()'), self.__about) |
|
86 acts.append(self.aboutAct) |
|
87 |
|
88 self.aboutQtAct = E4Action(self.trUtf8('About Qt'), |
|
89 UI.PixmapCache.getIcon("helpAboutQt.png"), |
|
90 self.trUtf8('About &Qt'), 0, 0, self, 'about_qt') |
|
91 self.aboutQtAct.setStatusTip(\ |
|
92 self.trUtf8('Display information about the Qt toolkit')) |
|
93 self.aboutQtAct.setWhatsThis(self.trUtf8( |
|
94 """<b>About Qt</b>""" |
|
95 """<p>Display some information about the Qt toolkit.</p>""" |
|
96 )) |
|
97 self.connect(self.aboutQtAct, SIGNAL('triggered()'), self.__aboutQt) |
|
98 acts.append(self.aboutQtAct) |
|
99 |
|
100 self.__ui.addE4Actions(acts, 'ui') |
|
101 |
|
102 def __initMenu(self): |
|
103 """ |
|
104 Private method to add the actions to the right menu. |
|
105 """ |
|
106 menu = self.__ui.getMenu("help") |
|
107 if menu: |
|
108 act = self.__ui.getMenuAction("help", "show_versions") |
|
109 if act: |
|
110 menu.insertAction(act, self.aboutAct) |
|
111 menu.insertAction(act, self.aboutQtAct) |
|
112 else: |
|
113 menu.addAction(self.aboutAct) |
|
114 menu.addAction(self.aboutQtAct) |
|
115 |
|
116 def __about(self): |
|
117 """ |
|
118 Private slot to handle the About dialog. |
|
119 """ |
|
120 dlg = AboutDialog(self.__ui) |
|
121 dlg.exec_() |
|
122 |
|
123 def __aboutQt(self): |
|
124 """ |
|
125 Private slot to handle the About Qt dialog. |
|
126 """ |
|
127 QMessageBox.aboutQt(self.__ui, Program) |