Debugger: Remove return value from AnalyzerManager::createDockWidget()

Change-Id: If6cd2a68f2f99a1977ded0f05a12790194143274
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2016-03-01 07:51:06 +01:00
parent 6492d16408
commit f3bd7412ef
20 changed files with 335 additions and 726 deletions

View File

@@ -126,7 +126,8 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString
addAutoReleasedObject(new ClangStaticAnalyzerRunControlFactory(m_analyzerTool)); addAutoReleasedObject(new ClangStaticAnalyzerRunControlFactory(m_analyzerTool));
addAutoReleasedObject(new ClangStaticAnalyzerOptionsPage); addAutoReleasedObject(new ClangStaticAnalyzerOptionsPage);
auto widgetCreator = [tool] { return tool->createWidgets(); }; AnalyzerManager::registerToolbar(ClangStaticAnalyzerPerspectiveId, tool->createWidgets());
auto runControlCreator = [tool](ProjectExplorer::RunConfiguration *runConfiguration, auto runControlCreator = [tool](ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id runMode) { Core::Id runMode) {
return tool->createRunControl(runConfiguration, runMode); return tool->createRunControl(runConfiguration, runMode);
@@ -135,24 +136,21 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString
const QString toolTip = tr("Clang Static Analyzer uses the analyzer from the clang project " const QString toolTip = tr("Clang Static Analyzer uses the analyzer from the clang project "
"to find bugs."); "to find bugs.");
Perspective perspective(ClangStaticAnalyzerPerspective); AnalyzerManager::registerPerspective(ClangStaticAnalyzerPerspectiveId, {
perspective.addDock(ClangStaticAnalyzerDock, Core::Id(), Perspective::SplitVertical); { ClangStaticAnalyzerDockId, Core::Id(), Perspective::SplitVertical }
AnalyzerManager::addPerspective(perspective); });
ActionDescription desc; ActionDescription desc;
desc.setText(tr("Clang Static Analyzer")); desc.setText(tr("Clang Static Analyzer"));
desc.setToolTip(toolTip); desc.setToolTip(toolTip);
desc.setEnabled(false);
desc.setRunMode(Constants::CLANGSTATICANALYZER_RUN_MODE); desc.setRunMode(Constants::CLANGSTATICANALYZER_RUN_MODE);
desc.setPerspectiveId(ClangStaticAnalyzerPerspective); desc.setPerspectiveId(ClangStaticAnalyzerPerspectiveId);
desc.setActionId(ClangStaticAnalyzerAction);
desc.setWidgetCreator(widgetCreator);
desc.setRunControlCreator(runControlCreator); desc.setRunControlCreator(runControlCreator);
desc.setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) { desc.setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
tool->startTool(rc); tool->startTool(rc);
}); });
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction(ClangStaticAnalyzerActionId, desc);
return true; return true;
} }

View File

@@ -104,7 +104,7 @@ QWidget *ClangStaticAnalyzerTool::createWidgets()
this, &ClangStaticAnalyzerTool::handleStateUpdate); this, &ClangStaticAnalyzerTool::handleStateUpdate);
} }
AnalyzerManager::createDockWidget(m_diagnosticView, ClangStaticAnalyzerDock); AnalyzerManager::registerDockWidget(ClangStaticAnalyzerDockId, m_diagnosticView);
// //
// Toolbar widget // Toolbar widget
@@ -291,7 +291,7 @@ void ClangStaticAnalyzerTool::handleStateUpdate()
message += tr("%n issues found (%1 suppressed).", 0, issuesFound) message += tr("%n issues found (%1 suppressed).", 0, issuesFound)
.arg(issuesFound - issuesVisible); .arg(issuesFound - issuesVisible);
} }
AnalyzerManager::showPermanentStatusMessage(ClangStaticAnalyzerPerspective, message); AnalyzerManager::showPermanentStatusMessage(ClangStaticAnalyzerPerspectiveId, message);
} }
} // namespace Internal } // namespace Internal

View File

@@ -38,11 +38,10 @@ class ClangStaticAnalyzerDiagnosticFilterModel;
class ClangStaticAnalyzerDiagnosticModel; class ClangStaticAnalyzerDiagnosticModel;
class ClangStaticAnalyzerDiagnosticView; class ClangStaticAnalyzerDiagnosticView;
class Diagnostic; class Diagnostic;
class DummyRunConfiguration;
const char ClangStaticAnalyzerPerspective[] = "ClangStaticAnalyzerPerspective"; const char ClangStaticAnalyzerPerspectiveId[] = "ClangStaticAnalyzer.Perspective";
const char ClangStaticAnalyzerAction[] = "ClangStaticAnalyzerAction"; const char ClangStaticAnalyzerActionId[] = "ClangStaticAnalyzer.Action";
const char ClangStaticAnalyzerDock[] = "ClangStaticAnalyzerDock"; const char ClangStaticAnalyzerDockId[] = "ClangStaticAnalyzer.Dock";
class ClangStaticAnalyzerTool : public QObject class ClangStaticAnalyzerTool : public QObject
{ {

View File

@@ -89,7 +89,7 @@ void ClangStaticAnalyzerUnitTests::testProject()
CppTools::Tests::ProjectOpenerAndCloser projectManager; CppTools::Tests::ProjectOpenerAndCloser projectManager;
const CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true); const CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true);
QVERIFY(projectInfo.isValid()); QVERIFY(projectInfo.isValid());
AnalyzerManager::selectAction(ClangStaticAnalyzerPerspective, /* alsoRunIt = */ true); AnalyzerManager::selectAction(ClangStaticAnalyzerPerspectiveId, /* alsoRunIt = */ true);
QSignalSpy waiter(m_analyzerTool, SIGNAL(finished(bool))); QSignalSpy waiter(m_analyzerTool, SIGNAL(finished(bool)));
QVERIFY(waiter.wait(30000)); QVERIFY(waiter.wait(30000));
const QList<QVariant> arguments = waiter.takeFirst(); const QList<QVariant> arguments = waiter.takeFirst();

View File

