forked from qt-creator/qt-creator
Debugger: Start introducing dynamic perspectives
Make perspectives and tool bars destroyable. This is a step forward to multiply debugger engines whose perspective's life time is connected to the engine, not the debug mode. In the present setup there are two kind of perspective: 1 - static: with a lifetime associated to the application (or, rather, plugin that defines them). These are listed in the perspective chooser, later e.g. Debugger for pre-set breakpoints 2 - dynamic: with a shorted lifetime, e.g. running GDB engine. Presently, and possibly also in future so, a dynamic perspective is related to exactly one of the static perspectives, i.e. are kind of "child". Change-Id: Ic11572e7121e14f8da2927a0c0ac3441c99073a3 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -103,10 +103,18 @@ DebuggerMainWindow::~DebuggerMainWindow()
|
||||
void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, const Perspective *perspective)
|
||||
{
|
||||
m_perspectiveForPerspectiveId.insert(perspectiveId, perspective);
|
||||
m_perspectiveChooser->addItem(perspective->name(), perspectiveId);
|
||||
// adjust width if necessary
|
||||
QByteArray parentPerspective = perspective->parentPerspective();
|
||||
// Add "main" perspectives to the chooser.
|
||||
if (parentPerspective.isEmpty()) {
|
||||
m_perspectiveChooser->addItem(perspective->name(), perspectiveId);
|
||||
increaseChooserWidthIfNecessary(perspective->name());
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerMainWindow::increaseChooserWidthIfNecessary(const QString &visibleName)
|
||||
{
|
||||
const int oldWidth = m_perspectiveChooser->width();
|
||||
const int contentWidth = m_perspectiveChooser->fontMetrics().width(perspective->name());
|
||||
const int contentWidth = m_perspectiveChooser->fontMetrics().width(visibleName);
|
||||
QStyleOptionComboBox option;
|
||||
option.initFrom(m_perspectiveChooser);
|
||||
const QSize sz(contentWidth, 1);
|
||||
@@ -116,12 +124,35 @@ void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, co
|
||||
m_perspectiveChooser->setFixedWidth(width);
|
||||
}
|
||||
|
||||
void DebuggerMainWindow::destroyDynamicPerspective(const QByteArray &perspectiveId)
|
||||
{
|
||||
savePerspectiveHelper(perspectiveId);
|
||||
|
||||
const Perspective *perspective = m_perspectiveForPerspectiveId.take(perspectiveId);
|
||||
QTC_ASSERT(perspective, return);
|
||||
// Dynamic perspectives are currently not visible in the chooser.
|
||||
// This might change in the future, make sure we notice.
|
||||
const int idx = m_perspectiveChooser->findData(perspectiveId);
|
||||
QTC_ASSERT(idx == -1, m_perspectiveChooser->removeItem(idx));
|
||||
QByteArray parentPerspective = perspective->parentPerspective();
|
||||
delete perspective;
|
||||
// All dynamic perspectives currently have a static parent perspective.
|
||||
// This might change in the future, make sure we notice.
|
||||
QTC_CHECK(!parentPerspective.isEmpty());
|
||||
restorePerspective(parentPerspective);
|
||||
}
|
||||
|
||||
void DebuggerMainWindow::registerToolbar(const QByteArray &perspectiveId, QWidget *widget)
|
||||
{
|
||||
m_toolbarForPerspectiveId.insert(perspectiveId, widget);
|
||||
m_controlsStackWidget->addWidget(widget);
|
||||
}
|
||||
|
||||
void DebuggerMainWindow::destroyDynamicToolbar(const QByteArray &perspectiveId)
|
||||
{
|
||||
delete m_toolbarForPerspectiveId.take(perspectiveId);
|
||||
}
|
||||
|
||||
void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS)
|
||||
{
|
||||
m_statusLabel->showStatusMessage(message, timeoutMS);
|
||||
@@ -456,6 +487,16 @@ void Perspective::aboutToActivate() const
|
||||
m_aboutToActivateCallback();
|
||||
}
|
||||
|
||||
QByteArray Perspective::parentPerspective() const
|
||||
{
|
||||
return m_parentPerspective;
|
||||
}
|
||||
|
||||
void Perspective::setParentPerspective(const QByteArray &parentPerspective)
|
||||
{
|
||||
m_parentPerspective = parentPerspective;
|
||||
}
|
||||
|
||||
QList<QWidget *> ToolbarDescription::widgets() const
|
||||
{
|
||||
return m_widgets;
|
||||
|
||||
Reference in New Issue
Block a user