summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-11-24 13:54:21 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-12 15:52:40 -0800
commit0fab09a9901314f5597b16da370d3712ce28c4ae (patch)
tree3b7169c64e83b74a93821a86dcd355be276eed13 /desktop-widgets
parentf3a2ee8082fd5b9e54564b77ac49efdf9444e802 (diff)
downloadsubsurface-0fab09a9901314f5597b16da370d3712ce28c4ae.tar.gz
preferences: don't remove/add pages in refreshPages()
This function was called when opening the preferences dialog to update all the pages with the current preferences. For unknown reasons it also removed / readded all the pages. Remove that code and use the now leaner function when refreshing the pages. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index 1b4119e81..6ad91acec 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -24,7 +24,6 @@
#include <QStackedWidget>
#include <QDialogButtonBox>
#include <QAbstractButton>
-#include <QDebug>
PreferencesDialog *PreferencesDialog::instance()
{
@@ -80,7 +79,12 @@ PreferencesDialog::PreferencesDialog()
pages.push_back(new PreferencesReset);
std::sort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
- refreshPages();
+ for (AbstractPreferencesWidget *page: pages) {
+ QListWidgetItem *item = new QListWidgetItem(page->icon(), page->name());
+ pagesList->addItem(item);
+ pagesStack->addWidget(page);
+ page->refreshSettings();
+ }
connect(pagesList, &QListWidget::currentRowChanged,
pagesStack, &QStackedWidget::setCurrentIndex);
@@ -106,21 +110,8 @@ void PreferencesDialog::buttonClicked(QAbstractButton* btn)
void PreferencesDialog::refreshPages()
{
- // Remove things
- pagesList->clear();
- while(pagesStack->count()) {
- QWidget *curr = pagesStack->widget(0);
- pagesStack->removeWidget(curr);
- curr->setParent(0);
- }
-
- // Read things
- Q_FOREACH(AbstractPreferencesWidget *page, pages) {
- QListWidgetItem *item = new QListWidgetItem(page->icon(), page->name());
- pagesList->addItem(item);
- pagesStack->addWidget(page);
+ for (AbstractPreferencesWidget *page: pages)
page->refreshSettings();
- }
}
void PreferencesDialog::applyRequested(bool closeIt)
@@ -136,18 +127,14 @@ void PreferencesDialog::applyRequested(bool closeIt)
void PreferencesDialog::cancelRequested()
{
- Q_FOREACH(AbstractPreferencesWidget *page, pages) {
- page->refreshSettings();
- }
+ refreshPages();
reject();
}
void PreferencesDialog::defaultsRequested()
{
copy_prefs(&default_prefs, &prefs);
- Q_FOREACH(AbstractPreferencesWidget *page, pages) {
- page->refreshSettings();
- }
+ refreshPages();
emit diveListNotifier.settingsChanged();
accept();
}