From 712e4680cae91ca3ca7291bc7f5124d5a3578a4d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 24 Nov 2020 14:10:53 +0100 Subject: preferences: connect() dialog page only once Weirdly, the settingsChanged() signal of the dialog-pages was connected() to the settingsChanged() signal of the dialog every time the settings were accepted. Do it only once in the constructor. Signed-off-by: Berthold Stoeger --- desktop-widgets/preferences/preferencesdialog.cpp | 5 ++--- desktop-widgets/preferences/preferencesdialog.h | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'desktop-widgets/preferences') diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 6ad91acec..1164c5de3 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -84,6 +84,7 @@ PreferencesDialog::PreferencesDialog() pagesList->addItem(item); pagesStack->addWidget(page); page->refreshSettings(); + connect(page, &AbstractPreferencesWidget::settingsChanged, &diveListNotifier, &DiveListNotifier::settingsChanged); } connect(pagesList, &QListWidget::currentRowChanged, @@ -116,10 +117,8 @@ void PreferencesDialog::refreshPages() void PreferencesDialog::applyRequested(bool closeIt) { - Q_FOREACH(AbstractPreferencesWidget *page, pages) { - connect(page, &AbstractPreferencesWidget::settingsChanged, &diveListNotifier, &DiveListNotifier::settingsChanged, Qt::UniqueConnection); + for (AbstractPreferencesWidget *page: pages) page->syncSettings(); - } emit diveListNotifier.settingsChanged(); if (closeIt) accept(); diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h index d05487b98..4eb222006 100644 --- a/desktop-widgets/preferences/preferencesdialog.h +++ b/desktop-widgets/preferences/preferencesdialog.h @@ -3,7 +3,6 @@ #define PREFERENCES_WIDGET_H #include -#include "core/pref.h" class AbstractPreferencesWidget; class QListWidget; @@ -14,7 +13,7 @@ class QAbstractButton; class PreferencesDialog : public QDialog { Q_OBJECT public: - static PreferencesDialog* instance(); + static PreferencesDialog *instance(); ~PreferencesDialog(); void refreshPages(); void defaultsRequested(); -- cgit v1.2.3-70-g09d2