diff options
author | hjk <hjk@qt.io> | 2018-01-29 11:46:23 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-02-01 13:29:58 +0000 |
commit | 974022c77b7227ef048740dee9a61beca928304c (patch) | |
tree | 159d77c88ae25d6fe72756a22bf6c2e4b80287cd /src/plugins/coreplugin/icore.cpp | |
parent | 9d8abd935205106917f2706750f27d698b699305 (diff) |
Core: Reduce code path ping-pong between ICore and MainWindow
Public entry points for displaying settings dialog were in ICore,
diverting to MainWindow, and back in some cases.
Move implementation to icore.cpp instead.
Change-Id: I02cbf1dcfe6241c665d7d701b4b4af1a8a242af5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/coreplugin/icore.cpp')
-rw-r--r-- | src/plugins/coreplugin/icore.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 1f9d400985..e7f41ee9d5 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -27,6 +27,7 @@ #include "windowsupport.h" #include <app/app_version.h> +#include <dialogs/settingsdialog.h> #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> @@ -289,6 +290,8 @@ #include <QCoreApplication> #include <QDebug> #include <QDir> +#include <QMessageBox> +#include <QPushButton> #include <QStatusBar> #include <QTimer> @@ -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) |