forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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)
|
||||
|
@@ -57,7 +57,6 @@
|
||||
#include <coreplugin/actionmanager/actionmanager_p.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/dialogs/newdialog.h>
|
||||
#include <coreplugin/dialogs/settingsdialog.h>
|
||||
#include <coreplugin/dialogs/shortcutsettings.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/editormanager_p.h>
|
||||
@@ -85,9 +84,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QPrinter>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QStatusBar>
|
||||
#include <QStyleFactory>
|
||||
@@ -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();
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user