forked from qt-creator/qt-creator
Core: Combine finalizing SettingsDialog code paths
The accepted() and rejected() cases shared a bit of code, with more common code in the done() implementation. Moving all to done() removes some duplication and makes it easier to follow the logic in the calling sequence of virtual functions (and their base implementations). No change in functionality intended. Change-Id: Ib0d2f5222bfa195a5843a9656622a9fc0d954595 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -447,8 +447,6 @@ private:
|
||||
QSize sizeHint() const final { return minimumSize(); }
|
||||
|
||||
void done(int) final;
|
||||
void accept() final;
|
||||
void reject() final;
|
||||
|
||||
void apply();
|
||||
void currentChanged(const QModelIndex ¤t);
|
||||
@@ -730,33 +728,6 @@ void SettingsDialog::filter(const QString &text)
|
||||
updateEnabledTabs(category, text);
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
if (m_finished)
|
||||
return;
|
||||
m_finished = true;
|
||||
disconnectTabWidgets();
|
||||
m_applied = true;
|
||||
for (IOptionsPage *page : std::as_const(m_visitedPages))
|
||||
page->apply();
|
||||
for (IOptionsPage *page : std::as_const(m_pages))
|
||||
page->finish();
|
||||
done(QDialog::Accepted);
|
||||
}
|
||||
|
||||
void SettingsDialog::reject()
|
||||
{
|
||||
if (m_finished)
|
||||
return;
|
||||
m_finished = true;
|
||||
disconnectTabWidgets();
|
||||
for (IOptionsPage *page : std::as_const(m_pages)) {
|
||||
page->cancel();
|
||||
page->finish();
|
||||
}
|
||||
done(QDialog::Rejected);
|
||||
}
|
||||
|
||||
void SettingsDialog::apply()
|
||||
{
|
||||
for (IOptionsPage *page : std::as_const(m_visitedPages))
|
||||
@@ -766,6 +737,25 @@ void SettingsDialog::apply()
|
||||
|
||||
void SettingsDialog::done(int val)
|
||||
{
|
||||
if (m_finished)
|
||||
return;
|
||||
|
||||
m_finished = true;
|
||||
|
||||
disconnectTabWidgets();
|
||||
|
||||
if (val == QDialog::Accepted) {
|
||||
m_applied = true;
|
||||
for (IOptionsPage *page : std::as_const(m_visitedPages))
|
||||
page->apply();
|
||||
} else {
|
||||
for (IOptionsPage *page : std::as_const(m_pages))
|
||||
page->cancel();
|
||||
}
|
||||
|
||||
for (IOptionsPage *page : std::as_const(m_pages))
|
||||
page->finish();
|
||||
|
||||
QtcSettings *settings = ICore::settings();
|
||||
settings->setValue(pageKeyC, m_currentPage.toSetting());
|
||||
settings->setValue(sortKeyC, m_sortCheckBox->isChecked());
|
||||
|
Reference in New Issue
Block a user