From 75b5be8f40df3d3b7d354eead0439b53b2490024 Mon Sep 17 00:00:00 2001 From: willemferguson Date: Tue, 10 Dec 2019 15:02:13 +0200 Subject: Preferences UI: add reset tab Add a separate preferences tab for resetting all preferences to their default values. One or two very small alterations to other sections of the preferences UI code. Signed-off-by: willemferguson Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/CMakeLists.txt | 17 ++-- .../preferences/preferences_defaults.cpp | 7 ++ desktop-widgets/preferences/preferences_defaults.h | 1 + .../preferences/preferences_defaults.ui | 97 ++++++++++++--------- desktop-widgets/preferences/preferences_reset.cpp | 34 ++++++++ desktop-widgets/preferences/preferences_reset.h | 29 ++++++ desktop-widgets/preferences/preferences_reset.ui | 77 ++++++++++++++++ desktop-widgets/preferences/preferencesdialog.cpp | 6 +- desktop-widgets/preferences/preferencesdialog.h | 2 +- icons/pref_reset.png | Bin 0 -> 586 bytes subsurface.qrc | 2 + 11 files changed, 219 insertions(+), 53 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_reset.cpp create mode 100644 desktop-widgets/preferences/preferences_reset.h create mode 100644 desktop-widgets/preferences/preferences_reset.ui create mode 100644 icons/pref_reset.png diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 2298db6b9..757e9940d 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -5,17 +5,18 @@ include_directories(. ) set(SUBSURFACE_PREFERENCES_UI - preferences_defaults.ui - preferences_graph.ui - preferences_network.ui preferences_cloud.ui - preferences_units.ui + preferences_dc.ui + preferences_defaults.ui + preferences_equipment.ui preferences_georeference.ui + preferences_graph.ui preferences_language.ui - preferences_media.ui - preferences_equipment.ui - preferences_dc.ui preferences_log.ui + preferences_media.ui + preferences_network.ui + preferences_reset.ui + preferences_units.ui ) qt5_wrap_ui(SUBSURFACE_PREFERENCES_UI_HDRS ${SUBSURFACE_PREFERENCES_UI}) @@ -45,6 +46,8 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS preferences_media.h preferences_network.cpp preferences_network.h + preferences_reset.cpp + preferences_reset.h preferences_units.cpp preferences_units.h preferencesdialog.cpp diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index dbf1091e4..7b3c16148 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -2,6 +2,7 @@ #include "preferences_defaults.h" #include "ui_preferences_defaults.h" #include "core/dive.h" +#include "preferencesdialog.h" #include "core/settings/qPrefGeneral.h" #include "core/settings/qPrefDisplay.h" #include "core/settings/qPrefCloudStorage.h" @@ -21,6 +22,12 @@ PreferencesDefaults::~PreferencesDefaults() delete ui; } +/*void PreferencesDefaults::on_resetSettings_clicked() +{ + auto dialog = PreferencesDialog::instance(); + dialog->defaultsRequested(); +} */ + void PreferencesDefaults::refreshSettings() { ui->font->setCurrentFont(qPrefDisplay::divelist_font()); diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h index cc92ade40..44856a6fa 100644 --- a/desktop-widgets/preferences/preferences_defaults.h +++ b/desktop-widgets/preferences/preferences_defaults.h @@ -16,6 +16,7 @@ public: ~PreferencesDefaults(); void refreshSettings() override; void syncSettings() override; + public slots: private: diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui index 3d9e45c98..030bb77d6 100644 --- a/desktop-widgets/preferences/preferences_defaults.ui +++ b/desktop-widgets/preferences/preferences_defaults.ui @@ -14,15 +14,17 @@ Form + - Lists and tables + Font for lists and tables 5 + @@ -33,6 +35,18 @@ + + + + + true + + + + + + + @@ -43,6 +57,7 @@ + @@ -52,43 +67,55 @@ Animations - + 5 + - - - Speed + + + - - - - - - 500 + + true - - Qt::Horizontal + + In some actions, e.g. when zooming the dive profile, the changing axis values are animated. Select the speed with which this animation should occur (maximum = 500): - - - - 500 - - + + + + + + + Speed + + + + + + + 500 + + + Qt::Horizontal + + + + + + + 500 + + + + - - - - - - - Reset all settings to their default value - + @@ -109,22 +136,6 @@ - - btnUseDefaultFile - toggled(bool) - chooseFile - setHidden(bool) - - - 462 - 136 - - - 528 - 145 - - - velocitySlider valueChanged(int) diff --git a/desktop-widgets/preferences/preferences_reset.cpp b/desktop-widgets/preferences/preferences_reset.cpp new file mode 100644 index 000000000..2ebfef91a --- /dev/null +++ b/desktop-widgets/preferences/preferences_reset.cpp @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "preferences_reset.h" +#include "ui_preferences_reset.h" +#include "core/dive.h" +#include "preferencesdialog.h" + +PreferencesReset::PreferencesReset(): AbstractPreferencesWidget(tr("Reset"), QIcon(":preferences-reset-icon"), 11 ), ui(new Ui::PreferencesReset()) +{ + ui->setupUi(this); + + int h = 2 * ui->resetWarningIcon->height(); + QPixmap warning (":preferences-reset-warning-icon"); + ui->resetWarningIcon->setPixmap(warning.scaled(h,h,Qt::KeepAspectRatio)); +} + +PreferencesReset::~PreferencesReset() +{ + delete ui; +} + +void PreferencesReset::on_resetSettings_clicked() +{ + auto dialog = PreferencesDialog::instance(); + dialog->defaultsRequested(); +} + +void PreferencesReset::refreshSettings() +{ +} + +void PreferencesReset::syncSettings() +{ +} + diff --git a/desktop-widgets/preferences/preferences_reset.h b/desktop-widgets/preferences/preferences_reset.h new file mode 100644 index 000000000..bf5af593b --- /dev/null +++ b/desktop-widgets/preferences/preferences_reset.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef PREFERENCES_RESET_H +#define PREFERENCES_RESET_H + +#include "abstractpreferenceswidget.h" +#include "core/pref.h" + +namespace Ui { + class PreferencesReset; +} + +class PreferencesReset : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesReset(); + ~PreferencesReset(); + void refreshSettings() override; + void syncSettings() override; + +public slots: + void on_resetSettings_clicked(); + +private: + Ui::PreferencesReset *ui; +}; + + +#endif + diff --git a/desktop-widgets/preferences/preferences_reset.ui b/desktop-widgets/preferences/preferences_reset.ui new file mode 100644 index 000000000..c9e53dd5f --- /dev/null +++ b/desktop-widgets/preferences/preferences_reset.ui @@ -0,0 +1,77 @@ + + + PreferencesReset + + + + 0 + 0 + 561 + 558 + + + + Form + + + + + + + + + + + + + true + + + + + + + + + + + + true + + + Selecting this button will reset all settings to their default values + + + + + + + + + + + Reset all settings + + + + + > + + + Qt::Vertical + + + + 0 + 195 + + + + + + + + + + + diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 7602a3817..7f9f91dd4 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -13,6 +13,7 @@ #include "preferences_media.h" #include "preferences_dc.h" #include "preferences_log.h" +#include "preferences_reset.h" #include "core/qthelper.h" @@ -52,8 +53,8 @@ PreferencesDialog::PreferencesDialog() QDialogButtonBox::Apply | QDialogButtonBox::Cancel); - pagesList->setMinimumWidth(120); - pagesList->setMaximumWidth(120); + pagesList->setMinimumWidth(140); + pagesList->setMaximumWidth(140); QHBoxLayout *h = new QHBoxLayout(); h->addWidget(pagesList); @@ -75,6 +76,7 @@ PreferencesDialog::PreferencesDialog() addPreferencePage(new PreferencesMedia()); addPreferencePage(new PreferencesDc()); addPreferencePage(new PreferencesLog()); + addPreferencePage(new PreferencesReset()); refreshPages(); diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index 2a1b53315..569733436 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -19,13 +19,13 @@ public: void addPreferencePage(AbstractPreferencesWidget *page); void refreshPages(); void emitSettingsChanged(); + void defaultsRequested(); signals: void settingsChanged(); private: PreferencesDialog(); void cancelRequested(); void applyRequested(bool closeIt); - void defaultsRequested(); void buttonClicked(QAbstractButton *btn); QList pages; QListWidget *pagesList; diff --git a/icons/pref_reset.png b/icons/pref_reset.png new file mode 100644 index 000000000..cb6277a1a Binary files /dev/null and b/icons/pref_reset.png differ diff --git a/subsurface.qrc b/subsurface.qrc index 15d627e5c..f15428ae0 100644 --- a/subsurface.qrc +++ b/subsurface.qrc @@ -18,6 +18,8 @@ icons/pref_dc.png icons/pref_log.png icons/pref_display.png + icons/pref_reset.png + icons/warning.png icons/graph.png icons/minimum.png icons/maximum.png -- cgit v1.2.3-70-g09d2