forked from qt-creator/qt-creator
Debugger: Make perspective toolbar items part of the perspective
This simplifies the toolbar setup and removes the need for the stack of toolbar widgets. The actions themselves have been owned by the plugin already, so nothing changed in this respect. Change-Id: I44754e16c8fc2acc53633dd9d560b1e732eece27 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -271,7 +271,6 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
|||||||
|
|
||||||
auto perspective = new Perspective(tr("Clang-Tidy and Clazy"));
|
auto perspective = new Perspective(tr("Clang-Tidy and Clazy"));
|
||||||
perspective->addWindow(m_diagnosticView, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_diagnosticView, Perspective::SplitVertical, nullptr);
|
||||||
Debugger::registerPerspective(ClangTidyClazyPerspectiveId, perspective);
|
|
||||||
|
|
||||||
action = new QAction(tr("Clang-Tidy and Clazy..."), this);
|
action = new QAction(tr("Clang-Tidy and Clazy..."), this);
|
||||||
action->setToolTip(toolTip);
|
action->setToolTip(toolTip);
|
||||||
@@ -283,14 +282,14 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
|||||||
action->setEnabled(m_startAction->isEnabled());
|
action->setEnabled(m_startAction->isEnabled());
|
||||||
});
|
});
|
||||||
|
|
||||||
ToolbarDescription tidyClazyToolbar;
|
perspective->addToolbarAction(m_startAction);
|
||||||
tidyClazyToolbar.addAction(m_startAction);
|
perspective->addToolbarAction(m_stopAction);
|
||||||
tidyClazyToolbar.addAction(m_stopAction);
|
perspective->addToolbarAction(m_goBack);
|
||||||
tidyClazyToolbar.addAction(m_goBack);
|
perspective->addToolbarAction(m_goNext);
|
||||||
tidyClazyToolbar.addAction(m_goNext);
|
perspective->addToolbarWidget(m_filterLineEdit);
|
||||||
tidyClazyToolbar.addWidget(m_filterLineEdit);
|
perspective->addToolbarWidget(m_applyFixitsButton);
|
||||||
tidyClazyToolbar.addWidget(m_applyFixitsButton);
|
|
||||||
Debugger::registerToolbar(ClangTidyClazyPerspectiveId, tidyClazyToolbar);
|
Debugger::registerPerspective(ClangTidyClazyPerspectiveId, perspective);
|
||||||
|
|
||||||
updateRunActions();
|
updateRunActions();
|
||||||
|
|
||||||
|
@@ -62,11 +62,9 @@ DEBUGGER_EXPORT bool wantRunTool(ToolMode toolMode, const QString &toolName);
|
|||||||
DEBUGGER_EXPORT void showCannotStartDialog(const QString &toolName);
|
DEBUGGER_EXPORT void showCannotStartDialog(const QString &toolName);
|
||||||
|
|
||||||
// Register a tool for a given start mode.
|
// Register a tool for a given start mode.
|
||||||
DEBUGGER_EXPORT void registerPerspective(const QByteArray &perspectiveId, const Utils::Perspective *perspective);
|
DEBUGGER_EXPORT void registerPerspective(const QByteArray &perspectiveId, Utils::Perspective *perspective);
|
||||||
DEBUGGER_EXPORT void destroyDynamicPerspective(const QByteArray &perspectiveId);
|
DEBUGGER_EXPORT void destroyDynamicPerspective(const QByteArray &perspectiveId);
|
||||||
DEBUGGER_EXPORT void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enable);
|
DEBUGGER_EXPORT void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enable);
|
||||||
DEBUGGER_EXPORT void registerToolbar(const QByteArray &perspectiveId, const Utils::ToolbarDescription &desc);
|
|
||||||
DEBUGGER_EXPORT void destroyDynamicToolbar(const QByteArray &perspectiveId);
|
|
||||||
|
|
||||||
DEBUGGER_EXPORT void enableMainWindow(bool on);
|
DEBUGGER_EXPORT void enableMainWindow(bool on);
|
||||||
DEBUGGER_EXPORT QWidget *mainWindow();
|
DEBUGGER_EXPORT QWidget *mainWindow();
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/projectexplorericons.h>
|
#include <projectexplorer/projectexplorericons.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/proxyaction.h>
|
#include <utils/proxyaction.h>
|
||||||
@@ -65,7 +66,6 @@ const char LAST_PERSPECTIVE_KEY[] = "LastPerspective";
|
|||||||
|
|
||||||
DebuggerMainWindow::DebuggerMainWindow()
|
DebuggerMainWindow::DebuggerMainWindow()
|
||||||
{
|
{
|
||||||
m_controlsStackWidget = new QStackedWidget;
|
|
||||||
m_centralWidgetStack = new QStackedWidget;
|
m_centralWidgetStack = new QStackedWidget;
|
||||||
m_statusLabel = new Utils::StatusLabel;
|
m_statusLabel = new Utils::StatusLabel;
|
||||||
m_editorPlaceHolder = new EditorManagerPlaceHolder;
|
m_editorPlaceHolder = new EditorManagerPlaceHolder;
|
||||||
@@ -73,7 +73,9 @@ DebuggerMainWindow::DebuggerMainWindow()
|
|||||||
m_perspectiveChooser = new QComboBox;
|
m_perspectiveChooser = new QComboBox;
|
||||||
m_perspectiveChooser->setObjectName(QLatin1String("PerspectiveChooser"));
|
m_perspectiveChooser->setObjectName(QLatin1String("PerspectiveChooser"));
|
||||||
connect(m_perspectiveChooser, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
connect(m_perspectiveChooser, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
||||||
this, [this](int item) { restorePerspective(m_perspectiveChooser->itemData(item).toByteArray()); });
|
this, [this](int item) {
|
||||||
|
restorePerspective(findPerspective(m_perspectiveChooser->itemData(item).toByteArray()));
|
||||||
|
});
|
||||||
|
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
setDockActionsVisible(false);
|
setDockActionsVisible(false);
|
||||||
@@ -85,7 +87,7 @@ DebuggerMainWindow::DebuggerMainWindow()
|
|||||||
|
|
||||||
DebuggerMainWindow::~DebuggerMainWindow()
|
DebuggerMainWindow::~DebuggerMainWindow()
|
||||||
{
|
{
|
||||||
savePerspectiveHelper(m_currentPerspectiveId);
|
savePerspectiveHelper(m_currentPerspective);
|
||||||
|
|
||||||
delete m_editorPlaceHolder;
|
delete m_editorPlaceHolder;
|
||||||
m_editorPlaceHolder = nullptr;
|
m_editorPlaceHolder = nullptr;
|
||||||
@@ -96,17 +98,18 @@ DebuggerMainWindow::~DebuggerMainWindow()
|
|||||||
delete dock;
|
delete dock;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const Perspective *perspective, m_perspectiveForPerspectiveId)
|
foreach (const Perspective *perspective, m_perspectives)
|
||||||
delete perspective;
|
delete perspective;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, const Perspective *perspective)
|
void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, Perspective *perspective)
|
||||||
{
|
{
|
||||||
m_perspectiveForPerspectiveId.insert(perspectiveId, perspective);
|
m_perspectives.append(perspective);
|
||||||
|
perspective->m_id = perspectiveId;
|
||||||
QByteArray parentPerspective = perspective->parentPerspective();
|
QByteArray parentPerspective = perspective->parentPerspective();
|
||||||
// Add "main" perspectives to the chooser.
|
// Add "main" perspectives to the chooser.
|
||||||
if (parentPerspective.isEmpty()) {
|
if (parentPerspective.isEmpty()) {
|
||||||
m_perspectiveChooser->addItem(perspective->name(), perspectiveId);
|
m_perspectiveChooser->addItem(perspective->name(), perspective->m_id);
|
||||||
increaseChooserWidthIfNecessary(perspective->name());
|
increaseChooserWidthIfNecessary(perspective->name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,33 +127,22 @@ void DebuggerMainWindow::increaseChooserWidthIfNecessary(const QString &visibleN
|
|||||||
m_perspectiveChooser->setFixedWidth(width);
|
m_perspectiveChooser->setFixedWidth(width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::destroyDynamicPerspective(const QByteArray &perspectiveId)
|
void DebuggerMainWindow::destroyDynamicPerspective(Perspective *perspective)
|
||||||
{
|
{
|
||||||
savePerspectiveHelper(perspectiveId);
|
|
||||||
|
|
||||||
const Perspective *perspective = m_perspectiveForPerspectiveId.take(perspectiveId);
|
|
||||||
QTC_ASSERT(perspective, return);
|
QTC_ASSERT(perspective, return);
|
||||||
|
savePerspectiveHelper(perspective);
|
||||||
|
|
||||||
|
m_perspectives.removeAll(perspective);
|
||||||
// Dynamic perspectives are currently not visible in the chooser.
|
// Dynamic perspectives are currently not visible in the chooser.
|
||||||
// This might change in the future, make sure we notice.
|
// This might change in the future, make sure we notice.
|
||||||
const int idx = m_perspectiveChooser->findData(perspectiveId);
|
const int idx = indexInChooser(perspective);
|
||||||
QTC_ASSERT(idx == -1, m_perspectiveChooser->removeItem(idx));
|
QTC_ASSERT(idx == -1, m_perspectiveChooser->removeItem(idx));
|
||||||
QByteArray parentPerspective = perspective->parentPerspective();
|
QByteArray parentPerspective = perspective->parentPerspective();
|
||||||
delete perspective;
|
delete perspective;
|
||||||
// All dynamic perspectives currently have a static parent perspective.
|
// All dynamic perspectives currently have a static parent perspective.
|
||||||
// This might change in the future, make sure we notice.
|
// This might change in the future, make sure we notice.
|
||||||
QTC_CHECK(!parentPerspective.isEmpty());
|
QTC_CHECK(!parentPerspective.isEmpty());
|
||||||
restorePerspective(parentPerspective);
|
restorePerspective(findPerspective(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)
|
void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS)
|
||||||
@@ -168,11 +160,16 @@ void DebuggerMainWindow::raiseDock(const QByteArray &dockId)
|
|||||||
dock->raise();
|
dock->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray DebuggerMainWindow::currentPerspective() const
|
||||||
|
{
|
||||||
|
return m_currentPerspective ? m_currentPerspective->m_id : QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::onModeChanged(Core::Id mode)
|
void DebuggerMainWindow::onModeChanged(Core::Id mode)
|
||||||
{
|
{
|
||||||
if (mode == Debugger::Constants::MODE_DEBUG) {
|
if (mode == Debugger::Constants::MODE_DEBUG) {
|
||||||
setDockActionsVisible(true);
|
setDockActionsVisible(true);
|
||||||
restorePerspective({});
|
restorePerspective(nullptr);
|
||||||
} else {
|
} else {
|
||||||
setDockActionsVisible(false);
|
setDockActionsVisible(false);
|
||||||
|
|
||||||
@@ -186,7 +183,8 @@ void DebuggerMainWindow::onModeChanged(Core::Id mode)
|
|||||||
|
|
||||||
void DebuggerMainWindow::setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
|
void DebuggerMainWindow::setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
|
||||||
{
|
{
|
||||||
const int index = m_perspectiveChooser->findData(perspectiveId);
|
Perspective *perspective = findPerspective(perspectiveId);
|
||||||
|
const int index = indexInChooser(perspective);
|
||||||
QTC_ASSERT(index != -1, return);
|
QTC_ASSERT(index != -1, return);
|
||||||
auto model = qobject_cast<QStandardItemModel*>(m_perspectiveChooser->model());
|
auto model = qobject_cast<QStandardItemModel*>(m_perspectiveChooser->model());
|
||||||
QTC_ASSERT(model, return);
|
QTC_ASSERT(model, return);
|
||||||
@@ -194,18 +192,28 @@ void DebuggerMainWindow::setPerspectiveEnabled(const QByteArray &perspectiveId,
|
|||||||
item->setFlags(enabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
|
item->setFlags(enabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::resetCurrentPerspective()
|
Perspective *DebuggerMainWindow::findPerspective(const QByteArray &perspectiveId) const
|
||||||
{
|
{
|
||||||
loadPerspectiveHelper(m_currentPerspectiveId, false);
|
return Utils::findOr(m_perspectives, nullptr, [&](Perspective *perspective) {
|
||||||
|
return perspective->m_id == perspectiveId;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::restorePerspective(const QByteArray &perspectiveId)
|
void DebuggerMainWindow::resetCurrentPerspective()
|
||||||
{
|
{
|
||||||
loadPerspectiveHelper(perspectiveId, true);
|
loadPerspectiveHelper(m_currentPerspective, false);
|
||||||
|
}
|
||||||
|
|
||||||
int index = m_perspectiveChooser->findData(perspectiveId);
|
int DebuggerMainWindow::indexInChooser(Perspective *perspective) const
|
||||||
if (index == -1)
|
{
|
||||||
index = m_perspectiveChooser->findData(m_currentPerspectiveId);
|
return perspective ? m_perspectiveChooser->findData(perspective->m_id) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerMainWindow::restorePerspective(Perspective *perspective)
|
||||||
|
{
|
||||||
|
loadPerspectiveHelper(perspective, true);
|
||||||
|
|
||||||
|
const int index = indexInChooser(m_currentPerspective);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
m_perspectiveChooser->setCurrentIndex(index);
|
m_perspectiveChooser->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
@@ -219,13 +227,19 @@ void DebuggerMainWindow::finalizeSetup()
|
|||||||
closeButton->setIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon());
|
closeButton->setIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon());
|
||||||
closeButton->setToolTip(tr("Leave Debug Mode"));
|
closeButton->setToolTip(tr("Leave Debug Mode"));
|
||||||
|
|
||||||
|
auto toolbuttonBox = new QWidget;
|
||||||
|
m_toolbuttonBoxLayout = new QHBoxLayout(toolbuttonBox);
|
||||||
|
m_toolbuttonBoxLayout->setMargin(0);
|
||||||
|
m_toolbuttonBoxLayout->setSpacing(0);
|
||||||
|
|
||||||
auto toolbar = new Utils::StyledBar;
|
auto toolbar = new Utils::StyledBar;
|
||||||
toolbar->setProperty("topBorder", true);
|
toolbar->setProperty("topBorder", true);
|
||||||
auto hbox = new QHBoxLayout(toolbar);
|
auto hbox = new QHBoxLayout(toolbar);
|
||||||
hbox->setMargin(0);
|
hbox->setMargin(0);
|
||||||
hbox->setSpacing(0);
|
hbox->setSpacing(0);
|
||||||
hbox->addWidget(m_perspectiveChooser);
|
hbox->addWidget(m_perspectiveChooser);
|
||||||
hbox->addWidget(m_controlsStackWidget);
|
hbox->addWidget(toolbuttonBox);
|
||||||
|
hbox->addStretch(3);
|
||||||
hbox->addWidget(m_statusLabel);
|
hbox->addWidget(m_statusLabel);
|
||||||
hbox->addStretch(1);
|
hbox->addStretch(1);
|
||||||
hbox->addWidget(new Utils::StyledSeparator);
|
hbox->addWidget(new Utils::StyledSeparator);
|
||||||
@@ -329,15 +343,13 @@ QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow)
|
|||||||
return splitter;
|
return splitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings)
|
void DebuggerMainWindow::loadPerspectiveHelper(Perspective *perspective, bool fromStoredSettings)
|
||||||
{
|
{
|
||||||
// Clean up old perspective.
|
// Clean up old perspective.
|
||||||
if (!m_currentPerspectiveId.isEmpty()) {
|
if (m_currentPerspective) {
|
||||||
savePerspectiveHelper(m_currentPerspectiveId);
|
savePerspectiveHelper(m_currentPerspective);
|
||||||
for (QDockWidget *dock : m_dockForDockId) {
|
for (QDockWidget *dock : m_dockForDockId) {
|
||||||
QTC_ASSERT(dock, continue);
|
QTC_ASSERT(dock, continue);
|
||||||
dock->setFloating(false);
|
|
||||||
removeDockWidget(dock);
|
|
||||||
dock->setParent(nullptr);
|
dock->setParent(nullptr);
|
||||||
dock->widget()->setParent(nullptr);
|
dock->widget()->setParent(nullptr);
|
||||||
ActionManager::unregisterAction(dock->toggleViewAction(),
|
ActionManager::unregisterAction(dock->toggleViewAction(),
|
||||||
@@ -346,31 +358,50 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
|
|||||||
}
|
}
|
||||||
m_dockForDockId.clear();
|
m_dockForDockId.clear();
|
||||||
|
|
||||||
ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspectiveId)));
|
ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspective->m_id)));
|
||||||
const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId);
|
QWidget *central = m_currentPerspective->centralWidget();
|
||||||
QWidget *central = perspective ? perspective->centralWidget() : nullptr;
|
|
||||||
m_centralWidgetStack->removeWidget(central ? central : m_editorPlaceHolder);
|
m_centralWidgetStack->removeWidget(central ? central : m_editorPlaceHolder);
|
||||||
|
|
||||||
|
// Detach potentially re-used widgets to prevent deletion.
|
||||||
|
for (const Perspective::ToolbarOperation &op : m_currentPerspective->m_toolbarOperations) {
|
||||||
|
if (op.widget)
|
||||||
|
op.widget->setParent(nullptr);
|
||||||
|
if (op.toolbutton)
|
||||||
|
op.toolbutton->setParent(nullptr);
|
||||||
|
if (op.separator)
|
||||||
|
op.separator->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentPerspectiveId = perspectiveId;
|
while (QLayoutItem *item = m_toolbuttonBoxLayout->takeAt(0))
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_currentPerspectiveId.isEmpty()) {
|
if (perspective) {
|
||||||
|
m_currentPerspective = perspective;
|
||||||
|
} else {
|
||||||
const QSettings *settings = ICore::settings();
|
const QSettings *settings = ICore::settings();
|
||||||
m_currentPerspectiveId = settings->value(QLatin1String(LAST_PERSPECTIVE_KEY)).toByteArray();
|
m_currentPerspective = findPerspective(settings->value(QLatin1String(LAST_PERSPECTIVE_KEY)).toByteArray());
|
||||||
if (m_currentPerspectiveId.isEmpty())
|
if (!m_currentPerspective)
|
||||||
m_currentPerspectiveId = Debugger::Constants::CppPerspectiveId;
|
m_currentPerspective = findPerspective(Debugger::Constants::CppPerspectiveId);
|
||||||
|
if (!m_currentPerspective && !m_perspectives.isEmpty())
|
||||||
|
m_currentPerspective = m_perspectives.first();
|
||||||
|
}
|
||||||
|
QTC_ASSERT(m_currentPerspective, return);
|
||||||
|
|
||||||
|
ICore::addAdditionalContext(Context(Id::fromName(m_currentPerspective->m_id)));
|
||||||
|
|
||||||
|
m_currentPerspective->aboutToActivate();
|
||||||
|
|
||||||
|
for (const Perspective::ToolbarOperation &op : m_currentPerspective->m_toolbarOperations) {
|
||||||
|
if (op.widget)
|
||||||
|
m_toolbuttonBoxLayout->addWidget(op.widget);
|
||||||
|
if (op.toolbutton)
|
||||||
|
m_toolbuttonBoxLayout->addWidget(op.toolbutton);
|
||||||
|
if (op.separator)
|
||||||
|
m_toolbuttonBoxLayout->addWidget(op.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICore::addAdditionalContext(Context(Id::fromName(m_currentPerspectiveId)));
|
for (const Perspective::Operation &op : m_currentPerspective->m_operations) {
|
||||||
|
|
||||||
const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId);
|
|
||||||
if (!perspective) {
|
|
||||||
QTC_ASSERT(!m_perspectiveForPerspectiveId.isEmpty(), return);
|
|
||||||
perspective = *m_perspectiveForPerspectiveId.begin();
|
|
||||||
}
|
|
||||||
QTC_ASSERT(perspective, return);
|
|
||||||
perspective->aboutToActivate();
|
|
||||||
for (const Perspective::Operation &op : perspective->m_operations) {
|
|
||||||
QTC_ASSERT(op.widget, continue);
|
QTC_ASSERT(op.widget, continue);
|
||||||
const QByteArray dockId = op.widget->objectName().toUtf8();
|
const QByteArray dockId = op.widget->objectName().toUtf8();
|
||||||
QDockWidget *dock = m_dockForDockId.value(dockId);
|
QDockWidget *dock = m_dockForDockId.value(dockId);
|
||||||
@@ -384,7 +415,7 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
|
|||||||
|
|
||||||
Command *cmd = ActionManager::registerAction(toggleViewAction,
|
Command *cmd = ActionManager::registerAction(toggleViewAction,
|
||||||
Id("Dock.").withSuffix(dock->objectName()),
|
Id("Dock.").withSuffix(dock->objectName()),
|
||||||
Context(Id::fromName(m_currentPerspectiveId)));
|
Context(Id::fromName(m_currentPerspective->m_id)));
|
||||||
cmd->setAttribute(Command::CA_Hide);
|
cmd->setAttribute(Command::CA_Hide);
|
||||||
|
|
||||||
ActionManager::actionContainer(Core::Constants::M_WINDOW_VIEWS)->addAction(cmd);
|
ActionManager::actionContainer(Core::Constants::M_WINDOW_VIEWS)->addAction(cmd);
|
||||||
@@ -422,7 +453,7 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
|
|||||||
|
|
||||||
if (fromStoredSettings) {
|
if (fromStoredSettings) {
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginGroup(QString::fromLatin1(m_currentPerspectiveId));
|
settings->beginGroup(QString::fromLatin1(m_currentPerspective->m_id));
|
||||||
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
|
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
|
||||||
restoreSettings(settings);
|
restoreSettings(settings);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
@@ -431,29 +462,32 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
|
|||||||
showCentralWidgetAction()->setChecked(true);
|
showCentralWidgetAction()->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *central = perspective->centralWidget();
|
QWidget *central = m_currentPerspective->centralWidget();
|
||||||
m_centralWidgetStack->addWidget(central ? central : m_editorPlaceHolder);
|
m_centralWidgetStack->addWidget(central ? central : m_editorPlaceHolder);
|
||||||
showCentralWidgetAction()->setText(central ? central->windowTitle() : tr("Editor"));
|
showCentralWidgetAction()->setText(central ? central->windowTitle() : tr("Editor"));
|
||||||
|
|
||||||
QTC_CHECK(m_toolbarForPerspectiveId.contains(m_currentPerspectiveId));
|
|
||||||
m_controlsStackWidget->setCurrentWidget(m_toolbarForPerspectiveId.value(m_currentPerspectiveId));
|
|
||||||
m_statusLabel->clear();
|
m_statusLabel->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::savePerspectiveHelper(const QByteArray &perspectiveId)
|
void DebuggerMainWindow::savePerspectiveHelper(const Perspective *perspective)
|
||||||
{
|
{
|
||||||
if (perspectiveId.isEmpty())
|
if (!perspective)
|
||||||
return;
|
return;
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginGroup(QString::fromLatin1(perspectiveId));
|
settings->beginGroup(QString::fromLatin1(perspective->m_id));
|
||||||
saveSettings(settings);
|
saveSettings(settings);
|
||||||
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
|
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), perspectiveId);
|
settings->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), perspective->m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Perspective::~Perspective()
|
Perspective::~Perspective()
|
||||||
{
|
{
|
||||||
|
for (const ToolbarOperation &op : m_toolbarOperations) {
|
||||||
|
// op.widget and op.actions are owned by the plugins
|
||||||
|
delete op.toolbutton;
|
||||||
|
delete op.separator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Perspective::setCentralWidget(QWidget *centralWidget)
|
void Perspective::setCentralWidget(QWidget *centralWidget)
|
||||||
@@ -493,23 +527,36 @@ void Perspective::setParentPerspective(const QByteArray &parentPerspective)
|
|||||||
m_parentPerspective = parentPerspective;
|
m_parentPerspective = parentPerspective;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QWidget *> ToolbarDescription::widgets() const
|
QToolButton *Perspective::addToolbarAction(QAction *action, const QIcon &toolbarIcon)
|
||||||
{
|
{
|
||||||
return m_widgets;
|
ToolbarOperation op;
|
||||||
}
|
op.action = action;
|
||||||
|
op.icon = toolbarIcon;
|
||||||
QToolButton *ToolbarDescription::addAction(QAction *action, const QIcon &toolbarIcon)
|
op.toolbutton = new QToolButton;
|
||||||
{
|
op.toolbutton->setDefaultAction(toolbarIcon.isNull()
|
||||||
auto button = new QToolButton;
|
|
||||||
button->setDefaultAction(toolbarIcon.isNull()
|
|
||||||
? action : ProxyAction::proxyActionWithIcon(action, toolbarIcon));
|
? action : ProxyAction::proxyActionWithIcon(action, toolbarIcon));
|
||||||
m_widgets.append(button);
|
m_toolbarOperations.append(op);
|
||||||
return button;
|
|
||||||
|
return op.toolbutton;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolbarDescription::addWidget(QWidget *widget)
|
void Perspective::addToolbarWidget(QWidget *widget)
|
||||||
{
|
{
|
||||||
m_widgets.append(widget);
|
ToolbarOperation op;
|
||||||
|
op.widget = widget;
|
||||||
|
m_toolbarOperations.append(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perspective::addToolbarSeparator()
|
||||||
|
{
|
||||||
|
ToolbarOperation op;
|
||||||
|
op.separator = new StyledSeparator;
|
||||||
|
m_toolbarOperations.append(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *Perspective::centralWidget() const
|
||||||
|
{
|
||||||
|
return m_centralWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
Perspective::Perspective(const QString &name)
|
Perspective::Perspective(const QString &name)
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
#include <utils/statuslabel.h>
|
#include <utils/statuslabel.h>
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
@@ -61,7 +62,11 @@ public:
|
|||||||
bool visibleByDefault = true,
|
bool visibleByDefault = true,
|
||||||
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
|
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
|
||||||
|
|
||||||
QWidget *centralWidget() const { return m_centralWidget; }
|
QToolButton *addToolbarAction(QAction *action, const QIcon &toolbarIcon = QIcon());
|
||||||
|
void addToolbarWidget(QWidget *widget);
|
||||||
|
void addToolbarSeparator();
|
||||||
|
|
||||||
|
QWidget *centralWidget() const;
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
@@ -78,7 +83,7 @@ private:
|
|||||||
void operator=(const Perspective &) = delete;
|
void operator=(const Perspective &) = delete;
|
||||||
|
|
||||||
friend class DebuggerMainWindow;
|
friend class DebuggerMainWindow;
|
||||||
|
class PerspectivePrivate *d = nullptr;
|
||||||
class Operation
|
class Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -89,26 +94,23 @@ private:
|
|||||||
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea;
|
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ToolbarOperation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QPointer<QWidget> widget; // Owned by plugin if present
|
||||||
|
QPointer<QAction> action; // Owned by plugin if present
|
||||||
|
QPointer<QToolButton> toolbutton; // Owned here in case action is used
|
||||||
|
QPointer<QWidget> separator;
|
||||||
|
QIcon icon;
|
||||||
|
};
|
||||||
|
|
||||||
|
QByteArray m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QByteArray m_parentPerspective;
|
QByteArray m_parentPerspective;
|
||||||
QVector<Operation> m_operations;
|
QVector<Operation> m_operations;
|
||||||
QPointer<QWidget> m_centralWidget;
|
QPointer<QWidget> m_centralWidget;
|
||||||
Callback m_aboutToActivateCallback;
|
Callback m_aboutToActivateCallback;
|
||||||
};
|
QVector<ToolbarOperation> m_toolbarOperations;
|
||||||
|
|
||||||
class DEBUGGER_EXPORT ToolbarDescription
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ToolbarDescription() = default;
|
|
||||||
ToolbarDescription(const QList<QWidget *> &widgets) : m_widgets(widgets) {}
|
|
||||||
|
|
||||||
QList<QWidget *> widgets() const;
|
|
||||||
|
|
||||||
QToolButton *addAction(QAction *action, const QIcon &toolbarIcon = QIcon());
|
|
||||||
void addWidget(QWidget *widget);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<QWidget *> m_widgets;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebuggerMainWindow : public FancyMainWindow
|
class DEBUGGER_EXPORT DebuggerMainWindow : public FancyMainWindow
|
||||||
@@ -119,43 +121,43 @@ public:
|
|||||||
DebuggerMainWindow();
|
DebuggerMainWindow();
|
||||||
~DebuggerMainWindow() override;
|
~DebuggerMainWindow() override;
|
||||||
|
|
||||||
void registerPerspective(const QByteArray &perspectiveId, const Perspective *perspective);
|
void registerPerspective(const QByteArray &perspectiveId, Perspective *perspective);
|
||||||
void destroyDynamicPerspective(const QByteArray &perspectiveId);
|
void destroyDynamicPerspective(Perspective *perspective);
|
||||||
void registerToolbar(const QByteArray &perspectiveId, QWidget *widget);
|
|
||||||
void destroyDynamicToolbar(const QByteArray &perspectiveId);
|
|
||||||
|
|
||||||
void resetCurrentPerspective();
|
void resetCurrentPerspective();
|
||||||
void restorePerspective(const QByteArray &perspectiveId);
|
void restorePerspective(Perspective *perspective);
|
||||||
|
|
||||||
void finalizeSetup();
|
void finalizeSetup();
|
||||||
|
|
||||||
void showStatusMessage(const QString &message, int timeoutMS);
|
void showStatusMessage(const QString &message, int timeoutMS);
|
||||||
void raiseDock(const QByteArray &dockId);
|
void raiseDock(const QByteArray &dockId);
|
||||||
QByteArray currentPerspective() const { return m_currentPerspectiveId; }
|
QByteArray currentPerspective() const;
|
||||||
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
|
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
|
||||||
|
|
||||||
void onModeChanged(Core::Id mode);
|
void onModeChanged(Core::Id mode);
|
||||||
|
|
||||||
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled);
|
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled);
|
||||||
|
|
||||||
|
Perspective *findPerspective(const QByteArray &perspectiveId) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspectiveId); }
|
void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspective); }
|
||||||
|
|
||||||
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
|
void loadPerspectiveHelper(Perspective *perspective, bool fromStoredSettings = true);
|
||||||
void savePerspectiveHelper(const QByteArray &perspectiveId);
|
void savePerspectiveHelper(const Perspective *perspective);
|
||||||
void increaseChooserWidthIfNecessary(const QString &visibleName);
|
void increaseChooserWidthIfNecessary(const QString &visibleName);
|
||||||
|
int indexInChooser(Perspective *perspective) const;
|
||||||
|
|
||||||
QByteArray m_currentPerspectiveId;
|
Perspective *m_currentPerspective = nullptr;
|
||||||
QComboBox *m_perspectiveChooser;
|
QComboBox *m_perspectiveChooser = nullptr;
|
||||||
QStackedWidget *m_controlsStackWidget;
|
QHBoxLayout *m_toolbuttonBoxLayout = nullptr;
|
||||||
QStackedWidget *m_centralWidgetStack;
|
QStackedWidget *m_centralWidgetStack = nullptr;
|
||||||
QWidget *m_editorPlaceHolder;
|
QWidget *m_editorPlaceHolder = nullptr;
|
||||||
Utils::StatusLabel *m_statusLabel;
|
Utils::StatusLabel *m_statusLabel = nullptr;
|
||||||
QDockWidget *m_toolbarDock = nullptr;
|
QDockWidget *m_toolbarDock = nullptr;
|
||||||
|
|
||||||
QHash<QByteArray, QDockWidget *> m_dockForDockId;
|
QHash<QByteArray, QDockWidget *> m_dockForDockId;
|
||||||
QHash<QByteArray, QWidget *> m_toolbarForPerspectiveId;
|
QList<Perspective *> m_perspectives;
|
||||||
QHash<QByteArray, const Perspective *> m_perspectiveForPerspectiveId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow);
|
DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow);
|
||||||
|
@@ -1809,35 +1809,18 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
connect(action(SettingsDialog), &QAction::triggered,
|
connect(action(SettingsDialog), &QAction::triggered,
|
||||||
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); });
|
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); });
|
||||||
|
|
||||||
// Toolbar
|
|
||||||
ToolbarDescription toolbar;
|
|
||||||
toolbar.addAction(m_visibleStartAction);
|
|
||||||
toolbar.addAction(ActionManager::command(Constants::STOP)->action(), Icons::DEBUG_EXIT_SMALL_TOOLBAR.icon());
|
|
||||||
toolbar.addAction(ActionManager::command(Constants::NEXT)->action(), Icons::STEP_OVER_TOOLBAR.icon());
|
|
||||||
toolbar.addAction(ActionManager::command(Constants::STEP)->action(), Icons::STEP_INTO_TOOLBAR.icon());
|
|
||||||
toolbar.addAction(ActionManager::command(Constants::STEPOUT)->action(), Icons::STEP_OUT_TOOLBAR.icon());
|
|
||||||
toolbar.addAction(ActionManager::command(Constants::RESET)->action(), Icons::RESTART_TOOLBAR.icon());
|
|
||||||
toolbar.addAction(ActionManager::command(Constants::OPERATE_BY_INSTRUCTION)->action());
|
|
||||||
|
|
||||||
if (isReverseDebuggingEnabled()) {
|
if (isReverseDebuggingEnabled()) {
|
||||||
m_reverseToolButton = new QToolButton;
|
m_reverseToolButton = new QToolButton;
|
||||||
m_reverseToolButton->setDefaultAction(m_reverseDirectionAction);
|
m_reverseToolButton->setDefaultAction(m_reverseDirectionAction);
|
||||||
toolbar.addWidget(m_reverseToolButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar.addWidget(new StyledSeparator);
|
|
||||||
|
|
||||||
m_threadLabel = new QLabel(tr("Threads:"));
|
m_threadLabel = new QLabel(tr("Threads:"));
|
||||||
toolbar.addWidget(m_threadLabel);
|
|
||||||
|
|
||||||
m_threadBox = new QComboBox;
|
m_threadBox = new QComboBox;
|
||||||
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
connect(m_threadBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
connect(m_threadBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
||||||
this, &DebuggerPluginPrivate::selectThread);
|
this, &DebuggerPluginPrivate::selectThread);
|
||||||
|
|
||||||
toolbar.addWidget(m_threadBox);
|
|
||||||
// toolbar.addSpacerItem(new QSpacerItem(4, 0));
|
|
||||||
|
|
||||||
// ToolbarDescription qmlToolbar
|
// ToolbarDescription qmlToolbar
|
||||||
// qmlToolbar.addAction(qmlUpdateOnSaveDummyAction);
|
// qmlToolbar.addAction(qmlUpdateOnSaveDummyAction);
|
||||||
// qmlToolbar.addAction(qmlShowAppOnTopDummyAction, Icons::APP_ON_TOP_TOOLBAR.icon());
|
// qmlToolbar.addAction(qmlShowAppOnTopDummyAction, Icons::APP_ON_TOP_TOOLBAR.icon());
|
||||||
@@ -1846,7 +1829,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
// qmlToolbar.addWidget(new StyledSeparator);
|
// qmlToolbar.addWidget(new StyledSeparator);
|
||||||
|
|
||||||
auto createBasePerspective = [this] {
|
auto createBasePerspective = [this] {
|
||||||
auto perspective = new Perspective;
|
auto perspective = new Perspective("Debugger");
|
||||||
perspective->addWindow(m_stackWindow, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_stackWindow, Perspective::SplitVertical, nullptr);
|
||||||
perspective->addWindow(m_breakWindow, Perspective::SplitHorizontal, m_stackWindow);
|
perspective->addWindow(m_breakWindow, Perspective::SplitHorizontal, m_stackWindow);
|
||||||
perspective->addWindow(m_threadsWindow, Perspective::AddToTab, m_breakWindow, false);
|
perspective->addWindow(m_threadsWindow, Perspective::AddToTab, m_breakWindow, false);
|
||||||
@@ -1859,6 +1842,23 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
Qt::RightDockWidgetArea);
|
Qt::RightDockWidgetArea);
|
||||||
perspective->addWindow(m_logWindow, Perspective::AddToTab, nullptr, false, Qt::TopDockWidgetArea);
|
perspective->addWindow(m_logWindow, Perspective::AddToTab, nullptr, false, Qt::TopDockWidgetArea);
|
||||||
perspective->addWindow(m_breakWindow, Perspective::Raise, nullptr);
|
perspective->addWindow(m_breakWindow, Perspective::Raise, nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
perspective->addToolbarAction(m_visibleStartAction);
|
||||||
|
perspective->addToolbarAction(ActionManager::command(Constants::STOP)->action(), Icons::DEBUG_EXIT_SMALL_TOOLBAR.icon());
|
||||||
|
perspective->addToolbarAction(ActionManager::command(Constants::NEXT)->action(), Icons::STEP_OVER_TOOLBAR.icon());
|
||||||
|
perspective->addToolbarAction(ActionManager::command(Constants::STEP)->action(), Icons::STEP_INTO_TOOLBAR.icon());
|
||||||
|
perspective->addToolbarAction(ActionManager::command(Constants::STEPOUT)->action(), Icons::STEP_OUT_TOOLBAR.icon());
|
||||||
|
perspective->addToolbarAction(ActionManager::command(Constants::RESET)->action(), Icons::RESTART_TOOLBAR.icon());
|
||||||
|
perspective->addToolbarAction(ActionManager::command(Constants::OPERATE_BY_INSTRUCTION)->action());
|
||||||
|
|
||||||
|
if (isReverseDebuggingEnabled())
|
||||||
|
perspective->addToolbarWidget(m_reverseToolButton);
|
||||||
|
|
||||||
|
perspective->addToolbarSeparator();
|
||||||
|
perspective->addToolbarWidget(m_threadLabel);
|
||||||
|
perspective->addToolbarWidget(m_threadBox);
|
||||||
|
|
||||||
return perspective;
|
return perspective;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1866,7 +1866,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
cppPerspective->setName(tr("Debugger"));
|
cppPerspective->setName(tr("Debugger"));
|
||||||
cppPerspective->addWindow(m_registerWindow, Perspective::AddToTab, m_snapshotWindow, false);
|
cppPerspective->addWindow(m_registerWindow, Perspective::AddToTab, m_snapshotWindow, false);
|
||||||
|
|
||||||
Debugger::registerToolbar(CppPerspectiveId, toolbar);
|
|
||||||
Debugger::registerPerspective(CppPerspectiveId, cppPerspective);
|
Debugger::registerPerspective(CppPerspectiveId, cppPerspective);
|
||||||
|
|
||||||
// Perspective *qmlPerspective = createBasePerspective();
|
// Perspective *qmlPerspective = createBasePerspective();
|
||||||
@@ -3495,26 +3494,6 @@ bool wantRunTool(ToolMode toolMode, const QString &toolName)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerToolbar(const QByteArray &perspectiveId, const ToolbarDescription &desc)
|
|
||||||
{
|
|
||||||
auto toolbar = new QWidget;
|
|
||||||
toolbar->setObjectName(QString::fromLatin1(perspectiveId + ".Toolbar"));
|
|
||||||
auto hbox = new QHBoxLayout(toolbar);
|
|
||||||
hbox->setMargin(0);
|
|
||||||
hbox->setSpacing(0);
|
|
||||||
for (QWidget *widget : desc.widgets())
|
|
||||||
hbox->addWidget(widget);
|
|
||||||
hbox->addStretch();
|
|
||||||
toolbar->setLayout(hbox);
|
|
||||||
|
|
||||||
dd->m_mainWindow->registerToolbar(perspectiveId, toolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroyDynamicToolbar(const QByteArray &perspectiveId)
|
|
||||||
{
|
|
||||||
dd->m_mainWindow->destroyDynamicToolbar(perspectiveId);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *createStartAction()
|
QAction *createStartAction()
|
||||||
{
|
{
|
||||||
auto action = new QAction(DebuggerMainWindow::tr("Start"), DebuggerPlugin::instance());
|
auto action = new QAction(DebuggerMainWindow::tr("Start"), DebuggerPlugin::instance());
|
||||||
@@ -3531,16 +3510,11 @@ QAction *createStopAction()
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerPerspective(const QByteArray &perspectiveId, const Perspective *perspective)
|
void registerPerspective(const QByteArray &perspectiveId, Perspective *perspective)
|
||||||
{
|
{
|
||||||
dd->m_mainWindow->registerPerspective(perspectiveId, perspective);
|
dd->m_mainWindow->registerPerspective(perspectiveId, perspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyDynamicPerspective(const QByteArray &perspectiveId)
|
|
||||||
{
|
|
||||||
dd->m_mainWindow->destroyDynamicPerspective(perspectiveId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
|
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
|
||||||
{
|
{
|
||||||
dd->m_mainWindow->setPerspectiveEnabled(perspectiveId, enabled);
|
dd->m_mainWindow->setPerspectiveEnabled(perspectiveId, enabled);
|
||||||
@@ -3557,7 +3531,7 @@ void selectPerspective(const QByteArray &perspectiveId)
|
|||||||
if (perspectiveId.isEmpty())
|
if (perspectiveId.isEmpty())
|
||||||
return;
|
return;
|
||||||
ModeManager::activateMode(MODE_DEBUG);
|
ModeManager::activateMode(MODE_DEBUG);
|
||||||
dd->m_mainWindow->restorePerspective(perspectiveId);
|
dd->m_mainWindow->restorePerspective(dd->m_mainWindow->findPerspective(perspectiveId));
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray currentPerspective()
|
QByteArray currentPerspective()
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
|
|
||||||
#include <debugger/debuggericons.h>
|
#include <debugger/debuggericons.h>
|
||||||
|
#include <debugger/debuggermainwindow.h>
|
||||||
#include <debugger/analyzer/analyzermanager.h>
|
#include <debugger/analyzer/analyzermanager.h>
|
||||||
|
|
||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
@@ -228,15 +229,14 @@ QmlProfilerTool::QmlProfilerTool()
|
|||||||
|
|
||||||
QObject::connect(d->m_startAction, &QAction::triggered, this, &QmlProfilerTool::profileStartupProject);
|
QObject::connect(d->m_startAction, &QAction::triggered, this, &QmlProfilerTool::profileStartupProject);
|
||||||
|
|
||||||
Utils::ToolbarDescription toolbar;
|
Utils::Perspective *perspective = d->m_viewContainer->perspective();
|
||||||
toolbar.addAction(d->m_startAction);
|
perspective->addToolbarAction(d->m_startAction);
|
||||||
toolbar.addAction(d->m_stopAction);
|
perspective->addToolbarAction(d->m_stopAction);
|
||||||
toolbar.addWidget(d->m_recordButton);
|
perspective->addToolbarWidget(d->m_recordButton);
|
||||||
toolbar.addWidget(d->m_clearButton);
|
perspective->addToolbarWidget(d->m_clearButton);
|
||||||
toolbar.addWidget(d->m_searchButton);
|
perspective->addToolbarWidget(d->m_searchButton);
|
||||||
toolbar.addWidget(d->m_displayFeaturesButton);
|
perspective->addToolbarWidget(d->m_displayFeaturesButton);
|
||||||
toolbar.addWidget(d->m_timeLabel);
|
perspective->addToolbarWidget(d->m_timeLabel);
|
||||||
Debugger::registerToolbar(Constants::QmlProfilerPerspectiveId, toolbar);
|
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
||||||
this, &QmlProfilerTool::updateRunActions);
|
this, &QmlProfilerTool::updateRunActions);
|
||||||
|
@@ -61,8 +61,8 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
|
|
||||||
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
||||||
|
|
||||||
auto perspective = new Utils::Perspective;
|
m_perspective = new Utils::Perspective;
|
||||||
perspective->setName(tr("QML Profiler"));
|
m_perspective->setName(tr("QML Profiler"));
|
||||||
|
|
||||||
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
||||||
connect(view, &QmlProfilerEventsView::typeSelected,
|
connect(view, &QmlProfilerEventsView::typeSelected,
|
||||||
@@ -86,16 +86,16 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
QWidget *anchor = nullptr;
|
QWidget *anchor = nullptr;
|
||||||
if (m_traceView->isUsable()) {
|
if (m_traceView->isUsable()) {
|
||||||
anchor = m_traceView;
|
anchor = m_traceView;
|
||||||
perspective->addWindow(m_traceView, Perspective::SplitVertical, nullptr);
|
m_perspective->addWindow(m_traceView, Perspective::SplitVertical, nullptr);
|
||||||
perspective->addWindow(m_flameGraphView, Perspective::AddToTab, anchor);
|
m_perspective->addWindow(m_flameGraphView, Perspective::AddToTab, anchor);
|
||||||
} else {
|
} else {
|
||||||
anchor = m_flameGraphView;
|
anchor = m_flameGraphView;
|
||||||
perspective->addWindow(m_flameGraphView, Perspective::SplitVertical, nullptr);
|
m_perspective->addWindow(m_flameGraphView, Perspective::SplitVertical, nullptr);
|
||||||
}
|
}
|
||||||
perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchor);
|
m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchor);
|
||||||
perspective->addWindow(anchor, Perspective::Raise, nullptr);
|
m_perspective->addWindow(anchor, Perspective::Raise, nullptr);
|
||||||
|
|
||||||
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
|
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, m_perspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerViewManager::~QmlProfilerViewManager()
|
QmlProfilerViewManager::~QmlProfilerViewManager()
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace Utils { class Perspective; }
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ public:
|
|||||||
QmlProfilerTraceView *traceView() const { return m_traceView; }
|
QmlProfilerTraceView *traceView() const { return m_traceView; }
|
||||||
QmlProfilerStatisticsView *statisticsView() const { return m_statisticsView; }
|
QmlProfilerStatisticsView *statisticsView() const { return m_statisticsView; }
|
||||||
FlameGraphView *flameGraphView() const { return m_flameGraphView; }
|
FlameGraphView *flameGraphView() const { return m_flameGraphView; }
|
||||||
|
Utils::Perspective *perspective() const { return m_perspective; }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
@@ -62,6 +65,7 @@ private:
|
|||||||
FlameGraphView *m_flameGraphView = nullptr;
|
FlameGraphView *m_flameGraphView = nullptr;
|
||||||
QmlProfilerStateManager *m_profilerState = nullptr;
|
QmlProfilerStateManager *m_profilerState = nullptr;
|
||||||
QmlProfilerModelManager *m_profilerModelManager = nullptr;
|
QmlProfilerModelManager *m_profilerModelManager = nullptr;
|
||||||
|
Utils::Perspective *m_perspective = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -419,18 +419,18 @@ CallgrindTool::CallgrindTool()
|
|||||||
this, &CallgrindTool::setCostEvent);
|
this, &CallgrindTool::setCostEvent);
|
||||||
updateEventCombo();
|
updateEventCombo();
|
||||||
|
|
||||||
ToolbarDescription toolbar;
|
auto perspective = new Perspective(tr("Callgrind"));
|
||||||
toolbar.addAction(m_startAction);
|
perspective->addToolbarAction(m_startAction);
|
||||||
toolbar.addAction(m_stopAction);
|
perspective->addToolbarAction(m_stopAction);
|
||||||
toolbar.addAction(m_loadExternalLogFile);
|
perspective->addToolbarAction(m_loadExternalLogFile);
|
||||||
toolbar.addAction(m_dumpAction);
|
perspective->addToolbarAction(m_dumpAction);
|
||||||
toolbar.addAction(m_resetAction);
|
perspective->addToolbarAction(m_resetAction);
|
||||||
toolbar.addAction(m_pauseAction);
|
perspective->addToolbarAction(m_pauseAction);
|
||||||
toolbar.addAction(m_discardAction);
|
perspective->addToolbarAction(m_discardAction);
|
||||||
toolbar.addAction(m_goBack);
|
perspective->addToolbarAction(m_goBack);
|
||||||
toolbar.addAction(m_goNext);
|
perspective->addToolbarAction(m_goNext);
|
||||||
toolbar.addWidget(new Utils::StyledSeparator);
|
perspective->addToolbarSeparator();
|
||||||
toolbar.addWidget(m_eventCombo);
|
perspective->addToolbarWidget(m_eventCombo);
|
||||||
|
|
||||||
// Cost formatting
|
// Cost formatting
|
||||||
{
|
{
|
||||||
@@ -463,7 +463,7 @@ CallgrindTool::CallgrindTool()
|
|||||||
button->setPopupMode(QToolButton::InstantPopup);
|
button->setPopupMode(QToolButton::InstantPopup);
|
||||||
button->setText(QLatin1String("$"));
|
button->setText(QLatin1String("$"));
|
||||||
button->setToolTip(tr("Cost Format"));
|
button->setToolTip(tr("Cost Format"));
|
||||||
toolbar.addWidget(button);
|
perspective->addToolbarWidget(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings();
|
ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings();
|
||||||
@@ -500,13 +500,11 @@ CallgrindTool::CallgrindTool()
|
|||||||
setCostFormat(settings->costFormat());
|
setCostFormat(settings->costFormat());
|
||||||
enableCycleDetection(settings->detectCycles());
|
enableCycleDetection(settings->detectCycles());
|
||||||
|
|
||||||
toolbar.addAction(m_cycleDetection);
|
perspective->addToolbarAction(m_cycleDetection);
|
||||||
toolbar.addAction(m_shortenTemplates);
|
perspective->addToolbarAction(m_shortenTemplates);
|
||||||
toolbar.addAction(m_filterProjectCosts);
|
perspective->addToolbarAction(m_filterProjectCosts);
|
||||||
toolbar.addWidget(m_searchFilter);
|
perspective->addToolbarWidget(m_searchFilter);
|
||||||
Debugger::registerToolbar(CallgrindPerspectiveId, toolbar);
|
|
||||||
|
|
||||||
auto perspective = new Perspective(tr("Callgrind"));
|
|
||||||
perspective->addWindow(m_flatView, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_flatView, Perspective::SplitVertical, nullptr);
|
||||||
perspective->addWindow(m_calleesView, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_calleesView, Perspective::SplitVertical, nullptr);
|
||||||
perspective->addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView);
|
perspective->addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView);
|
||||||
|
@@ -558,7 +558,6 @@ MemcheckTool::MemcheckTool()
|
|||||||
|
|
||||||
auto perspective = new Perspective(tr("Memcheck"));
|
auto perspective = new Perspective(tr("Memcheck"));
|
||||||
perspective->addWindow(m_errorView, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_errorView, Perspective::SplitVertical, nullptr);
|
||||||
Debugger::registerPerspective(MemcheckPerspectiveId, perspective);
|
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
||||||
this, &MemcheckTool::maybeActiveRunConfigurationChanged);
|
this, &MemcheckTool::maybeActiveRunConfigurationChanged);
|
||||||
@@ -684,15 +683,14 @@ MemcheckTool::MemcheckTool()
|
|||||||
ProjectExplorerPlugin::startRunControl(rc);
|
ProjectExplorerPlugin::startRunControl(rc);
|
||||||
});
|
});
|
||||||
|
|
||||||
ToolbarDescription toolbar;
|
perspective->addToolbarAction(m_startAction);
|
||||||
toolbar.addAction(m_startAction);
|
|
||||||
//toolbar.addAction(m_startWithGdbAction);
|
//toolbar.addAction(m_startWithGdbAction);
|
||||||
toolbar.addAction(m_stopAction);
|
perspective->addToolbarAction(m_stopAction);
|
||||||
toolbar.addAction(m_loadExternalLogFile);
|
perspective->addToolbarAction(m_loadExternalLogFile);
|
||||||
toolbar.addAction(m_goBack);
|
perspective->addToolbarAction(m_goBack);
|
||||||
toolbar.addAction(m_goNext);
|
perspective->addToolbarAction(m_goNext);
|
||||||
toolbar.addWidget(filterButton);
|
perspective->addToolbarWidget(filterButton);
|
||||||
Debugger::registerToolbar(MemcheckPerspectiveId, toolbar);
|
Debugger::registerPerspective(MemcheckPerspectiveId, perspective);
|
||||||
|
|
||||||
updateFromSettings();
|
updateFromSettings();
|
||||||
maybeActiveRunConfigurationChanged();
|
maybeActiveRunConfigurationChanged();
|
||||||
|
Reference in New Issue
Block a user