Commit 48fb9e18 authored by hjk's avatar hjk

Debugger: Move main splitter creation to DebugMainWindow setup

To allow other mode main windows to re-use the perspective
concept.

Change-Id: Icf00b4f0e4bd73a09ebec131ef9c578154f25eec
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 5b8c2546
......@@ -32,7 +32,12 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/outputpane.h>
#include <coreplugin/rightpane.h>
#include <projectexplorer/projectexplorericons.h>
......@@ -111,7 +116,12 @@ void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS
QDockWidget *DebuggerMainWindow::dockWidget(const QByteArray &dockId) const
{
return m_dockForDockId.value(dockId);
return m_dockForDockId.value(dockId);
}
QWidget *DebuggerMainWindow::modeWindow()
{
return m_modeWindow;
}
void DebuggerMainWindow::resetCurrentPerspective()
......@@ -130,7 +140,7 @@ void DebuggerMainWindow::restorePerspective(const QByteArray &perspectiveId)
m_perspectiveChooser->setCurrentIndex(index);
}
void DebuggerMainWindow::finalizeSetup()
void DebuggerMainWindow::finalizeSetup(Core::IMode *mode, QWidget *central)
{
auto viewButton = new QToolButton;
viewButton->setText(tr("Views"));
......@@ -185,6 +195,56 @@ void DebuggerMainWindow::finalizeSetup()
m_toolbarDock = dock;
addDockWidget(Qt::BottomDockWidgetArea, dock);
if (!central)
central = new EditorManagerPlaceHolder(mode);
auto editorHolderLayout = new QVBoxLayout;
editorHolderLayout->setMargin(0);
editorHolderLayout->setSpacing(0);
auto editorAndFindWidget = new QWidget;
editorAndFindWidget->setLayout(editorHolderLayout);
editorHolderLayout->addWidget(central);
editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget));
auto documentAndRightPane = new MiniSplitter;
documentAndRightPane->addWidget(editorAndFindWidget);
documentAndRightPane->addWidget(new RightPanePlaceHolder(mode));
documentAndRightPane->setStretchFactor(0, 1);
documentAndRightPane->setStretchFactor(1, 0);
auto centralEditorWidget = new QWidget;
auto centralLayout = new QVBoxLayout(centralEditorWidget);
centralEditorWidget->setLayout(centralLayout);
centralLayout->setMargin(0);
centralLayout->setSpacing(0);
centralLayout->addWidget(documentAndRightPane);
centralLayout->setStretch(0, 1);
centralLayout->setStretch(1, 0);
// Right-side window with editor, output etc.
auto mainWindowSplitter = new MiniSplitter;
mainWindowSplitter->addWidget(this);
mainWindowSplitter->addWidget(new OutputPanePlaceHolder(mode, mainWindowSplitter));
auto outputPane = new OutputPanePlaceHolder(mode, mainWindowSplitter);
outputPane->setObjectName(QLatin1String("DebuggerOutputPanePlaceHolder"));
mainWindowSplitter->addWidget(outputPane);
mainWindowSplitter->setStretchFactor(0, 10);
mainWindowSplitter->setStretchFactor(1, 0);
mainWindowSplitter->setOrientation(Qt::Vertical);
// Navigation and right-side window.
auto splitter = new MiniSplitter;
splitter->setFocusProxy(central);
splitter->addWidget(new NavigationWidgetPlaceHolder(mode));
splitter->addWidget(mainWindowSplitter);
splitter->setStretchFactor(0, 0);
splitter->setStretchFactor(1, 1);
splitter->setObjectName(QLatin1String("DebugModeWidget"));
setCentralWidget(centralEditorWidget);
m_modeWindow = splitter;
}
void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings)
......@@ -215,8 +275,8 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
ICore::addAdditionalContext(Context(Id::fromName(m_currentPerspectiveId)));
QTC_ASSERT(m_perspectiveForPerspectiveId.contains(m_currentPerspectiveId), return);
const auto operations = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId).operations();
for (const Perspective::Operation &operation : operations) {
const Perspective perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId);
for (const Perspective::Operation &operation : perspective.operations()) {
QDockWidget *dock = m_dockForDockId.value(operation.dockId);
if (!dock) {
QTC_CHECK(!operation.widget->objectName().isEmpty());
......
......@@ -41,6 +41,8 @@ class QComboBox;
class QStackedWidget;
QT_END_NAMESPACE
namespace Core { class IMode; }
namespace Utils {
class DEBUGGER_EXPORT Perspective
......@@ -98,7 +100,7 @@ private:
QList<QWidget *> m_widgets;
};
class DebuggerMainWindow : public FancyMainWindow
class DEBUGGER_EXPORT DebuggerMainWindow : public FancyMainWindow
{
Q_OBJECT
......@@ -113,12 +115,14 @@ public:
void resetCurrentPerspective();
void restorePerspective(const QByteArray &perspectiveId);
void finalizeSetup();
void finalizeSetup(Core::IMode *mode, QWidget *central = 0);
void showStatusMessage(const QString &message, int timeoutMS);
QDockWidget *dockWidget(const QByteArray &dockId) const;
QByteArray currentPerspective() const { return m_currentPerspectiveId; }
QWidget *modeWindow();
private:
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
......@@ -136,6 +140,8 @@ private:
// list of dock widgets to prevent memory leak
typedef QPointer<QDockWidget> DockPtr;
QList<DockPtr> m_dockWidgets;
QWidget *m_modeWindow = 0;
};
} // Utils
......
......@@ -497,10 +497,24 @@ bool DummyEngine::hasCapability(unsigned cap) const
//
///////////////////////////////////////////////////////////////////////
class DebugModeContext : public IContext
{
public:
DebugModeContext(DebuggerMainWindow *mainWindow) : m_mainWindow(mainWindow)
{
setContext(Context(CC::C_EDITORMANAGER));
ICore::addContextObject(this);
}
QWidget *widget() const override { return m_mainWindow->modeWindow(); }
DebuggerMainWindow *m_mainWindow;
};
class DebugMode : public IMode
{
public:
DebugMode()
DebugMode(DebuggerMainWindow *mainWindow) : m_mainWindow(mainWindow)
{
setObjectName(QLatin1String("DebugMode"));
setContext(Context(C_DEBUGMODE, CC::C_NAVIGATION_PANE));
......@@ -513,10 +527,14 @@ public:
setId(MODE_DEBUG);
}
QWidget *widget() const override { return m_mainWindow->modeWindow(); }
~DebugMode()
{
// delete m_widget;
}
DebuggerMainWindow *m_mainWindow;
};
///////////////////////////////////////////////////////////////////////
......@@ -1061,8 +1079,6 @@ public:
CommonOptionsPage *m_commonOptionsPage = 0;
DummyEngine *m_dummyEngine = 0;
const QSharedPointer<GlobalDebuggerOptions> m_globalDebuggerOptions;
DebugMode *m_debugMode = 0;
};
DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin)
......@@ -1742,68 +1758,16 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
// Debug mode setup
m_debugMode = new DebugMode;
auto mode = new DebugMode(m_mainWindow);
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
this, &DebuggerPluginPrivate::updateUiForProject);
(void) new DebugModeContext(m_mainWindow);
m_mainWindow->finalizeSetup(mode);
m_plugin->addAutoReleasedObject(mode);
auto editorHolderLayout = new QVBoxLayout;
editorHolderLayout->setMargin(0);
editorHolderLayout->setSpacing(0);
auto editorAndFindWidget = new QWidget;
editorAndFindWidget->setLayout(editorHolderLayout);
auto editorManagerPlaceHolder = new EditorManagerPlaceHolder(m_debugMode);
editorHolderLayout->addWidget(editorManagerPlaceHolder);
editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget));
auto documentAndRightPane = new MiniSplitter;
documentAndRightPane->addWidget(editorAndFindWidget);
documentAndRightPane->addWidget(new RightPanePlaceHolder(m_debugMode));
documentAndRightPane->setStretchFactor(0, 1);
documentAndRightPane->setStretchFactor(1, 0);
auto centralWidget = new QWidget;
m_mainWindow->setCentralWidget(centralWidget);
m_mainWindow->finalizeSetup();
auto centralLayout = new QVBoxLayout(centralWidget);
centralWidget->setLayout(centralLayout);
centralLayout->setMargin(0);
centralLayout->setSpacing(0);
centralLayout->addWidget(documentAndRightPane);
centralLayout->setStretch(0, 1);
centralLayout->setStretch(1, 0);
// Right-side window with editor, output etc.
auto mainWindowSplitter = new MiniSplitter;
mainWindowSplitter->addWidget(m_mainWindow);
mainWindowSplitter->addWidget(new OutputPanePlaceHolder(m_debugMode, mainWindowSplitter));
auto outputPane = new OutputPanePlaceHolder(m_debugMode, mainWindowSplitter);
outputPane->setObjectName(QLatin1String("DebuggerOutputPanePlaceHolder"));
mainWindowSplitter->addWidget(outputPane);
mainWindowSplitter->setStretchFactor(0, 10);
mainWindowSplitter->setStretchFactor(1, 0);
mainWindowSplitter->setOrientation(Qt::Vertical);
// Navigation and right-side window.
auto splitter = new MiniSplitter;
splitter->setFocusProxy(editorManagerPlaceHolder);
splitter->addWidget(new NavigationWidgetPlaceHolder(m_debugMode));
splitter->addWidget(mainWindowSplitter);
splitter->setStretchFactor(0, 0);
splitter->setStretchFactor(1, 1);
splitter->setObjectName(QLatin1String("DebugModeWidget"));
IContext *modeContextObject = new IContext(this);
modeContextObject->setContext(Context(CC::C_EDITORMANAGER));
modeContextObject->setWidget(splitter);
ICore::addContextObject(modeContextObject);
m_debugMode->setWidget(splitter);
m_plugin->addAutoReleasedObject(m_debugMode);
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
this, &DebuggerPluginPrivate::updateUiForProject);
//
// Connections
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment