|
1 | 1 | import os |
| 2 | +from importlib.metadata import version |
| 3 | + |
2 | 4 | from PySide2 import QtGui, QtWidgets |
3 | 5 | from PySide2.QtCore import QSize, QUrl, Slot |
4 | 6 |
|
5 | | -from activity_browser import actions, signals |
| 7 | +from activity_browser import actions, signals, application, info |
6 | 8 | from activity_browser.mod import bw2data as bd |
7 | 9 |
|
8 | | -from ..info import __version__ as ab_version |
9 | 10 | from .icons import qicons |
10 | 11 |
|
11 | 12 | AB_BW25 = True if os.environ.get("AB_BW25", False) else False |
|
14 | 15 | class MenuBar(QtWidgets.QMenuBar): |
15 | 16 | def __init__(self, window): |
16 | 17 | super().__init__(parent=window) |
17 | | - self.help_menu = QtWidgets.QMenu("&Help", self) |
18 | 18 |
|
19 | 19 | self.addMenu(ProjectMenu(self)) |
20 | 20 | self.addMenu(ViewMenu(self)) |
21 | 21 | self.addMenu(ToolsMenu(self)) |
22 | | - self.addMenu(self.help_menu) |
23 | | - |
24 | | - self.setup_help_menu() |
25 | | - |
26 | | - def setup_help_menu(self) -> None: |
27 | | - """Build the help menu for the menubar.""" |
28 | | - self.help_menu.addAction( |
29 | | - self.window().icon, "&About Activity Browser", self.about |
30 | | - ) |
31 | | - self.help_menu.addAction( |
32 | | - "&About Qt", lambda: QtWidgets.QMessageBox.aboutQt(self.parent()) |
33 | | - ) |
34 | | - self.help_menu.addAction( |
35 | | - qicons.question, "&Get help on the wiki", self.open_wiki |
36 | | - ) |
37 | | - self.help_menu.addAction( |
38 | | - qicons.issue, "&Report an idea/issue on GitHub", self.raise_issue_github |
39 | | - ) |
40 | | - |
41 | | - def about(self): |
42 | | - text = """ |
43 | | -Activity Browser - a graphical interface for Brightway2.<br><br> |
44 | | -Application version: <b>{}</b><br><br> |
45 | | -All development happens on <a href="https://github.com/LCA-ActivityBrowser/activity-browser">github</a>.<br><br> |
46 | | -For copyright information please see the copyright on <a href="https://github.com/LCA-ActivityBrowser/activity-browser/tree/main#copyright">this page</a>.<br><br> |
47 | | -For license information please see the copyright on <a href="https://github.com/LCA-ActivityBrowser/activity-browser/blob/main/LICENSE.txt">this page</a>.<br><br> |
48 | | -""" |
49 | | - msgBox = QtWidgets.QMessageBox(parent=self.parent()) |
50 | | - msgBox.setWindowTitle("About the Activity Browser") |
51 | | - pixmap = self.parent().icon.pixmap(QSize(150, 150)) |
52 | | - msgBox.setIconPixmap(pixmap) |
53 | | - msgBox.setWindowIcon(self.parent().icon) |
54 | | - msgBox.setText(text.format(ab_version)) |
55 | | - msgBox.exec_() |
56 | | - |
57 | | - def open_wiki(self): |
58 | | - url = QUrl( |
59 | | - "https://github.com/LCA-ActivityBrowser/activity-browser/wiki" |
60 | | - ) |
61 | | - QtGui.QDesktopServices.openUrl(url) |
62 | | - |
63 | | - def raise_issue_github(self): |
64 | | - url = QUrl( |
65 | | - "https://github.com/LCA-ActivityBrowser/activity-browser/issues/new/choose" |
66 | | - ) |
67 | | - QtGui.QDesktopServices.openUrl(url) |
| 22 | + self.addMenu(HelpMenu(self)) |
68 | 23 |
|
69 | 24 |
|
70 | 25 | class ProjectMenu(QtWidgets.QMenu): |
@@ -145,6 +100,56 @@ def __init__(self, parent=None) -> None: |
145 | 100 | self.addAction(self.manage_plugins_action) |
146 | 101 |
|
147 | 102 |
|
| 103 | +class HelpMenu(QtWidgets.QMenu): |
| 104 | + def __init__(self, parent=None) -> None: |
| 105 | + super().__init__(parent) |
| 106 | + self.setTitle("&Help") |
| 107 | + |
| 108 | + self.addAction( |
| 109 | + qicons.ab, "&About Activity Browser", self.about |
| 110 | + ) |
| 111 | + self.addAction( |
| 112 | + "&About Qt", lambda: QtWidgets.QMessageBox.aboutQt(application.main_window) |
| 113 | + ) |
| 114 | + self.addAction( |
| 115 | + qicons.question, "&Get help on the wiki", self.open_wiki |
| 116 | + ) |
| 117 | + self.addAction( |
| 118 | + qicons.issue, "&Report an idea/issue on GitHub", self.raise_issue_github |
| 119 | + ) |
| 120 | + |
| 121 | + def about(self): |
| 122 | + text = f""" |
| 123 | + Activity Browser - a graphical interface for Brightway2.<br><br> |
| 124 | + Application version: <b>{version("activity_browser")}</b><br> |
| 125 | + bw2data version: <b>{version("bw2data")}</b><br> |
| 126 | + bw2io version: <b>{version("bw2calc")}</b><br> |
| 127 | + bw2calc version: <b>{version("bw2io")}</b><br><br> |
| 128 | + All development happens on <a href="https://github.com/LCA-ActivityBrowser/activity-browser">github</a>.<br><br> |
| 129 | + For copyright information please see the copyright on <a href="https://github.com/LCA-ActivityBrowser/activity-browser/tree/main#copyright">this page</a>.<br><br> |
| 130 | + For license information please see the copyright on <a href="https://github.com/LCA-ActivityBrowser/activity-browser/blob/main/LICENSE.txt">this page</a>.<br><br> |
| 131 | + """ |
| 132 | + |
| 133 | + about_window = QtWidgets.QMessageBox(parent=application.main_window) |
| 134 | + about_window.setWindowTitle("About the Activity Browser") |
| 135 | + about_window.setIconPixmap(qicons.ab.pixmap(QSize(150, 150))) |
| 136 | + about_window.setText(text) |
| 137 | + |
| 138 | + about_window.exec_() |
| 139 | + |
| 140 | + def open_wiki(self): |
| 141 | + url = QUrl( |
| 142 | + "https://github.com/LCA-ActivityBrowser/activity-browser/wiki" |
| 143 | + ) |
| 144 | + QtGui.QDesktopServices.openUrl(url) |
| 145 | + |
| 146 | + def raise_issue_github(self): |
| 147 | + url = QUrl( |
| 148 | + "https://github.com/LCA-ActivityBrowser/activity-browser/issues/new/choose" |
| 149 | + ) |
| 150 | + QtGui.QDesktopServices.openUrl(url) |
| 151 | + |
| 152 | + |
148 | 153 | class ProjectSelectionMenu(QtWidgets.QMenu): |
149 | 154 | """ |
150 | 155 | Menu that lists all the projects available through bw2data.projects |
|
0 commit comments