Skip to content

Commit

Permalink
Fix main program in folder (#3026)
Browse files Browse the repository at this point in the history
- Add helper function to browse for root directory
- Update release notes

Re #3020
  • Loading branch information
ptsavol authored Dec 20, 2024
1 parent fd040c3 commit 20b5967
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)

### Added

- [Bundled App] **Embedded Python** now includes spinedb-api and pandas
in addition to ipykernel and jill.
- [Bundled App] **Embedded Python** now includes spinedb-api and pandas in addition to ipykernel and jill.
- Support PySide 6.8.1
- Tools now support executing programs where the main program file is not in the work directory root, but
in a subfolder. You can use this feature by setting a 'root directory path' for a Tool in **Tool Properties**.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-e git+https://github.com/spine-tools/Spine-Database-API.git#egg=spinedb_api
-e git+https://github.com/spine-tools/spine-engine.git#egg=spine_engine
-e git+https://github.com/spine-tools/spine-items.git#egg=spine_items
-e git+https://github.com/spine-tools/spine-items.git@fix_main_program_in_folder#egg=spine_items
-e .
18 changes: 18 additions & 0 deletions spinetoolbox/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,24 @@ def select_certificate_directory(parent, line_edit):
line_edit.setText(answer)


def select_root_directory(parent, line_edit, project_path):
"""Shows file browser and inserts selected root directory to given line edit.
Used in Tool Properties.
Args:
parent (QWidget, optional): Parent of QFileDialog
line_edit (QLineEdit): Line edit where the selected path will be inserted
project_path (str): Project path
"""
current_path = get_current_path(line_edit)
initial_path = current_path if current_path is not None else project_path
answer = QFileDialog.getExistingDirectory(parent, "Select root directory", initial_path)
if not answer:
return
line_edit.setText(answer)
return


def get_current_path(le):
"""Returns the text in the given line edit. If no text, returns the
placeholder text if it is a valid path. If it's not a valid path,
Expand Down
2 changes: 1 addition & 1 deletion spinetoolbox/project_item/project_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def undo_specification(self):
return self._specification

def set_specification(self, specification):
"""Pushes a new SetItemSpecificationCommand to the toolbox' undo stack."""
"""Pushes a new SetItemSpecificationCommand to the undo stack."""
if specification == self._specification:
return
self._toolbox.undo_stack.push(
Expand Down
2 changes: 1 addition & 1 deletion spinetoolbox/project_item/specification_editor_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(self, toolbox, specification=None, item=None):
self._spec_toolbar = _SpecNameDescriptionToolbar(self, specification, self._undo_stack)
self._spec_toolbar.show_toolbox_action.triggered.connect(self._toolbox.restore_and_activate)
self._spec_toolbar.name_changed.connect(self._set_window_title)
self.addToolBar(Qt.TopToolBarArea, self._spec_toolbar)
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self._spec_toolbar)
self._populate_main_menu()
self._spec_toolbar.save_action.triggered.connect(self._save)
self._spec_toolbar.duplicate_action.triggered.connect(self._duplicate)
Expand Down
10 changes: 5 additions & 5 deletions spinetoolbox/widgets/settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ def read_settings(self):
snap_entities = self._qsettings.value("appSettings/snapEntities", defaultValue="false")
merge_dbs = self._qsettings.value("appSettings/mergeDBs", defaultValue="true")
db_editor_show_undo = int(self._qsettings.value("appSettings/dbEditorShowUndo", defaultValue="2"))
max_ent_dim_count = int(self.qsettings.value("appSettings/maxEntityDimensionCount", defaultValue="5"))
build_iters = int(self.qsettings.value("appSettings/layoutAlgoBuildIterations", defaultValue="12"))
spread_factor = int(self.qsettings.value("appSettings/layoutAlgoSpreadFactor", defaultValue="100"))
neg_weight_exp = int(self.qsettings.value("appSettings/layoutAlgoNegWeightExp", defaultValue="2"))
max_ent_dim_count = int(self._qsettings.value("appSettings/maxEntityDimensionCount", defaultValue="5"))
build_iters = int(self._qsettings.value("appSettings/layoutAlgoBuildIterations", defaultValue="12"))
spread_factor = int(self._qsettings.value("appSettings/layoutAlgoSpreadFactor", defaultValue="100"))
neg_weight_exp = int(self._qsettings.value("appSettings/layoutAlgoNegWeightExp", defaultValue="2"))
if commit_at_exit == 0: # Not needed but makes the code more readable.
self.ui.checkBox_commit_at_exit.setCheckState(Qt.CheckState.Unchecked)
elif commit_at_exit == 1:
self.ui.checkBox_commit_at_exit.setCheckState(Qt.PartiallyChecked)
self.ui.checkBox_commit_at_exit.setCheckState(Qt.CheckState.PartiallyChecked)
else: # commit_at_exit == "2":
self.ui.checkBox_commit_at_exit.setCheckState(Qt.CheckState.Checked)
self.ui.checkBox_entity_tree_sticky_selection.setChecked(sticky_selection == "true")
Expand Down

0 comments on commit 20b5967

Please sign in to comment.