Skip to content

Commit

Permalink
Add reset settings button to a new group box in Settings Widget
Browse files Browse the repository at this point in the history
- Remove reset main window settings
  • Loading branch information
ptsavol committed Dec 2, 2024
1 parent 239922c commit 8158050
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 169 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()

Check warning on line 1899 in spinetoolbox/helpers.py

View check run for this annotation

Codecov / codecov/patch

spinetoolbox/helpers.py#L1897-L1899

Added lines #L1897 - L1899 were not covered by tests
118 changes: 57 additions & 61 deletions spinetoolbox/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,6 @@ 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_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_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.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, 3, 0, 1, 1)

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

Expand All @@ -242,15 +222,10 @@ def setupUi(self, SettingsForm):

self.gridLayout_2.addWidget(self.checkBox_use_rounded_items, 5, 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_use_smooth_zoom = QCheckBox(self.groupBox_ui)
self.checkBox_use_smooth_zoom.setObjectName(u"checkBox_use_smooth_zoom")
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_smooth_zoom, 7, 0, 1, 1)
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 @@ -344,34 +319,58 @@ def setupUi(self, SettingsForm):

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, 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_ui)
self.label_17 = QLabel(self.groupBox_3)
self.label_17.setObjectName(u"label_17")

self.horizontalLayout.addWidget(self.label_17)

self.toolButton_reset_main_window = QToolButton(self.groupBox_ui)
self.toolButton_reset_main_window.setObjectName(u"toolButton_reset_main_window")
icon6 = QIcon()
icon6.addFile(u":/icons/menu_icons/undo.svg", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.toolButton_reset_main_window.setIcon(icon6)

self.horizontalLayout.addWidget(self.toolButton_reset_main_window)

self.toolButton_reset_all_settings = QToolButton(self.groupBox_ui)
self.toolButton_reset_all_settings = QToolButton(self.groupBox_3)
self.toolButton_reset_all_settings.setObjectName(u"toolButton_reset_all_settings")
icon7 = QIcon()
icon7.addFile(u":/icons/menu_icons/trash-alt.svg", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.toolButton_reset_all_settings.setIcon(icon7)
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_2.addLayout(self.horizontalLayout, 9, 0, 1, 1)
self.gridLayout_6.addLayout(self.horizontalLayout, 0, 0, 1, 1)


self.verticalLayout_6.addWidget(self.groupBox_ui)
self.verticalLayout_6.addWidget(self.groupBox_3)

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

Expand Down Expand Up @@ -1038,8 +1037,7 @@ 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.toolButton_reset_main_window)
QWidget.setTabOrder(self.toolButton_reset_main_window, self.toolButton_reset_all_settings)
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)
Expand Down Expand Up @@ -1148,23 +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))
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_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_drag_to_draw_links.setText(QCoreApplication.translate("SettingsForm", u"Drag to draw links", 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_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))
#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))
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_smooth_zoom.setText(QCoreApplication.translate("SettingsForm", u"Smooth zoom", None))
self.checkBox_use_curved_links.setText(QCoreApplication.translate("SettingsForm", u"Curved links", 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 @@ -1176,13 +1163,22 @@ def retranslateUi(self, SettingsForm):
self.label_4.setText(QCoreApplication.translate("SettingsForm", u"Link flash speed", None))
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.label_17.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>See tool tip in button</p></body></html>", None))
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.label_17.setText(QCoreApplication.translate("SettingsForm", u"Reset to factory defaults", None))
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.toolButton_reset_main_window.setToolTip(QCoreApplication.translate("SettingsForm", u"<html><head/><body><p>Resets main window size, position, dock widget sizes and positions, and slider positions 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))
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)
Expand Down
Loading

0 comments on commit 8158050

Please sign in to comment.