@@ -213,7 +213,7 @@ void ActionDescription::startTool() const
namespace Internal { namespace Internal {
const char LAST_ACTIVE_TOOL[] = "Analyzer.Plugin.LastActiveTool"; const char LAST_ACTIVE_ACTION[] = "Analyzer.Plugin.LastActiveTool";
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
@@ -253,9 +253,9 @@ public:
class AnalyzerManagerPrivate : public QObject class AnalyzerManagerPrivate : public QObject
{ {
Q_DECLARE_TR_FUNCTIONS(Analyzer::AnalyzerManager) Q_DECLARE_TR_FUNCTIONS(Analyzer::AnalyzerManager)
public: public:
AnalyzerManagerPrivate(AnalyzerManager *qq); AnalyzerManagerPrivate(AnalyzerManager *qq);
~AnalyzerManagerPrivate();
/** /**
* After calling this, a proper instance of IMode is initialized * After calling this, a proper instance of IMode is initialized
@@ -270,7 +270,7 @@ public:
bool showPromptDialog(const QString &title, const QString &text, bool showPromptDialog(const QString &title, const QString &text,
const QString &stopButtonText, const QString &cancelButtonText) const; const QString &stopButtonText, const QString &cancelButtonText) const;
void addAction(const ActionDescription &desc); void registerAction(Core::Id actionId, const ActionDescription &desc);
void selectSavedTool(); void selectSavedTool();
void selectAction(Id actionId); void selectAction(Id actionId);
void handleToolStarted(); void handleToolStarted();
@@ -278,8 +278,6 @@ public:
void modeChanged(IMode *mode); void modeChanged(IMode *mode);
void resetLayout(); void resetLayout();
void updateRunActions(); void updateRunActions();
const ActionDescription *findAction(Id actionId) const;
const Id currentPerspectiveId() const;
public: public:
AnalyzerManager *q; AnalyzerManager *q;
@@ -287,11 +285,10 @@ public:
bool m_isRunning = false; bool m_isRunning = false;
Core::Id m_currentActionId; Core::Id m_currentActionId;
QHash<Id, QAction *> m_actions; QHash<Id, QAction *> m_actions;
QList<ActionDescription> m_descriptions; QHash<Id, ActionDescription> m_descriptions;
QAction *m_startAction = 0; QAction *m_startAction = 0;
QAction *m_stopAction = 0; QAction *m_stopAction = 0;
ActionContainer *m_menu = 0; ActionContainer *m_menu = 0;
MainWindowBase *m_mainWindow; MainWindowBase *m_mainWindow;
}; };
@@ -311,10 +308,6 @@ AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
connect(pe, &ProjectExplorerPlugin::updateRunActions, this, &AnalyzerManagerPrivate::updateRunActions); connect(pe, &ProjectExplorerPlugin::updateRunActions, this, &AnalyzerManagerPrivate::updateRunActions);
} }
AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
{
}
void AnalyzerManagerPrivate::setupActions() void AnalyzerManagerPrivate::setupActions()
{ {
Command *command = 0; Command *command = 0;
@@ -337,8 +330,8 @@ void AnalyzerManagerPrivate::setupActions()
m_startAction->setIcon(Analyzer::Icons::ANALYZER_CONTROL_START.icon()); m_startAction->setIcon(Analyzer::Icons::ANALYZER_CONTROL_START.icon());
ActionManager::registerAction(m_startAction, "Analyzer.Start"); ActionManager::registerAction(m_startAction, "Analyzer.Start");
connect(m_startAction, &QAction::triggered, this, [this] { connect(m_startAction, &QAction::triggered, this, [this] {
if (const ActionDescription *act = findAction(m_currentActionId)) QTC_ASSERT(m_descriptions.contains(m_currentActionId), return);
act->startTool(); m_descriptions.value(m_currentActionId).startTool();
}); });
m_stopAction = new QAction(tr("Stop"), m_menu); m_stopAction = new QAction(tr("Stop"), m_menu);
@@ -417,11 +410,7 @@ static QToolButton *toolButton(QAction *action)
void AnalyzerManagerPrivate::createModeMainWindow() void AnalyzerManagerPrivate::createModeMainWindow()
{ {
m_mainWindow->setObjectName(QLatin1String("AnalyzerManagerMainWindow")); m_mainWindow->setObjectName(QLatin1String("AnalyzerManagerMainWindow"));
m_mainWindow->setSettingsName(QLatin1String("AnalyzerViewSettings_")); m_mainWindow->setLastSettingsName(QLatin1String(Internal::LAST_ACTIVE_ACTION));
m_mainWindow->setLastSettingsName(QLatin1String(Internal::LAST_ACTIVE_TOOL));
connect(m_mainWindow, &FancyMainWindow::resetLayout,
this, &AnalyzerManagerPrivate::resetLayout);
auto editorHolderLayout = new QVBoxLayout; auto editorHolderLayout = new QVBoxLayout;
editorHolderLayout->setMargin(0); editorHolderLayout->setMargin(0);
@@ -510,67 +499,43 @@ void AnalyzerManagerPrivate::selectSavedTool()
{ {
const QSettings *settings = ICore::settings(); const QSettings *settings = ICore::settings();
if (settings->contains(QLatin1String(Internal::LAST_ACTIVE_TOOL))) { if (settings->contains(QLatin1String(Internal::LAST_ACTIVE_ACTION))) {
const Id lastAction = Id::fromSetting(settings->value(QLatin1String(Internal::LAST_ACTIVE_TOOL))); const Id lastAction = Id::fromSetting(settings->value(QLatin1String(Internal::LAST_ACTIVE_ACTION)));
foreach (const ActionDescription &action, m_descriptions) { selectAction(lastAction);
if (action.perspectiveId() == lastAction) {
selectAction(action.actionId());
return;
}
}
} }
// fallback to first available tool // fallback to first available tool
if (!m_descriptions.isEmpty()) if (!m_descriptions.isEmpty())
selectAction(m_descriptions.first().actionId()); selectAction(m_descriptions.begin().key());
}
const ActionDescription *AnalyzerManagerPrivate::findAction(Id actionId) const
{
foreach (const ActionDescription &action, m_descriptions)
if (action.actionId() == actionId)
return &action;
return 0;
}
const Id AnalyzerManagerPrivate::currentPerspectiveId() const
{
const ActionDescription *action = findAction(m_currentActionId);
return action ? action->perspectiveId() : Core::Id();
} }
void AnalyzerManagerPrivate::selectAction(Id actionId) void AnalyzerManagerPrivate::selectAction(Id actionId)
{ {
const ActionDescription *desc = findAction(actionId); QTC_ASSERT(m_descriptions.contains(actionId), return);
QTC_ASSERT(desc, return);
if (m_currentActionId == actionId) if (m_currentActionId == actionId)
return; return;
// Clean up old tool.
Id currentPerspective = currentPerspectiveId();
m_mainWindow->closePerspective(currentPerspective);
// Now change the tool. // Now change the tool.
m_currentActionId = actionId; m_currentActionId = actionId;
ActionDescription desc = m_descriptions.value(actionId);
m_mainWindow->restorePerspective(desc->perspectiveId(), m_mainWindow->restorePerspective(desc.perspectiveId());
[desc] { return desc->createWidget(); },
true);
const int toolboxIndex = m_mainWindow->toolBox()->findText(desc->text()); const int toolboxIndex = m_mainWindow->toolBox()->findText(desc.text());
QTC_ASSERT(toolboxIndex >= 0, return); QTC_ASSERT(toolboxIndex >= 0, return);
m_mainWindow->toolBox()->setCurrentIndex(toolboxIndex); m_mainWindow->toolBox()->setCurrentIndex(toolboxIndex);
updateRunActions(); updateRunActions();
} }
void AnalyzerManagerPrivate::addAction(const ActionDescription &desc) void AnalyzerManagerPrivate::registerAction(Id actionId, const ActionDescription &desc)
{ {
delayedInit(); // Make sure that there is a valid IMode instance. delayedInit(); // Make sure that there is a valid IMode instance.
auto action = new QAction(this); auto action = new QAction(this);
action->setText(desc.text()); action->setText(desc.text());
action->setToolTip(desc.toolTip()); action->setToolTip(desc.toolTip());
m_actions[desc.actionId()] = action; m_actions.insert(actionId, action);
m_descriptions.insert(actionId, desc);
int index = -1; int index = -1;
if (desc.menuGroup() == Constants::G_ANALYZER_REMOTE_TOOLS) { if (desc.menuGroup() == Constants::G_ANALYZER_REMOTE_TOOLS) {
@@ -582,18 +547,16 @@ void AnalyzerManagerPrivate::addAction(const ActionDescription &desc)
} }
if (index >= 0) if (index >= 0)
m_mainWindow->toolBox()->insertItem(index, desc.text(), desc.actionId().toSetting()); m_mainWindow->toolBox()->insertItem(index, desc.text(), actionId.toSetting());
Id menuGroup = desc.menuGroup(); Id menuGroup = desc.menuGroup();
if (menuGroup.isValid()) { if (menuGroup.isValid()) {
Command *command = ActionManager::registerAction(action, desc.actionId()); Command *command = ActionManager::registerAction(action, actionId);
m_menu->addAction(command, menuGroup); m_menu->addAction(command, menuGroup);
} }
m_descriptions.append(desc); connect(action, &QAction::triggered, this, [this, desc, actionId] {
selectAction(actionId);
connect(action, &QAction::triggered, this, [this, desc] {
selectAction(desc.actionId());
desc.startTool(); desc.startTool();
}); });
} }
@@ -616,8 +579,8 @@ void AnalyzerManagerPrivate::updateRunActions()
bool enabled = false; bool enabled = false;
if (m_isRunning) if (m_isRunning)
disabledReason = tr("An analysis is still in progress."); disabledReason = tr("An analysis is still in progress.");
else if (const ActionDescription *current = findAction(m_currentActionId)) else if (m_currentActionId.isValid())
enabled = current->isRunnable(&disabledReason); enabled = m_descriptions.value(m_currentActionId).isRunnable(&disabledReason);
else else
disabledReason = tr("No analyzer tool selected."); disabledReason = tr("No analyzer tool selected.");
@@ -626,10 +589,8 @@ void AnalyzerManagerPrivate::updateRunActions()
m_mainWindow->toolBox()->setEnabled(!m_isRunning); m_mainWindow->toolBox()->setEnabled(!m_isRunning);
m_stopAction->setEnabled(m_isRunning); m_stopAction->setEnabled(m_isRunning);
foreach (const ActionDescription &desc, m_descriptions) { for (auto it = m_actions.begin(), end = m_actions.end(); it != end; ++it)
if (QAction *action = m_actions.value(desc.actionId())) it.value()->setEnabled(!m_isRunning && m_descriptions.value(it.key()).isRunnable());
action->setEnabled(!m_isRunning && desc.isRunnable());
}
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@@ -656,18 +617,18 @@ AnalyzerManager::~AnalyzerManager()
void AnalyzerManager::shutdown() void AnalyzerManager::shutdown()
{ {
d->m_mainWindow->savePerspective(d->currentPerspectiveId()); d->m_mainWindow->saveCurrentPerspective();
} }
void AnalyzerManager::addAction(const ActionDescription &desc) void AnalyzerManager::registerAction(Id actionId, const ActionDescription &desc)
{ {
d->addAction(desc); d->registerAction(actionId, desc);
} }
QDockWidget *AnalyzerManager::createDockWidget(QWidget *widget, Id dockId) void AnalyzerManager::registerDockWidget(Id dockId, QWidget *widget)
{ {
QTC_ASSERT(!widget->objectName().isEmpty(), return 0); QTC_ASSERT(!widget->objectName().isEmpty(), return);
QDockWidget *dockWidget = d->m_mainWindow->createDockWidget(widget, dockId); QDockWidget *dockWidget = d->m_mainWindow->registerDockWidget(dockId, widget);
QAction *toggleViewAction = dockWidget->toggleViewAction(); QAction *toggleViewAction = dockWidget->toggleViewAction();
toggleViewAction->setText(dockWidget->windowTitle()); toggleViewAction->setText(dockWidget->windowTitle());
@@ -678,29 +639,40 @@ QDockWidget *AnalyzerManager::createDockWidget(QWidget *widget, Id dockId)
ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS)); ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS));
viewsMenu->addAction(cmd); viewsMenu->addAction(cmd);
return dockWidget;
} }
void Perspective::addDock(Id dockId, Id existing, SplitType splitType, void AnalyzerManager::registerToolbar(Id toolbarId, QWidget *widget)
bool visibleByDefault, Qt::DockWidgetArea area)
{ {
m_docks.append(dockId); d->m_mainWindow->registerToolbar(toolbarId, widget);
m_splits.append({existing, dockId, splitType, visibleByDefault, area});
} }
void AnalyzerManager::addPerspective(const Perspective &perspective) Perspective::Split::Split(Id dockId, Id existing, Perspective::SplitType splitType, bool visibleByDefault, Qt::DockWidgetArea area)
: dockId(dockId), existing(existing), splitType(splitType), visibleByDefault(visibleByDefault), area(area)
{}
Perspective::Perspective(std::initializer_list<Perspective::Split> splits)
: m_splits(splits)
{ {
d->m_mainWindow->addPerspective(perspective); for (const Split &split : splits)
m_docks.append(split.dockId);
}
void Perspective::addSplit(const Split &split)
{
m_docks.append(split.dockId);
m_splits.append(split);
}
void AnalyzerManager::registerPerspective(Id perspectiveId, const Perspective &perspective)
{
d->m_mainWindow->registerPerspective(perspectiveId, perspective);
} }
void AnalyzerManager::selectAction(Id actionId, bool alsoRunIt) void AnalyzerManager::selectAction(Id actionId, bool alsoRunIt)
{ {
if (const ActionDescription *desc = d->findAction(actionId)) {
d->selectAction(actionId); d->selectAction(actionId);
if (alsoRunIt) if (alsoRunIt)
desc->startTool(); d->m_descriptions.value(actionId).startTool();
}
} }
void AnalyzerManager::enableMainWindow(bool on) void AnalyzerManager::enableMainWindow(bool on)
@@ -708,13 +680,6 @@ void AnalyzerManager::enableMainWindow(bool on)
d->m_mainWindow->setEnabled(on); d->m_mainWindow->setEnabled(on);
} }
void AnalyzerManagerPrivate::resetLayout()
{
d->m_mainWindow->restorePerspective(currentPerspectiveId(),
std::function<QWidget *()>(),
false);
}
void AnalyzerManager::showStatusMessage(Id perspective, const QString &message, int timeoutMS) void AnalyzerManager::showStatusMessage(Id perspective, const QString &message, int timeoutMS)
{ {
d->m_mainWindow->showStatusMessage(perspective, message, timeoutMS); d->m_mainWindow->showStatusMessage(perspective, message, timeoutMS);

View File

@@ -85,9 +85,6 @@ public:
Core::Id menuGroup() const { return m_menuGroup; } Core::Id menuGroup() const { return m_menuGroup; }
void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; } void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; }
Core::Id actionId() const { return m_actionId; }
void setActionId(Core::Id id) { m_actionId = id; }
Core::Id perspectiveId() const { return m_perspective; } Core::Id perspectiveId() const { return m_perspective; }
void setPerspectiveId(Core::Id id) { m_perspective = id; } void setPerspectiveId(Core::Id id) { m_perspective = id; }
void setToolMode(QFlags<ToolMode> mode) { m_toolMode = mode; } void setToolMode(QFlags<ToolMode> mode) { m_toolMode = mode; }
@@ -96,13 +93,6 @@ public:
void setRunMode(Core::Id mode) { m_runMode = mode; } void setRunMode(Core::Id mode) { m_runMode = mode; }
bool isRunnable(QString *reason = 0) const; bool isRunnable(QString *reason = 0) const;
/// Creates all widgets used by the tool.
/// Returns a control widget which will be shown in the status bar when
/// this tool is selected.
typedef std::function<QWidget *()> WidgetCreator;
QWidget *createWidget() const { return m_widgetCreator(); }
void setWidgetCreator(const WidgetCreator &creator) { m_widgetCreator = creator; }
/// Returns a new engine for the given start parameters. /// Returns a new engine for the given start parameters.
/// Called each time the tool is launched. /// Called each time the tool is launched.
typedef std::function<AnalyzerRunControl *(ProjectExplorer::RunConfiguration *runConfiguration, typedef std::function<AnalyzerRunControl *(ProjectExplorer::RunConfiguration *runConfiguration,
@@ -126,19 +116,13 @@ public:
QString text() const { return m_text; } QString text() const { return m_text; }
void setText(const QString &text) { m_text = text; } void setText(const QString &text) { m_text = text; }
bool enabled() const { return m_enabled; }
void setEnabled(bool enabled) { m_enabled = enabled; }
private: private:
bool m_enabled = false;
QString m_text; QString m_text;
QString m_toolTip; QString m_toolTip;
Core::Id m_menuGroup; Core::Id m_menuGroup;
Core::Id m_actionId;
Core::Id m_perspective; Core::Id m_perspective;
QFlags<ToolMode> m_toolMode = AnyMode; QFlags<ToolMode> m_toolMode = AnyMode;
Core::Id m_runMode; Core::Id m_runMode;
WidgetCreator m_widgetCreator;
RunControlCreator m_runControlCreator; RunControlCreator m_runControlCreator;
ToolStarter m_customToolStarter; ToolStarter m_customToolStarter;
ToolPreparer m_toolPreparer; ToolPreparer m_toolPreparer;
@@ -156,11 +140,10 @@ public:
static void shutdown(); static void shutdown();
// Register a tool for a given start mode. // Register a tool for a given start mode.
static void addAction(const ActionDescription &desc); static void registerAction(Core::Id actionId, const ActionDescription &desc);
static void addPerspective(const Perspective &perspective); static void registerPerspective(Core::Id perspectiveId, const Perspective &perspective);
static void registerDockWidget(Core::Id dockId, QWidget *widget);
// Dockwidgets are registered to the main window. static void registerToolbar(Core::Id toolbarId, QWidget *widget);
static QDockWidget *createDockWidget(QWidget *widget, Core::Id dockId);
static void enableMainWindow(bool on); static void enableMainWindow(bool on);

View File

@@ -201,10 +201,12 @@ enum DebuggerEngineType
enum DebuggerLanguage enum DebuggerLanguage
{ {
AnyLanguage = 0x0, NoLanguage = 0x0,
CppLanguage = 0x1, CppLanguage = 0x1,
QmlLanguage = 0x2 QmlLanguage = 0x2,
AnyLanguage = CppLanguage | QmlLanguage
}; };
Q_DECLARE_FLAGS(DebuggerLanguages, DebuggerLanguage) Q_DECLARE_FLAGS(DebuggerLanguages, DebuggerLanguage)
} // namespace Debugger } // namespace Debugger

View File

@@ -66,7 +66,6 @@ QIcon locationMarkIcon();
const CPlusPlus::Snapshot &cppCodeModelSnapshot(); const CPlusPlus::Snapshot &cppCodeModelSnapshot();
bool hasSnapshots(); bool hasSnapshots();
void openTextEditor(const QString &titlePattern, const QString &contents); void openTextEditor(const QString &titlePattern, const QString &contents);
bool isActiveDebugLanguage(int language);
// void runTest(const QString &fileName); // void runTest(const QString &fileName);
void showMessage(const QString &msg, int channel, int timeout = -1); void showMessage(const QString &msg, int channel, int timeout = -1);

View File

@@ -43,12 +43,15 @@ namespace Internal {
MainWindowBase::MainWindowBase() MainWindowBase::MainWindowBase()
{ {
m_controlsStackWidget = new QStackedWidget; m_controlsStackWidget = new QStackedWidget;
m_statusLabelsStackWidget= new QStackedWidget; m_statusLabelsStackWidget = new QStackedWidget;
m_toolBox = new QComboBox; m_toolBox = new QComboBox;
setDockNestingEnabled(true); setDockNestingEnabled(true);
setDockActionsVisible(false); setDockActionsVisible(false);
setDocumentMode(true); setDocumentMode(true);
connect(this, &FancyMainWindow::resetLayout,
this, &MainWindowBase::resetCurrentPerspective);
} }
MainWindowBase::~MainWindowBase() MainWindowBase::~MainWindowBase()
@@ -61,42 +64,52 @@ MainWindowBase::~MainWindowBase()
} }
} }
void MainWindowBase::addPerspective(const Perspective &perspective) void MainWindowBase::registerPerspective(Id perspectiveId, const Perspective &perspective)
{ {
m_perspectives.append(perspective); m_perspectiveForPerspectiveId.insert(perspectiveId, perspective);
}
void MainWindowBase::registerToolbar(Id perspectiveId, QWidget *widget)
{
m_toolbarForPerspectiveId.insert(perspectiveId, widget);
m_controlsStackWidget->addWidget(widget);
StatusLabel * const toolStatusLabel = new StatusLabel;
m_statusLabelForPerspectiveId[perspectiveId] = toolStatusLabel;
m_statusLabelsStackWidget->addWidget(toolStatusLabel);
} }
void MainWindowBase::showStatusMessage(Id perspective, const QString &message, int timeoutMS) void MainWindowBase::showStatusMessage(Id perspective, const QString &message, int timeoutMS)
{ {
StatusLabel *statusLabel = m_statusLabelForPerspective.value(perspective); StatusLabel *statusLabel = m_statusLabelForPerspectiveId.value(perspective);
QTC_ASSERT(statusLabel, return); QTC_ASSERT(statusLabel, return);
statusLabel->showStatusMessage(message, timeoutMS); statusLabel->showStatusMessage(message, timeoutMS);
} }
void MainWindowBase::restorePerspective(Id perspectiveId, void MainWindowBase::resetCurrentPerspective()
std::function<QWidget *()> creator,
bool fromStoredSettings)
{ {
if (!perspectiveId.isValid()) loadPerspectiveHelper(m_currentPerspectiveId, false);
return; }
if (!m_defaultSettings.contains(perspectiveId) && creator) { void MainWindowBase::restorePerspective(Id perspectiveId)
QWidget *widget = creator(); {
QTC_CHECK(widget); loadPerspectiveHelper(perspectiveId, true);
m_defaultSettings.insert(perspectiveId); }
QTC_CHECK(!m_controlsWidgetForPerspective.contains(perspectiveId));
m_controlsWidgetForPerspective[perspectiveId] = widget;
m_controlsStackWidget->addWidget(widget);
StatusLabel * const toolStatusLabel = new StatusLabel;
m_statusLabelForPerspective[perspectiveId] = toolStatusLabel;
m_statusLabelsStackWidget->addWidget(toolStatusLabel);
}
const Perspective *perspective = findPerspective(perspectiveId); void MainWindowBase::loadPerspectiveHelper(Id perspectiveId, bool fromStoredSettings)
QTC_ASSERT(perspective, return); {
QTC_ASSERT(perspectiveId.isValid(), return);
foreach (const Perspective::Split &split, perspective->splits()) { // Clean up old perspective.
closeCurrentPerspective();
m_currentPerspectiveId = perspectiveId;
QTC_ASSERT(m_perspectiveForPerspectiveId.contains(perspectiveId), return);
const auto splits = m_perspectiveForPerspectiveId.value(perspectiveId).splits();
for (const Perspective::Split &split : splits) {
QDockWidget *dock = m_dockForDockId.value(split.dockId); QDockWidget *dock = m_dockForDockId.value(split.dockId);
QTC_ASSERT(dock, continue);
addDockWidget(split.area, dock); addDockWidget(split.area, dock);
QDockWidget *existing = m_dockForDockId.value(split.existing); QDockWidget *existing = m_dockForDockId.value(split.existing);
if (!existing && split.area == Qt::BottomDockWidgetArea) if (!existing && split.area == Qt::BottomDockWidgetArea)
@@ -116,30 +129,30 @@ void MainWindowBase::restorePerspective(Id perspectiveId,
} }
if (!split.visibleByDefault) if (!split.visibleByDefault)
dock->hide(); dock->hide();
else
dock->show();
} }
if (fromStoredSettings) { if (fromStoredSettings) {
QSettings *settings = ICore::settings(); QSettings *settings = ICore::settings();
settings->beginGroup(m_settingsName + perspectiveId.toString()); settings->beginGroup(perspectiveId.toString());
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool()) if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
restoreSettings(settings); restoreSettings(settings);
settings->endGroup(); settings->endGroup();
} }
QTC_CHECK(m_controlsWidgetForPerspective.contains(perspectiveId)); QTC_CHECK(m_toolbarForPerspectiveId.contains(perspectiveId));
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetForPerspective.value(perspectiveId)); m_controlsStackWidget->setCurrentWidget(m_toolbarForPerspectiveId.value(perspectiveId));
m_statusLabelsStackWidget->setCurrentWidget(m_statusLabelForPerspective.value(perspectiveId)); m_statusLabelsStackWidget->setCurrentWidget(m_statusLabelForPerspectiveId.value(perspectiveId));
} }
void MainWindowBase::closePerspective(Id perspectiveId) void MainWindowBase::closeCurrentPerspective()
{ {
if (!perspectiveId.isValid()) if (!m_currentPerspectiveId.isValid())
return; return;
savePerspective(perspectiveId);
const Perspective *perspective = findPerspective(perspectiveId); saveCurrentPerspective();
QTC_ASSERT(perspective, return); foreach (QDockWidget *dockWidget, m_dockForDockId) {
foreach (Id dockId, perspective->docks()) {
QDockWidget *dockWidget = m_dockForDockId.value(dockId);
QTC_ASSERT(dockWidget, continue); QTC_ASSERT(dockWidget, continue);
removeDockWidget(dockWidget); removeDockWidget(dockWidget);
dockWidget->hide(); dockWidget->hide();
@@ -148,25 +161,19 @@ void MainWindowBase::closePerspective(Id perspectiveId)
} }
} }
const Perspective *MainWindowBase::findPerspective(Id perspectiveId) const void MainWindowBase::saveCurrentPerspective()
{
foreach (const Perspective &perspective, m_perspectives)
if (perspective.id() == perspectiveId)
return &perspective;
return 0;
}
void MainWindowBase::savePerspective(Id perspectiveId)
{ {
if (!m_currentPerspectiveId.isValid())
return;
QSettings *settings = ICore::settings(); QSettings *settings = ICore::settings();
settings->beginGroup(m_settingsName + perspectiveId.toString()); settings->beginGroup(m_currentPerspectiveId.toString());
saveSettings(settings); saveSettings(settings);
settings->setValue(QLatin1String("ToolSettingsSaved"), true); settings->setValue(QLatin1String("ToolSettingsSaved"), true);
settings->endGroup(); settings->endGroup();
settings->setValue(m_lastSettingsName, perspectiveId.toString()); settings->setValue(m_lastSettingsName, m_currentPerspectiveId.toString());
} }
QDockWidget *MainWindowBase::createDockWidget(QWidget *widget, Id dockId) QDockWidget *MainWindowBase::registerDockWidget(Id dockId, QWidget *widget)
{ {
QTC_ASSERT(!widget->objectName().isEmpty(), return 0); QTC_ASSERT(!widget->objectName().isEmpty(), return 0);
QDockWidget *dockWidget = addDockForWidget(widget); QDockWidget *dockWidget = addDockForWidget(widget);
@@ -175,14 +182,9 @@ QDockWidget *MainWindowBase::createDockWidget(QWidget *widget, Id dockId)
return dockWidget; return dockWidget;
} }
QString MainWindowBase::settingsName() const Core::Id MainWindowBase::currentPerspectiveId() const
{ {
return m_settingsName; return m_currentPerspectiveId;
}
void MainWindowBase::setSettingsName(const QString &settingsName)
{
m_settingsName = settingsName;
} }
QString MainWindowBase::lastSettingsName() const QString MainWindowBase::lastSettingsName() const

View File

@@ -38,6 +38,7 @@
#include <QSet> #include <QSet>
#include <functional> #include <functional>
#include <initializer_list>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QComboBox; class QComboBox;
@@ -51,33 +52,32 @@ class ANALYZER_EXPORT Perspective
public: public:
enum SplitType { SplitVertical, SplitHorizontal, AddToTab }; enum SplitType { SplitVertical, SplitHorizontal, AddToTab };
struct Split { class Split
{
public:
Split() = default; Split() = default;
Split(Core::Id e, Core::Id d, SplitType t, bool v, Qt::DockWidgetArea a) Split(Core::Id dockId, Core::Id existing, SplitType splitType,
: existing(e), dockId(d), splitType(t), visibleByDefault(v), area(a) bool visibleByDefault = true,
{} Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
Core::Id existing;
Core::Id dockId; Core::Id dockId;
Core::Id existing;
SplitType splitType; SplitType splitType;
bool visibleByDefault; bool visibleByDefault;
Qt::DockWidgetArea area; Qt::DockWidgetArea area;
}; };
typedef QVector<Split> Splits;
Perspective(Core::Id id = Core::Id()) : m_id(id) {} Perspective() = default;
Perspective(std::initializer_list<Split> splits);
Core::Id id() const { return m_id; } void addSplit(const Split &split);
void addDock(Core::Id dockId, Core::Id existing, SplitType splitType,
bool visibleByDefault = true,
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
Splits splits() const { return m_splits; } QVector<Split> splits() const { return m_splits; }
QList<Core::Id> docks() const { return m_docks; } QVector<Core::Id> docks() const { return m_docks; }
private: private:
Core::Id m_id; QVector<Core::Id> m_docks;
QList<Core::Id> m_docks; QVector<Split> m_splits;
Splits m_splits;
}; };
} // Analyzer } // Analyzer
@@ -95,8 +95,9 @@ const char DOCKWIDGET_STACK[] = "Debugger.Docks.Stack";
const char DOCKWIDGET_SOURCE_FILES[] = "Debugger.Docks.SourceFiles"; const char DOCKWIDGET_SOURCE_FILES[] = "Debugger.Docks.SourceFiles";
const char DOCKWIDGET_THREADS[] = "Debugger.Docks.Threads"; const char DOCKWIDGET_THREADS[] = "Debugger.Docks.Threads";
const char DOCKWIDGET_WATCHERS[] = "Debugger.Docks.LocalsAndWatchers"; const char DOCKWIDGET_WATCHERS[] = "Debugger.Docks.LocalsAndWatchers";
const char DOCKWIDGET_QML_INSPECTOR[] = "Debugger.Docks.QmlInspector";
const char DOCKWIDGET_DEFAULT_AREA[] = "Debugger.Docks.DefaultArea"; const char CppPerspectiveId[] = "Debugger.Perspective.Cpp";
const char QmlPerspectiveId[] = "Debugger.Perspective.Qml";
class MainWindowBase : public Utils::FancyMainWindow class MainWindowBase : public Utils::FancyMainWindow
{ {
@@ -110,35 +111,34 @@ public:
QStackedWidget *controlsStack() const { return m_controlsStackWidget; } QStackedWidget *controlsStack() const { return m_controlsStackWidget; }
QStackedWidget *statusLabelsStack() const { return m_statusLabelsStackWidget; } QStackedWidget *statusLabelsStack() const { return m_statusLabelsStackWidget; }
void addPerspective(const Analyzer::Perspective &perspective); void registerPerspective(Core::Id perspectiveId, const Analyzer::Perspective &perspective);
void registerToolbar(Core::Id perspectiveId, QWidget *widget);
QDockWidget *registerDockWidget(Core::Id dockId, QWidget *widget);
void saveCurrentPerspective();
void closeCurrentPerspective();
void resetCurrentPerspective();
void restorePerspective(Core::Id perspectiveId);
void showStatusMessage(Core::Id perspective, const QString &message, int timeoutMS); void showStatusMessage(Core::Id perspective, const QString &message, int timeoutMS);
const Analyzer::Perspective *findPerspective(Core::Id perspectiveId) const;
void restorePerspective(Core::Id perspectiveId,
std::function<QWidget *()> creator,
bool fromStoredSettings);
void savePerspective(Core::Id perspectiveId);
void closePerspective(Core::Id perspectiveId);
QString settingsName() const;
void setSettingsName(const QString &settingsName);
QString lastSettingsName() const; QString lastSettingsName() const;
void setLastSettingsName(const QString &lastSettingsName); void setLastSettingsName(const QString &lastSettingsName);
QDockWidget *createDockWidget(QWidget *widget, Core::Id dockId); Core::Id currentPerspectiveId() const;
private: private:
QString m_settingsName; void loadPerspectiveHelper(Core::Id perspectiveId, bool fromStoredSettings = true);
Core::Id m_currentPerspectiveId;
QString m_lastSettingsName; QString m_lastSettingsName;
QComboBox *m_toolBox; QComboBox *m_toolBox;
QStackedWidget *m_controlsStackWidget; QStackedWidget *m_controlsStackWidget;
QStackedWidget *m_statusLabelsStackWidget; QStackedWidget *m_statusLabelsStackWidget;
QHash<Core::Id, QDockWidget *> m_dockForDockId; QHash<Core::Id, QDockWidget *> m_dockForDockId;
QList<Analyzer::Perspective> m_perspectives; QHash<Core::Id, QWidget *> m_toolbarForPerspectiveId;
QHash<Core::Id, QWidget *> m_controlsWidgetForPerspective; QHash<Core::Id, Analyzer::Perspective> m_perspectiveForPerspectiveId;
QHash<Core::Id, Utils::StatusLabel *> m_statusLabelForPerspective; QHash<Core::Id, Utils::StatusLabel *> m_statusLabelForPerspectiveId;
QSet<Core::Id> m_defaultSettings;
// list of dock widgets to prevent memory leak // list of dock widgets to prevent memory leak
typedef QPointer<QDockWidget> DockPtr; typedef QPointer<QDockWidget> DockPtr;

View File

@@ -144,6 +144,7 @@
#include <QMenu> #include <QMenu>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QStackedWidget>
#include <QTextBlock> #include <QTextBlock>
#include <QToolButton> #include <QToolButton>
#include <QTreeWidget> #include <QTreeWidget>
@@ -579,14 +580,14 @@ static Kit *findUniversalCdbKit()
static DebuggerPluginPrivate *dd = 0; static DebuggerPluginPrivate *dd = 0;
class DockWidgetEventFilter : public QObject //class DockWidgetEventFilter : public QObject
{ //{
public: //public:
DockWidgetEventFilter() {} // DockWidgetEventFilter() {}
private: //private:
bool eventFilter(QObject *obj, QEvent *event) override; // bool eventFilter(QObject *obj, QEvent *event) override;
}; //};
/*! /*!
\class Debugger::Internal::DebuggerCore \class Debugger::Internal::DebuggerCore
@@ -633,7 +634,7 @@ public:
void writeSettings() void writeSettings()
{ {
m_debuggerSettings->writeSettings(); m_debuggerSettings->writeSettings();
writeWindowSettings(); // writeWindowSettings();
} }
void selectThread(int index) void selectThread(int index)
@@ -962,12 +963,8 @@ public slots:
void parseCommandLineArguments(); void parseCommandLineArguments();
public: public:
// Debugger toolbars are registered with this function.
void setToolBar(DebuggerLanguage language, QWidget *widget);
// Active languages to be debugged. // Active languages to be debugged.
DebuggerLanguages activeDebugLanguages() const; DebuggerLanguages activeDebugLanguages() const;
void setEngineDebugLanguages(DebuggerLanguages languages);
// Called when all dependent plugins have loaded. // Called when all dependent plugins have loaded.
void initialize(); void initialize();
@@ -975,57 +972,29 @@ public:
void onModeChangedHelper(Core::IMode *mode); void onModeChangedHelper(Core::IMode *mode);
// Dockwidgets are registered to the main window. // Dockwidgets are registered to the main window.
QDockWidget *createDockWidget(const DebuggerLanguage &language, QWidget *widget); QDockWidget *createDockWidget(Id dockId, QWidget *widget);
void addStagedMenuEntries();
QWidget *createContents(Core::IMode *mode); QWidget *createContents(Core::IMode *mode);
void readWindowSettings(); void readWindowSettings();
void writeWindowSettings() const; void writeWindowSettings() const;
void activateQmlCppLayout();
void activateCppLayout();
void createViewsMenuItems(); void createViewsMenuItems();
bool isQmlCppActive() const;
bool isQmlActive() const;
void setSimpleDockWidgetArrangement();
// Debuggable languages are registered with this function.
void addLanguage(DebuggerLanguage language, const Core::Context &context);
QDockWidget *dockWidget(const QString &objectName) const;
QWidget *mainWindow() const { return m_mainWindow; } QWidget *mainWindow() const { return m_mainWindow; }
void resetDebuggerLayout();
void updateUiForProject(ProjectExplorer::Project *project); void updateUiForProject(ProjectExplorer::Project *project);
void updateUiForTarget(ProjectExplorer::Target *target); void updateUiForTarget(ProjectExplorer::Target *target);
void updateUiForRunConfiguration(ProjectExplorer::RunConfiguration *rc); void updateUiForRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void updateUiForCurrentRunConfiguration();
void updateActiveLanguages(); void updateActiveLanguages();
void updateDockWidgetSettings();
public: public:
Utils::FancyMainWindow *m_mainWindow = 0; MainWindowBase *m_mainWindow = 0;
QHash<QString, QVariant> m_dockWidgetActiveStateCpp; // DockWidgetEventFilter m_resizeEventFilter;
QHash<QString, QVariant> m_dockWidgetActiveStateQmlCpp;
DockWidgetEventFilter m_resizeEventFilter;
QMap<DebuggerLanguage, QWidget *> m_toolBars;
DebuggerLanguages m_supportedLanguages = AnyLanguage;
QWidget *m_debugToolBar = 0;
QToolButton *m_viewButton = 0;
QHBoxLayout *m_debugToolBarLayout = 0;
QHash<DebuggerLanguage, Core::Context> m_contextsForLanguage; QHash<DebuggerLanguage, Core::Context> m_contextsForLanguage;
bool m_inDebugMode = false; bool m_inDebugMode = false;
bool m_changingUI = false;
DebuggerLanguages m_previousDebugLanguages = AnyLanguage;
DebuggerLanguages m_activeDebugLanguages = AnyLanguage;
DebuggerLanguages m_engineDebugLanguages = AnyLanguage;
Core::ActionContainer *m_viewsMenu = 0; Core::ActionContainer *m_viewsMenu = 0;
@@ -1033,7 +1002,6 @@ public:
ProjectExplorer::Target *m_previousTarget = 0; ProjectExplorer::Target *m_previousTarget = 0;
ProjectExplorer::RunConfiguration *m_previousRunConfiguration = 0; ProjectExplorer::RunConfiguration *m_previousRunConfiguration = 0;
Id m_previousMode; Id m_previousMode;
QVector<QPair<DebuggerRunParameters, Kit *>> m_scheduledStarts; QVector<QPair<DebuggerRunParameters, Kit *>> m_scheduledStarts;
@@ -1079,7 +1047,6 @@ public:
QIcon m_locationMarkIcon; QIcon m_locationMarkIcon;
QIcon m_resetIcon; QIcon m_resetIcon;
StatusLabel *m_statusLabel = 0;
QComboBox *m_threadBox = 0; QComboBox *m_threadBox = 0;
BaseTreeView *m_breakView = 0; BaseTreeView *m_breakView = 0;
@@ -1137,17 +1104,10 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin)
m_plugin = plugin; m_plugin = plugin;
m_debugToolBar = new QWidget; // m_toolBars.insert(CppLanguage, 0);
m_debugToolBarLayout = new QHBoxLayout(m_debugToolBar); // m_toolBars.insert(QmlLanguage, 0);
m_contextsForLanguage.insert(CppLanguage, Context(C_CPPDEBUGGER));
m_mainWindow = new Utils::FancyMainWindow; m_contextsForLanguage.insert(QmlLanguage, Context(C_QMLDEBUGGER));
m_debugToolBarLayout->setMargin(0);
m_debugToolBarLayout->setSpacing(0);
createViewsMenuItems();
addLanguage(AnyLanguage, Context());
addLanguage(CppLanguage, Context(C_CPPDEBUGGER));
addLanguage(QmlLanguage, Context(C_QMLDEBUGGER));
} }
DebuggerPluginPrivate::~DebuggerPluginPrivate() DebuggerPluginPrivate::~DebuggerPluginPrivate()
@@ -1310,7 +1270,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
connect(KitManager::instance(), &KitManager::kitsLoaded, connect(KitManager::instance(), &KitManager::kitsLoaded,
this, &DebuggerPluginPrivate::parseCommandLineArguments); this, &DebuggerPluginPrivate::parseCommandLineArguments);
m_mainWindow = new FancyMainWindow; m_mainWindow = new MainWindowBase;
m_mainWindow->setObjectName(QLatin1String("DebuggerMainWindow"));
createViewsMenuItems();
m_plugin->addAutoReleasedObject(debuggerConsole()); m_plugin->addAutoReleasedObject(debuggerConsole());
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO, TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO,
@@ -1836,8 +1800,6 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
engine->watchHandler()->resetWatchers(); engine->watchHandler()->resetWatchers();
m_localsView->hideProgressIndicator(); m_localsView->hideProgressIndicator();
setEngineDebugLanguages(engine->runParameters().languages);
} }
static void changeFontSize(QWidget *widget, qreal size) static void changeFontSize(QWidget *widget, qreal size)
@@ -2170,7 +2132,7 @@ void DebuggerPluginPrivate::onModeChangedHelper(IMode *mode)
// Hide all the debugger windows if mode is different. // Hide all the debugger windows if mode is different.
if (m_inDebugMode) { if (m_inDebugMode) {
readWindowSettings(); // readWindowSettings();
updateActiveLanguages(); updateActiveLanguages();
} else { } else {
// Hide dock widgets manually in case they are floating. // Hide dock widgets manually in case they are floating.
@@ -2250,7 +2212,7 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
showMessage(msg0, LogStatus); showMessage(msg0, LogStatus);
QString msg = msg0; QString msg = msg0;
msg.replace(QChar::LineFeed, QLatin1String("; ")); msg.replace(QChar::LineFeed, QLatin1String("; "));
m_statusLabel->showStatusMessage(msg, timeout); m_mainWindow->showStatusMessage(m_mainWindow->currentPerspectiveId(), msg, timeout);
} }
void DebuggerPluginPrivate::coreShutdown() void DebuggerPluginPrivate::coreShutdown()
@@ -2308,9 +2270,10 @@ void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int tim
} }
} }
void createNewDock(QWidget *widget) static void createNewDock(QWidget *widget)
{ {
QDockWidget *dockWidget = dd->createDockWidget(CppLanguage, widget); dd->createDockWidget(Core::Id::fromString(widget->objectName()), widget);
QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget->parentWidget());
dockWidget->setWindowTitle(widget->windowTitle()); dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable); dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
dockWidget->show(); dockWidget->show();
@@ -2456,8 +2419,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_busy = false; m_busy = false;
m_statusLabel = new StatusLabel;
m_logWindow = new LogWindow; m_logWindow = new LogWindow;
m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT)); m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT));
@@ -2599,25 +2560,23 @@ void DebuggerPluginPrivate::extensionsInitialized()
// Dock widgets // Dock widgets
QDockWidget *dock = 0; QDockWidget *dock = 0;
dock = createDockWidget(CppLanguage, m_modulesWindow); dock = createDockWidget(DOCKWIDGET_MODULES, m_modulesWindow);
connect(dock->toggleViewAction(), &QAction::toggled, connect(dock->toggleViewAction(), &QAction::toggled,
this, &DebuggerPluginPrivate::modulesDockToggled, Qt::QueuedConnection); this, &DebuggerPluginPrivate::modulesDockToggled, Qt::QueuedConnection);
dock = createDockWidget(CppLanguage, m_registerWindow); dock = createDockWidget(DOCKWIDGET_REGISTER, m_registerWindow);
connect(dock->toggleViewAction(), &QAction::toggled, connect(dock->toggleViewAction(), &QAction::toggled,
this, &DebuggerPluginPrivate::registerDockToggled, Qt::QueuedConnection); this, &DebuggerPluginPrivate::registerDockToggled, Qt::QueuedConnection);
dock = createDockWidget(CppLanguage, m_sourceFilesWindow); dock = createDockWidget(DOCKWIDGET_SOURCE_FILES, m_sourceFilesWindow);
connect(dock->toggleViewAction(), &QAction::toggled, connect(dock->toggleViewAction(), &QAction::toggled,
this, &DebuggerPluginPrivate::sourceFilesDockToggled, Qt::QueuedConnection); this, &DebuggerPluginPrivate::sourceFilesDockToggled, Qt::QueuedConnection);
dock = createDockWidget(AnyLanguage, m_logWindow); createDockWidget(DOCKWIDGET_OUTPUT, m_logWindow);
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::TopDockWidgetArea); createDockWidget(DOCKWIDGET_BREAK, m_breakWindow);
createDockWidget(DOCKWIDGET_SNAPSHOTS, m_snapshotWindow);
createDockWidget(CppLanguage, m_breakWindow); createDockWidget(DOCKWIDGET_STACK, m_stackWindow);
createDockWidget(CppLanguage, m_snapshotWindow); createDockWidget(DOCKWIDGET_THREADS, m_threadsWindow);
createDockWidget(CppLanguage, m_stackWindow);
createDockWidget(CppLanguage, m_threadsWindow);
m_localsAndExpressionsWindow = new LocalsAndExpressionsWindow( m_localsAndExpressionsWindow = new LocalsAndExpressionsWindow(
m_localsWindow, m_inspectorWindow, m_returnWindow, m_localsWindow, m_inspectorWindow, m_returnWindow,
@@ -2625,10 +2584,9 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_localsAndExpressionsWindow->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS)); m_localsAndExpressionsWindow->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS));
m_localsAndExpressionsWindow->setWindowTitle(m_localsWindow->windowTitle()); m_localsAndExpressionsWindow->setWindowTitle(m_localsWindow->windowTitle());
dock = createDockWidget(CppLanguage, m_localsAndExpressionsWindow); dock = createDockWidget(DOCKWIDGET_WATCHERS, m_localsAndExpressionsWindow);
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::RightDockWidgetArea);
addStagedMenuEntries(); m_mainWindow->addDockActionsToMenu(m_viewsMenu->menu());
m_plugin->addAutoReleasedObject(createDebuggerRunControlFactory(m_plugin)); m_plugin->addAutoReleasedObject(createDebuggerRunControlFactory(m_plugin));
@@ -2975,7 +2933,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); }); [] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); });
// Toolbar // Toolbar
QWidget *toolbarContainer = new QWidget; QWidget *toolbarContainer = new QWidget(mainWindow());
QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer); QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
hbox->setMargin(0); hbox->setMargin(0);
@@ -3004,8 +2962,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
hbox->addWidget(m_threadBox); hbox->addWidget(m_threadBox);
hbox->addSpacerItem(new QSpacerItem(4, 0)); hbox->addSpacerItem(new QSpacerItem(4, 0));
setToolBar(CppLanguage, toolbarContainer);
QWidget *qmlToolbar = new QWidget(mainWindow()); QWidget *qmlToolbar = new QWidget(mainWindow());
hbox = new QHBoxLayout(qmlToolbar); hbox = new QHBoxLayout(qmlToolbar);
hbox->setMargin(0); hbox->setMargin(0);
@@ -3017,9 +2973,32 @@ void DebuggerPluginPrivate::extensionsInitialized()
hbox->addWidget(toolButton(Constants::QML_SELECTTOOL)); hbox->addWidget(toolButton(Constants::QML_SELECTTOOL));
hbox->addWidget(toolButton(Constants::QML_ZOOMTOOL)); hbox->addWidget(toolButton(Constants::QML_ZOOMTOOL));
hbox->addWidget(new StyledSeparator); hbox->addWidget(new StyledSeparator);
setToolBar(QmlLanguage, qmlToolbar);
setToolBar(AnyLanguage, m_statusLabel); m_mainWindow->registerToolbar(CppPerspectiveId, toolbarContainer);
m_mainWindow->registerPerspective(CppPerspectiveId, {
{ DOCKWIDGET_STACK, Core::Id(), Perspective::SplitVertical },
{ DOCKWIDGET_BREAK, DOCKWIDGET_STACK, Perspective::SplitHorizontal },
{ DOCKWIDGET_MODULES, DOCKWIDGET_BREAK, Perspective::AddToTab },
{ DOCKWIDGET_SOURCE_FILES, DOCKWIDGET_MODULES, Perspective::AddToTab },
{ DOCKWIDGET_WATCHERS, Core::Id(), Perspective::AddToTab,
true, Qt::RightDockWidgetArea },
{ DOCKWIDGET_REGISTER, DOCKWIDGET_WATCHERS, Perspective::AddToTab,
true, Qt::RightDockWidgetArea },
{ DOCKWIDGET_OUTPUT, Core::Id(), Perspective::AddToTab,
false, Qt::TopDockWidgetArea }
});
m_mainWindow->registerToolbar(QmlPerspectiveId, toolbarContainer);
m_mainWindow->registerPerspective(QmlPerspectiveId, {
{ DOCKWIDGET_STACK, Core::Id(), Perspective::SplitVertical },
{ DOCKWIDGET_BREAK, DOCKWIDGET_STACK, Perspective::SplitHorizontal },
{ DOCKWIDGET_MODULES, DOCKWIDGET_BREAK, Perspective::AddToTab },
{ DOCKWIDGET_SOURCE_FILES, DOCKWIDGET_MODULES, Perspective::AddToTab },
{ DOCKWIDGET_WATCHERS, Core::Id(), Perspective::AddToTab,
true, Qt::RightDockWidgetArea },
{ DOCKWIDGET_OUTPUT, Core::Id(), Perspective::AddToTab,
false, Qt::TopDockWidgetArea }
});
connect(action(EnableReverseDebugging), &SavedAction::valueChanged, connect(action(EnableReverseDebugging), &SavedAction::valueChanged,
this, &DebuggerPluginPrivate::enableReverseDebuggingTriggered); this, &DebuggerPluginPrivate::enableReverseDebuggingTriggered);
@@ -3174,11 +3153,6 @@ void openTextEditor(const QString &titlePattern0, const QString &contents)
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
} }
bool isActiveDebugLanguage(int language)
{
return dd->activeDebugLanguages() & language;
}
// void runTest(const QString &fileName); // void runTest(const QString &fileName);
void showMessage(const QString &msg, int channel, int timeout) void showMessage(const QString &msg, int channel, int timeout)
{ {
@@ -3467,64 +3441,25 @@ void DebuggerPluginPrivate::updateUiForRunConfiguration(RunConfiguration *rc)
{ {
if (m_previousRunConfiguration) if (m_previousRunConfiguration)
disconnect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate, disconnect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate,
this, &DebuggerPluginPrivate::updateUiForCurrentRunConfiguration); this, &DebuggerPluginPrivate::updateActiveLanguages);
m_previousRunConfiguration = rc; m_previousRunConfiguration = rc;
updateUiForCurrentRunConfiguration();
if (!rc)
return;
connect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate,
this, &DebuggerPluginPrivate::updateUiForCurrentRunConfiguration);
}
void DebuggerPluginPrivate::updateUiForCurrentRunConfiguration()
{
updateActiveLanguages(); updateActiveLanguages();
if (m_previousRunConfiguration)
connect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate,
this, &DebuggerPluginPrivate::updateActiveLanguages);
} }
void DebuggerPluginPrivate::updateActiveLanguages() void DebuggerPluginPrivate::updateActiveLanguages()
{ {
DebuggerLanguages newLanguages = AnyLanguage; if (!(activeDebugLanguages() & QmlLanguage))
m_mainWindow->restorePerspective(CppPerspectiveId);
if (m_engineDebugLanguages != AnyLanguage) {
newLanguages = m_engineDebugLanguages;
} else if (m_previousRunConfiguration) {
if (m_previousRunConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useCppDebugger())
newLanguages |= CppLanguage;
if (m_previousRunConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useQmlDebugger())
newLanguages |= QmlLanguage;
}
if (newLanguages != m_activeDebugLanguages)
m_activeDebugLanguages = newLanguages;
if (m_changingUI || !m_inDebugMode)
return;
m_changingUI = true;
if (isQmlActive())
activateQmlCppLayout();
else else
activateCppLayout(); m_mainWindow->restorePerspective(QmlPerspectiveId);
m_previousDebugLanguages = m_activeDebugLanguages;
m_changingUI = false;
} }
DebuggerLanguages DebuggerPluginPrivate::activeDebugLanguages() const DebuggerLanguages DebuggerPluginPrivate::activeDebugLanguages() const
{ {
return m_activeDebugLanguages; return dd->m_currentEngine->runParameters().languages;
}
void DebuggerPluginPrivate::setEngineDebugLanguages(DebuggerLanguages languages)
{
if (m_engineDebugLanguages == languages)
return;
m_engineDebugLanguages = languages;
updateActiveLanguages();
} }
void DebuggerPluginPrivate::createViewsMenuItems() void DebuggerPluginPrivate::createViewsMenuItems()
@@ -3554,126 +3489,29 @@ void DebuggerPluginPrivate::createViewsMenuItems()
m_viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); m_viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
} }
void DebuggerPluginPrivate::addLanguage(DebuggerLanguage languageId,
const Context &context)
{
m_supportedLanguages = m_supportedLanguages | languageId;
m_toolBars.insert(languageId, 0);
m_contextsForLanguage.insert(languageId, context);
}
QDockWidget *DebuggerPluginPrivate::dockWidget(const QString &objectName) const
{
return findChild<QDockWidget *>(objectName);
}
void DebuggerPluginPrivate::activateQmlCppLayout()
{
Context qmlCppContext = m_contextsForLanguage.value(QmlLanguage);
qmlCppContext.add(m_contextsForLanguage.value(CppLanguage));
if (m_toolBars.value(QmlLanguage)) {
m_debugToolBarLayout->insertWidget(1, m_toolBars.value(QmlLanguage));
m_toolBars.value(QmlLanguage)->show();
}
if (m_previousDebugLanguages & QmlLanguage) {
m_dockWidgetActiveStateQmlCpp = m_mainWindow->saveSettings();
ICore::removeAdditionalContext(qmlCppContext);
} else if (m_previousDebugLanguages & CppLanguage) {
m_dockWidgetActiveStateCpp = m_mainWindow->saveSettings();
ICore::removeAdditionalContext(m_contextsForLanguage.value(CppLanguage));
}
m_mainWindow->restoreSettings(m_dockWidgetActiveStateQmlCpp);
ICore::addAdditionalContext(qmlCppContext);
}
void DebuggerPluginPrivate::activateCppLayout()
{
Context qmlCppContext = m_contextsForLanguage.value(QmlLanguage);
qmlCppContext.add(m_contextsForLanguage.value(CppLanguage));
if (m_toolBars.value(QmlLanguage)) {
m_toolBars.value(QmlLanguage)->hide();
m_debugToolBarLayout->removeWidget(m_toolBars.value(QmlLanguage));
}
if (m_previousDebugLanguages & QmlLanguage) {
m_dockWidgetActiveStateQmlCpp = m_mainWindow->saveSettings();
ICore::removeAdditionalContext(qmlCppContext);
} else if (m_previousDebugLanguages & CppLanguage) {
m_dockWidgetActiveStateCpp = m_mainWindow->saveSettings();
ICore::removeAdditionalContext(m_contextsForLanguage.value(CppLanguage));
}
m_mainWindow->restoreSettings(m_dockWidgetActiveStateCpp);
const Context &cppContext = m_contextsForLanguage.value(CppLanguage);
ICore::addAdditionalContext(cppContext);
}
void DebuggerPluginPrivate::setToolBar(DebuggerLanguage language, QWidget *widget)
{
Q_ASSERT(m_toolBars.contains(language));
m_toolBars[language] = widget;
if (language == CppLanguage)
m_debugToolBarLayout->addWidget(widget);
//Add widget at the end
if (language == AnyLanguage)
m_debugToolBarLayout->insertWidget(-1, widget, 10);
}
/*! /*!
Keep track of dock widgets so they can be shown/hidden for different languages Keep track of dock widgets so they can be shown/hidden for different languages
*/ */
QDockWidget *DebuggerPluginPrivate::createDockWidget(const DebuggerLanguage &language, QDockWidget *DebuggerPluginPrivate::createDockWidget(Core::Id dockId, QWidget *widget)
QWidget *widget)
{ {
QDockWidget *dockWidget = m_mainWindow->addDockForWidget(widget); m_mainWindow->registerDockWidget(dockId, widget);
dockWidget->setObjectName(widget->objectName());
m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
if (!(m_activeDebugLanguages & language)) QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget->parentWidget());
dockWidget->hide();
QAction *toggleViewAction = dockWidget->toggleViewAction(); QAction *toggleViewAction = dockWidget->toggleViewAction();
Command *cmd = ActionManager::registerAction(toggleViewAction, Command *cmd = ActionManager::registerAction(toggleViewAction,
Id("Debugger.").withSuffix(widget->objectName())); Id("Debugger.").withSuffix(widget->objectName()));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
dockWidget->installEventFilter(&m_resizeEventFilter); //dockWidget->installEventFilter(&m_resizeEventFilter);
connect(dockWidget->toggleViewAction(), &QAction::triggered,
this, &DebuggerPluginPrivate::updateDockWidgetSettings);
connect(dockWidget, &QDockWidget::topLevelChanged,
this, &DebuggerPluginPrivate::updateDockWidgetSettings);
connect(dockWidget, &QDockWidget::dockLocationChanged,
this, &DebuggerPluginPrivate::updateDockWidgetSettings);
return dockWidget; return dockWidget;
} }
void DebuggerPluginPrivate::addStagedMenuEntries()
{
m_mainWindow->addDockActionsToMenu(m_viewsMenu->menu());
}
QWidget *DebuggerPluginPrivate::createContents(IMode *mode) QWidget *DebuggerPluginPrivate::createContents(IMode *mode)
{ {
connect(SessionManager::instance(), &SessionManager::startupProjectChanged, connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
this, &DebuggerPluginPrivate::updateUiForProject); this, &DebuggerPluginPrivate::updateUiForProject);
m_viewsMenu = ActionManager::actionContainer(Id(Core::Constants::M_WINDOW_VIEWS));
QTC_ASSERT(m_viewsMenu, return 0);
//m_mainWindow = new Internal::DebuggerPluginPrivate(this);
m_mainWindow->setDocumentMode(true);
m_mainWindow->setDockNestingEnabled(true);
connect(m_mainWindow, &Utils::FancyMainWindow::resetLayout,
this, &DebuggerPluginPrivate::resetDebuggerLayout);
connect(m_mainWindow->autoHideTitleBarsAction(), &QAction::triggered,
this, &DebuggerPluginPrivate::updateDockWidgetSettings);
auto editorHolderLayout = new QVBoxLayout; auto editorHolderLayout = new QVBoxLayout;
editorHolderLayout->setMargin(0); editorHolderLayout->setMargin(0);
editorHolderLayout->setSpacing(0); editorHolderLayout->setSpacing(0);
@@ -3690,22 +3528,25 @@ QWidget *DebuggerPluginPrivate::createContents(IMode *mode)
documentAndRightPane->setStretchFactor(0, 1); documentAndRightPane->setStretchFactor(0, 1);
documentAndRightPane->setStretchFactor(1, 0); documentAndRightPane->setStretchFactor(1, 0);
m_viewButton = new QToolButton(); auto viewButton = new QToolButton();
m_viewButton->setText(tr("Views")); viewButton->setText(tr("Views"));
auto debugToolBar = new Utils::StyledBar; auto debugToolBar = new Utils::StyledBar;
debugToolBar->setProperty("topBorder", true); debugToolBar->setProperty("topBorder", true);
auto debugToolBarLayout = new QHBoxLayout(debugToolBar); auto debugToolBarLayout = new QHBoxLayout(debugToolBar);
debugToolBarLayout->setMargin(0); debugToolBarLayout->setMargin(0);
debugToolBarLayout->setSpacing(0); debugToolBarLayout->setSpacing(0);
debugToolBarLayout->addWidget(m_debugToolBar); // debugToolBarLayout->addWidget(m_mainWindow->toolBox());
debugToolBarLayout->addWidget(m_mainWindow->controlsStack());
debugToolBarLayout->addWidget(m_mainWindow->statusLabelsStack());
debugToolBarLayout->addWidget(new Utils::StyledSeparator); debugToolBarLayout->addWidget(new Utils::StyledSeparator);
debugToolBarLayout->addWidget(m_viewButton); debugToolBarLayout->addStretch();
debugToolBarLayout->addWidget(viewButton);
connect(m_viewButton, &QAbstractButton::clicked, [this] { connect(viewButton, &QAbstractButton::clicked, [this, viewButton] {
QMenu menu; QMenu menu;
m_mainWindow->addDockActionsToMenu(&menu); m_mainWindow->addDockActionsToMenu(&menu);
menu.exec(m_viewButton->mapToGlobal(QPoint())); menu.exec(viewButton->mapToGlobal(QPoint()));
}); });
auto dock = new QDockWidget(DebuggerPluginPrivate::tr("Debugger Toolbar")); auto dock = new QDockWidget(DebuggerPluginPrivate::tr("Debugger Toolbar"));
@@ -3750,181 +3591,18 @@ QWidget *DebuggerPluginPrivate::createContents(IMode *mode)
return splitter; return splitter;
} }
void DebuggerPluginPrivate::writeWindowSettings() const //bool DockWidgetEventFilter::eventFilter(QObject *obj, QEvent *event)
{ //{
QSettings *settings = ICore::settings(); // switch (event->type()) {
settings->beginGroup(QLatin1String("DebugMode.CppMode")); // case QEvent::Resize:
QHashIterator<QString, QVariant> it(m_dockWidgetActiveStateCpp); // case QEvent::ZOrderChange:
while (it.hasNext()) { // dd->updateDockWidgetSettings();
it.next(); // break;
settings->setValue(it.key(), it.value()); // default:
} // break;
settings->endGroup(); // }
// return QObject::eventFilter(obj, event);
settings->beginGroup(QLatin1String("DebugMode.CppQmlMode")); //}
it = QHashIterator<QString, QVariant>(m_dockWidgetActiveStateQmlCpp);
while (it.hasNext()) {
it.next();
settings->setValue(it.key(), it.value());
}
settings->endGroup();
}
void DebuggerPluginPrivate::readWindowSettings()
{
QSettings *settings = ICore::settings();
m_dockWidgetActiveStateCpp.clear();
m_dockWidgetActiveStateQmlCpp.clear();
settings->beginGroup(QLatin1String("DebugMode.CppMode"));
foreach (const QString &key, settings->childKeys())
m_dockWidgetActiveStateCpp.insert(key, settings->value(key));
settings->endGroup();
settings->beginGroup(QLatin1String("DebugMode.CppQmlMode"));
foreach (const QString &key, settings->childKeys())
m_dockWidgetActiveStateQmlCpp.insert(key, settings->value(key));
settings->endGroup();
// Reset initial settings when there are none yet.
if (m_dockWidgetActiveStateQmlCpp.isEmpty()) {
m_activeDebugLanguages = DebuggerLanguage(QmlLanguage|CppLanguage);
setSimpleDockWidgetArrangement();
m_dockWidgetActiveStateCpp = m_mainWindow->saveSettings();
}
if (m_dockWidgetActiveStateCpp.isEmpty()) {
m_activeDebugLanguages = CppLanguage;
setSimpleDockWidgetArrangement();
m_dockWidgetActiveStateCpp = m_mainWindow->saveSettings();
}
writeWindowSettings();
}
void DebuggerPluginPrivate::resetDebuggerLayout()
{
m_activeDebugLanguages = DebuggerLanguage(QmlLanguage | CppLanguage);
setSimpleDockWidgetArrangement();
m_dockWidgetActiveStateQmlCpp = m_mainWindow->saveSettings();
m_activeDebugLanguages = CppLanguage;
m_previousDebugLanguages = CppLanguage;
setSimpleDockWidgetArrangement();
// will save state in m_dockWidgetActiveStateCpp
updateActiveLanguages();
}
void DebuggerPluginPrivate::updateDockWidgetSettings()
{
if (!m_inDebugMode || m_changingUI)
return;
if (isQmlActive())
m_dockWidgetActiveStateQmlCpp = m_mainWindow->saveSettings();
else
m_dockWidgetActiveStateCpp = m_mainWindow->saveSettings();
}
bool DebuggerPluginPrivate::isQmlCppActive() const
{
return (m_activeDebugLanguages & CppLanguage)
&& (m_activeDebugLanguages & QmlLanguage);
}
bool DebuggerPluginPrivate::isQmlActive() const
{
return (m_activeDebugLanguages & QmlLanguage);
}
void DebuggerPluginPrivate::setSimpleDockWidgetArrangement()
{
using namespace Constants;
QTC_ASSERT(m_mainWindow, return);
m_mainWindow->setTrackingEnabled(false);
QList<QDockWidget *> dockWidgets = m_mainWindow->dockWidgets();
foreach (QDockWidget *dockWidget, dockWidgets) {
dockWidget->setFloating(false);
m_mainWindow->removeDockWidget(dockWidget);
}
foreach (QDockWidget *dockWidget, dockWidgets) {
int area = Qt::BottomDockWidgetArea;
QVariant p = dockWidget->property(DOCKWIDGET_DEFAULT_AREA);
if (p.isValid())
area = Qt::DockWidgetArea(p.toInt());
m_mainWindow->addDockWidget(Qt::DockWidgetArea(area), dockWidget);
dockWidget->hide();
}
QDockWidget *toolBarDock = m_mainWindow->toolBarDockWidget();
QDockWidget *breakDock = qobject_cast<QDockWidget *>(m_breakWindow->parent());
QDockWidget *stackDock = qobject_cast<QDockWidget *>(m_stackWindow->parent());
QDockWidget *watchDock = qobject_cast<QDockWidget *>(m_localsAndExpressionsWindow->parent());
QDockWidget *snapshotsDock = qobject_cast<QDockWidget *>(m_snapshotWindow->parent());
QDockWidget *threadsDock = qobject_cast<QDockWidget *>(m_threadsWindow->parent());
QDockWidget *outputDock = qobject_cast<QDockWidget *>(m_logWindow->parent());
QDockWidget *qmlInspectorDock = 0; // FIXME: qobject_cast<QDockWidget *>(m_qmlInspectorWindow->parent());
QDockWidget *modulesDock = qobject_cast<QDockWidget *>(m_modulesWindow->parent());
QDockWidget *registerDock = qobject_cast<QDockWidget *>(m_registerWindow->parent());
QDockWidget *sourceFilesDock = qobject_cast<QDockWidget *>(m_sourceFilesWindow->parent());
QTC_ASSERT(breakDock, return);
QTC_ASSERT(stackDock, return);
QTC_ASSERT(watchDock, return);
QTC_ASSERT(snapshotsDock, return);
QTC_ASSERT(threadsDock, return);
QTC_ASSERT(outputDock, return);
QTC_ASSERT(modulesDock, return);
QTC_ASSERT(registerDock, return);
QTC_ASSERT(sourceFilesDock, return);
// make sure main docks are visible so that split equally divides the space
toolBarDock->show();
stackDock->show();
breakDock->show();
watchDock->show();
// toolBar
// --------------------------------------------------------------------------------
// stack,qmlinspector | breakpoints,modules,register,threads,sourceFiles,snapshots
//
m_mainWindow->splitDockWidget(toolBarDock, stackDock, Qt::Vertical);
m_mainWindow->splitDockWidget(stackDock, breakDock, Qt::Horizontal);
if (qmlInspectorDock)
m_mainWindow->tabifyDockWidget(stackDock, qmlInspectorDock);
m_mainWindow->tabifyDockWidget(breakDock, modulesDock);
m_mainWindow->tabifyDockWidget(breakDock, registerDock);
m_mainWindow->tabifyDockWidget(breakDock, threadsDock);
m_mainWindow->tabifyDockWidget(breakDock, sourceFilesDock);
m_mainWindow->tabifyDockWidget(breakDock, snapshotsDock);
if (m_activeDebugLanguages.testFlag(Debugger::QmlLanguage)) {
if (qmlInspectorDock)
qmlInspectorDock->show();
} else {
// CPP only
threadsDock->show();
snapshotsDock->show();
}
m_mainWindow->setTrackingEnabled(true);
m_mainWindow->update();
}
bool DockWidgetEventFilter::eventFilter(QObject *obj, QEvent *event)
{
switch (event->type()) {
case QEvent::Resize:
case QEvent::ZOrderChange:
dd->updateDockWidgetSettings();
break;
default:
break;
}
return QObject::eventFilter(obj, event);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@@ -41,9 +41,8 @@ const char ANALYZER[] = "Analyzer";
const char TraceFileExtension[] = ".qtd"; const char TraceFileExtension[] = ".qtd";
const char QmlProfilerTimelineDock[] = "QmlProfilerTimelineDock"; const char QmlProfilerPerspectiveId[] = "QmlProfiler.Perspective";
const char QmlProfilerTimelineDockId[] = "QmlProfiler.Timeline.Dock";
const char QmlProfilerPerspective[] = "QmlProfilerPerspective";
const char QmlProfilerLocalActionId[] = "QmlProfiler.Local"; const char QmlProfilerLocalActionId[] = "QmlProfiler.Local";
const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote"; const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote";

View File

@@ -49,11 +49,19 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)
QmlProfilerPlugin::instance = this;
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorString)) if (!Utils::HostOsInfo::canCreateOpenGLContext(errorString))
return false; return false;
return true;
}
void QmlProfilerPlugin::extensionsInitialized()
{
factory = ExtensionSystem::PluginManager::getObject<QmlProfilerTimelineModelFactory>();
auto tool = new QmlProfilerTool(this); auto tool = new QmlProfilerTool(this);
auto widgetCreator = [tool] { return tool->createWidgets(); };
auto runControlCreator = [tool](ProjectExplorer::RunConfiguration *runConfiguration, Core::Id) { auto runControlCreator = [tool](ProjectExplorer::RunConfiguration *runConfiguration, Core::Id) {
return tool->createRunControl(runConfiguration); return tool->createRunControl(runConfiguration);
}; };
@@ -65,20 +73,16 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
ActionDescription desc; ActionDescription desc;
desc.setText(tr("QML Profiler")); desc.setText(tr("QML Profiler"));
desc.setToolTip(description); desc.setToolTip(description);
desc.setActionId(Constants::QmlProfilerLocalActionId); desc.setPerspectiveId(Constants::QmlProfilerPerspectiveId);
desc.setPerspectiveId(Constants::QmlProfilerPerspective);
desc.setWidgetCreator(widgetCreator);
desc.setRunControlCreator(runControlCreator); desc.setRunControlCreator(runControlCreator);
desc.setToolPreparer([tool] { return tool->prepareTool(); }); desc.setToolPreparer([tool] { return tool->prepareTool(); });
desc.setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); desc.setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction(Constants::QmlProfilerLocalActionId, desc);
desc.setText(tr("QML Profiler (External)")); desc.setText(tr("QML Profiler (External)"));
desc.setToolTip(description); desc.setToolTip(description);
desc.setActionId(Constants::QmlProfilerRemoteActionId); desc.setPerspectiveId(Constants::QmlProfilerPerspectiveId);
desc.setPerspectiveId(Constants::QmlProfilerPerspective);
desc.setWidgetCreator(widgetCreator);
desc.setRunControlCreator(runControlCreator); desc.setRunControlCreator(runControlCreator);
desc.setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) { desc.setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
tool->startRemoteTool(rc); tool->startRemoteTool(rc);
@@ -86,18 +90,12 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
desc.setToolPreparer([tool] { return tool->prepareTool(); }); desc.setToolPreparer([tool] { return tool->prepareTool(); });
desc.setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); desc.setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction(Constants::QmlProfilerRemoteActionId, desc);
addAutoReleasedObject(new QmlProfilerRunControlFactory()); addAutoReleasedObject(new QmlProfilerRunControlFactory());
addAutoReleasedObject(new Internal::QmlProfilerOptionsPage()); addAutoReleasedObject(new Internal::QmlProfilerOptionsPage());
QmlProfilerPlugin::instance = this;
return true; AnalyzerManager::registerToolbar(Constants::QmlProfilerPerspectiveId, tool->createWidgets());
}
void QmlProfilerPlugin::extensionsInitialized()
{
factory = ExtensionSystem::PluginManager::getObject<QmlProfilerTimelineModelFactory>();
} }
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()

