Skip to content

Commit

Permalink
Fix Save action
Browse files Browse the repository at this point in the history
The slot cannot accept the filename argument. This needs to be stored elsewhere.
  • Loading branch information
rhaschke committed Apr 14, 2024
1 parent 3da5714 commit 2695a5f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions python/stack_of_tasks/ui/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,23 @@ def _update_latest_project_list(self, url: Path):

# Projecct management

def _safe(self, url: Path):
def _safe_file(self, url: Path):
yaml_str = dump(self.current_project.controller)
url.write_text(yaml_str)

self.current_project.url = url
self._update_latest_project_list(url)

def _safe(self):
if self.current_project.url is None:
self._safe_as()
else:
self._safe_file(self.current_project.url)

def _safe_as(self):
url, _ = QFileDialog.getSaveFileName(filter="YAML - Files (*.yml)")
self._safe(Path(url))
if url: # only save if a file was chosen
self._safe_file(Path(url))

def new_project(self):
from stack_of_tasks.robot_model.actuators import JointStatePublisherActuator
Expand Down Expand Up @@ -225,6 +233,7 @@ def _load_project(self, config_location: Path):
config = load(config_location.read_text())
self._update_latest_project_list(config_location)
self._create_project(config)
self.current_project.url = config_location
self.ui.close()

def _open_recent(self, index: int):
Expand All @@ -238,6 +247,7 @@ def _open_from_file(self):

class Logic_Project(BaseSoTHasTraits):

url: Path = None
ref_objects: List[RefFrame] = ta.List(RefFrame)
marker_objects: List[IAMarker] = ta.List(IAMarker)
solver_cls = ta.Property()
Expand Down

0 comments on commit 2695a5f

Please sign in to comment.