Skip to content

Commit

Permalink
Show Tool Spec type icon on Design View
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsavol committed Jan 17, 2024
1 parent fc5e79d commit 90fd893
Show file tree
Hide file tree
Showing 9 changed files with 676 additions and 7 deletions.
360 changes: 353 additions & 7 deletions spine_items/resources_icons_rc.py

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions spine_items/tool/item_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ def item_category():
def item_type():
"""See base class."""
return "Tool"

@staticmethod
def specification_icon(specification):
if not specification:
return None
if specification.tooltype == "python":
return ":icons/item_icons/python-logo.svg"
elif specification.tooltype == "julia":
return ":icons/item_icons/julia-logo.svg"
elif specification.tooltype == "executable":
return ":icons/item_icons/terminal-logo.svg"
elif specification.tooltype == "gams":
return ":icons/item_icons/gams-logo.svg"
return None
16 changes: 16 additions & 0 deletions spine_items/tool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ def set_up(self):
super().set_up()
self.do_update_execution_mode(execute_in_work)

def setup_specification_icon(self, spec_icon_path):
"""Adds a specification icon as the child of this item's icon."""
if not self._specification:
return
icon = self.get_icon()
icon.setup_spec_icon(spec_icon_path)

def update_specification_icon(self):
"""Updates the spec icon when a Tool is selected or when the specification is changed."""
icon = self.get_icon()
if icon.spec_item is not None:
icon.remove_specification_icon()
spec_icon = ItemInfo.specification_icon(self.specification())
self.setup_specification_icon(spec_icon)

@property
def group_id(self):
return self._group_id
Expand Down Expand Up @@ -376,6 +391,7 @@ def _update_tool_ui(self):
self._properties_ui.kill_consoles_check_box.setChecked(self._kill_completed_processes)
self._update_kill_consoles_check_box_enabled()
self._properties_ui.log_process_output_check_box.setChecked(self._log_process_output)
self.update_specification_icon()

def _show_execution_settings(self):
"""Updates the label in Tool properties to show the selected execution settings for this Tool."""
Expand Down
14 changes: 14 additions & 0 deletions spine_items/tool/tool_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ def icon():
def icon_color():
return QColor("red")

@staticmethod
def specification_icon(specification):
if not specification:
return None
if specification.tooltype == "python":
return ":icons/item_icons/python-logo.svg"
elif specification.tooltype == "julia":
return ":icons/item_icons/julia-logo.svg"
elif specification.tooltype == "executable":
return ":icons/item_icons/terminal-logo.svg"
elif specification.tooltype == "gams":
return ":icons/item_icons/gams-logo.svg"
return None

@staticmethod
def make_add_item_widget(toolbox, x, y, specification):
return AddToolWidget(toolbox, x, y, specification)
Expand Down
1 change: 1 addition & 0 deletions spine_items/ui/resources/item_icons/gams-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions spine_items/ui/resources/item_icons/julia-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
265 changes: 265 additions & 0 deletions spine_items/ui/resources/item_icons/python-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions spine_items/ui/resources/item_icons/terminal-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions spine_items/ui/resources/resources_icons.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<RCC>
<qresource prefix="/icons">
<file>item_icons/gams-logo.svg</file>
<file>item_icons/terminal-logo.svg</file>
<file>item_icons/julia-logo.svg</file>
<file>item_icons/python-logo.svg</file>
<file>share.svg</file>
<file>bolt-lightning.svg</file>
<file>item_icons/satellite.svg</file>
Expand Down

0 comments on commit 90fd893

Please sign in to comment.