mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 17:23:23 +00:00
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>
This commit is contained in:
parent
f3a2ee8082
commit
0fab09a990
1 changed files with 9 additions and 22 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue