Skip to content

Commit

Permalink
Add reset settings buttons (#3019)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsavol authored Dec 2, 2024
1 parent 0d27a72 commit e318e36
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 103 deletions.
14 changes: 13 additions & 1 deletion spinetoolbox/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from typing import Sequence # pylint: disable=unused-import
from xml.etree import ElementTree
import matplotlib
from PySide6.QtCore import QEvent, QFile, QIODevice, QObject, QPoint, QRect, QSize, Qt, QUrl, Slot
from PySide6.QtCore import QEvent, QFile, QIODevice, QObject, QPoint, QRect, QSize, Qt, QUrl, Slot, QSettings
from PySide6.QtCore import __version__ as qt_version
from PySide6.QtCore import __version_info__ as qt_version_info
from PySide6.QtGui import (
Expand Down Expand Up @@ -1885,3 +1885,15 @@ def add_keyboard_shortcuts_to_action_tool_tips(ui):
if not isinstance(action, QAction):
continue
add_keyboard_shortcut_to_tool_tip(action)


def clear_qsettings(settings):
"""Clears Application Settings.
Args:
settings (QSettings): Settings instance that refers to
'Spine Toolbox' application in a 'SpineProject' organization.
"""
settings.clear()
s1 = QSettings("SpineProject", "AddUpSpineOptWizard")
s1.clear()
118 changes: 76 additions & 42 deletions spinetoolbox/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,40 +212,20 @@ def setupUi(self, SettingsForm):
self.groupBox_ui.setObjectName(u"groupBox_ui")
self.gridLayout_2 = QGridLayout(self.groupBox_ui)
self.gridLayout_2.setObjectName(u"gridLayout_2")
self.checkBox_use_smooth_zoom = QCheckBox(self.groupBox_ui)
self.checkBox_use_smooth_zoom.setObjectName(u"checkBox_use_smooth_zoom")

self.gridLayout_2.addWidget(self.checkBox_use_smooth_zoom, 10, 0, 1, 1)

self.checkBox_datetime = QCheckBox(self.groupBox_ui)
self.checkBox_datetime.setObjectName(u"checkBox_datetime")

self.gridLayout_2.addWidget(self.checkBox_datetime, 8, 0, 1, 1)

self.checkBox_use_curved_links = QCheckBox(self.groupBox_ui)
self.checkBox_use_curved_links.setObjectName(u"checkBox_use_curved_links")

self.gridLayout_2.addWidget(self.checkBox_use_curved_links, 4, 0, 1, 1)

self.checkBox_color_properties_widgets = QCheckBox(self.groupBox_ui)
self.checkBox_color_properties_widgets.setObjectName(u"checkBox_color_properties_widgets")

self.gridLayout_2.addWidget(self.checkBox_color_properties_widgets, 3, 0, 1, 1)

self.checkBox_color_toolbar_icons = QCheckBox(self.groupBox_ui)
self.checkBox_color_toolbar_icons.setObjectName(u"checkBox_color_toolbar_icons")

self.gridLayout_2.addWidget(self.checkBox_color_toolbar_icons, 2, 0, 1, 1)

self.checkBox_prevent_overlapping = QCheckBox(self.groupBox_ui)
self.checkBox_prevent_overlapping.setObjectName(u"checkBox_prevent_overlapping")

self.gridLayout_2.addWidget(self.checkBox_prevent_overlapping, 6, 0, 1, 1)
self.gridLayout_2.addWidget(self.checkBox_prevent_overlapping, 4, 0, 1, 1)

self.checkBox_use_rounded_items = QCheckBox(self.groupBox_ui)
self.checkBox_use_rounded_items.setObjectName(u"checkBox_use_rounded_items")

self.gridLayout_2.addWidget(self.checkBox_use_rounded_items, 7, 0, 1, 1)
self.gridLayout_2.addWidget(self.checkBox_use_rounded_items, 5, 0, 1, 1)

self.checkBox_use_curved_links = QCheckBox(self.groupBox_ui)
self.checkBox_use_curved_links.setObjectName(u"checkBox_use_curved_links")

self.gridLayout_2.addWidget(self.checkBox_use_curved_links, 2, 0, 1, 1)

self.formLayout = QFormLayout()
self.formLayout.setObjectName(u"formLayout")
Expand Down Expand Up @@ -337,16 +317,61 @@ def setupUi(self, SettingsForm):
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.frame_1)


self.gridLayout_2.addLayout(self.formLayout, 12, 0, 1, 1)
self.gridLayout_2.addLayout(self.formLayout, 8, 0, 1, 1)

self.checkBox_drag_to_draw_links = QCheckBox(self.groupBox_ui)
self.checkBox_drag_to_draw_links.setObjectName(u"checkBox_drag_to_draw_links")

self.gridLayout_2.addWidget(self.checkBox_drag_to_draw_links, 5, 0, 1, 1)
self.gridLayout_2.addWidget(self.checkBox_drag_to_draw_links, 3, 0, 1, 1)

self.checkBox_datetime = QCheckBox(self.groupBox_ui)
self.checkBox_datetime.setObjectName(u"checkBox_datetime")

self.gridLayout_2.addWidget(self.checkBox_datetime, 6, 0, 1, 1)

self.checkBox_color_toolbar_icons = QCheckBox(self.groupBox_ui)
self.checkBox_color_toolbar_icons.setObjectName(u"checkBox_color_toolbar_icons")

self.gridLayout_2.addWidget(self.checkBox_color_toolbar_icons, 0, 0, 1, 1)

self.checkBox_color_properties_widgets = QCheckBox(self.groupBox_ui)
self.checkBox_color_properties_widgets.setObjectName(u"checkBox_color_properties_widgets")

self.gridLayout_2.addWidget(self.checkBox_color_properties_widgets, 1, 0, 1, 1)

self.checkBox_use_smooth_zoom = QCheckBox(self.groupBox_ui)
self.checkBox_use_smooth_zoom.setObjectName(u"checkBox_use_smooth_zoom")

self.gridLayout_2.addWidget(self.checkBox_use_smooth_zoom, 7, 0, 1, 1)


self.verticalLayout_6.addWidget(self.groupBox_ui)

self.groupBox_3 = QGroupBox(self.General)
self.groupBox_3.setObjectName(u"groupBox_3")
self.gridLayout_6 = QGridLayout(self.groupBox_3)
self.gridLayout_6.setObjectName(u"gridLayout_6")
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.label_17 = QLabel(self.groupBox_3)
self.label_17.setObjectName(u"label_17")

self.horizontalLayout.addWidget(self.label_17)

self.toolButton_reset_all_settings = QToolButton(self.groupBox_3)
self.toolButton_reset_all_settings.setObjectName(u"toolButton_reset_all_settings")
icon6 = QIcon()
icon6.addFile(u":/icons/menu_icons/trash-alt.svg", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.toolButton_reset_all_settings.setIcon(icon6)

self.horizontalLayout.addWidget(self.toolButton_reset_all_settings)


self.gridLayout_6.addLayout(self.horizontalLayout, 0, 0, 1, 1)


self.verticalLayout_6.addWidget(self.groupBox_3)

self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)

self.verticalLayout_6.addItem(self.verticalSpacer)
Expand Down Expand Up @@ -1012,7 +1037,8 @@ def setupUi(self, SettingsForm):
QWidget.setTabOrder(self.radioButton_bg_tree, self.radioButton_bg_solid)
QWidget.setTabOrder(self.radioButton_bg_solid, self.toolButton_bg_color)
QWidget.setTabOrder(self.toolButton_bg_color, self.horizontalSlider_data_flow_animation_duration)
QWidget.setTabOrder(self.horizontalSlider_data_flow_animation_duration, self.lineEdit_gams_path)
QWidget.setTabOrder(self.horizontalSlider_data_flow_animation_duration, self.toolButton_reset_all_settings)
QWidget.setTabOrder(self.toolButton_reset_all_settings, self.lineEdit_gams_path)
QWidget.setTabOrder(self.lineEdit_gams_path, self.toolButton_browse_gams)
QWidget.setTabOrder(self.toolButton_browse_gams, self.radioButton_use_julia_basic_console)
QWidget.setTabOrder(self.radioButton_use_julia_basic_console, self.radioButton_use_julia_jupyter_console)
Expand Down Expand Up @@ -1120,22 +1146,12 @@ def retranslateUi(self, SettingsForm):
#endif // QT_CONFIG(tooltip)
self.checkBox_open_previous_project.setText(QCoreApplication.translate("SettingsForm", u"Open previous project at startup", None))
self.groupBox_ui.setTitle(QCoreApplication.translate("SettingsForm", u"UI", None))
#if QT_CONFIG(tooltip)
self.checkBox_use_smooth_zoom.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>Controls whether smooth or discete zoom is used in Design and Graph Views.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.checkBox_use_smooth_zoom.setText(QCoreApplication.translate("SettingsForm", u"Smooth zoom", None))
#if QT_CONFIG(tooltip)
self.checkBox_datetime.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>If checked, date and time string is appended into Event Log messages</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.checkBox_datetime.setText(QCoreApplication.translate("SettingsForm", u"Show date and time in Event Log messages", None))
self.checkBox_prevent_overlapping.setText(QCoreApplication.translate("SettingsForm", u"Prevent items from overlapping", None))
self.checkBox_use_rounded_items.setText(QCoreApplication.translate("SettingsForm", u"Rounded items", None))
#if QT_CONFIG(tooltip)
self.checkBox_use_curved_links.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>Controls whether smooth or straight connectors are used in Design View.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.checkBox_use_curved_links.setText(QCoreApplication.translate("SettingsForm", u"Curved links", None))
self.checkBox_color_properties_widgets.setText(QCoreApplication.translate("SettingsForm", u"Color properties widgets", None))
self.checkBox_color_toolbar_icons.setText(QCoreApplication.translate("SettingsForm", u"Color toolbar icons", None))
self.checkBox_prevent_overlapping.setText(QCoreApplication.translate("SettingsForm", u"Prevent items from overlapping", None))
self.checkBox_use_rounded_items.setText(QCoreApplication.translate("SettingsForm", u"Rounded items", None))
self.label_7.setText(QCoreApplication.translate("SettingsForm", u"Background", None))
self.radioButton_bg_grid.setText(QCoreApplication.translate("SettingsForm", u"Grid", None))
self.radioButton_bg_tree.setText(QCoreApplication.translate("SettingsForm", u"Tree of Life", None))
Expand All @@ -1148,6 +1164,24 @@ def retranslateUi(self, SettingsForm):
self.label_5.setText(QCoreApplication.translate("SettingsForm", u"Slow", None))
self.label_8.setText(QCoreApplication.translate("SettingsForm", u"Fast", None))
self.checkBox_drag_to_draw_links.setText(QCoreApplication.translate("SettingsForm", u"Drag to draw links", None))
#if QT_CONFIG(tooltip)
self.checkBox_datetime.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>If checked, date and time string is appended into Event Log messages</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.checkBox_datetime.setText(QCoreApplication.translate("SettingsForm", u"Show date and time in Event Log messages", None))
self.checkBox_color_toolbar_icons.setText(QCoreApplication.translate("SettingsForm", u"Color toolbar icons", None))
self.checkBox_color_properties_widgets.setText(QCoreApplication.translate("SettingsForm", u"Color properties widgets", None))
#if QT_CONFIG(tooltip)
self.checkBox_use_smooth_zoom.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>Controls whether smooth or discete zoom is used in Design and Graph Views.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.checkBox_use_smooth_zoom.setText(QCoreApplication.translate("SettingsForm", u"Smooth zoom", None))
self.groupBox_3.setTitle(QCoreApplication.translate("SettingsForm", u"Danger zone", None))
#if QT_CONFIG(tooltip)
self.label_17.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>See tool tip in button</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.label_17.setText(QCoreApplication.translate("SettingsForm", u"Reset settings to factory defaults", None))
#if QT_CONFIG(tooltip)
self.toolButton_reset_all_settings.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>Resets all settings to factory defaults.</p><p><span style=\" font-weight:700;\">The app must be shutdown</span> for the changes to take effect, so make sure to close all windows and save the project before clicking this button.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.groupBox_gams.setTitle(QCoreApplication.translate("SettingsForm", u"GAMS", None))
self.label_11.setText(QCoreApplication.translate("SettingsForm", u"GAMS executable", None))
#if QT_CONFIG(tooltip)
Expand Down
123 changes: 79 additions & 44 deletions spinetoolbox/ui/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,21 @@
<string>UI</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="10" column="0">
<widget class="QCheckBox" name="checkBox_use_smooth_zoom">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Controls whether smooth or discete zoom is used in Design and Graph Views.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_prevent_overlapping">
<property name="text">
<string>Smooth zoom</string>
<string>Prevent items from overlapping</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkBox_datetime">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, date and time string is appended into Event Log messages&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_use_rounded_items">
<property name="text">
<string>Show date and time in Event Log messages</string>
<string>Rounded items</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_use_curved_links">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Controls whether smooth or straight connectors are used in Design View.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand All @@ -383,35 +377,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_color_properties_widgets">
<property name="text">
<string>Color properties widgets</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_color_toolbar_icons">
<property name="text">
<string>Color toolbar icons</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_prevent_overlapping">
<property name="text">
<string>Prevent items from overlapping</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBox_use_rounded_items">
<property name="text">
<string>Rounded items</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="8" column="0">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
Expand Down Expand Up @@ -585,13 +551,81 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_drag_to_draw_links">
<property name="text">
<string>Drag to draw links</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_datetime">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, date and time string is appended into Event Log messages&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Show date and time in Event Log messages</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_color_toolbar_icons">
<property name="text">
<string>Color toolbar icons</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_color_properties_widgets">
<property name="text">
<string>Color properties widgets</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBox_use_smooth_zoom">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Controls whether smooth or discete zoom is used in Design and Graph Views.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Smooth zoom</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Danger zone</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_17">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;See tool tip in button&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Reset settings to factory defaults</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_reset_all_settings">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Resets all settings to factory defaults.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;The app must be shutdown&lt;/span&gt; for the changes to take effect, so make sure to close all windows and save the project before clicking this button.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="icon">
<iconset resource="resources/resources_icons.qrc">
<normaloff>:/icons/menu_icons/trash-alt.svg</normaloff>:/icons/menu_icons/trash-alt.svg</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1732,6 +1766,7 @@
<tabstop>radioButton_bg_solid</tabstop>
<tabstop>toolButton_bg_color</tabstop>
<tabstop>horizontalSlider_data_flow_animation_duration</tabstop>
<tabstop>toolButton_reset_all_settings</tabstop>
<tabstop>lineEdit_gams_path</tabstop>
<tabstop>toolButton_browse_gams</tabstop>
<tabstop>radioButton_use_julia_basic_console</tabstop>
Expand Down Expand Up @@ -1805,7 +1840,7 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="engine_processes_button_group"/>
<buttongroup name="persistent_processes_button_group"/>
<buttongroup name="engine_processes_button_group"/>
</buttongroups>
</ui>
Loading

0 comments on commit e318e36

Please sign in to comment.