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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-11-24 14:10:53 +01:00 committed by Dirk Hohndel
parent 0fab09a990
commit 712e4680ca
2 changed files with 3 additions and 5 deletions

View file

@ -84,6 +84,7 @@ PreferencesDialog::PreferencesDialog()
pagesList->addItem(item); pagesList->addItem(item);
pagesStack->addWidget(page); pagesStack->addWidget(page);
page->refreshSettings(); page->refreshSettings();
connect(page, &AbstractPreferencesWidget::settingsChanged, &diveListNotifier, &DiveListNotifier::settingsChanged);
} }
connect(pagesList, &QListWidget::currentRowChanged, connect(pagesList, &QListWidget::currentRowChanged,
@ -116,10 +117,8 @@ void PreferencesDialog::refreshPages()
void PreferencesDialog::applyRequested(bool closeIt) void PreferencesDialog::applyRequested(bool closeIt)
{ {
Q_FOREACH(AbstractPreferencesWidget *page, pages) { for (AbstractPreferencesWidget *page: pages)
connect(page, &AbstractPreferencesWidget::settingsChanged, &diveListNotifier, &DiveListNotifier::settingsChanged, Qt::UniqueConnection);
page->syncSettings(); page->syncSettings();
}
emit diveListNotifier.settingsChanged(); emit diveListNotifier.settingsChanged();
if (closeIt) if (closeIt)
accept(); accept();

View file

@ -3,7 +3,6 @@
#define PREFERENCES_WIDGET_H #define PREFERENCES_WIDGET_H
#include <QDialog> #include <QDialog>
#include "core/pref.h"
class AbstractPreferencesWidget; class AbstractPreferencesWidget;
class QListWidget; class QListWidget;
@ -14,7 +13,7 @@ class QAbstractButton;
class PreferencesDialog : public QDialog { class PreferencesDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
static PreferencesDialog* instance(); static PreferencesDialog *instance();
~PreferencesDialog(); ~PreferencesDialog();
void refreshPages(); void refreshPages();
void defaultsRequested(); void defaultsRequested();