Skip to content

Commit

Permalink
Fix things
Browse files Browse the repository at this point in the history
- Fix saving root directory into local project settings
- Edit root directory lineEdit placeholder text
- Add label above root directory lineEdit
- Browse root directory button now opens the file explorer in the project dir by default
- Enable Clear buttons in both lineEdits in the Tool Properties
  • Loading branch information
ptsavol committed Dec 12, 2024
1 parent 3cd01c1 commit 02e3b80
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 29 deletions.
3 changes: 2 additions & 1 deletion spine_items/tool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def restore_selections(self):
@Slot(bool)
def _browse_root_directory(self, _=False):
"""Calls static method that shows a file browser for selecting a Python interpreter."""
select_root_directory(self._toolbox, self._properties_ui.lineEdit_root_directory)
select_root_directory(self._toolbox, self._properties_ui.lineEdit_root_directory, self._project.project_dir)
self._set_root_directory()

Check warning on line 235 in spine_items/tool/tool.py

View check run for this annotation

Codecov / codecov/patch

spine_items/tool/tool.py#L234-L235

Added lines #L234 - L235 were not covered by tests

@Slot()
def _set_root_directory(self):
Expand Down
29 changes: 18 additions & 11 deletions spine_items/tool/ui/tool_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,21 @@ def setupUi(self, Form):

self.verticalLayout_2.addLayout(self.horizontalLayout)

self.label = QLabel(self.frame)
self.label.setObjectName(u"label")

self.verticalLayout_2.addWidget(self.label)

self.horizontalLayout_3 = QHBoxLayout()
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
self.lineEdit_root_directory = QLineEdit(self.frame)
self.lineEdit_root_directory.setObjectName(u"lineEdit_root_directory")
sizePolicy3 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.lineEdit_root_directory.sizePolicy().hasHeightForWidth())
self.lineEdit_root_directory.setSizePolicy(sizePolicy3)
self.lineEdit_root_directory.setClearButtonEnabled(True)

self.horizontalLayout_3.addWidget(self.lineEdit_root_directory)

Expand All @@ -210,20 +221,18 @@ def setupUi(self, Form):

self.verticalLayout_2.addLayout(self.horizontalLayout_3)

self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.label_group_id = QLabel(self.frame)
self.label_group_id.setObjectName(u"label_group_id")

self.horizontalLayout_2.addWidget(self.label_group_id)
self.verticalLayout_2.addWidget(self.label_group_id)

self.lineEdit_group_id = QLineEdit(self.frame)
self.lineEdit_group_id.setObjectName(u"lineEdit_group_id")
sizePolicy3.setHeightForWidth(self.lineEdit_group_id.sizePolicy().hasHeightForWidth())
self.lineEdit_group_id.setSizePolicy(sizePolicy3)
self.lineEdit_group_id.setClearButtonEnabled(True)

self.horizontalLayout_2.addWidget(self.lineEdit_group_id)


self.verticalLayout_2.addLayout(self.horizontalLayout_2)
self.verticalLayout_2.addWidget(self.lineEdit_group_id)

self.label_jupyter = ElidedLabel(self.frame)
self.label_jupyter.setObjectName(u"label_jupyter")
Expand All @@ -245,9 +254,6 @@ def setupUi(self, Form):
self.horizontalLayout_11.setObjectName(u"horizontalLayout_11")
self.pushButton_tool_results = QPushButton(self.frame)
self.pushButton_tool_results.setObjectName(u"pushButton_tool_results")
sizePolicy3 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.pushButton_tool_results.sizePolicy().hasHeightForWidth())
self.pushButton_tool_results.setSizePolicy(sizePolicy3)

Expand Down Expand Up @@ -307,8 +313,9 @@ def retranslateUi(self, Form):
self.label_2.setText(QCoreApplication.translate("Form", u"Execute in", None))
self.radioButton_execute_in_source.setText(QCoreApplication.translate("Form", u"Source dir", None))
self.radioButton_execute_in_work.setText(QCoreApplication.translate("Form", u"Work dir", None))
self.label.setText(QCoreApplication.translate("Form", u"Source code root directory:", None))
self.lineEdit_root_directory.setText("")
self.lineEdit_root_directory.setPlaceholderText(QCoreApplication.translate("Form", u"Root directory...", None))
self.lineEdit_root_directory.setPlaceholderText(QCoreApplication.translate("Form", u"Root directory path...", None))
self.label_group_id.setText(QCoreApplication.translate("Form", u"Reuse console id:", None))
#if QT_CONFIG(tooltip)
self.lineEdit_group_id.setToolTip(QCoreApplication.translate("Form", u"<html><head/><body><p>Enter an id for sharing a console with other Tools in this project. Leave empty to run this Tool in isolation.</p></body></html>", None))
Expand Down
55 changes: 38 additions & 17 deletions spine_items/tool/ui/tool_properties.ui
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,31 @@ QScrollArea &gt; QWidget &gt; QWidget { background: transparent; }</string>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Source code root directory:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="lineEdit_root_directory">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Root directory...</string>
<string>Root directory path...</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -335,22 +351,27 @@ QScrollArea &gt; QWidget &gt; QWidget { background: transparent; }</string>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_group_id">
<property name="text">
<string>Reuse console id:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_group_id">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter an id for sharing a console with other Tools in this project. Leave empty to run this Tool in isolation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="label_group_id">
<property name="text">
<string>Reuse console id:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_group_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter an id for sharing a console with other Tools in this project. Leave empty to run this Tool in isolation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ElidedLabel" name="label_jupyter">
Expand Down

0 comments on commit 02e3b80

Please sign in to comment.