View File

@@ -90,12 +90,13 @@ void QmlProfilerViewManager::createViews()
this, &QmlProfilerViewManager::typeSelected); this, &QmlProfilerViewManager::typeSelected);
connect(this, &QmlProfilerViewManager::typeSelected, connect(this, &QmlProfilerViewManager::typeSelected,
d->traceView, &QmlProfilerTraceView::selectByTypeId); d->traceView, &QmlProfilerTraceView::selectByTypeId);
AnalyzerManager::createDockWidget(d->traceView, Constants::QmlProfilerTimelineDock); AnalyzerManager::registerDockWidget(Constants::QmlProfilerTimelineDockId, d->traceView);
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView); new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView);
Perspective perspective(Constants::QmlProfilerPerspective); Perspective perspective;
perspective.addDock(Constants::QmlProfilerTimelineDock, Core::Id(), Perspective::SplitVertical); perspective.addSplit({Constants::QmlProfilerTimelineDockId, Core::Id(),
Perspective::SplitVertical});
d->eventsViews << new QmlProfilerStatisticsView(0, d->profilerModelManager); d->eventsViews << new QmlProfilerStatisticsView(0, d->profilerModelManager);
if (d->eventsViewFactory) if (d->eventsViewFactory)
@@ -104,7 +105,7 @@ void QmlProfilerViewManager::createViews()
// Clear settings if the new views aren't there yet. Otherwise we get glitches // Clear settings if the new views aren't there yet. Otherwise we get glitches
QSettings *settings = Core::ICore::settings(); QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + settings->beginGroup(QLatin1String("AnalyzerViewSettings_") +
QLatin1String(QmlProfiler::Constants::QmlProfilerPerspective)); QLatin1String(QmlProfiler::Constants::QmlProfilerPerspectiveId));
foreach (QmlProfilerEventsView *view, d->eventsViews) { foreach (QmlProfilerEventsView *view, d->eventsViews) {
connect(view, &QmlProfilerEventsView::typeSelected, connect(view, &QmlProfilerEventsView::typeSelected,
@@ -118,14 +119,14 @@ void QmlProfilerViewManager::createViews()
connect(view, &QmlProfilerEventsView::showFullRange, connect(view, &QmlProfilerEventsView::showFullRange,
this, [this](){restrictEventsToRange(-1, -1);}); this, [this](){restrictEventsToRange(-1, -1);});
Core::Id dockId = Core::Id::fromString(view->objectName()); Core::Id dockId = Core::Id::fromString(view->objectName());
QDockWidget *eventsDock = AnalyzerManager::createDockWidget(view, dockId); AnalyzerManager::registerDockWidget(dockId, view);
perspective.addDock(dockId, Constants::QmlProfilerTimelineDock, Perspective::AddToTab); perspective.addSplit({dockId, Constants::QmlProfilerTimelineDockId, Perspective::AddToTab});
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view); new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
if (!settings->contains(eventsDock->objectName())) if (!settings->contains(view->parent()->objectName())) // parent() is QDockWidget.
settings->remove(QString()); settings->remove(QString());
} }
AnalyzerManager::addPerspective(perspective); AnalyzerManager::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
settings->endGroup(); settings->endGroup();
QTC_ASSERT(qobject_cast<QDockWidget *>(d->traceView->parentWidget()), return); QTC_ASSERT(qobject_cast<QDockWidget *>(d->traceView->parentWidget()), return);

View File

@@ -53,7 +53,7 @@ CallgrindRunControl::CallgrindRunControl(ProjectExplorer::RunConfiguration *runC
void CallgrindRunControl::showStatusMessage(const QString &msg) void CallgrindRunControl::showStatusMessage(const QString &msg)
{ {
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, msg); AnalyzerManager::showPermanentStatusMessage(CallgrindPerspectiveId, msg);
} }
QStringList CallgrindRunControl::toolArguments() const QStringList CallgrindRunControl::toolArguments() const

View File

@@ -618,18 +618,18 @@ QWidget *CallgrindToolPrivate::createWidgets()
updateCostFormat(); updateCostFormat();
AnalyzerManager::createDockWidget(m_callersView, CallgrindCallersDock); AnalyzerManager::registerDockWidget(CallgrindCallersDockId, m_callersView);
AnalyzerManager::createDockWidget(m_flatView, CallgrindFlatDock); AnalyzerManager::registerDockWidget(CallgrindFlatDockId, m_flatView);
AnalyzerManager::createDockWidget(m_calleesView, CallgrindCalleesDock); AnalyzerManager::registerDockWidget(CallgrindCalleesDockId, m_calleesView);
AnalyzerManager::createDockWidget(m_visualisation, CallgrindVisualizationDock); AnalyzerManager::registerDockWidget(CallgrindVisualizationDockId, m_visualisation);
Perspective perspective(CallgrindPerspective); AnalyzerManager::registerPerspective(CallgrindPerspectiveId, {
perspective.addDock(CallgrindFlatDock, Id(), Perspective::SplitVertical); { CallgrindFlatDockId, Id(), Perspective::SplitVertical },
perspective.addDock(CallgrindCalleesDock, Id(), Perspective::SplitVertical); { CallgrindCalleesDockId, Id(), Perspective::SplitVertical },
perspective.addDock(CallgrindCallersDock, CallgrindCalleesDock, Perspective::SplitHorizontal); { CallgrindCallersDockId, CallgrindCalleesDockId, Perspective::SplitHorizontal },
perspective.addDock(CallgrindVisualizationDock, Id(), Perspective::SplitVertical, { CallgrindVisualizationDockId, Id(), Perspective::SplitVertical,
false, Qt::RightDockWidgetArea); false, Qt::RightDockWidgetArea }
AnalyzerManager::addPerspective(perspective); });
// //
// Control Widget // Control Widget
@@ -823,7 +823,7 @@ void CallgrindToolPrivate::engineFinished()
if (data) if (data)
showParserResults(data); showParserResults(data);
else else
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, tr("Profiling aborted.")); AnalyzerManager::showPermanentStatusMessage(CallgrindPerspectiveId, tr("Profiling aborted."));
setBusyCursor(false); setBusyCursor(false);
} }
@@ -842,7 +842,7 @@ void CallgrindToolPrivate::showParserResults(const ParseData *data)
} else { } else {
msg = tr("Parsing failed."); msg = tr("Parsing failed.");
} }
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, msg); AnalyzerManager::showPermanentStatusMessage(CallgrindPerspectiveId, msg);
} }
void CallgrindToolPrivate::editorOpened(IEditor *editor) void CallgrindToolPrivate::editorOpened(IEditor *editor)
@@ -907,7 +907,7 @@ void CallgrindToolPrivate::loadExternalLogFile()
return; return;
} }
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, tr("Parsing Profile Data...")); AnalyzerManager::showPermanentStatusMessage(CallgrindPerspectiveId, tr("Parsing Profile Data..."));
QCoreApplication::processEvents(); QCoreApplication::processEvents();
Parser parser; Parser parser;

