forked from qt-creator/qt-creator
Debugger: Tighten Perspective interface
Pass id in constructor, so it can be const. Change-Id: Id33fe19c4416109af8aa05a3ed0a09918eeb5cdf Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -269,7 +269,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
|||||||
const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the "
|
const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the "
|
||||||
"Clang project to search for errors and warnings.");
|
"Clang project to search for errors and warnings.");
|
||||||
|
|
||||||
auto perspective = new Perspective(tr("Clang-Tidy and Clazy"));
|
auto perspective = new Perspective(ClangTidyClazyPerspectiveId, tr("Clang-Tidy and Clazy"));
|
||||||
perspective->addWindow(m_diagnosticView, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_diagnosticView, Perspective::SplitVertical, nullptr);
|
||||||
|
|
||||||
action = new QAction(tr("Clang-Tidy and Clazy..."), this);
|
action = new QAction(tr("Clang-Tidy and Clazy..."), this);
|
||||||
@@ -289,7 +289,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
|||||||
perspective->addToolbarWidget(m_filterLineEdit);
|
perspective->addToolbarWidget(m_filterLineEdit);
|
||||||
perspective->addToolbarWidget(m_applyFixitsButton);
|
perspective->addToolbarWidget(m_applyFixitsButton);
|
||||||
|
|
||||||
Debugger::registerPerspective(ClangTidyClazyPerspectiveId, perspective);
|
Debugger::registerPerspective(perspective);
|
||||||
|
|
||||||
updateRunActions();
|
updateRunActions();
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ 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, Utils::Perspective *perspective);
|
DEBUGGER_EXPORT void registerPerspective(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);
|
||||||
|
|
||||||
|
|||||||
@@ -102,10 +102,9 @@ DebuggerMainWindow::~DebuggerMainWindow()
|
|||||||
delete perspective;
|
delete perspective;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, Perspective *perspective)
|
void DebuggerMainWindow::registerPerspective(Perspective *perspective)
|
||||||
{
|
{
|
||||||
m_perspectives.append(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()) {
|
||||||
@@ -481,6 +480,13 @@ void DebuggerMainWindow::savePerspectiveHelper(const Perspective *perspective)
|
|||||||
settings->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), perspective->m_id);
|
settings->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), perspective->m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Perspective
|
||||||
|
|
||||||
|
Perspective::Perspective(const QByteArray &id, const QString &name)
|
||||||
|
: m_id(id), m_name(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Perspective::~Perspective()
|
Perspective::~Perspective()
|
||||||
{
|
{
|
||||||
for (const ToolbarOperation &op : m_toolbarOperations) {
|
for (const ToolbarOperation &op : m_toolbarOperations) {
|
||||||
@@ -501,11 +507,6 @@ QString Perspective::name() const
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Perspective::setName(const QString &name)
|
|
||||||
{
|
|
||||||
m_name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Perspective::setAboutToActivateCallback(const Perspective::Callback &cb)
|
void Perspective::setAboutToActivateCallback(const Perspective::Callback &cb)
|
||||||
{
|
{
|
||||||
m_aboutToActivateCallback = cb;
|
m_aboutToActivateCallback = cb;
|
||||||
@@ -563,11 +564,6 @@ QWidget *Perspective::centralWidget() const
|
|||||||
return m_centralWidget;
|
return m_centralWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
Perspective::Perspective(const QString &name)
|
|
||||||
: m_name(name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Perspective::addWindow(QWidget *widget, OperationType type, QWidget *anchorWidget,
|
void Perspective::addWindow(QWidget *widget, OperationType type, QWidget *anchorWidget,
|
||||||
bool visibleByDefault, Qt::DockWidgetArea area)
|
bool visibleByDefault, Qt::DockWidgetArea area)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ class DEBUGGER_EXPORT Perspective
|
|||||||
public:
|
public:
|
||||||
enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise };
|
enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise };
|
||||||
|
|
||||||
Perspective() = default;
|
explicit Perspective(const QByteArray &id, const QString &name);
|
||||||
explicit Perspective(const QString &name);
|
|
||||||
~Perspective();
|
~Perspective();
|
||||||
|
|
||||||
void setCentralWidget(QWidget *centralWidget);
|
void setCentralWidget(QWidget *centralWidget);
|
||||||
@@ -69,7 +68,6 @@ public:
|
|||||||
QWidget *centralWidget() const;
|
QWidget *centralWidget() const;
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
|
||||||
|
|
||||||
using Callback = std::function<void()>;
|
using Callback = std::function<void()>;
|
||||||
void setAboutToActivateCallback(const Callback &cb);
|
void setAboutToActivateCallback(const Callback &cb);
|
||||||
@@ -104,7 +102,7 @@ private:
|
|||||||
QIcon icon;
|
QIcon icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
QByteArray m_id;
|
const QByteArray m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QByteArray m_parentPerspective;
|
QByteArray m_parentPerspective;
|
||||||
QVector<Operation> m_operations;
|
QVector<Operation> m_operations;
|
||||||
@@ -121,7 +119,7 @@ public:
|
|||||||
DebuggerMainWindow();
|
DebuggerMainWindow();
|
||||||
~DebuggerMainWindow() override;
|
~DebuggerMainWindow() override;
|
||||||
|
|
||||||
void registerPerspective(const QByteArray &perspectiveId, Perspective *perspective);
|
void registerPerspective(Perspective *perspective);
|
||||||
void destroyDynamicPerspective(Perspective *perspective);
|
void destroyDynamicPerspective(Perspective *perspective);
|
||||||
|
|
||||||
void resetCurrentPerspective();
|
void resetCurrentPerspective();
|
||||||
|
|||||||
@@ -1828,8 +1828,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
// qmlToolbar.addAction(qmlSelectDummyAction, Icons::SELECT_TOOLBAR.icon());
|
// qmlToolbar.addAction(qmlSelectDummyAction, Icons::SELECT_TOOLBAR.icon());
|
||||||
// qmlToolbar.addWidget(new StyledSeparator);
|
// qmlToolbar.addWidget(new StyledSeparator);
|
||||||
|
|
||||||
auto createBasePerspective = [this] {
|
auto perspective = new Perspective("Debugger", tr("Debugger"));
|
||||||
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);
|
||||||
@@ -1842,7 +1841,7 @@ 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->addWindow(m_registerWindow, Perspective::AddToTab, m_snapshotWindow, false);
|
||||||
|
|
||||||
perspective->addToolbarAction(m_visibleStartAction);
|
perspective->addToolbarAction(m_visibleStartAction);
|
||||||
perspective->addToolbarAction(ActionManager::command(Constants::STOP)->action(), Icons::DEBUG_EXIT_SMALL_TOOLBAR.icon());
|
perspective->addToolbarAction(ActionManager::command(Constants::STOP)->action(), Icons::DEBUG_EXIT_SMALL_TOOLBAR.icon());
|
||||||
@@ -1859,14 +1858,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
perspective->addToolbarWidget(m_threadLabel);
|
perspective->addToolbarWidget(m_threadLabel);
|
||||||
perspective->addToolbarWidget(m_threadBox);
|
perspective->addToolbarWidget(m_threadBox);
|
||||||
|
|
||||||
return perspective;
|
Debugger::registerPerspective(perspective);
|
||||||
};
|
|
||||||
|
|
||||||
Perspective *cppPerspective = createBasePerspective();
|
|
||||||
cppPerspective->setName(tr("Debugger"));
|
|
||||||
cppPerspective->addWindow(m_registerWindow, Perspective::AddToTab, m_snapshotWindow, false);
|
|
||||||
|
|
||||||
Debugger::registerPerspective(CppPerspectiveId, cppPerspective);
|
|
||||||
|
|
||||||
// Perspective *qmlPerspective = createBasePerspective();
|
// Perspective *qmlPerspective = createBasePerspective();
|
||||||
// qmlPerspective->setName(tr("QML Debugger"));
|
// qmlPerspective->setName(tr("QML Debugger"));
|
||||||
@@ -3510,9 +3502,9 @@ QAction *createStopAction()
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerPerspective(const QByteArray &perspectiveId, Perspective *perspective)
|
void registerPerspective(Perspective *perspective)
|
||||||
{
|
{
|
||||||
dd->m_mainWindow->registerPerspective(perspectiveId, perspective);
|
dd->m_mainWindow->registerPerspective(perspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
|
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
|
|
||||||
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
new QmlProfilerStateWidget(m_profilerState, m_profilerModelManager, m_traceView);
|
||||||
|
|
||||||
m_perspective = new Utils::Perspective;
|
m_perspective = new Utils::Perspective(Constants::QmlProfilerPerspectiveId, 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,
|
||||||
@@ -95,7 +94,7 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
|||||||
m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchor);
|
m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchor);
|
||||||
m_perspective->addWindow(anchor, Perspective::Raise, nullptr);
|
m_perspective->addWindow(anchor, Perspective::Raise, nullptr);
|
||||||
|
|
||||||
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, m_perspective);
|
Debugger::registerPerspective(m_perspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerViewManager::~QmlProfilerViewManager()
|
QmlProfilerViewManager::~QmlProfilerViewManager()
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ CallgrindTool::CallgrindTool()
|
|||||||
this, &CallgrindTool::setCostEvent);
|
this, &CallgrindTool::setCostEvent);
|
||||||
updateEventCombo();
|
updateEventCombo();
|
||||||
|
|
||||||
auto perspective = new Perspective(tr("Callgrind"));
|
auto perspective = new Perspective(CallgrindPerspectiveId, tr("Callgrind"));
|
||||||
perspective->addToolbarAction(m_startAction);
|
perspective->addToolbarAction(m_startAction);
|
||||||
perspective->addToolbarAction(m_stopAction);
|
perspective->addToolbarAction(m_stopAction);
|
||||||
perspective->addToolbarAction(m_loadExternalLogFile);
|
perspective->addToolbarAction(m_loadExternalLogFile);
|
||||||
@@ -510,7 +510,7 @@ CallgrindTool::CallgrindTool()
|
|||||||
perspective->addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView);
|
perspective->addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView);
|
||||||
perspective->addWindow(m_visualization, Perspective::SplitVertical, nullptr,
|
perspective->addWindow(m_visualization, Perspective::SplitVertical, nullptr,
|
||||||
false, Qt::RightDockWidgetArea);
|
false, Qt::RightDockWidgetArea);
|
||||||
Debugger::registerPerspective(CallgrindPerspectiveId, perspective);
|
Debugger::registerPerspective(perspective);
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
||||||
this, &CallgrindTool::updateRunActions);
|
this, &CallgrindTool::updateRunActions);
|
||||||
|
|||||||
@@ -556,7 +556,7 @@ MemcheckTool::MemcheckTool()
|
|||||||
m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView"));
|
m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView"));
|
||||||
m_errorView->setWindowTitle(tr("Memory Issues"));
|
m_errorView->setWindowTitle(tr("Memory Issues"));
|
||||||
|
|
||||||
auto perspective = new Perspective(tr("Memcheck"));
|
auto perspective = new Perspective(MemcheckPerspectiveId, tr("Memcheck"));
|
||||||
perspective->addWindow(m_errorView, Perspective::SplitVertical, nullptr);
|
perspective->addWindow(m_errorView, Perspective::SplitVertical, nullptr);
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
||||||
@@ -690,7 +690,7 @@ MemcheckTool::MemcheckTool()
|
|||||||
perspective->addToolbarAction(m_goBack);
|
perspective->addToolbarAction(m_goBack);
|
||||||
perspective->addToolbarAction(m_goNext);
|
perspective->addToolbarAction(m_goNext);
|
||||||
perspective->addToolbarWidget(filterButton);
|
perspective->addToolbarWidget(filterButton);
|
||||||
Debugger::registerPerspective(MemcheckPerspectiveId, perspective);
|
Debugger::registerPerspective(perspective);
|
||||||
|
|
||||||
updateFromSettings();
|
updateFromSettings();
|
||||||
maybeActiveRunConfigurationChanged();
|
maybeActiveRunConfigurationChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user