diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 1f9d400985c..e7f41ee9d56 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -27,6 +27,7 @@ #include "windowsupport.h" #include +#include #include #include @@ -289,6 +290,8 @@ #include #include #include +#include +#include #include #include @@ -354,7 +357,13 @@ void ICore::showNewItemDialog(const QString &title, bool ICore::showOptionsDialog(const Id page, QWidget *parent) { - return m_mainwindow->showOptionsDialog(page, parent); + // Make sure all wizards are there when the user might access the keyboard shortcuts: + emit m_instance->optionsDialogRequested(); + + if (!parent) + parent = dialogParent(); + SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, page); + return dialog->execDialog(); } QString ICore::msgShowOptionsDialog() @@ -372,10 +381,24 @@ QString ICore::msgShowOptionsDialogToolTip() "msgShowOptionsDialogToolTip (non-mac version)"); } +// Display a warning with an additional button to open +// the settings dialog at a specified page if settingsId is nonempty. bool ICore::showWarningWithOptions(const QString &title, const QString &text, const QString &details, Id settingsId, QWidget *parent) { - return m_mainwindow->showWarningWithOptions(title, text, details, settingsId, parent); + if (!parent) + parent = m_mainwindow; + QMessageBox msgBox(QMessageBox::Warning, title, text, + QMessageBox::Ok, parent); + if (!details.isEmpty()) + msgBox.setDetailedText(details); + QAbstractButton *settingsButton = nullptr; + if (settingsId.isValid()) + settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole); + msgBox.exec(); + if (settingsButton && msgBox.clickedButton() == settingsButton) + return showOptionsDialog(settingsId); + return false; } QSettings *ICore::settings(QSettings::Scope scope) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index a17dc50e28a..b2b86038827 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -85,9 +84,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -632,7 +629,7 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS); cmd->setDefaultKeySequence(QKeySequence::Preferences); mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS); - connect(m_optionsAction, &QAction::triggered, this, [this]() { showOptionsDialog(); }); + connect(m_optionsAction, &QAction::triggered, this, [] { ICore::showOptionsDialog(Id()); }); mwindow->addSeparator(Constants::G_WINDOW_LIST); @@ -832,15 +829,6 @@ void MainWindow::setFocusToEditor() EditorManagerPrivate::doEscapeKeyFocusMoveMagic(); } -bool MainWindow::showOptionsDialog(Id page, QWidget *parent) -{ - emit m_coreImpl->optionsDialogRequested(); - if (!parent) - parent = ICore::dialogParent(); - SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, page); - return dialog->execDialog(); -} - void MainWindow::saveAll() { DocumentManager::saveAllModifiedDocumentsSilently(); @@ -1121,30 +1109,6 @@ QPrinter *MainWindow::printer() const return m_printer; } -// Display a warning with an additional button to open -// the debugger settings dialog if settingsId is nonempty. - -bool MainWindow::showWarningWithOptions(const QString &title, - const QString &text, - const QString &details, - Id settingsId, - QWidget *parent) -{ - if (parent == 0) - parent = this; - QMessageBox msgBox(QMessageBox::Warning, title, text, - QMessageBox::Ok, parent); - if (!details.isEmpty()) - msgBox.setDetailedText(details); - QAbstractButton *settingsButton = nullptr; - if (settingsId.isValid()) - settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole); - msgBox.exec(); - if (settingsButton && msgBox.clickedButton() == settingsButton) - return showOptionsDialog(settingsId); - return false; -} - void MainWindow::restoreWindowState() { QSettings *settings = PluginManager::settings(); diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 51ae3309f40..52d46b092db 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -111,13 +111,6 @@ public slots: void openFileWith(); void exit(); - bool showOptionsDialog(Id page = Id(), QWidget *parent = 0); - - bool showWarningWithOptions(const QString &title, const QString &text, - const QString &details = QString(), - Id settingsId = Id(), - QWidget *parent = 0); - protected: virtual void closeEvent(QCloseEvent *event);