forked from qt-creator/qt-creator
Core: Swap ICore and MainWindow "ownership"
Change-Id: Ibfa223da0f4d5195ae2f2783352346ca72b920bd Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "idocument.h"
|
#include "idocument.h"
|
||||||
#include "iwizardfactory.h"
|
#include "iwizardfactory.h"
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "settingsdatabase.h"
|
#include "settingsdatabase.h"
|
||||||
@@ -96,7 +95,7 @@ CorePlugin::~CorePlugin()
|
|||||||
|
|
||||||
DesignMode::destroyModeIfRequired();
|
DesignMode::destroyModeIfRequired();
|
||||||
|
|
||||||
delete m_mainWindow;
|
delete m_core;
|
||||||
SettingsDatabase::destroy();
|
SettingsDatabase::destroy();
|
||||||
setCreatorTheme(nullptr);
|
setCreatorTheme(nullptr);
|
||||||
}
|
}
|
||||||
@@ -158,12 +157,12 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
CheckableMessageBox::initialize(ICore::settings());
|
CheckableMessageBox::initialize(ICore::settings());
|
||||||
new ActionManager(this);
|
new ActionManager(this);
|
||||||
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
||||||
m_mainWindow = new MainWindow;
|
m_core = new ICore;
|
||||||
if (args.overrideColor.isValid())
|
if (args.overrideColor.isValid())
|
||||||
m_mainWindow->setOverrideColor(args.overrideColor);
|
ICore::setOverrideColor(args.overrideColor);
|
||||||
m_locator = new Locator;
|
m_locator = new Locator;
|
||||||
std::srand(unsigned(QDateTime::currentDateTime().toSecsSinceEpoch()));
|
std::srand(unsigned(QDateTime::currentDateTime().toSecsSinceEpoch()));
|
||||||
m_mainWindow->init();
|
ICore::init();
|
||||||
m_editMode = new EditMode;
|
m_editMode = new EditMode;
|
||||||
ModeManager::activateMode(m_editMode->id());
|
ModeManager::activateMode(m_editMode->id());
|
||||||
m_folderNavigationWidgetFactory = new FolderNavigationWidgetFactory;
|
m_folderNavigationWidgetFactory = new FolderNavigationWidgetFactory;
|
||||||
@@ -291,9 +290,9 @@ void CorePlugin::extensionsInitialized()
|
|||||||
DesignMode::createModeIfRequired();
|
DesignMode::createModeIfRequired();
|
||||||
Find::extensionsInitialized();
|
Find::extensionsInitialized();
|
||||||
m_locator->extensionsInitialized();
|
m_locator->extensionsInitialized();
|
||||||
m_mainWindow->extensionsInitialized();
|
ICore::extensionsInitialized();
|
||||||
if (ExtensionSystem::PluginManager::hasError()) {
|
if (ExtensionSystem::PluginManager::hasError()) {
|
||||||
auto errorOverview = new ExtensionSystem::PluginErrorOverview(m_mainWindow);
|
auto errorOverview = new ExtensionSystem::PluginErrorOverview(ICore::mainWindow());
|
||||||
errorOverview->setAttribute(Qt::WA_DeleteOnClose);
|
errorOverview->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
errorOverview->setModal(true);
|
errorOverview->setModal(true);
|
||||||
errorOverview->show();
|
errorOverview->show();
|
||||||
@@ -324,7 +323,7 @@ QObject *CorePlugin::remoteCommand(const QStringList & /* options */,
|
|||||||
filePaths,
|
filePaths,
|
||||||
ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineAndColumnNumbers | ICore::SwitchSplitIfAlreadyVisible),
|
ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineAndColumnNumbers | ICore::SwitchSplitIfAlreadyVisible),
|
||||||
FilePath::fromString(workingDirectory));
|
FilePath::fromString(workingDirectory));
|
||||||
m_mainWindow->raiseWindow();
|
ICore::raiseMainWindow();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,6 +492,6 @@ ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
|
|||||||
{
|
{
|
||||||
Find::aboutToShutdown();
|
Find::aboutToShutdown();
|
||||||
m_locator->aboutToShutdown();
|
m_locator->aboutToShutdown();
|
||||||
m_mainWindow->aboutToShutdown();
|
ICore::aboutToShutdown();
|
||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace Core {
|
|||||||
|
|
||||||
class FolderNavigationWidgetFactory;
|
class FolderNavigationWidgetFactory;
|
||||||
class SessionManager;
|
class SessionManager;
|
||||||
|
class ICore;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ private:
|
|||||||
void checkSettings();
|
void checkSettings();
|
||||||
void warnAboutCrashReporing();
|
void warnAboutCrashReporing();
|
||||||
|
|
||||||
MainWindow *m_mainWindow = nullptr;
|
ICore *m_core = nullptr;
|
||||||
EditMode *m_editMode = nullptr;
|
EditMode *m_editMode = nullptr;
|
||||||
Locator *m_locator = nullptr;
|
Locator *m_locator = nullptr;
|
||||||
std::unique_ptr<SessionManager> m_sessionManager;
|
std::unique_ptr<SessionManager> m_sessionManager;
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ QWidget *ICore::newItemDialog()
|
|||||||
ICore::ICore()
|
ICore::ICore()
|
||||||
{
|
{
|
||||||
m_core = this;
|
m_core = this;
|
||||||
|
m_mainwindow = new MainWindow;
|
||||||
|
|
||||||
connect(PluginManager::instance(), &PluginManager::testsFinished,
|
connect(PluginManager::instance(), &PluginManager::testsFinished,
|
||||||
this, [this](int failedTests) {
|
this, [this](int failedTests) {
|
||||||
@@ -388,6 +389,7 @@ ICore::ICore()
|
|||||||
*/
|
*/
|
||||||
ICore::~ICore()
|
ICore::~ICore()
|
||||||
{
|
{
|
||||||
|
delete m_mainwindow;
|
||||||
m_core = nullptr;
|
m_core = nullptr;
|
||||||
m_mainwindow = nullptr;
|
m_mainwindow = nullptr;
|
||||||
}
|
}
|
||||||
@@ -886,6 +888,11 @@ void ICore::raiseWindow(QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ICore::raiseMainWindow()
|
||||||
|
{
|
||||||
|
m_mainwindow->raiseWindow();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Removes the contexts specified by \a remove from the list of active
|
Removes the contexts specified by \a remove from the list of active
|
||||||
additional contexts, and adds the contexts specified by \a add with \a
|
additional contexts, and adds the contexts specified by \a add with \a
|
||||||
@@ -1152,7 +1159,6 @@ enum { debugMainWindow = 0 };
|
|||||||
|
|
||||||
void MainWindowPrivate::init()
|
void MainWindowPrivate::init()
|
||||||
{
|
{
|
||||||
m_core = new ICore;
|
|
||||||
m_progressManager = new ProgressManagerPrivate;
|
m_progressManager = new ProgressManagerPrivate;
|
||||||
m_jsExpander = JsExpander::createGlobalJsExpander();
|
m_jsExpander = JsExpander::createGlobalJsExpander();
|
||||||
m_vcsManager = new VcsManager;
|
m_vcsManager = new VcsManager;
|
||||||
@@ -1266,11 +1272,6 @@ void MainWindowPrivate::setSidebarVisible(bool visible, Side side)
|
|||||||
navigationWidget(side)->setShown(visible);
|
navigationWidget(side)->setShown(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setOverrideColor(const QColor &color)
|
|
||||||
{
|
|
||||||
d->m_overrideColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList MainWindow::additionalAboutInformation() const
|
QStringList MainWindow::additionalAboutInformation() const
|
||||||
{
|
{
|
||||||
return d->m_aboutInformation;
|
return d->m_aboutInformation;
|
||||||
@@ -1336,9 +1337,6 @@ MainWindowPrivate::~MainWindowPrivate()
|
|||||||
delete m_progressManager;
|
delete m_progressManager;
|
||||||
m_progressManager = nullptr;
|
m_progressManager = nullptr;
|
||||||
|
|
||||||
delete m_core;
|
|
||||||
m_core = nullptr;
|
|
||||||
|
|
||||||
delete m_rightPaneWidget;
|
delete m_rightPaneWidget;
|
||||||
m_rightPaneWidget = nullptr;
|
m_rightPaneWidget = nullptr;
|
||||||
|
|
||||||
@@ -1349,18 +1347,20 @@ MainWindowPrivate::~MainWindowPrivate()
|
|||||||
m_jsExpander = nullptr;
|
m_jsExpander = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::init()
|
} // Internal
|
||||||
|
|
||||||
|
void ICore::init()
|
||||||
{
|
{
|
||||||
d->m_progressManager->init(); // needs the status bar manager
|
d->m_progressManager->init(); // needs the status bar manager
|
||||||
MessageManager::init();
|
MessageManager::init();
|
||||||
OutputPaneManager::create();
|
OutputPaneManager::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::extensionsInitialized()
|
void ICore::extensionsInitialized()
|
||||||
{
|
{
|
||||||
EditorManagerPrivate::extensionsInitialized();
|
EditorManagerPrivate::extensionsInitialized();
|
||||||
MimeTypeSettings::restoreSettings();
|
MimeTypeSettings::restoreSettings();
|
||||||
d->m_windowSupport = new WindowSupport(this, Context("Core.MainWindow"));
|
d->m_windowSupport = new WindowSupport(m_mainwindow, Context("Core.MainWindow"));
|
||||||
d->m_windowSupport->setCloseActionEnabled(false);
|
d->m_windowSupport->setCloseActionEnabled(false);
|
||||||
OutputPaneManager::initialize();
|
OutputPaneManager::initialize();
|
||||||
VcsManager::extensionsInitialized();
|
VcsManager::extensionsInitialized();
|
||||||
@@ -1378,6 +1378,17 @@ void MainWindow::extensionsInitialized()
|
|||||||
QMetaObject::invokeMethod(m_core, &ICore::coreOpened, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(m_core, &ICore::coreOpened, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ICore::aboutToShutdown()
|
||||||
|
{
|
||||||
|
disconnect(qApp, &QApplication::focusChanged, d, &MainWindowPrivate::updateFocusWidget);
|
||||||
|
for (auto contextPair : d->m_contextWidgets)
|
||||||
|
disconnect(contextPair.second, &QObject::destroyed, m_mainwindow, nullptr);
|
||||||
|
d->m_activeContext.clear();
|
||||||
|
m_mainwindow->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
static void setRestart(bool restart)
|
static void setRestart(bool restart)
|
||||||
{
|
{
|
||||||
qApp->setProperty("restart", restart);
|
qApp->setProperty("restart", restart);
|
||||||
@@ -2221,15 +2232,6 @@ void MainWindowPrivate::updateContextObject(const QList<IContext *> &context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::aboutToShutdown()
|
|
||||||
{
|
|
||||||
disconnect(qApp, &QApplication::focusChanged, d, &MainWindowPrivate::updateFocusWidget);
|
|
||||||
for (auto contextPair : d->m_contextWidgets)
|
|
||||||
disconnect(contextPair.second, &QObject::destroyed, this, nullptr);
|
|
||||||
d->m_activeContext.clear();
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindowPrivate::readSettings()
|
void MainWindowPrivate::readSettings()
|
||||||
{
|
{
|
||||||
QtcSettings *settings = PluginManager::settings();
|
QtcSettings *settings = PluginManager::settings();
|
||||||
@@ -2608,4 +2610,10 @@ void MainWindowPrivate::restoreWindowState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
|
void ICore::setOverrideColor(const QColor &color)
|
||||||
|
{
|
||||||
|
d->m_overrideColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ class CORE_EXPORT ICore : public QObject
|
|||||||
friend class Internal::MainWindow;
|
friend class Internal::MainWindow;
|
||||||
friend class Internal::MainWindowPrivate;
|
friend class Internal::MainWindowPrivate;
|
||||||
|
|
||||||
|
public:
|
||||||
ICore();
|
ICore();
|
||||||
~ICore() override;
|
~ICore() override;
|
||||||
|
|
||||||
public:
|
|
||||||
enum class ContextPriority {
|
enum class ContextPriority {
|
||||||
High,
|
High,
|
||||||
Low
|
Low
|
||||||
@@ -91,6 +91,7 @@ public:
|
|||||||
static Utils::InfoBar *infoBar();
|
static Utils::InfoBar *infoBar();
|
||||||
|
|
||||||
static void raiseWindow(QWidget *widget);
|
static void raiseWindow(QWidget *widget);
|
||||||
|
static void raiseMainWindow();
|
||||||
|
|
||||||
static IContext *currentContextObject();
|
static IContext *currentContextObject();
|
||||||
static QWidget *currentContextWidget();
|
static QWidget *currentContextWidget();
|
||||||
@@ -157,6 +158,12 @@ public:
|
|||||||
static void saveSettings(SaveSettingsReason reason);
|
static void saveSettings(SaveSettingsReason reason);
|
||||||
static void setNewDialogFactory(const std::function<NewDialog *(QWidget *)> &newFactory);
|
static void setNewDialogFactory(const std::function<NewDialog *(QWidget *)> &newFactory);
|
||||||
static void updateNewItemDialogState();
|
static void updateNewItemDialogState();
|
||||||
|
|
||||||
|
static void setOverrideColor(const QColor &color);
|
||||||
|
|
||||||
|
static void init();
|
||||||
|
static void extensionsInitialized();
|
||||||
|
static void aboutToShutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -169,10 +176,6 @@ public:
|
|||||||
MainWindow();
|
MainWindow();
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
void init();
|
|
||||||
void extensionsInitialized();
|
|
||||||
void aboutToShutdown();
|
|
||||||
|
|
||||||
IContext *contextObject(QWidget *widget) const;
|
IContext *contextObject(QWidget *widget) const;
|
||||||
void addContextObject(IContext *context);
|
void addContextObject(IContext *context);
|
||||||
void removeContextObject(IContext *context);
|
void removeContextObject(IContext *context);
|
||||||
@@ -189,8 +192,6 @@ public:
|
|||||||
void updateAdditionalContexts(const Context &remove, const Context &add,
|
void updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
ICore::ContextPriority priority);
|
ICore::ContextPriority priority);
|
||||||
|
|
||||||
void setOverrideColor(const QColor &color);
|
|
||||||
|
|
||||||
QStringList additionalAboutInformation() const;
|
QStringList additionalAboutInformation() const;
|
||||||
void clearAboutInformation();
|
void clearAboutInformation();
|
||||||
void appendAboutInformation(const QString &line);
|
void appendAboutInformation(const QString &line);
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
class ICore;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class MainWindowPrivate;
|
class MainWindowPrivate;
|
||||||
@@ -42,8 +44,10 @@ private:
|
|||||||
~MessageManager() override;
|
~MessageManager() override;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
friend class Core::Internal::MainWindow;
|
|
||||||
friend class Core::Internal::MainWindowPrivate;
|
friend class ICore;
|
||||||
|
friend class Internal::MainWindow;
|
||||||
|
friend class Internal::MainWindowPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
class ICore;
|
||||||
class IMode;
|
class IMode;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -68,6 +69,7 @@ private:
|
|||||||
void currentTabAboutToChange(int index);
|
void currentTabAboutToChange(int index);
|
||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
|
|
||||||
|
friend class ICore;
|
||||||
friend class IMode;
|
friend class IMode;
|
||||||
friend class Core::Internal::MainWindow;
|
friend class Core::Internal::MainWindow;
|
||||||
friend class Core::Internal::MainWindowPrivate;
|
friend class Core::Internal::MainWindowPrivate;
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ class QTimeLine;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
class ICore;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@@ -34,6 +37,11 @@ public:
|
|||||||
static int outputPaneHeightSetting();
|
static int outputPaneHeightSetting();
|
||||||
static void setOutputPaneHeightSetting(int value);
|
static void setOutputPaneHeightSetting(int value);
|
||||||
|
|
||||||
|
// FIXME: Hide again
|
||||||
|
static void create();
|
||||||
|
static void initialize();
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotHide();
|
void slotHide();
|
||||||
void slotNext();
|
void slotNext();
|
||||||
@@ -45,14 +53,11 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// the only class that is allowed to create and destroy
|
// the only class that is allowed to create and destroy
|
||||||
|
friend class ICore;
|
||||||
friend class MainWindow;
|
friend class MainWindow;
|
||||||
friend class MainWindowPrivate;
|
friend class MainWindowPrivate;
|
||||||
friend class OutputPaneManageButton;
|
friend class OutputPaneManageButton;
|
||||||
|
|
||||||
static void create();
|
|
||||||
static void initialize();
|
|
||||||
static void destroy();
|
|
||||||
|
|
||||||
explicit OutputPaneManager(QWidget *parent = nullptr);
|
explicit OutputPaneManager(QWidget *parent = nullptr);
|
||||||
~OutputPaneManager() override;
|
~OutputPaneManager() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user