Skip to content

Commit

Permalink
Merge branch 'master' into pyside2-refactor
Browse files Browse the repository at this point in the history
# Conflicts:
#	activity_browser/app/ui/menu_bar.py
#	activity_browser/app/ui/tables/activity.py
  • Loading branch information
dgdekoning committed Nov 4, 2019
2 parents f404d71 + dd81d2f commit 0a5c096
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 110 deletions.
77 changes: 49 additions & 28 deletions activity_browser/app/ui/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,63 @@ def create_path(folder: str, filename: str) -> str:
return os.path.join(PACKAGE_DIRECTORY, "icons", folder, filename)


# CURRENTLY UNUSED ICONS

# Modular LCA (keep until this is reintegrated)
# add_db = create_path('metaprocess', 'add_database.png')
# close_db = create_path('metaprocess', 'close_database.png')
# cut = create_path('metaprocess', 'cut.png')
# duplicate = create_path('metaprocess', 'duplicate.png')
# graph_lmp = create_path('metaprocess', 'graph_linkedmetaprocess.png')
# graph_mp = create_path('metaprocess', 'graph_metaprocess.png')
# load_db = create_path('metaprocess', 'open_database.png')
# metaprocess = create_path('metaprocess', 'metaprocess.png')
# new = create_path('metaprocess', 'new_metaprocess.png')
# save_db = create_path('metaprocess', 'save_database.png')
# save_mp = create_path('metaprocess', 'save_metaprocess.png')

# key = create_path('main', 'key.png')
# search = create_path('main', 'search.png')
# switch = create_path('main', 'switch-state.png')

# left = create_path('main', 'left.png')
# forward = create_path('main', 'forward.png')
# backward = create_path('main', 'backward.png')


class Icons(object):
# Icons from href="https://www.flaticon.com/
# By https://www.flaticon.com/authors/freepik,
# https://www.flaticon.com/authors/rami-mcmin,
# and others
# And are licensed by CC BY 3.0

# MAIN
ab = create_path('main', 'activitybrowser.png')

# arrows
right = create_path('main', 'right.png')

# Simple actions
delete = create_path('context', 'delete.png')
copy = create_path('context', 'copy.png')
add = create_path('context', 'add.png')
# Icon made by 'Roundicons' from www.flaticon.com
edit = create_path('main', 'edit.png')
calculate = create_path('main', 'calculate.png')
question = create_path('context', 'question.png')

add_db = create_path('metaprocess', 'add_database.png')
close_db = create_path('metaprocess', 'close_database.png')
cut = create_path('metaprocess', 'cut.png')
duplicate = create_path('metaprocess', 'duplicate.png')
graph_lmp = create_path('metaprocess', 'graph_linkedmetaprocess.png')
graph_mp = create_path('metaprocess', 'graph_metaprocess.png')
load_db = create_path('metaprocess', 'open_database.png')
metaprocess = create_path('metaprocess', 'metaprocess.png')
new = create_path('metaprocess', 'new_metaprocess.png')
save_db = create_path('metaprocess', 'save_database.png')
save_mp = create_path('metaprocess', 'save_metaprocess.png')

debug = create_path('main', 'debug.png')
forward = create_path('main', 'forward.png')
right = create_path('main', 'right.png')
left = create_path('main', 'left.png')
backward = create_path('main', 'backward.png')
edit = create_path('main', 'edit.png')
key = create_path('main', 'key.png')
search = create_path('main', 'search.png')
switch = create_path('main', 'switch-state.png')
ab = create_path('main', 'activitybrowser.png')
# database
import_db = create_path('main', 'import_database.png')
duplicate_database = create_path('main', 'duplicate_database.png')

# activity
duplicate_activity = create_path('main', 'duplicate_activity.png')
duplicate_to_other_database = create_path('main', 'import_database.png')

# windows
graph_explorer = create_path('main', 'graph_explorer.png')
calculate = create_path('main', 'calculate.png')
debug = create_path('main', 'ladybird.png')
issue = create_path('main', 'idea.png')
settings = create_path('main', 'settings.png')
history = create_path('main', 'history.png')
welcome = create_path('main', 'welcome.png')
main_window = create_path('main', 'home.png')


class QIcons(Icons):
Expand Down
2 changes: 2 additions & 0 deletions activity_browser/app/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self):
self.vertical_container.addLayout(self.main_horizontal_box)

self.main_widget = QtWidgets.QWidget()
self.main_widget.icon = qicons.main_window
self.main_widget.name = "&Main Window"
self.main_widget.setLayout(self.vertical_container)

Expand All @@ -71,6 +72,7 @@ def __init__(self):
working_layout.addWidget(self.log)

self.debug_widget = QtWidgets.QWidget()
self.debug_widget.icon = qicons.debug
self.debug_widget.name = "&Debug Window"
self.debug_widget.setLayout(working_layout)

