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 ClangStaticAnalyzerOptionsPage);
auto widgetCreator = [tool] { return tool->createWidgets(); };
AnalyzerManager::registerToolbar(ClangStaticAnalyzerPerspectiveId, tool->createWidgets());
auto runControlCreator = [tool](ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id 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 "
"to find bugs.");
Perspective perspective(ClangStaticAnalyzerPerspective);
perspective.addDock(ClangStaticAnalyzerDock, Core::Id(), Perspective::SplitVertical);
AnalyzerManager::addPerspective(perspective);
AnalyzerManager::registerPerspective(ClangStaticAnalyzerPerspectiveId, {
{ ClangStaticAnalyzerDockId, Core::Id(), Perspective::SplitVertical }
});
ActionDescription desc;
desc.setText(tr("Clang Static Analyzer"));
desc.setToolTip(toolTip);
desc.setEnabled(false);
desc.setRunMode(Constants::CLANGSTATICANALYZER_RUN_MODE);
desc.setPerspectiveId(ClangStaticAnalyzerPerspective);
desc.setActionId(ClangStaticAnalyzerAction);
desc.setWidgetCreator(widgetCreator);
desc.setPerspectiveId(ClangStaticAnalyzerPerspectiveId);
desc.setRunControlCreator(runControlCreator);
desc.setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
tool->startTool(rc);
});
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc);
AnalyzerManager::registerAction(ClangStaticAnalyzerActionId, desc);
return true;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -85,9 +85,6 @@ public:
Core::Id menuGroup() const { return m_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; }
void setPerspectiveId(Core::Id id) { m_perspective = id; }
void setToolMode(QFlags<ToolMode> mode) { m_toolMode = mode; }
@@ -96,13 +93,6 @@ public:
void setRunMode(Core::Id mode) { m_runMode = mode; }
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.
/// Called each time the tool is launched.
typedef std::function<AnalyzerRunControl *(ProjectExplorer::RunConfiguration *runConfiguration,
@@ -126,19 +116,13 @@ public:
QString text() const { return m_text; }
void setText(const QString &text) { m_text = text; }
bool enabled() const { return m_enabled; }
void setEnabled(bool enabled) { m_enabled = enabled; }
private:
bool m_enabled = false;
QString m_text;
QString m_toolTip;
Core::Id m_menuGroup;
Core::Id m_actionId;
Core::Id m_perspective;
QFlags<ToolMode> m_toolMode = AnyMode;
Core::Id m_runMode;
WidgetCreator m_widgetCreator;
RunControlCreator m_runControlCreator;
ToolStarter m_customToolStarter;
ToolPreparer m_toolPreparer;
@@ -156,11 +140,10 @@ public:
static void shutdown();
// Register a tool for a given start mode.
static void addAction(const ActionDescription &desc);
static void addPerspective(const Perspective &perspective);
// Dockwidgets are registered to the main window.
static QDockWidget *createDockWidget(QWidget *widget, Core::Id dockId);
static void registerAction(Core::Id actionId, const ActionDescription &desc);
static void registerPerspective(Core::Id perspectiveId, const Perspective &perspective);
static void registerDockWidget(Core::Id dockId, QWidget *widget);
static void registerToolbar(Core::Id toolbarId, QWidget *widget);
static void enableMainWindow(bool on);

View File

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

View File

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

View File

@@ -49,6 +49,9 @@ MainWindowBase::MainWindowBase()
setDockNestingEnabled(true);
setDockActionsVisible(false);
setDocumentMode(true);
connect(this, &FancyMainWindow::resetLayout,
this, &MainWindowBase::resetCurrentPerspective);
}
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)
{
StatusLabel *statusLabel = m_statusLabelForPerspective.value(perspective);
StatusLabel *statusLabel = m_statusLabelForPerspectiveId.value(perspective);
QTC_ASSERT(statusLabel, return);
statusLabel->showStatusMessage(message, timeoutMS);
}
void MainWindowBase::restorePerspective(Id perspectiveId,
std::function<QWidget *()> creator,
bool fromStoredSettings)
void MainWindowBase::resetCurrentPerspective()
{
if (!perspectiveId.isValid())
return;
if (!m_defaultSettings.contains(perspectiveId) && creator) {
QWidget *widget = creator();
QTC_CHECK(widget);
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);
loadPerspectiveHelper(m_currentPerspectiveId, false);
}
const Perspective *perspective = findPerspective(perspectiveId);
QTC_ASSERT(perspective, return);
void MainWindowBase::restorePerspective(Id perspectiveId)
{
loadPerspectiveHelper(perspectiveId, true);
}
foreach (const Perspective::Split &split, perspective->splits()) {
void MainWindowBase::loadPerspectiveHelper(Id perspectiveId, bool fromStoredSettings)
{
QTC_ASSERT(perspectiveId.isValid(), return);
// 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);
QTC_ASSERT(dock, continue);
addDockWidget(split.area, dock);
QDockWidget *existing = m_dockForDockId.value(split.existing);
if (!existing && split.area == Qt::BottomDockWidgetArea)
@@ -116,30 +129,30 @@ void MainWindowBase::restorePerspective(Id perspectiveId,
}
if (!split.visibleByDefault)
dock->hide();
else
dock->show();
}
if (fromStoredSettings) {
QSettings *settings = ICore::settings();
settings->beginGroup(m_settingsName + perspectiveId.toString());
settings->beginGroup(perspectiveId.toString());
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
restoreSettings(settings);
settings->endGroup();
}
QTC_CHECK(m_controlsWidgetForPerspective.contains(perspectiveId));
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetForPerspective.value(perspectiveId));
m_statusLabelsStackWidget->setCurrentWidget(m_statusLabelForPerspective.value(perspectiveId));
QTC_CHECK(m_toolbarForPerspectiveId.contains(perspectiveId));
m_controlsStackWidget->setCurrentWidget(m_toolbarForPerspectiveId.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;
savePerspective(perspectiveId);
const Perspective *perspective = findPerspective(perspectiveId);
QTC_ASSERT(perspective, return);
foreach (Id dockId, perspective->docks()) {
QDockWidget *dockWidget = m_dockForDockId.value(dockId);
saveCurrentPerspective();
foreach (QDockWidget *dockWidget, m_dockForDockId) {
QTC_ASSERT(dockWidget, continue);
removeDockWidget(dockWidget);
dockWidget->hide();
@@ -148,25 +161,19 @@ void MainWindowBase::closePerspective(Id perspectiveId)
}
}
const Perspective *MainWindowBase::findPerspective(Id perspectiveId) const
{
foreach (const Perspective &perspective, m_perspectives)
if (perspective.id() == perspectiveId)
return &perspective;
return 0;
}
void MainWindowBase::savePerspective(Id perspectiveId)
void MainWindowBase::saveCurrentPerspective()
{
if (!m_currentPerspectiveId.isValid())
return;
QSettings *settings = ICore::settings();
settings->beginGroup(m_settingsName + perspectiveId.toString());
settings->beginGroup(m_currentPerspectiveId.toString());
saveSettings(settings);
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
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);
QDockWidget *dockWidget = addDockForWidget(widget);
@@ -175,14 +182,9 @@ QDockWidget *MainWindowBase::createDockWidget(QWidget *widget, Id dockId)
return dockWidget;
}
QString MainWindowBase::settingsName() const
Core::Id MainWindowBase::currentPerspectiveId() const
{
return m_settingsName;
}
void MainWindowBase::setSettingsName(const QString &settingsName)
{
m_settingsName = settingsName;
return m_currentPerspectiveId;
}
QString MainWindowBase::lastSettingsName() const

