forked from qt-creator/qt-creator
Analyzer: Merge AnalyzerAction::useStartupProject and ::toolStarter
Also rename ToolStarter to CustomToolStarter to make clearer that this is not the normal startupProject based setup. Change-Id: I6c538eed9280e0c02912954541423f030e88585f Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
This commit is contained in:
@@ -59,12 +59,12 @@ using namespace ProjectExplorer;
|
||||
namespace Analyzer {
|
||||
|
||||
AnalyzerAction::AnalyzerAction(QObject *parent)
|
||||
: QAction(parent), m_useStartupProject(true), m_toolMode(AnyMode)
|
||||
: QAction(parent), m_toolMode(AnyMode)
|
||||
{}
|
||||
|
||||
bool AnalyzerAction::isRunnable(QString *reason) const
|
||||
{
|
||||
if (m_toolStarter) // Something special. Pretend we can always run it.
|
||||
if (m_customToolStarter) // Something special. Pretend we can always run it.
|
||||
return true;
|
||||
|
||||
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason);
|
||||
@@ -72,7 +72,8 @@ bool AnalyzerAction::isRunnable(QString *reason) const
|
||||
|
||||
AnalyzerRunControl *AnalyzerAction::tryCreateRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) const
|
||||
{
|
||||
if (m_runMode == sp.runMode && m_useStartupProject == sp.useStartupProject)
|
||||
const bool useStartupProject = !m_customToolStarter;
|
||||
if (m_runMode == sp.runMode && useStartupProject == sp.useStartupProject)
|
||||
return m_runControlCreator(sp, runConfiguration);
|
||||
return 0;
|
||||
}
|
||||
@@ -101,8 +102,8 @@ void AnalyzerAction::startTool()
|
||||
return;
|
||||
|
||||
// Custom start.
|
||||
if (m_toolStarter) {
|
||||
m_toolStarter();
|
||||
if (m_customToolStarter) {
|
||||
m_customToolStarter();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,4 +156,9 @@ void AnalyzerAction::startTool()
|
||||
ProjectExplorerPlugin::runStartupProject(m_runMode);
|
||||
}
|
||||
|
||||
void AnalyzerAction::setCustomToolStarter(const AnalyzerAction::ToolStarter &toolStarter)
|
||||
{
|
||||
m_customToolStarter = toolStarter;
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
|
@@ -76,8 +76,6 @@ public:
|
||||
explicit AnalyzerAction(QObject *parent = 0);
|
||||
|
||||
public:
|
||||
void setUseSpecialStart() { m_useStartupProject = false; }
|
||||
|
||||
Core::Id menuGroup() const { return m_menuGroup; }
|
||||
void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; }
|
||||
|
||||
@@ -106,16 +104,17 @@ public:
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) const;
|
||||
void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; }
|
||||
|
||||
typedef std::function<void()> ToolStarter;
|
||||
void startTool();
|
||||
void setToolStarter(const ToolStarter &toolStarter) { m_toolStarter = toolStarter; }
|
||||
|
||||
typedef std::function<bool()> ToolPreparer;
|
||||
ToolPreparer toolPreparer() const { return m_toolPreparer; }
|
||||
void setToolPreparer(const ToolPreparer &toolPreparer) { m_toolPreparer = toolPreparer; }
|
||||
|
||||
void startTool();
|
||||
|
||||
/// This is only used for setups not using the startup project.
|
||||
typedef std::function<void()> ToolStarter;
|
||||
void setCustomToolStarter(const ToolStarter &toolStarter);
|
||||
|
||||
protected:
|
||||
bool m_useStartupProject;
|
||||
Core::Id m_menuGroup;
|
||||
Core::Id m_actionId;
|
||||
Core::Id m_toolId;
|
||||
@@ -123,7 +122,7 @@ protected:
|
||||
ProjectExplorer::RunMode m_runMode;
|
||||
WidgetCreator m_widgetCreator;
|
||||
RunControlCreator m_runControlCreator;
|
||||
ToolStarter m_toolStarter;
|
||||
ToolStarter m_customToolStarter;
|
||||
ToolPreparer m_toolPreparer;
|
||||
};
|
||||
|
||||
|
@@ -82,12 +82,11 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action->setToolId(QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter([tool] { tool->startRemoteTool(); });
|
||||
action->setCustomToolStarter([tool] { tool->startRemoteTool(); });
|
||||
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
action->setToolTip(description);
|
||||
action->setUseSpecialStart();
|
||||
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
|
@@ -213,12 +213,11 @@ void ValgrindPlugin::extensionsInitialized()
|
||||
action->setToolId("Memcheck");
|
||||
action->setWidgetCreator(mcWidgetCreator);
|
||||
action->setRunControlCreator(mcRunControlCreator);
|
||||
action->setToolStarter([] { customStart(MemcheckRunMode); });
|
||||
action->setCustomToolStarter([] { customStart(MemcheckRunMode); });
|
||||
action->setRunMode(MemcheckRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
|
||||
action->setToolTip(memcheckToolTip);
|
||||
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
action->setUseSpecialStart();
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
@@ -226,12 +225,11 @@ void ValgrindPlugin::extensionsInitialized()
|
||||
action->setToolId(CallgrindToolId);
|
||||
action->setWidgetCreator(cgWidgetCreator);
|
||||
action->setRunControlCreator(cgRunControlCreator);
|
||||
action->setToolStarter([] { customStart(CallgrindRunMode); });
|
||||
action->setCustomToolStarter([] { customStart(CallgrindRunMode); });
|
||||
action->setRunMode(CallgrindRunMode);
|
||||
action->setText(tr("Valgrind Function Profiler (External Remote Application)"));
|
||||
action->setToolTip(callgrindToolTip);
|
||||
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
action->setUseSpecialStart();
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
// If there is a CppEditor context menu add our own context menu actions.
|
||||
|
Reference in New Issue
Block a user