Expand Down
95 changes: 24 additions & 71 deletions activity_browser/app/ui/menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import json

import brightway2 as bw
import requests
from PySide2 import QtCore, QtWidgets, QtGui

from .icons import qicons
from .utils import abt1
from ..signals import signals
from .widgets import BiosphereUpdater
from .wizards.settings_wizard import SettingsWizard
Expand All @@ -22,6 +20,7 @@ def __init__(self, window):
self.menubar.addMenu(self.setup_file_menu())
# self.menubar.addMenu(self.setup_tools_menu())
# self.menubar.addMenu(self.setup_extensions_menu())
self.menubar.addMenu(self.setup_view_menu())
self.menubar.addMenu(self.setup_windows_menu())
self.menubar.addMenu(self.setup_help_menu())
window.setMenuBar(self.menubar)
Expand All @@ -37,50 +36,41 @@ def connect_signals(self):
def setup_file_menu(self):
menu = QtWidgets.QMenu('&File', self.window)
menu.addAction(
qicons.import_db,
'&Import database...',
signals.import_database.emit
)
menu.addAction(self.update_biosphere_action)
menu.addAction(
qicons.settings,
'&Settings...',
self.open_settings_wizard
)
return menu

# # TOOLS
# def setup_tools_menu(self):
# menu = QtWidgets.QMenu('&Tools', self.window)
# menu.addAction(
# '&Graph Explorer',
# lambda x="Graph Explorer": signals.show_tab.emit(x)
# )
# # menu.addAction(
# # '&Show/hide history',
# # lambda x="Project History": signals.show_or_hide_tab.emit(x)
# # )
#
# # self.graph_navigator = QtWidgets.QMenu('&Windows', self.window)
# # self.update_windows_menu()
# return menu

# WINDOWS
def setup_windows_menu(self):
self.windows_menu = QtWidgets.QMenu('&Windows', self.window)

