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