View File

@@ -38,6 +38,7 @@
#include <QSet>
#include <functional>
#include <initializer_list>
QT_BEGIN_NAMESPACE
class QComboBox;
@@ -51,33 +52,32 @@ class ANALYZER_EXPORT Perspective
public:
enum SplitType { SplitVertical, SplitHorizontal, AddToTab };
struct Split {
class Split
{
public:
Split() = default;
Split(Core::Id e, Core::Id d, SplitType t, bool v, Qt::DockWidgetArea a)
: existing(e), dockId(d), splitType(t), visibleByDefault(v), area(a)
{}
Core::Id existing;
Split(Core::Id dockId, Core::Id existing, SplitType splitType,
bool visibleByDefault = true,
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
Core::Id dockId;
Core::Id existing;
SplitType splitType;
bool visibleByDefault;
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 addDock(Core::Id dockId, Core::Id existing, SplitType splitType,
bool visibleByDefault = true,
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
void addSplit(const Split &split);
Splits splits() const { return m_splits; }
QList<Core::Id> docks() const { return m_docks; }
QVector<Split> splits() const { return m_splits; }
QVector<Core::Id> docks() const { return m_docks; }
private:
Core::Id m_id;
QList<Core::Id> m_docks;
Splits m_splits;
QVector<Core::Id> m_docks;
QVector<Split> m_splits;
};
} // Analyzer
@@ -95,8 +95,9 @@ const char DOCKWIDGET_STACK[] = "Debugger.Docks.Stack";
const char DOCKWIDGET_SOURCE_FILES[] = "Debugger.Docks.SourceFiles";
const char DOCKWIDGET_THREADS[] = "Debugger.Docks.Threads";
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
{
@@ -110,35 +111,34 @@ public:
QStackedWidget *controlsStack() const { return m_controlsStackWidget; }
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);
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;
void setLastSettingsName(const QString &lastSettingsName);
QDockWidget *createDockWidget(QWidget *widget, Core::Id dockId);
Core::Id currentPerspectiveId() const;
private:
QString m_settingsName;
void loadPerspectiveHelper(Core::Id perspectiveId, bool fromStoredSettings = true);
Core::Id m_currentPerspectiveId;
QString m_lastSettingsName;
QComboBox *m_toolBox;
QStackedWidget *m_controlsStackWidget;
QStackedWidget *m_statusLabelsStackWidget;
QHash<Core::Id, QDockWidget *> m_dockForDockId;
QList<Analyzer::Perspective> m_perspectives;
QHash<Core::Id, QWidget *> m_controlsWidgetForPerspective;
QHash<Core::Id, Utils::StatusLabel *> m_statusLabelForPerspective;
QSet<Core::Id> m_defaultSettings;
QHash<Core::Id, QWidget *> m_toolbarForPerspectiveId;
QHash<Core::Id, Analyzer::Perspective> m_perspectiveForPerspectiveId;
QHash<Core::Id, Utils::StatusLabel *> m_statusLabelForPerspectiveId;
// list of dock widgets to prevent memory leak
typedef QPointer<QDockWidget> DockPtr;

View File

@@ -144,6 +144,7 @@
#include <QMenu>
#include <QMenu>
#include <QMessageBox>
#include <QStackedWidget>
#include <QTextBlock>
#include <QToolButton>
#include <QTreeWidget>
@@ -579,14 +580,14 @@ static Kit *findUniversalCdbKit()
static DebuggerPluginPrivate *dd = 0;
class DockWidgetEventFilter : public QObject
{
public:
DockWidgetEventFilter() {}
//class DockWidgetEventFilter : public QObject
//{
//public:
// DockWidgetEventFilter() {}
private:
bool eventFilter(QObject *obj, QEvent *event) override;
};
//private:
// bool eventFilter(QObject *obj, QEvent *event) override;
//};
/*!
\class Debugger::Internal::DebuggerCore
@@ -633,7 +634,7 @@ public:
void writeSettings()
{
m_debuggerSettings->writeSettings();
writeWindowSettings();
// writeWindowSettings();
}
void selectThread(int index)
@@ -962,12 +963,8 @@ public slots:
void parseCommandLineArguments();
public:
// Debugger toolbars are registered with this function.
void setToolBar(DebuggerLanguage language, QWidget *widget);
// Active languages to be debugged.
DebuggerLanguages activeDebugLanguages() const;
void setEngineDebugLanguages(DebuggerLanguages languages);
// Called when all dependent plugins have loaded.
void initialize();
@@ -975,57 +972,29 @@ public:
void onModeChangedHelper(Core::IMode *mode);
// Dockwidgets are registered to the main window.
QDockWidget *createDockWidget(const DebuggerLanguage &language, QWidget *widget);
void addStagedMenuEntries();
QDockWidget *createDockWidget(Id dockId, QWidget *widget);
QWidget *createContents(Core::IMode *mode);
void readWindowSettings();
void writeWindowSettings() const;
void activateQmlCppLayout();
void activateCppLayout();
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; }
void resetDebuggerLayout();
void updateUiForProject(ProjectExplorer::Project *project);
void updateUiForTarget(ProjectExplorer::Target *target);
void updateUiForRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void updateUiForCurrentRunConfiguration();
void updateActiveLanguages();
void updateDockWidgetSettings();
public:
Utils::FancyMainWindow *m_mainWindow = 0;
MainWindowBase *m_mainWindow = 0;
QHash<QString, QVariant> m_dockWidgetActiveStateCpp;
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;
// DockWidgetEventFilter m_resizeEventFilter;
QHash<DebuggerLanguage, Core::Context> m_contextsForLanguage;
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;
@@ -1033,7 +1002,6 @@ public:
ProjectExplorer::Target *m_previousTarget = 0;
ProjectExplorer::RunConfiguration *m_previousRunConfiguration = 0;
Id m_previousMode;
QVector<QPair<DebuggerRunParameters, Kit *>> m_scheduledStarts;
@@ -1079,7 +1047,6 @@ public:
QIcon m_locationMarkIcon;
QIcon m_resetIcon;
StatusLabel *m_statusLabel = 0;
QComboBox *m_threadBox = 0;
BaseTreeView *m_breakView = 0;
@@ -1137,17 +1104,10 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin)
m_plugin = plugin;
m_debugToolBar = new QWidget;
m_debugToolBarLayout = new QHBoxLayout(m_debugToolBar);
m_mainWindow = new Utils::FancyMainWindow;
m_debugToolBarLayout->setMargin(0);
m_debugToolBarLayout->setSpacing(0);
createViewsMenuItems();
addLanguage(AnyLanguage, Context());
addLanguage(CppLanguage, Context(C_CPPDEBUGGER));
addLanguage(QmlLanguage, Context(C_QMLDEBUGGER));
// m_toolBars.insert(CppLanguage, 0);
// m_toolBars.insert(QmlLanguage, 0);
m_contextsForLanguage.insert(CppLanguage, Context(C_CPPDEBUGGER));
m_contextsForLanguage.insert(QmlLanguage, Context(C_QMLDEBUGGER));
}
DebuggerPluginPrivate::~DebuggerPluginPrivate()
@@ -1310,7 +1270,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
connect(KitManager::instance(), &KitManager::kitsLoaded,
this, &DebuggerPluginPrivate::parseCommandLineArguments);
m_mainWindow = new FancyMainWindow;
m_mainWindow = new MainWindowBase;
m_mainWindow->setObjectName(QLatin1String("DebuggerMainWindow"));
createViewsMenuItems();
m_plugin->addAutoReleasedObject(debuggerConsole());
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO,
@@ -1836,8 +1800,6 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
engine->watchHandler()->resetWatchers();
m_localsView->hideProgressIndicator();
setEngineDebugLanguages(engine->runParameters().languages);
}
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.
if (m_inDebugMode) {
readWindowSettings();
// readWindowSettings();
updateActiveLanguages();
} else {
// Hide dock widgets manually in case they are floating.
@@ -2250,7 +2212,7 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
showMessage(msg0, LogStatus);
QString msg = msg0;
msg.replace(QChar::LineFeed, QLatin1String("; "));
m_statusLabel->showStatusMessage(msg, timeout);
m_mainWindow->showStatusMessage(m_mainWindow->currentPerspectiveId(), msg, timeout);
}
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->setFeatures(QDockWidget::DockWidgetClosable);
dockWidget->show();
@@ -2456,8 +2419,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_busy = false;
m_statusLabel = new StatusLabel;
m_logWindow = new LogWindow;
m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT));
@@ -2599,25 +2560,23 @@ void DebuggerPluginPrivate::extensionsInitialized()
// Dock widgets
QDockWidget *dock = 0;
dock = createDockWidget(CppLanguage, m_modulesWindow);
dock = createDockWidget(DOCKWIDGET_MODULES, m_modulesWindow);
connect(dock->toggleViewAction(), &QAction::toggled,
this, &DebuggerPluginPrivate::modulesDockToggled, Qt::QueuedConnection);
dock = createDockWidget(CppLanguage, m_registerWindow);
dock = createDockWidget(DOCKWIDGET_REGISTER, m_registerWindow);
connect(dock->toggleViewAction(), &QAction::toggled,
this, &DebuggerPluginPrivate::registerDockToggled, Qt::QueuedConnection);
dock = createDockWidget(CppLanguage, m_sourceFilesWindow);
dock = createDockWidget(DOCKWIDGET_SOURCE_FILES, m_sourceFilesWindow);
connect(dock->toggleViewAction(), &QAction::toggled,
this, &DebuggerPluginPrivate::sourceFilesDockToggled, Qt::QueuedConnection);
dock = createDockWidget(AnyLanguage, m_logWindow);
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::TopDockWidgetArea);
createDockWidget(CppLanguage, m_breakWindow);
createDockWidget(CppLanguage, m_snapshotWindow);
createDockWidget(CppLanguage, m_stackWindow);
createDockWidget(CppLanguage, m_threadsWindow);
createDockWidget(DOCKWIDGET_OUTPUT, m_logWindow);
createDockWidget(DOCKWIDGET_BREAK, m_breakWindow);
createDockWidget(DOCKWIDGET_SNAPSHOTS, m_snapshotWindow);
createDockWidget(DOCKWIDGET_STACK, m_stackWindow);
createDockWidget(DOCKWIDGET_THREADS, m_threadsWindow);
m_localsAndExpressionsWindow = new LocalsAndExpressionsWindow(
m_localsWindow, m_inspectorWindow, m_returnWindow,
@@ -2625,10 +2584,9 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_localsAndExpressionsWindow->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS));
m_localsAndExpressionsWindow->setWindowTitle(m_localsWindow->windowTitle());
dock = createDockWidget(CppLanguage, m_localsAndExpressionsWindow);
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::RightDockWidgetArea);
dock = createDockWidget(DOCKWIDGET_WATCHERS, m_localsAndExpressionsWindow);
addStagedMenuEntries();
m_mainWindow->addDockActionsToMenu(m_viewsMenu->menu());
m_plugin->addAutoReleasedObject(createDebuggerRunControlFactory(m_plugin));
@@ -2975,7 +2933,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); });
// Toolbar
QWidget *toolbarContainer = new QWidget;
QWidget *toolbarContainer = new QWidget(mainWindow());
QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
hbox->setMargin(0);
@@ -3004,8 +2962,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
hbox->addWidget(m_threadBox);
hbox->addSpacerItem(new QSpacerItem(4, 0));
setToolBar(CppLanguage, toolbarContainer);
QWidget *qmlToolbar = new QWidget(mainWindow());
hbox = new QHBoxLayout(qmlToolbar);
hbox->setMargin(0);
@@ -3017,9 +2973,32 @@ void DebuggerPluginPrivate::extensionsInitialized()
hbox->addWidget(toolButton(Constants::QML_SELECTTOOL));
hbox->addWidget(toolButton(Constants::QML_ZOOMTOOL));
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,
this, &DebuggerPluginPrivate::enableReverseDebuggingTriggered);
@@ -3174,11 +3153,6 @@ void openTextEditor(const QString &titlePattern0, const QString &contents)
QTC_ASSERT(editor, return);
}
bool isActiveDebugLanguage(int language)
{
return dd->activeDebugLanguages() & language;
}
// void runTest(const QString &fileName);
void showMessage(const QString &msg, int channel, int timeout)
{
@@ -3467,64 +3441,25 @@ void DebuggerPluginPrivate::updateUiForRunConfiguration(RunConfiguration *rc)
{
if (m_previousRunConfiguration)
disconnect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate,
this, &DebuggerPluginPrivate::updateUiForCurrentRunConfiguration);
this, &DebuggerPluginPrivate::updateActiveLanguages);
m_previousRunConfiguration = rc;
updateUiForCurrentRunConfiguration();
if (!rc)
return;
connect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate,
this, &DebuggerPluginPrivate::updateUiForCurrentRunConfiguration);
}
void DebuggerPluginPrivate::updateUiForCurrentRunConfiguration()
{
updateActiveLanguages();
if (m_previousRunConfiguration)
connect(m_previousRunConfiguration, &RunConfiguration::requestRunActionsUpdate,
this, &DebuggerPluginPrivate::updateActiveLanguages);
}
void DebuggerPluginPrivate::updateActiveLanguages()
{
DebuggerLanguages newLanguages = AnyLanguage;
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();
if (!(activeDebugLanguages() & QmlLanguage))
m_mainWindow->restorePerspective(CppPerspectiveId);
else
activateCppLayout();
m_previousDebugLanguages = m_activeDebugLanguages;
m_changingUI = false;
m_mainWindow->restorePerspective(QmlPerspectiveId);
}
DebuggerLanguages DebuggerPluginPrivate::activeDebugLanguages() const
{
return m_activeDebugLanguages;
}
void DebuggerPluginPrivate::setEngineDebugLanguages(DebuggerLanguages languages)
{
if (m_engineDebugLanguages == languages)
return;
m_engineDebugLanguages = languages;
updateActiveLanguages();
return dd->m_currentEngine->runParameters().languages;
}
void DebuggerPluginPrivate::createViewsMenuItems()
@@ -3554,126 +3489,29 @@ void DebuggerPluginPrivate::createViewsMenuItems()
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
*/
QDockWidget *DebuggerPluginPrivate::createDockWidget(const DebuggerLanguage &language,
QWidget *widget)
QDockWidget *DebuggerPluginPrivate::createDockWidget(Core::Id dockId, QWidget *widget)
{
QDockWidget *dockWidget = m_mainWindow->addDockForWidget(widget);
dockWidget->setObjectName(widget->objectName());
m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
m_mainWindow->registerDockWidget(dockId, widget);
if (!(m_activeDebugLanguages & language))
dockWidget->hide();
QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget->parentWidget());
QAction *toggleViewAction = dockWidget->toggleViewAction();
Command *cmd = ActionManager::registerAction(toggleViewAction,
Id("Debugger.").withSuffix(widget->objectName()));
cmd->setAttribute(Command::CA_Hide);
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);
//dockWidget->installEventFilter(&m_resizeEventFilter);
return dockWidget;
}
void DebuggerPluginPrivate::addStagedMenuEntries()
{
m_mainWindow->addDockActionsToMenu(m_viewsMenu->menu());
}
QWidget *DebuggerPluginPrivate::createContents(IMode *mode)
{
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
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;
editorHolderLayout->setMargin(0);
editorHolderLayout->setSpacing(0);
@@ -3690,22 +3528,25 @@ QWidget *DebuggerPluginPrivate::createContents(IMode *mode)
documentAndRightPane->setStretchFactor(0, 1);
documentAndRightPane->setStretchFactor(1, 0);
m_viewButton = new QToolButton();
m_viewButton->setText(tr("Views"));
auto viewButton = new QToolButton();
viewButton->setText(tr("Views"));
auto debugToolBar = new Utils::StyledBar;
debugToolBar->setProperty("topBorder", true);
auto debugToolBarLayout = new QHBoxLayout(debugToolBar);
debugToolBarLayout->setMargin(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(m_viewButton);
debugToolBarLayout->addStretch();
debugToolBarLayout->addWidget(viewButton);
connect(m_viewButton, &QAbstractButton::clicked, [this] {
connect(viewButton, &QAbstractButton::clicked, [this, viewButton] {
QMenu menu;
m_mainWindow->addDockActionsToMenu(&menu);
menu.exec(m_viewButton->mapToGlobal(QPoint()));
menu.exec(viewButton->mapToGlobal(QPoint()));
});
auto dock = new QDockWidget(DebuggerPluginPrivate::tr("Debugger Toolbar"));
@@ -3750,181 +3591,18 @@ QWidget *DebuggerPluginPrivate::createContents(IMode *mode)
return splitter;
}
void DebuggerPluginPrivate::writeWindowSettings() const
{
QSettings *settings = ICore::settings();
settings->beginGroup(QLatin1String("DebugMode.CppMode"));
QHashIterator<QString, QVariant> it(m_dockWidgetActiveStateCpp);
while (it.hasNext()) {
it.next();
settings->setValue(it.key(), it.value());
}
settings->endGroup();
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);
}
//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 QmlProfilerTimelineDock[] = "QmlProfilerTimelineDock";
const char QmlProfilerPerspective[] = "QmlProfilerPerspective";
const char QmlProfilerPerspectiveId[] = "QmlProfiler.Perspective";
const char QmlProfilerTimelineDockId[] = "QmlProfiler.Timeline.Dock";
const char QmlProfilerLocalActionId[] = "QmlProfiler.Local";
const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote";

View File

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

View File

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

View File

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

View File

@@ -33,14 +33,13 @@ namespace ProjectExplorer { class RunConfiguration; }
namespace Valgrind {
namespace Internal {
const char CallgrindPerspective[] = "CallgrindPerspective";
const char CallgrindLocalActionId[] = "Callgrind.Local";
const char CallgrindRemoteActionId[] = "Callgrind.Remote";
const char CallgrindCallersDock[] = "CallgrindCallersDock";
const char CallgrindCalleesDock[] = "CallgrindCalleesDock";
const char CallgrindFlatDock[] = "CallgrindFlatDock";
const char CallgrindVisualizationDock[] = "CallgrindVisualizationDock";
const char CallgrindPerspectiveId[] = "Callgrind.Perspective";
const char CallgrindLocalActionId[] = "Callgrind.Local.Action";
const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action";
const char CallgrindCallersDockId[] = "Callgrind.Callers.Dock";
const char CallgrindCalleesDockId[] = "Callgrind.Callees.Dock";
const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
class ValgrindRunControl;
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->setWindowTitle(tr("Memory Issues"));
AnalyzerManager::createDockWidget(m_errorView, MemcheckDock);
AnalyzerManager::registerDockWidget(MemcheckErrorDockId, m_errorView);
Perspective perspective(MemcheckPerspective);
perspective.addDock(MemcheckDock, Core::Id(), Perspective::SplitVertical);
AnalyzerManager::addPerspective(perspective);
AnalyzerManager::registerPerspective(MemcheckPerspectiveId, {
{ MemcheckErrorDockId, Core::Id(), Perspective::SplitVertical }
});
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &MemcheckTool::maybeActiveRunConfigurationChanged);
@@ -557,7 +557,7 @@ int MemcheckTool::updateUiAfterFinishedHelper()
void MemcheckTool::engineFinished()
{
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, no issues were found."));
}
@@ -565,7 +565,7 @@ void MemcheckTool::engineFinished()
void MemcheckTool::loadingExternalXmlLogFileFinished()
{
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, no issues were found."));
}

View File

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

View File

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