self.show_hide_menu = QtWidgets.QMenu('&Show/hide...', self.window)
self.show_hide_menu.addAction(
'&Project History',
lambda x="Project History": signals.toggle_show_or_hide_tab.emit(x)
)
self.show_hide_menu.addAction(
# VIEW
def setup_view_menu(self):
view_menu = QtWidgets.QMenu('&View', self.window)
view_menu.addAction(
qicons.graph_explorer,
'&Graph Explorer',
lambda x="Graph Explorer": signals.toggle_show_or_hide_tab.emit(x)
)
self.show_hide_menu.addAction(
view_menu.addAction(
qicons.history,
'&Activity History',
lambda x="History": signals.toggle_show_or_hide_tab.emit(x)
)
view_menu.addAction(
qicons.welcome,
'&Welcome screen',
lambda x="Welcome": signals.toggle_show_or_hide_tab.emit(x)
)
# self.windows_menu.addMenu(self.show_hide_menu)
return view_menu

# WINDOWS
def setup_windows_menu(self):
self.windows_menu = QtWidgets.QMenu('&Windows', self.window)
self.update_windows_menu()
return self.windows_menu

Expand All @@ -89,34 +79,28 @@ def update_windows_menu(self):
for index in range(self.window.stacked.count()): # iterate over widgets in QStackedWidget
widget = self.window.stacked.widget(index)
self.windows_menu.addAction(
widget.icon,
widget.name,
lambda widget=widget: self.window.stacked.setCurrentWidget(widget),
)
self.windows_menu.addMenu(self.show_hide_menu)

# HELP
def setup_help_menu(self):
bug_icon = qicons.debug
help_menu = QtWidgets.QMenu('&Help', self.window)
help_menu.addAction(
self.window.icon,
'&About Activity Browser',
self.about)

help_menu.addAction(
'&About Qt',
lambda: QtWidgets.QMessageBox.aboutQt(self.window)
)
help_menu.addAction(
bug_icon,
'&Report Bug on github',
qicons.issue,
'&Report an idea/issue on GitHub',
self.raise_issue_github
)
help_menu.addAction(
bug_icon,
'&Report Bug',
self.raise_issue_from_app
)

return help_menu

def about(self):
Expand Down Expand Up @@ -149,37 +133,6 @@ def raise_issue_github(self):
url = QtCore.QUrl('https://github.com/LCA-ActivityBrowser/activity-browser/issues/new')
QtGui.QDesktopServices.openUrl(url)

def raise_issue_api(self, content):
abt2 = 'C5F02AZ12E56E6D46Z811D'
auth = (
'ActivityBrowser',
''.join(reversed(abt1 + ''.join(reversed(abt2.lower())))).replace('z', '')
)
data = {
'title': 'New issue reported from app',
'body': content
}

url = 'https://api.github.com/repos/LCA-ActivityBrowser/activity-browser/issues'
response = requests.post(url, data=json.dumps(data), auth=auth)
if response.status_code != 201:
print(response)
print(response.text)

def raise_issue_from_app(self):
text, _ = QtWidgets.QInputDialog.getMultiLineText(
None,
'Report new bug',
('Please describe the buggy behaviour. View existing issues on ' +
'<a href="https://github.com/LCA-ActivityBrowser/activity-browser/issues">github</a>.'+
'<br>If you have a github account, please consider raising the issue directly on github.'
),
)
if text:
content = text + '\n\nLog Output:\n```\n{}```'.format(self.window.log.toPlainText())
self.raise_issue_api(content)
print(content)

def open_settings_wizard(self):
self.settings_wizard = SettingsWizard()

Expand Down
4 changes: 2 additions & 2 deletions activity_browser/app/ui/panels/left.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def __init__(self, *args):
self.tabs = {
"Project": ProjectTab(self),
"Impact Categories": MethodsTab(self),
"Project History": HistoryTab(self),
"History": HistoryTab(self),
}
for tab_name, tab in self.tabs.items():
self.addTab(tab, tab_name)
# tabs hidden at start
self.hide_tab("Project History")
self.hide_tab("History")

4 changes: 2 additions & 2 deletions activity_browser/app/ui/tables/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def _resize(self) -> None:

def contextMenuEvent(self, a0) -> None:
menu = QtWidgets.QMenu()
menu.addAction(qicons.left, "Open activity/activities", self.open_activities)
menu.addAction(qicons.right, "Open activities", self.open_activities)
menu.addAction(self.delete_exchange_action)
menu.addAction(self.remove_formula_action)
menu.exec_(a0.globalPos())
Expand Down Expand Up @@ -387,5 +387,5 @@ def _resize(self) -> None:

def contextMenuEvent(self, a0) -> None:
menu = QtWidgets.QMenu()
menu.addAction(qicons.left, "Open activity/activities", self.open_activities)
menu.addAction(qicons.right, "Open activities", self.open_activities)
menu.exec_(a0.globalPos())
6 changes: 3 additions & 3 deletions activity_browser/app/ui/tables/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def contextMenuEvent(self, a0) -> None:
lambda: signals.delete_database.emit(self.selected_db_name)
)
menu.addAction(
qicons.duplicate, "Copy database",
qicons.duplicate_database, "Copy database",
lambda: signals.copy_database.emit(self.selected_db_name)
)
menu.addAction(
Expand Down Expand Up @@ -157,7 +157,7 @@ def contextMenuEvent(self, event) -> None:
"""
menu = QtWidgets.QMenu()
menu.addAction(
qicons.left, "Open activity",
qicons.right, "Open activity",
lambda: self.open_activity_tab(self.currentIndex())
)
menu.addAction(
Expand All @@ -168,7 +168,7 @@ def contextMenuEvent(self, event) -> None:
menu.addAction(self.duplicate_activity_action)
menu.addAction(self.delete_activity_action)
menu.addAction(
qicons.add_db, "Duplicate to other database",
qicons.duplicate_to_other_database, "Duplicate to other database",
lambda: signals.show_duplicate_to_db_interface.emit(self.get_key(self.currentIndex()))
)
menu.exec_(event.globalPos())
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/app/ui/tables/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def contextMenuEvent(self, event: QContextMenuEvent):
"""
menu = QMenu(self)
menu.addAction(
qicons.add, "Open activity/activities", self.open_activity_tab
qicons.add, "Open activities", self.open_activity_tab
)
menu.addAction(self.rename_action)
menu.addAction(self.delete_action)
Expand Down
4 changes: 2 additions & 2 deletions activity_browser/app/ui/tabs/project_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ def __init__(self, parent):

# Buttons
self.add_default_data_button = QtWidgets.QPushButton(
qicons.add_db, "Add Default Data (Biosphere flows, LCIA methods)"
qicons.import_db, "Add Default Data (Biosphere flows, LCIA methods)"
)
self.new_database_button = QtWidgets.QPushButton(qicons.add, "New")
self.import_database_button = QtWidgets.QPushButton(qicons.add_db, "Import")
self.import_database_button = QtWidgets.QPushButton(qicons.import_db, "Import")

# Header widget
self.header_layout.addWidget(self.add_default_data_button)
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/app/ui/widgets/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def populate_database_combo(self):
available_target_dbs.remove(current_db)

for db_name in available_target_dbs:
self.database_combo.addItem(qicons.duplicate, db_name)
self.database_combo.addItem(qicons.duplicate_activity, db_name)
self.database_combo.blockSignals(False)

def duplicate_confirm_dialog(self, target_db):
Expand Down
Binary file removed activity_browser/icons/main/debug.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added activity_browser/icons/main/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added activity_browser/icons/main/idea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added activity_browser/icons/main/import_database.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added activity_browser/icons/main/ladybird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified activity_browser/icons/main/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added activity_browser/icons/main/welcome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a5c096

Please sign in to comment.