View File

@@ -33,14 +33,13 @@ namespace ProjectExplorer { class RunConfiguration; }
namespace Valgrind { namespace Valgrind {
namespace Internal { namespace Internal {
const char CallgrindPerspective[] = "CallgrindPerspective"; const char CallgrindPerspectiveId[] = "Callgrind.Perspective";
const char CallgrindLocalActionId[] = "Callgrind.Local"; const char CallgrindLocalActionId[] = "Callgrind.Local.Action";
const char CallgrindRemoteActionId[] = "Callgrind.Remote"; const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action";
const char CallgrindCallersDockId[] = "Callgrind.Callers.Dock";
const char CallgrindCallersDock[] = "CallgrindCallersDock"; const char CallgrindCalleesDockId[] = "Callgrind.Callees.Dock";
const char CallgrindCalleesDock[] = "CallgrindCalleesDock"; const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
const char CallgrindFlatDock[] = "CallgrindFlatDock"; const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
const char CallgrindVisualizationDock[] = "CallgrindVisualizationDock";
class ValgrindRunControl; class ValgrindRunControl;
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode"; const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";

View File

@@ -348,11 +348,11 @@ QWidget *MemcheckTool::createWidgets()
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"));
AnalyzerManager::createDockWidget(m_errorView, MemcheckDock); AnalyzerManager::registerDockWidget(MemcheckErrorDockId, m_errorView);
Perspective perspective(MemcheckPerspective); AnalyzerManager::registerPerspective(MemcheckPerspectiveId, {
perspective.addDock(MemcheckDock, Core::Id(), Perspective::SplitVertical); { MemcheckErrorDockId, Core::Id(), Perspective::SplitVertical }
AnalyzerManager::addPerspective(perspective); });
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &MemcheckTool::maybeActiveRunConfigurationChanged); this, &MemcheckTool::maybeActiveRunConfigurationChanged);
@@ -557,7 +557,7 @@ int MemcheckTool::updateUiAfterFinishedHelper()
void MemcheckTool::engineFinished() void MemcheckTool::engineFinished()
{ {
const int issuesFound = updateUiAfterFinishedHelper(); const int issuesFound = updateUiAfterFinishedHelper();
AnalyzerManager::showPermanentStatusMessage(MemcheckPerspective, issuesFound > 0 AnalyzerManager::showPermanentStatusMessage(MemcheckPerspectiveId, issuesFound > 0
? AnalyzerManager::tr("Memory Analyzer Tool finished, %n issues were found.", 0, issuesFound) ? AnalyzerManager::tr("Memory Analyzer Tool finished, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Memory Analyzer Tool finished, no issues were found.")); : AnalyzerManager::tr("Memory Analyzer Tool finished, no issues were found."));
} }
@@ -565,7 +565,7 @@ void MemcheckTool::engineFinished()
void MemcheckTool::loadingExternalXmlLogFileFinished() void MemcheckTool::loadingExternalXmlLogFileFinished()
{ {
const int issuesFound = updateUiAfterFinishedHelper(); const int issuesFound = updateUiAfterFinishedHelper();
AnalyzerManager::showPermanentStatusMessage(MemcheckPerspective, issuesFound > 0 AnalyzerManager::showPermanentStatusMessage(MemcheckPerspectiveId, issuesFound > 0
? AnalyzerManager::tr("Log file processed, %n issues were found.", 0, issuesFound) ? AnalyzerManager::tr("Log file processed, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Log file processed, no issues were found.")); : AnalyzerManager::tr("Log file processed, no issues were found."));
} }

View File

@@ -51,8 +51,8 @@ namespace Valgrind {
const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode"; const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode";
const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode"; const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode";
const char MemcheckPerspective[] = "MemcheckPerspective"; const char MemcheckPerspectiveId[] = "Memcheck.Perspective";
const char MemcheckDock[] = "MemcheckDock"; const char MemcheckErrorDockId[] = "Memcheck.Dock.Error";
namespace Internal { namespace Internal {

View File

@@ -128,65 +128,54 @@ void ValgrindPlugin::extensionsInitialized()
"Memcheck tool to find memory leaks."); "Memcheck tool to find memory leaks.");
auto mcTool = new MemcheckTool(this); auto mcTool = new MemcheckTool(this);
auto mcWidgetCreator = [mcTool] { return mcTool->createWidgets(); };
auto cgTool = new CallgrindTool(this); auto cgTool = new CallgrindTool(this);
auto cgWidgetCreator = [cgTool] { return cgTool->createWidgets(); };
auto cgRunControlCreator = [cgTool](RunConfiguration *runConfiguration, Id) { auto cgRunControlCreator = [cgTool](RunConfiguration *runConfiguration, Id) {
return cgTool->createRunControl(runConfiguration); return cgTool->createRunControl(runConfiguration);
}; };
AnalyzerManager::registerToolbar(MemcheckPerspectiveId, mcTool->createWidgets());
AnalyzerManager::registerToolbar(CallgrindPerspectiveId, cgTool->createWidgets());
ActionDescription desc; ActionDescription desc;
if (!Utils::HostOsInfo::isWindowsHost()) { if (!Utils::HostOsInfo::isWindowsHost()) {
desc.setText(tr("Valgrind Memory Analyzer")); desc.setText(tr("Valgrind Memory Analyzer"));
desc.setToolTip(memcheckToolTip); desc.setToolTip(memcheckToolTip);
desc.setEnabled(false); desc.setPerspectiveId(MemcheckPerspectiveId);
desc.setActionId("Memcheck.Local");
desc.setPerspectiveId(MemcheckPerspective);
desc.setWidgetCreator(mcWidgetCreator);
desc.setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) { desc.setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) {
return mcTool->createRunControl(runConfig, runMode); return mcTool->createRunControl(runConfig, runMode);
}); });
desc.setToolMode(DebugMode); desc.setToolMode(DebugMode);
desc.setRunMode(MEMCHECK_RUN_MODE); desc.setRunMode(MEMCHECK_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction("Memcheck.Local", desc);
auto mcgTool = new MemcheckTool(this);
desc.setText(tr("Valgrind Memory Analyzer with GDB")); desc.setText(tr("Valgrind Memory Analyzer with GDB"));
desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the " desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
"Memcheck tool to find memory leaks.\nWhen a problem is detected, " "Memcheck tool to find memory leaks.\nWhen a problem is detected, "
"the application is interrupted and can be debugged.")); "the application is interrupted and can be debugged."));
desc.setEnabled(false); desc.setPerspectiveId(MemcheckPerspectiveId);
desc.setActionId("MemcheckWithGdb.Local"); desc.setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) {
desc.setPerspectiveId(MemcheckPerspective); return mcTool->createRunControl(runConfig, runMode);
desc.setWidgetCreator([mcgTool] { return mcgTool->createWidgets(); });
desc.setRunControlCreator([mcgTool](RunConfiguration *runConfig, Id runMode) {
return mcgTool->createRunControl(runConfig, runMode);
}); });
desc.setToolMode(DebugMode); desc.setToolMode(DebugMode);
desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE); desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction("MemcheckWithGdb.Local", desc);
desc.setText(tr("Valgrind Function Profiler")); desc.setText(tr("Valgrind Function Profiler"));
desc.setToolTip(callgrindToolTip); desc.setToolTip(callgrindToolTip);
desc.setEnabled(false); desc.setPerspectiveId(CallgrindPerspectiveId);
desc.setActionId(CallgrindLocalActionId);
desc.setPerspectiveId(CallgrindPerspective);
desc.setWidgetCreator(cgWidgetCreator);
desc.setRunControlCreator(cgRunControlCreator); desc.setRunControlCreator(cgRunControlCreator);
desc.setToolMode(OptimizedMode); desc.setToolMode(OptimizedMode);
desc.setRunMode(CALLGRIND_RUN_MODE); desc.setRunMode(CALLGRIND_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction(CallgrindLocalActionId, desc);
} }
desc.setText(tr("Valgrind Memory Analyzer (External Remote Application)")); desc.setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
desc.setToolTip(memcheckToolTip); desc.setToolTip(memcheckToolTip);
desc.setActionId("Memcheck.Remote"); desc.setPerspectiveId(MemcheckPerspectiveId);
desc.setPerspectiveId(MemcheckPerspective);
desc.setWidgetCreator(mcWidgetCreator);
desc.setCustomToolStarter([mcTool](ProjectExplorer::RunConfiguration *runConfig) { desc.setCustomToolStarter([mcTool](ProjectExplorer::RunConfiguration *runConfig) {
StartRemoteDialog dlg; StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
@@ -202,11 +191,11 @@ void ValgrindPlugin::extensionsInitialized()
ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE); ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE);
}); });
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction("Memcheck.Remote", desc);
desc.setActionId(CallgrindRemoteActionId); desc.setText(tr("Valgrind Function Profiler (External Remote Application)"));
desc.setPerspectiveId(CallgrindPerspective); desc.setToolTip(callgrindToolTip);
desc.setWidgetCreator(cgWidgetCreator); desc.setPerspectiveId(CallgrindPerspectiveId);
desc.setCustomToolStarter([cgTool](ProjectExplorer::RunConfiguration *runConfig) { desc.setCustomToolStarter([cgTool](ProjectExplorer::RunConfiguration *runConfig) {
StartRemoteDialog dlg; StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
@@ -221,11 +210,8 @@ void ValgrindPlugin::extensionsInitialized()
rc->setDisplayName(runnable.executable); rc->setDisplayName(runnable.executable);
ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE); ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE);
}); });
desc.setText(tr("Valgrind Function Profiler (External Remote Application)"));
desc.setToolTip(callgrindToolTip);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS); desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(desc); AnalyzerManager::registerAction(CallgrindRemoteActionId, desc);
// If there is a CppEditor context menu add our own context menu actions. // If there is a CppEditor context menu add our own context menu actions.
if (ActionContainer *editorContextMenu = if (ActionContainer *editorContextMenu =