diff options
36 files changed, 143 insertions, 124 deletions
diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.h b/src/plugins/coreplugin/dialogs/ioptionspage.h index df38e3562a..b6cd4a0efe 100644 --- a/src/plugins/coreplugin/dialogs/ioptionspage.h +++ b/src/plugins/coreplugin/dialogs/ioptionspage.h @@ -54,7 +54,8 @@ public: virtual QString trCategory() const = 0; virtual QWidget *createPage(QWidget *parent) = 0; - virtual void finished(bool accepted) = 0; + virtual void apply() = 0; + virtual void finish() = 0; }; } // namespace Core diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index e2865bf183..0e136e7c22 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -126,20 +126,22 @@ void SettingsDialog::pageSelected(QTreeWidgetItem *) void SettingsDialog::accept() { - foreach (IOptionsPage *page, m_pages) - page->finished(true); + foreach (IOptionsPage *page, m_pages) { + page->apply(); + page->finish(); + } done(QDialog::Accepted); } void SettingsDialog::reject() { foreach (IOptionsPage *page, m_pages) - page->finished(false); + page->finish(); done(QDialog::Rejected); } void SettingsDialog::apply() { foreach (IOptionsPage *page, m_pages) - page->finished(true); + page->apply(); } diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp index 5d6ae28147..0b211f7661 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp @@ -120,14 +120,14 @@ QWidget *ShortcutSettings::createPage(QWidget *parent) return w; } -void ShortcutSettings::finished(bool accepted) +void ShortcutSettings::apply() { - if (accepted) { - foreach (ShortcutItem *item, m_scitems) { - item->m_cmd->setKeySequence(item->m_key); - } - } + foreach (ShortcutItem *item, m_scitems) + item->m_cmd->setKeySequence(item->m_key); +} +void ShortcutSettings::finish() +{ qDeleteAll(m_scitems); m_scitems.clear(); } diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.h b/src/plugins/coreplugin/dialogs/shortcutsettings.h index f79bf89386..0251eeafe1 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.h +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.h @@ -77,7 +77,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish(); protected: bool eventFilter(QObject *o, QEvent *e); diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 294bb36dec..3c57c44b74 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -81,11 +81,8 @@ QWidget *GeneralSettings::createPage(QWidget *parent) return w; } -void GeneralSettings::finished(bool accepted) +void GeneralSettings::apply() { - if (!accepted) - return; - // Apply the new base color if accepted StyleHelper::setBaseColor(m_page->colorButton->color()); EditorManager::instance()->setExternalEditor(m_page->externalEditorEdit->text()); diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h index ead5693033..b9885ef538 100644 --- a/src/plugins/coreplugin/generalsettings.h +++ b/src/plugins/coreplugin/generalsettings.h @@ -55,7 +55,8 @@ public: QString category() const; QString trCategory() const; QWidget* createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } private slots: void resetInterfaceColor(); diff --git a/src/plugins/cpaster/settingspage.cpp b/src/plugins/cpaster/settingspage.cpp index af35e7e576..b40535e990 100644 --- a/src/plugins/cpaster/settingspage.cpp +++ b/src/plugins/cpaster/settingspage.cpp @@ -86,11 +86,8 @@ QWidget *SettingsPage::createPage(QWidget *parent) return w; } -void SettingsPage::finished(bool accepted) +void SettingsPage::apply() { - if (!accepted) - return; - m_username = m_ui.userEdit->text(); m_server = QUrl(m_ui.serverEdit->text()); m_copy = m_ui.clipboardBox->isChecked(); diff --git a/src/plugins/cpaster/settingspage.h b/src/plugins/cpaster/settingspage.h index 9f2b4b25f7..ae144fb632 100644 --- a/src/plugins/cpaster/settingspage.h +++ b/src/plugins/cpaster/settingspage.h @@ -59,7 +59,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } QString username() const; QUrl serverUrl() const; diff --git a/src/plugins/cpptools/completionsettingspage.cpp b/src/plugins/cpptools/completionsettingspage.cpp index a885f45e06..27d16d4b44 100644 --- a/src/plugins/cpptools/completionsettingspage.cpp +++ b/src/plugins/cpptools/completionsettingspage.cpp @@ -78,11 +78,8 @@ QWidget *CompletionSettingsPage::createPage(QWidget *parent) return w; } -void CompletionSettingsPage::finished(bool accepted) +void CompletionSettingsPage::apply() { - if (!accepted) - return; - m_completion->setCaseSensitivity( m_page->caseSensitive->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive); m_completion->setAutoInsertBraces(m_page->autoInsertBraces->isChecked()); diff --git a/src/plugins/cpptools/completionsettingspage.h b/src/plugins/cpptools/completionsettingspage.h index b241ccd3b1..ba5ba77b2b 100644 --- a/src/plugins/cpptools/completionsettingspage.h +++ b/src/plugins/cpptools/completionsettingspage.h @@ -56,7 +56,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } private: CppCodeCompletion *m_completion; diff --git a/src/plugins/debugger/gdboptionpage.cpp b/src/plugins/debugger/gdboptionpage.cpp index efbb959fcf..3d0c802c79 100644 --- a/src/plugins/debugger/gdboptionpage.cpp +++ b/src/plugins/debugger/gdboptionpage.cpp @@ -122,11 +122,8 @@ void GdbOptionPage::onScriptFileChanged() m_settings->m_scriptFile = m_ui.scriptFileChooser->path(); } -void GdbOptionPage::finished(bool accepted) +void GdbOptionPage::apply() { - if (!accepted) - return; - m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path(); m_settings->m_gdbEnv = m_ui.environmentEdit->text(); m_settings->m_autoRun = m_ui.autoStartBox->isChecked(); diff --git a/src/plugins/debugger/gdboptionpage.h b/src/plugins/debugger/gdboptionpage.h index bb48d9e349..74d83ea3ca 100644 --- a/src/plugins/debugger/gdboptionpage.h +++ b/src/plugins/debugger/gdboptionpage.h @@ -59,7 +59,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } public slots: void onGdbLocationChanged(); diff --git a/src/plugins/designer/settingspage.cpp b/src/plugins/designer/settingspage.cpp index 7e0952ae76..f246c9ce81 100644 --- a/src/plugins/designer/settingspage.cpp +++ b/src/plugins/designer/settingspage.cpp @@ -39,7 +39,8 @@ using namespace Designer::Internal; SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) : - m_designerPage(designerPage) + m_designerPage(designerPage), + m_applyOnFinish(false) { } @@ -64,10 +65,17 @@ QString SettingsPage::trCategory() const QWidget *SettingsPage::createPage(QWidget *parent) { + m_applyOnFinish = false; return m_designerPage->createPage(parent); } -void SettingsPage::finished(bool accepted) +void SettingsPage::apply() { - m_designerPage->finish(accepted); + // FIXME: Since no cleanup should be done here, we can't call finish(true) + m_applyOnFinish = true; +} + +void SettingsPage::finish() +{ + m_designerPage->finish(m_applyOnFinish); } diff --git a/src/plugins/designer/settingspage.h b/src/plugins/designer/settingspage.h index 397bb36b3a..5637e24672 100644 --- a/src/plugins/designer/settingspage.h +++ b/src/plugins/designer/settingspage.h @@ -59,10 +59,12 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish(); private: QDesignerOptionsPageInterface *m_designerPage; + bool m_applyOnFinish; }; } // namespace Internal diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp index 037176b52d..838e3ad2dd 100644 --- a/src/plugins/git/settingspage.cpp +++ b/src/plugins/git/settingspage.cpp @@ -95,11 +95,10 @@ QWidget *SettingsPage::createPage(QWidget *parent) return m_widget; } -void SettingsPage::finished(bool accepted) +void SettingsPage::apply() { - if (!accepted || !m_widget) + if (!m_widget) return; GitPlugin::instance()->setSettings(m_widget->settings()); } - diff --git a/src/plugins/git/settingspage.h b/src/plugins/git/settingspage.h index e5cce4d34a..0aa2465d86 100644 --- a/src/plugins/git/settingspage.h +++ b/src/plugins/git/settingspage.h @@ -77,7 +77,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } private: QPointer<SettingsPageWidget> m_widget; diff --git a/src/plugins/help/docsettingspage.cpp b/src/plugins/help/docsettingspage.cpp index 65fd2669b4..1fd150db2f 100644 --- a/src/plugins/help/docsettingspage.cpp +++ b/src/plugins/help/docsettingspage.cpp @@ -38,7 +38,7 @@ #include <QtHelp/QHelpEngine> using namespace Help::Internal; - + DocSettingsPage::DocSettingsPage(QHelpEngine *helpEngine) : m_helpEngine(helpEngine), m_registeredDocs(false) @@ -64,16 +64,16 @@ QWidget *DocSettingsPage::createPage(QWidget *parent) { QWidget *w = new QWidget(parent); m_ui.setupUi(w); - + connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(addDocumentation())); connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDocumentation())); - + m_ui.docsListWidget->addItems(m_helpEngine->registeredDocumentations()); m_registeredDocs = false; m_removeDocs.clear(); - + return w; } @@ -82,7 +82,7 @@ void DocSettingsPage::addDocumentation() QStringList files = QFileDialog::getOpenFileNames(m_ui.addButton->parentWidget(), tr("Add Documentation"), QString(), tr("Qt Help Files (*.qch)")); - + if (files.isEmpty()) return; @@ -107,23 +107,20 @@ void DocSettingsPage::removeDocumentation() QListWidgetItem *item = m_ui.docsListWidget->currentItem(); if (!item) return; - + m_removeDocs.append(item->text()); int row = m_ui.docsListWidget->currentRow(); - m_ui.docsListWidget->takeItem(row); + m_ui.docsListWidget->takeItem(row); if (row > 0) --row; if (m_ui.docsListWidget->count()) m_ui.docsListWidget->setCurrentRow(row); - delete item; + delete item; } -void DocSettingsPage::finished(bool accepted) +void DocSettingsPage::apply() { - if (!accepted) - return; - emit dialogAccepted(); } diff --git a/src/plugins/help/docsettingspage.h b/src/plugins/help/docsettingspage.h index 1e74ae5404..e06e8c0e59 100644 --- a/src/plugins/help/docsettingspage.h +++ b/src/plugins/help/docsettingspage.h @@ -57,7 +57,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } bool applyChanges(); diff --git a/src/plugins/help/filtersettingspage.cpp b/src/plugins/help/filtersettingspage.cpp index 73a5f615d3..1b2310bc37 100644 --- a/src/plugins/help/filtersettingspage.cpp +++ b/src/plugins/help/filtersettingspage.cpp @@ -173,8 +173,10 @@ void FilterSettingsPage::removeFilter() m_ui.filterWidget->setCurrentRow(0); } -void FilterSettingsPage::finished(bool) +void FilterSettingsPage::apply() { + // This is handled via HelpPlugin::checkForHelpChanges, which is connected + // to DocSettingsPage::apply. } bool FilterSettingsPage::applyChanges() diff --git a/src/plugins/help/filtersettingspage.h b/src/plugins/help/filtersettingspage.h index 6eb12df181..82d52ecf0b 100644 --- a/src/plugins/help/filtersettingspage.h +++ b/src/plugins/help/filtersettingspage.h @@ -56,7 +56,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } bool applyChanges(); diff --git a/src/plugins/perforce/settingspage.cpp b/src/plugins/perforce/settingspage.cpp index 18fec0f846..d05b287160 100644 --- a/src/plugins/perforce/settingspage.cpp +++ b/src/plugins/perforce/settingspage.cpp @@ -96,9 +96,9 @@ QWidget *SettingsPage::createPage(QWidget *parent) return m_widget; } -void SettingsPage::finished(bool accepted) +void SettingsPage::apply() { - if (!accepted || !m_widget) + if (!m_widget) return; PerforcePlugin::perforcePluginInstance()->setSettings(m_widget->settings()); diff --git a/src/plugins/perforce/settingspage.h b/src/plugins/perforce/settingspage.h index e13dab5343..f9e3140185 100644 --- a/src/plugins/perforce/settingspage.h +++ b/src/plugins/perforce/settingspage.h @@ -70,7 +70,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } private: QPointer<SettingsPageWidget> m_widget; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index e39240118d..d311d084c7 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -162,11 +162,8 @@ void QtVersionManager::updateUniqueIdToIndexMap() m_uniqueIdToIndex.insert(m_versions.at(i)->uniqueId(), i); } -void QtVersionManager::finished(bool accepted) +void QtVersionManager::apply() { - if (!accepted) - return; - m_widget->finish(); QList<QtVersion*> newVersions = m_widget->versions(); bool versionPathsChanged = m_versions.size() != newVersions.size(); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index a76a62ada0..bde65c61cc 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -172,7 +172,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } void writeVersionsIntoSettings(); diff --git a/src/plugins/quickopen/quickopenfiltersfilter.cpp b/src/plugins/quickopen/quickopenfiltersfilter.cpp index 6bff7a73ed..4e01b19b5c 100644 --- a/src/plugins/quickopen/quickopenfiltersfilter.cpp +++ b/src/plugins/quickopen/quickopenfiltersfilter.cpp @@ -71,7 +71,7 @@ QList<FilterEntry> QuickOpenFiltersFilter::matchesFor(const QString &entry) { QList<FilterEntry> entries; if (entry.isEmpty()) { - foreach (IQuickOpenFilter *filter, m_plugin->filter()) { + foreach (IQuickOpenFilter *filter, m_plugin->filters()) { if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { FilterEntry entry(this, filter->shortcutString(), diff --git a/src/plugins/quickopen/quickopenplugin.cpp b/src/plugins/quickopen/quickopenplugin.cpp index 6eedeee68f..67bb5e2f73 100644 --- a/src/plugins/quickopen/quickopenplugin.cpp +++ b/src/plugins/quickopen/quickopenplugin.cpp @@ -76,8 +76,7 @@ QuickOpenPlugin::~QuickOpenPlugin() delete m_openDocumentsFilter; delete m_fileSystemFilter; delete m_settingsPage; - foreach (IQuickOpenFilter *filter, m_customFilter) - delete filter; + qDeleteAll(m_customFilters); } bool QuickOpenPlugin::initialize(const QStringList &, QString *) @@ -125,8 +124,8 @@ void QuickOpenPlugin::openQuickOpen() void QuickOpenPlugin::extensionsInitialized() { - m_filter = ExtensionSystem::PluginManager::instance()->getObjects<IQuickOpenFilter>(); - qSort(m_filter.begin(), m_filter.end(), filterLessThan); + m_filters = ExtensionSystem::PluginManager::instance()->getObjects<IQuickOpenFilter>(); + qSort(m_filters.begin(), m_filters.end(), filterLessThan); } void QuickOpenPlugin::startSettingsLoad() @@ -141,7 +140,7 @@ void QuickOpenPlugin::loadSettings() QSettings settings; settings.beginGroup("QuickOpen"); m_refreshTimer.setInterval(settings.value("RefreshInterval", 60).toInt()*60000); - foreach (IQuickOpenFilter *filter, m_filter) { + foreach (IQuickOpenFilter *filter, m_filters) { if (settings.contains(filter->name())) { const QByteArray state = settings.value(filter->name()).toByteArray(); if (!state.isEmpty()) @@ -153,10 +152,10 @@ void QuickOpenPlugin::loadSettings() foreach (const QString &key, settings.childKeys()) { IQuickOpenFilter *filter = new DirectoryFilter(core); filter->restoreState(settings.value(key).toByteArray()); - m_filter.append(filter); + m_filters.append(filter); customFilters.append(filter); } - setCustomFilter(customFilters); + setCustomFilters(customFilters); settings.endGroup(); settings.endGroup(); } @@ -176,14 +175,14 @@ void QuickOpenPlugin::saveSettings() s->beginGroup("QuickOpen"); s->setValue("Interval", m_refreshTimer.interval()/60000); s->remove(""); - foreach (IQuickOpenFilter *filter, m_filter) { - if (!m_customFilter.contains(filter)) { + foreach (IQuickOpenFilter *filter, m_filters) { + if (!m_customFilters.contains(filter)) { s->setValue(filter->name(), filter->saveState()); } } s->beginGroup("CustomFilters"); int i = 0; - foreach (IQuickOpenFilter *filter, m_customFilter) { + foreach (IQuickOpenFilter *filter, m_customFilters) { s->setValue(QString("directory%1").arg(i), filter->saveState()); ++i; } @@ -197,9 +196,9 @@ void QuickOpenPlugin::saveSettings() Return all filters, including the ones created by the user. */ -QList<IQuickOpenFilter*> QuickOpenPlugin::filter() +QList<IQuickOpenFilter*> QuickOpenPlugin::filters() { - return m_filter; + return m_filters; } /*! @@ -208,20 +207,20 @@ QList<IQuickOpenFilter*> QuickOpenPlugin::filter() This returns a subset of all the filters, that contains only the filters that have been created by the user at some point (maybe in a previous session). */ -QList<IQuickOpenFilter*> QuickOpenPlugin::customFilter() +QList<IQuickOpenFilter*> QuickOpenPlugin::customFilters() { - return m_customFilter; + return m_customFilters; } -void QuickOpenPlugin::setFilter(QList<IQuickOpenFilter*> f) +void QuickOpenPlugin::setFilters(QList<IQuickOpenFilter*> f) { - m_filter = f; + m_filters = f; m_quickOpenToolWindow->updateFilterList(); } -void QuickOpenPlugin::setCustomFilter(QList<IQuickOpenFilter *> filter) +void QuickOpenPlugin::setCustomFilters(QList<IQuickOpenFilter *> filters) { - m_customFilter = filter; + m_customFilters = filters; } int QuickOpenPlugin::refreshInterval() @@ -243,7 +242,7 @@ void QuickOpenPlugin::setRefreshInterval(int interval) void QuickOpenPlugin::refresh(QList<IQuickOpenFilter*> filters) { if (filters.isEmpty()) - filters = m_filter; + filters = m_filters; QFuture<void> task = QtConcurrent::run(&IQuickOpenFilter::refresh, filters); Core::FutureProgress *progress = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>() ->progressManager()->addTask(task, tr("Indexing"), Constants::TASK_INDEX, Core::ProgressManager::CloseOnSuccess); diff --git a/src/plugins/quickopen/quickopenplugin.h b/src/plugins/quickopen/quickopenplugin.h index e87e8b313d..3c1ebf99fc 100644 --- a/src/plugins/quickopen/quickopenplugin.h +++ b/src/plugins/quickopen/quickopenplugin.h @@ -61,10 +61,10 @@ public: bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); - QList<IQuickOpenFilter*> filter(); - QList<IQuickOpenFilter*> customFilter(); - void setFilter(QList<IQuickOpenFilter*> f); - void setCustomFilter(QList<IQuickOpenFilter*> f); + QList<IQuickOpenFilter*> filters(); + QList<IQuickOpenFilter*> customFilters(); + void setFilters(QList<IQuickOpenFilter*> f); + void setCustomFilters(QList<IQuickOpenFilter*> f); int refreshInterval(); void setRefreshInterval(int interval); @@ -83,8 +83,8 @@ private: QuickOpenToolWindow *m_quickOpenToolWindow; SettingsPage *m_settingsPage; - QList<IQuickOpenFilter*> m_filter; - QList<IQuickOpenFilter*> m_customFilter; + QList<IQuickOpenFilter*> m_filters; + QList<IQuickOpenFilter*> m_customFilters; int m_refreshInterval; QTimer m_refreshTimer; OpenDocumentsFilter *m_openDocumentsFilter; diff --git a/src/plugins/quickopen/quickopentoolwindow.cpp b/src/plugins/quickopen/quickopentoolwindow.cpp index c3f390f54b..420f554793 100644 --- a/src/plugins/quickopen/quickopentoolwindow.cpp +++ b/src/plugins/quickopen/quickopentoolwindow.cpp @@ -313,7 +313,7 @@ bool QuickOpenToolWindow::isShowingTypeHereMessage() const void QuickOpenToolWindow::updateFilterList() { m_filterMenu->clear(); - foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filter()) { + foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filters()) { if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected())); action->setData(qVariantFromValue(filter)); @@ -379,7 +379,7 @@ void QuickOpenToolWindow::textEdited(const QString &text) QList<IQuickOpenFilter*> QuickOpenToolWindow::filtersFor(const QString &text, QString &searchText) { - QList<IQuickOpenFilter*> filters = m_quickOpenPlugin->filter(); + QList<IQuickOpenFilter*> filters = m_quickOpenPlugin->filters(); int whiteSpace = text.indexOf(" "); QString prefix; if (whiteSpace >= 0) @@ -460,7 +460,7 @@ void QuickOpenToolWindow::filterSelected() // add shortcut string at front or replace existing shortcut string if (!currentText.isEmpty()) { searchText = currentText; - foreach (IQuickOpenFilter *otherfilter, m_quickOpenPlugin->filter()) { + foreach (IQuickOpenFilter *otherfilter, m_quickOpenPlugin->filters()) { if (currentText.startsWith(otherfilter->shortcutString() + " ")) { searchText = currentText.mid(otherfilter->shortcutString().length()+1); break; diff --git a/src/plugins/quickopen/settingspage.cpp b/src/plugins/quickopen/settingspage.cpp index c5ab95477b..e8edd3d635 100644 --- a/src/plugins/quickopen/settingspage.cpp +++ b/src/plugins/quickopen/settingspage.cpp @@ -67,30 +67,41 @@ QWidget *SettingsPage::createPage(QWidget *parent) this, SLOT(removeCustomFilter())); } m_ui.refreshInterval->setValue(m_plugin->refreshInterval()); - m_filters = m_plugin->filter(); - m_customFilters = m_plugin->customFilter(); + m_filters = m_plugin->filters(); + m_customFilters = m_plugin->customFilters(); saveFilterStates(); updateFilterList(); return m_page; } -void SettingsPage::finished(bool accepted) +void SettingsPage::apply() { - if (!accepted) { - restoreFilterStates(); - foreach (IQuickOpenFilter *filter, m_addedFilters) - delete filter; - } else { - foreach (IQuickOpenFilter *filter, m_removedFilters) - delete filter; - m_plugin->setFilter(m_filters); - m_plugin->setCustomFilter(m_customFilters); - m_plugin->setRefreshInterval(m_ui.refreshInterval->value()); - requestRefresh(); - m_plugin->saveSettings(); - } + // Delete removed filters and clear added filters + qDeleteAll(m_removedFilters); + m_removedFilters.clear(); + m_addedFilters.clear(); + + // Pass the new configuration on to the plugin + m_plugin->setFilters(m_filters); + m_plugin->setCustomFilters(m_customFilters); + m_plugin->setRefreshInterval(m_ui.refreshInterval->value()); + requestRefresh(); + m_plugin->saveSettings(); + saveFilterStates(); +} + +void SettingsPage::finish() +{ + // If settings were applied, this shouldn't change anything. Otherwise it + // makes sure the filter states aren't changed permanently. + restoreFilterStates(); + + // Delete added filters and clear removed filters + qDeleteAll(m_addedFilters); m_addedFilters.clear(); m_removedFilters.clear(); + + // Further cleanup m_filters.clear(); m_customFilters.clear(); m_refreshFilters.clear(); diff --git a/src/plugins/quickopen/settingspage.h b/src/plugins/quickopen/settingspage.h index 755763b2f6..cdec11c238 100644 --- a/src/plugins/quickopen/settingspage.h +++ b/src/plugins/quickopen/settingspage.h @@ -66,7 +66,8 @@ public: QString trCategory() const { return tr(Constants::QUICKOPEN_CATEGORY); } QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish(); private slots: void updateButtonStates(); diff --git a/src/plugins/subversion/settingspage.cpp b/src/plugins/subversion/settingspage.cpp index e8c300c600..4cbc0df21d 100644 --- a/src/plugins/subversion/settingspage.cpp +++ b/src/plugins/subversion/settingspage.cpp @@ -100,9 +100,9 @@ QWidget *SettingsPage::createPage(QWidget *parent) return m_widget; } -void SettingsPage::finished(bool accepted) +void SettingsPage::apply() { - if (!accepted || !m_widget) + if (!m_widget) return; SubversionPlugin::subversionPluginInstance()->setSettings(m_widget->settings()); } diff --git a/src/plugins/subversion/settingspage.h b/src/plugins/subversion/settingspage.h index 973a2824e0..4c5c72cbe4 100644 --- a/src/plugins/subversion/settingspage.h +++ b/src/plugins/subversion/settingspage.h @@ -76,7 +76,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } private: QPointer<SettingsPageWidget> m_widget; diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index bdc86ca3e1..994d56bea8 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -435,13 +435,8 @@ void FontSettingsPage::delayedChange() emit changed(d_ptr->m_value); } -void FontSettingsPage::finished(bool accepted) +void FontSettingsPage::apply() { - if (!accepted) { - d_ptr->m_value = d_ptr->m_lastValue; - return; - } - d_ptr->m_value.setFamily(d_ptr->ui.familyComboBox->currentText()); bool ok = true; @@ -460,6 +455,12 @@ void FontSettingsPage::finished(bool accepted) } } +void FontSettingsPage::finish() +{ + // If changes were applied, these are equal. Otherwise restores last value. + d_ptr->m_value = d_ptr->m_lastValue; +} + const FontSettings &FontSettingsPage::fontSettings() const { return d_ptr->m_value; diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index dd1711cfce..9b641f0f1a 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -99,7 +99,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish(); const FontSettings &fontSettings() const; diff --git a/src/plugins/texteditor/generalsettingspage.cpp b/src/plugins/texteditor/generalsettingspage.cpp index 149886cca5..a631ef8169 100644 --- a/src/plugins/texteditor/generalsettingspage.cpp +++ b/src/plugins/texteditor/generalsettingspage.cpp @@ -105,14 +105,12 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent) return w; } -void GeneralSettingsPage::finished(bool accepted) +void GeneralSettingsPage::apply() { - if (!accepted) - return; - TabSettings newTabSettings; StorageSettings newStorageSettings; DisplaySettings newDisplaySettings; + settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings); if (newTabSettings != m_d->m_tabSettings) { diff --git a/src/plugins/texteditor/generalsettingspage.h b/src/plugins/texteditor/generalsettingspage.h index 645390288b..cbc70b331c 100644 --- a/src/plugins/texteditor/generalsettingspage.h +++ b/src/plugins/texteditor/generalsettingspage.h @@ -72,7 +72,8 @@ public: QString trCategory() const; QWidget *createPage(QWidget *parent); - void finished(bool accepted); + void apply(); + void finish() { } TabSettings tabSettings() const; StorageSettings storageSettings() const; |