diff options
author | hjk <hjk@qt.io> | 2018-08-21 12:30:00 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-08-21 15:38:22 +0000 |
commit | 32d2a4c985061098700cff53054e0fe0aea30e69 (patch) | |
tree | c1f089ee860288ca80e445979022190f03dd7ff9 | |
parent | df4bfed60b5258c975d8be9f7e3e13925699c9ef (diff) | |
download | qt-creator-32d2a4c985061098700cff53054e0fe0aea30e69.tar.gz |
Shift perspective ownership to plugins
Change-Id: Id146ca771b4dc92f35cf156efbabae154f2d940f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/plugins/clangtools/clangtidyclazytool.cpp | 19 | ||||
-rw-r--r-- | src/plugins/clangtools/clangtidyclazytool.h | 4 | ||||
-rw-r--r-- | src/plugins/debugger/analyzer/analyzermanager.h | 4 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerengine.cpp | 3 | ||||
-rw-r--r-- | src/plugins/debugger/debuggermainwindow.cpp | 77 | ||||
-rw-r--r-- | src/plugins/debugger/debuggermainwindow.h | 32 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 51 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/valgrind/callgrindtool.cpp | 44 | ||||
-rw-r--r-- | src/plugins/valgrind/memchecktool.cpp | 17 |
10 files changed, 122 insertions, 131 deletions
diff --git a/src/plugins/clangtools/clangtidyclazytool.cpp b/src/plugins/clangtools/clangtidyclazytool.cpp index a5f28b9e49..a58cb6f1d4 100644 --- a/src/plugins/clangtools/clangtidyclazytool.cpp +++ b/src/plugins/clangtools/clangtidyclazytool.cpp @@ -269,8 +269,7 @@ ClangTidyClazyTool::ClangTidyClazyTool() const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the " "Clang project to search for errors and warnings."); - auto perspective = new Perspective(ClangTidyClazyPerspectiveId, tr("Clang-Tidy and Clazy")); - perspective->addWindow(m_diagnosticView, Perspective::SplitVertical, nullptr); + m_perspective.addWindow(m_diagnosticView, Perspective::SplitVertical, nullptr); action = new QAction(tr("Clang-Tidy and Clazy..."), this); action->setToolTip(toolTip); @@ -282,14 +281,12 @@ ClangTidyClazyTool::ClangTidyClazyTool() action->setEnabled(m_startAction->isEnabled()); }); - perspective->addToolBarAction(m_startAction); - perspective->addToolBarAction(m_stopAction); - perspective->addToolBarAction(m_goBack); - perspective->addToolBarAction(m_goNext); - perspective->addToolBarWidget(m_filterLineEdit); - perspective->addToolBarWidget(m_applyFixitsButton); - - Debugger::registerPerspective(perspective); + m_perspective.addToolBarAction(m_startAction); + m_perspective.addToolBarAction(m_stopAction); + m_perspective.addToolBarAction(m_goBack); + m_perspective.addToolBarAction(m_goNext); + m_perspective.addToolBarWidget(m_filterLineEdit); + m_perspective.addToolBarWidget(m_applyFixitsButton); updateRunActions(); @@ -355,7 +352,7 @@ void ClangTidyClazyTool::startTool(bool askUserForFileSelection) emit finished(success); }); - Debugger::selectPerspective(ClangTidyClazyPerspectiveId); + m_perspective.select(); m_diagnosticModel->clear(); setToolBusy(true); diff --git a/src/plugins/clangtools/clangtidyclazytool.h b/src/plugins/clangtools/clangtidyclazytool.h index 2391afbe3a..eb6430ab94 100644 --- a/src/plugins/clangtools/clangtidyclazytool.h +++ b/src/plugins/clangtools/clangtidyclazytool.h @@ -27,6 +27,8 @@ #include "clangtool.h" +#include <debugger/debuggermainwindow.h> + QT_BEGIN_NAMESPACE class QToolButton; QT_END_NAMESPACE @@ -67,6 +69,8 @@ private: QAction *m_goBack = nullptr; QAction *m_goNext = nullptr; + + Utils::Perspective m_perspective{ClangTidyClazyPerspectiveId, tr("Clang-Tidy and Clazy")}; }; } // namespace Internal diff --git a/src/plugins/debugger/analyzer/analyzermanager.h b/src/plugins/debugger/analyzer/analyzermanager.h index ebdaced8b0..d71cc4f930 100644 --- a/src/plugins/debugger/analyzer/analyzermanager.h +++ b/src/plugins/debugger/analyzer/analyzermanager.h @@ -60,11 +60,7 @@ enum ToolMode { DEBUGGER_EXPORT bool wantRunTool(ToolMode toolMode, const QString &toolName); DEBUGGER_EXPORT void showCannotStartDialog(const QString &toolName); -// Register a tool for a given start mode. -DEBUGGER_EXPORT void registerPerspective(Utils::Perspective *perspective); - DEBUGGER_EXPORT void enableMainWindow(bool on); -DEBUGGER_EXPORT QWidget *mainWindow(); DEBUGGER_EXPORT void selectPerspective(const QByteArray &perspectiveId); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 3717e502fd..20d3a71f52 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -330,7 +330,7 @@ public: DebuggerToolTipManager::deregisterEngine(m_engine); m_memoryAgents.handleDebuggerFinished(); - m_perspective->destroy(); + delete m_perspective; m_perspective = nullptr; setBusyCursor(false); @@ -787,7 +787,6 @@ void DebuggerEnginePrivate::setupViews() m_perspective->addWindow(m_registerWindow, Perspective::AddToTab, m_watchersWindow, true, Qt::RightDockWidgetArea); m_perspective->addWindow(m_logWindow, Perspective::AddToTab, nullptr, false, Qt::TopDockWidgetArea); - Debugger::registerPerspective(m_perspective); m_perspective->select(); } diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index ed950d4ca2..92b28cd448 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -158,7 +158,6 @@ class DebuggerMainWindowPrivate : public QObject { public: DebuggerMainWindowPrivate(DebuggerMainWindow *parent); - ~DebuggerMainWindowPrivate(); void ensureToolBarDockExists(); @@ -205,8 +204,6 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) DebuggerMainWindow::DebuggerMainWindow() : d(new DebuggerMainWindowPrivate(this)) { - theMainWindow = this; - setDockNestingEnabled(true); setDockActionsVisible(false); setDocumentMode(true); @@ -242,21 +239,20 @@ DebuggerMainWindow::DebuggerMainWindow() DebuggerMainWindow::~DebuggerMainWindow() { + d->savePerspectiveHelper(d->m_currentPerspective); delete d; - theMainWindow = nullptr; } -DebuggerMainWindowPrivate::~DebuggerMainWindowPrivate() +void DebuggerMainWindow::ensureMainWindowExists() { - savePerspectiveHelper(m_currentPerspective); - - delete m_editorPlaceHolder; - m_editorPlaceHolder = nullptr; + if (!theMainWindow) + theMainWindow = new DebuggerMainWindow; } -void DebuggerMainWindow::registerPerspective(Perspective *perspective) +void DebuggerMainWindow::doShutdown() { - d->registerPerspective(perspective); + delete theMainWindow; + theMainWindow = nullptr; } void DebuggerMainWindowPrivate::registerPerspective(Perspective *perspective) @@ -291,43 +287,53 @@ void DebuggerMainWindowPrivate::destroyPerspective(Perspective *perspective) // Dynamic perspectives are currently not visible in the chooser. // This might change in the future, make sure we notice. const int idx = indexInChooser(perspective); - QTC_ASSERT(idx == -1, m_perspectiveChooser->removeItem(idx)); - - // All dynamic perspectives currently have a static parent perspective. - // This might change in the future, make sure we notice. - QTC_CHECK(!perspective->d->m_parentPerspective.isEmpty()); - restorePerspective(findPerspective(perspective->d->m_parentPerspective)); + if (idx != -1) + m_perspectiveChooser->removeItem(idx); + + if (perspective == m_currentPerspective) { + m_currentPerspective = nullptr; + if (!perspective->d->m_parentPerspective.isEmpty()) { + if (Perspective *parent = findPerspective(perspective->d->m_parentPerspective)) + parent->select(); + } + } } void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS) { - d->m_statusLabel->showStatusMessage(message, timeoutMS); + if (theMainWindow) + theMainWindow->d->m_statusLabel->showStatusMessage(message, timeoutMS); } void DebuggerMainWindow::onModeChanged(Core::Id mode) { if (mode == Debugger::Constants::MODE_DEBUG) { - setDockActionsVisible(true); - d->restorePerspective(nullptr); + theMainWindow->setDockActionsVisible(true); + theMainWindow->d->restorePerspective(nullptr); } else { - setDockActionsVisible(false); + theMainWindow->setDockActionsVisible(false); // Hide dock widgets manually in case they are floating. - foreach (QDockWidget *dockWidget, dockWidgets()) { + foreach (QDockWidget *dockWidget, theMainWindow->dockWidgets()) { if (dockWidget->isFloating()) dockWidget->hide(); } } } -Perspective *DebuggerMainWindow::findPerspective(const QByteArray &perspectiveId) const +Perspective *DebuggerMainWindow::findPerspective(const QByteArray &perspectiveId) { - return d->findPerspective(perspectiveId); + return theMainWindow ? theMainWindow->d->findPerspective(perspectiveId) : nullptr; } QWidget *DebuggerMainWindow::centralWidgetStack() { - return d->m_centralWidgetStack; + return theMainWindow ? theMainWindow->d->m_centralWidgetStack : nullptr; +} + +DebuggerMainWindow *DebuggerMainWindow::instance() +{ + return theMainWindow; } Perspective *DebuggerMainWindowPrivate::findPerspective(const QByteArray &perspectiveId) const @@ -410,7 +416,7 @@ void DebuggerMainWindowPrivate::ensureToolBarDockExists() }); } -QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow) +QWidget *createModeWindow(const Core::Id &mode) { auto editorHolderLayout = new QVBoxLayout; editorHolderLayout->setMargin(0); @@ -418,7 +424,7 @@ QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow) auto editorAndFindWidget = new QWidget; editorAndFindWidget->setLayout(editorHolderLayout); - editorHolderLayout->addWidget(mainWindow->centralWidgetStack()); + editorHolderLayout->addWidget(theMainWindow->centralWidgetStack()); editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget)); auto documentAndRightPane = new MiniSplitter; @@ -438,7 +444,7 @@ QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow) // Right-side window with editor, output etc. auto mainWindowSplitter = new MiniSplitter; - mainWindowSplitter->addWidget(mainWindow); + mainWindowSplitter->addWidget(theMainWindow); mainWindowSplitter->addWidget(new OutputPanePlaceHolder(mode, mainWindowSplitter)); auto outputPane = new OutputPanePlaceHolder(mode, mainWindowSplitter); outputPane->setObjectName(QLatin1String("DebuggerOutputPanePlaceHolder")); @@ -449,13 +455,13 @@ QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow) // Navigation and right-side window. auto splitter = new MiniSplitter; - splitter->setFocusProxy(mainWindow->centralWidgetStack()); + splitter->setFocusProxy(theMainWindow->centralWidgetStack()); splitter->addWidget(new NavigationWidgetPlaceHolder(mode, Side::Left)); splitter->addWidget(mainWindowSplitter); splitter->setStretchFactor(0, 0); splitter->setStretchFactor(1, 1); splitter->setObjectName(QLatin1String("DebugModeWidget")); - mainWindow->setCentralWidget(centralEditorWidget); + theMainWindow->setCentralWidget(centralEditorWidget); return splitter; } @@ -587,10 +593,15 @@ Perspective::Perspective(const QString &id, const QString &name) { d->m_id = id; d->m_name = name; + + DebuggerMainWindow::ensureMainWindowExists(); + theMainWindow->d->registerPerspective(this); } Perspective::~Perspective() { + if (theMainWindow) + theMainWindow->d->destroyPerspective(this); delete d; } @@ -628,6 +639,7 @@ void Perspective::setParentPerspective(const QByteArray &parentPerspective) void Perspective::setEnabled(bool enabled) { + QTC_ASSERT(theMainWindow, return); const int index = theMainWindow->d->indexInChooser(this); QTC_ASSERT(index != -1, return); auto model = qobject_cast<QStandardItemModel*>(theMainWindow->d->m_perspectiveChooser->model()); @@ -673,11 +685,6 @@ QWidget *Perspective::centralWidget() const return d->m_centralWidget; } -void Perspective::destroy() -{ - theMainWindow->d->destroyPerspective(this); -} - Perspective *Perspective::currentPerspective() { return theMainWindow ? theMainWindow->d->m_currentPerspective : nullptr; diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index 0721d5b5c5..b01caf1008 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -60,16 +60,14 @@ public: Qt::ToolButtonStyle m_toolButtonStyle = Qt::ToolButtonIconOnly; }; -class DEBUGGER_EXPORT Perspective : public QObject +class DEBUGGER_EXPORT Perspective { - Q_OBJECT - public: - enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise }; - explicit Perspective(const QString &id, const QString &name); ~Perspective(); + enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise }; + void setCentralWidget(QWidget *centralWidget); void addWindow(QWidget *widget, OperationType op, @@ -94,7 +92,6 @@ public: void setParentPerspective(const QByteArray &parentPerspective); void setEnabled(bool enabled); - void destroy(); void select(); static Perspective *currentPerspective(); @@ -104,6 +101,9 @@ public: void hideToolBar(); private: + Perspective(const Perspective &) = delete; + void operator=(const Perspective &) = delete; + friend class DebuggerMainWindow; friend class DebuggerMainWindowPrivate; class PerspectivePrivate *d = nullptr; @@ -114,17 +114,21 @@ class DEBUGGER_EXPORT DebuggerMainWindow : public FancyMainWindow Q_OBJECT public: - DebuggerMainWindow(); - ~DebuggerMainWindow() override; + static DebuggerMainWindow *instance(); + + static void ensureMainWindowExists(); + static void doShutdown(); - void registerPerspective(Perspective *perspective); - void showStatusMessage(const QString &message, int timeoutMS); - void onModeChanged(Core::Id mode); + static void showStatusMessage(const QString &message, int timeoutMS); + static void onModeChanged(Core::Id mode); - Perspective *findPerspective(const QByteArray &perspectiveId) const; - QWidget *centralWidgetStack(); + static Perspective *findPerspective(const QByteArray &perspectiveId); + static QWidget *centralWidgetStack(); private: + DebuggerMainWindow(); + ~DebuggerMainWindow() override; + void closeEvent(QCloseEvent *) final; friend class Perspective; @@ -132,6 +136,6 @@ private: class DebuggerMainWindowPrivate *d = nullptr; }; -DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow); +DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode); } // Utils diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 730bc0b780..37ff2df931 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -691,7 +691,6 @@ public: void updatePresetState(); public: - QPointer<DebuggerMainWindow> m_mainWindow; QPointer<QWidget> m_modeWindow; QPointer<DebugMode> m_mode; @@ -765,6 +764,7 @@ public: IContext m_debugModeContext; DebugInfoTaskHandler m_debugInfoTaskHandler; + Perspective m_perspective{Constants::PRESET_PERSPRECTIVE_ID, tr("Debugger")}; }; DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) @@ -971,8 +971,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::finishedInitialization, this, &DebuggerPluginPrivate::parseCommandLineArguments); - m_mainWindow = new DebuggerMainWindow; - // Menus m_menu = ActionManager::createMenu(M_DEBUG_ANALYZER); m_menu->menu()->setTitle(tr("&Analyze")); @@ -1304,7 +1302,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, // Debug mode setup m_mode = new DebugMode; - m_modeWindow = createModeWindow(Constants::MODE_DEBUG, m_mainWindow); + m_modeWindow = createModeWindow(Constants::MODE_DEBUG); m_mode->setWidget(m_modeWindow); m_debugModeContext.setContext(Context(CC::C_EDITORMANAGER)); @@ -1353,11 +1351,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, connect(action(SettingsDialog), &QAction::triggered, [] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); }); - auto perspective = new Perspective(Constants::PRESET_PERSPRECTIVE_ID, tr("Debugger")); - Debugger::registerPerspective(perspective); - - perspective->addToolBarWidget(EngineManager::engineChooser()); - perspective->addToolBarAction(&m_startAction); + m_perspective.addToolBarWidget(EngineManager::engineChooser()); + m_perspective.addToolBarAction(&m_startAction); // QAction *operateByInstructionAction = action(OperateByInstruction); // operateByInstructionAction->setText(tr("Start in Operate by Instruction mode")); @@ -1368,11 +1363,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, //// Icons::SINGLE_INSTRUCTION_MODE.icon()}; // Action m_enableReverseDebuggingAction{tr("Start with recording information to reverse step if possible"), // Icons::REVERSE_MODE.icon()} -// perspective->addToolbarAction(operateByInstructionAction); +// m_perspective.addToolbarAction(operateByInstructionAction); - perspective->addWindow(m_breakpointManagerWindow, Perspective::SplitVertical, nullptr); - perspective->addWindow(m_globalLogWindow, Perspective::SplitHorizontal, m_breakpointManagerWindow); - perspective->addWindow(m_engineManagerWindow, Perspective::AddToTab, m_globalLogWindow); + m_perspective.addWindow(m_breakpointManagerWindow, Perspective::SplitVertical, nullptr); + m_perspective.addWindow(m_globalLogWindow, Perspective::SplitHorizontal, m_breakpointManagerWindow); + m_perspective.addWindow(m_engineManagerWindow, Perspective::AddToTab, m_globalLogWindow); // connect(action(EnableReverseDebugging), &SavedAction::valueChanged, // this, &DebuggerPluginPrivate::enableReverseDebuggingTriggered); @@ -2210,6 +2205,8 @@ void DebuggerPluginPrivate::extensionsInitialized() RunControl::registerWorker<DebuggerRunTool> (ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint); + + DebuggerMainWindow::ensureMainWindowExists(); } SavedAction *action(int code) @@ -2292,9 +2289,9 @@ void showModuleSections(const QString &moduleName, const Sections §ions) void DebuggerPluginPrivate::doShutdown() { + DebuggerMainWindow::doShutdown(); + m_shutdownTimer.stop(); - delete m_mainWindow; - m_mainWindow = nullptr; delete m_modeWindow; m_modeWindow = nullptr; @@ -2323,7 +2320,7 @@ void openTextEditor(const QString &titlePattern0, const QString &contents) QWidget *mainWindow() { - return dd->m_mainWindow; + return DebuggerMainWindow::instance(); } QSharedPointer<Internal::GlobalDebuggerOptions> globalDebuggerOptions() @@ -2416,14 +2413,14 @@ void DebuggerPlugin::extensionsInitialized() void DebuggerPluginPrivate::onModeChanged(Id mode) { - m_mainWindow->onModeChanged(mode); + DebuggerMainWindow::onModeChanged(mode); // FIXME: This one gets always called, even if switching between modes // different then the debugger mode. E.g. Welcome and Help mode and // also on shutdown. if (mode == MODE_DEBUG) { // if (EngineManager::engines().isEmpty()) -// m_mainWindow->restorePerspective(Constants::PRESET_PERSPRECTIVE_ID); +// DebuggerMainWindow::instance()->restorePerspective(Constants::PRESET_PERSPRECTIVE_ID); EngineManager::selectUiForCurrentEngine(); if (IEditor *editor = EditorManager::currentEditor()) editor->widget()->setFocus(); @@ -2551,35 +2548,25 @@ QAction *createStopAction() return action; } -void registerPerspective(Perspective *perspective) -{ - dd->m_mainWindow->registerPerspective(perspective); -} - void selectPerspective(const QByteArray &perspectiveId) { - if (auto perspective = dd->m_mainWindow->findPerspective(perspectiveId)) + if (auto perspective = DebuggerMainWindow::findPerspective(perspectiveId)) perspective->select(); } -QWidget *mainWindow() -{ - return dd->m_mainWindow; -} - void enableMainWindow(bool on) { - dd->m_mainWindow->setEnabled(on); + DebuggerMainWindow::instance()->setEnabled(on); } void showStatusMessage(const QString &message, int timeoutMS) { - dd->m_mainWindow->showStatusMessage(message, timeoutMS); + DebuggerMainWindow::showStatusMessage(message, timeoutMS); } void showPermanentStatusMessage(const QString &message) { - dd->m_mainWindow->showStatusMessage(message, -1); + DebuggerMainWindow::showStatusMessage(message, -1); } namespace Internal { diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp index 0692d80e9c..a5f07a63f2 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp @@ -93,8 +93,6 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent, } m_perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchorDock); m_perspective->addWindow(anchorDock, Perspective::Raise, nullptr); - - Debugger::registerPerspective(m_perspective); } QmlProfilerViewManager::~QmlProfilerViewManager() diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index a0dfbd96b6..0d87510ec2 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -215,6 +215,8 @@ public: QString m_toggleCollectFunction; bool m_toolBusy = false; + + Perspective m_perspective{CallgrindPerspectiveId, tr("Callgrind")}; }; CallgrindTool::CallgrindTool() @@ -419,18 +421,17 @@ CallgrindTool::CallgrindTool() this, &CallgrindTool::setCostEvent); updateEventCombo(); - auto perspective = new Perspective(CallgrindPerspectiveId, tr("Callgrind")); - perspective->addToolBarAction(m_startAction); - perspective->addToolBarAction(m_stopAction); - perspective->addToolBarAction(m_loadExternalLogFile); - perspective->addToolBarAction(m_dumpAction); - perspective->addToolBarAction(m_resetAction); - perspective->addToolBarAction(m_pauseAction); - perspective->addToolBarAction(m_discardAction); - perspective->addToolBarAction(m_goBack); - perspective->addToolBarAction(m_goNext); - perspective->addToolbarSeparator(); - perspective->addToolBarWidget(m_eventCombo); + m_perspective.addToolBarAction(m_startAction); + m_perspective.addToolBarAction(m_stopAction); + m_perspective.addToolBarAction(m_loadExternalLogFile); + m_perspective.addToolBarAction(m_dumpAction); + m_perspective.addToolBarAction(m_resetAction); + m_perspective.addToolBarAction(m_pauseAction); + m_perspective.addToolBarAction(m_discardAction); + m_perspective.addToolBarAction(m_goBack); + m_perspective.addToolBarAction(m_goNext); + m_perspective.addToolbarSeparator(); + m_perspective.addToolBarWidget(m_eventCombo); // Cost formatting { @@ -463,7 +464,7 @@ CallgrindTool::CallgrindTool() button->setPopupMode(QToolButton::InstantPopup); button->setText(QLatin1String("$")); button->setToolTip(tr("Cost Format")); - perspective->addToolBarWidget(button); + m_perspective.addToolBarWidget(button); } ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings(); @@ -500,17 +501,16 @@ CallgrindTool::CallgrindTool() setCostFormat(settings->costFormat()); enableCycleDetection(settings->detectCycles()); - perspective->addToolBarAction(m_cycleDetection); - perspective->addToolBarAction(m_shortenTemplates); - perspective->addToolBarAction(m_filterProjectCosts); - perspective->addToolBarWidget(m_searchFilter); + m_perspective.addToolBarAction(m_cycleDetection); + m_perspective.addToolBarAction(m_shortenTemplates); + m_perspective.addToolBarAction(m_filterProjectCosts); + m_perspective.addToolBarWidget(m_searchFilter); - perspective->addWindow(m_flatView, Perspective::SplitVertical, nullptr); - perspective->addWindow(m_calleesView, Perspective::SplitVertical, nullptr); - perspective->addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView); - perspective->addWindow(m_visualization, Perspective::SplitVertical, nullptr, + m_perspective.addWindow(m_flatView, Perspective::SplitVertical, nullptr); + m_perspective.addWindow(m_calleesView, Perspective::SplitVertical, nullptr); + m_perspective.addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView); + m_perspective.addWindow(m_visualization, Perspective::SplitVertical, nullptr, false, Qt::RightDockWidgetArea); - Debugger::registerPerspective(perspective); connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, this, &CallgrindTool::updateRunActions); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index b42090f3ef..19cb8ff72a 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -440,6 +440,7 @@ private: bool m_toolBusy = false; QString m_exitMsg; + Perspective m_perspective{MemcheckPerspectiveId, tr("Memcheck")}; }; #ifdef Q_OS_WIN @@ -556,8 +557,7 @@ MemcheckTool::MemcheckTool() m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView")); m_errorView->setWindowTitle(tr("Memory Issues")); - auto perspective = new Perspective(MemcheckPerspectiveId, tr("Memcheck")); - perspective->addWindow(m_errorView, Perspective::SplitVertical, nullptr); + m_perspective.addWindow(m_errorView, Perspective::SplitVertical, nullptr); connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, this, &MemcheckTool::maybeActiveRunConfigurationChanged); @@ -683,14 +683,13 @@ MemcheckTool::MemcheckTool() ProjectExplorerPlugin::startRunControl(rc); }); - perspective->addToolBarAction(m_startAction); + m_perspective.addToolBarAction(m_startAction); //toolbar.addAction(m_startWithGdbAction); - perspective->addToolBarAction(m_stopAction); - perspective->addToolBarAction(m_loadExternalLogFile); - perspective->addToolBarAction(m_goBack); - perspective->addToolBarAction(m_goNext); - perspective->addToolBarWidget(filterButton); - Debugger::registerPerspective(perspective); + m_perspective.addToolBarAction(m_stopAction); + m_perspective.addToolBarAction(m_loadExternalLogFile); + m_perspective.addToolBarAction(m_goBack); + m_perspective.addToolBarAction(m_goNext); + m_perspective.addToolBarWidget(filterButton); updateFromSettings(); maybeActiveRunConfigurationChanged(); |