forked from qt-creator/qt-creator
Analyzer: Reduce explicit use of StartMode enum
Change-Id: I27b1d06395dea940c8dd39cd2bd41fc09cee3a9c Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -53,7 +53,6 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
auto tool = new QmlProfilerTool(this);
|
||||
auto toolStarter = [tool](StartMode mode) { return tool->startTool(mode); };
|
||||
auto widgetCreator = [tool] { return tool->createWidgets(); };
|
||||
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) {
|
||||
@@ -71,7 +70,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action->setToolId(QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter(toolStarter);
|
||||
action->setToolStarter([tool] { tool->startLocalTool(); });
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler"));
|
||||
action->setToolTip(description);
|
||||
@@ -84,7 +83,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action->setToolId(QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter(toolStarter);
|
||||
action->setToolStarter([tool] { tool->startRemoteTool(); });
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
action->setToolTip(description);
|
||||
|
||||
@@ -486,8 +486,32 @@ void QmlProfilerTool::clearDisplay()
|
||||
updateTimeDisplay();
|
||||
}
|
||||
|
||||
static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
|
||||
void QmlProfilerTool::startLocalTool()
|
||||
{
|
||||
if (d->m_recordButton->isChecked()) {
|
||||
if (!checkForUnsavedNotes())
|
||||
return;
|
||||
clearData(); // clear right away to suppress second warning on server recording change
|
||||
}
|
||||
|
||||
// Make sure mode is shown.
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
Project *pro = SessionManager::startupProject();
|
||||
ProjectExplorerPlugin::runProject(pro, QmlProfilerRunMode);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::startRemoteTool()
|
||||
{
|
||||
if (d->m_recordButton->isChecked()) {
|
||||
if (!checkForUnsavedNotes())
|
||||
return;
|
||||
clearData(); // clear right away to suppress second warning on server recording change
|
||||
}
|
||||
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
Id kitId;
|
||||
quint16 port;
|
||||
Kit *kit = 0;
|
||||
@@ -514,7 +538,7 @@ static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
|
||||
}
|
||||
|
||||
AnalyzerStartParameters sp;
|
||||
sp.startMode = mode;
|
||||
sp.startMode = StartRemote;
|
||||
|
||||
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
||||
if (device) {
|
||||
@@ -524,32 +548,10 @@ static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
|
||||
sp.sysroot = SysRootKitInformation::sysRoot(kit).toString();
|
||||
sp.analyzerPort = port;
|
||||
|
||||
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
|
||||
|
||||
AnalyzerRunControl *rc = createRunControl(sp, 0);
|
||||
ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::startTool(StartMode mode)
|
||||
{
|
||||
if (d->m_recordButton->isChecked()) {
|
||||
if (!checkForUnsavedNotes())
|
||||
return;
|
||||
else
|
||||
clearData(); // clear right away to suppress second warning on server recording change
|
||||
}
|
||||
|
||||
// Make sure mode is shown.
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
if (mode == StartLocal) {
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
Project *pro = SessionManager::startupProject();
|
||||
ProjectExplorerPlugin::instance()->runProject(pro, QmlProfilerRunMode);
|
||||
} else if (mode == StartRemote) {
|
||||
Internal::startRemoteTool(this, mode);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerTool::logState(const QString &msg)
|
||||
{
|
||||
MessageManager::write(msg, MessageManager::Flash);
|
||||
|
||||
@@ -58,7 +58,8 @@ public:
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
|
||||
QWidget *createWidgets();
|
||||
void startTool(Analyzer::StartMode mode);
|
||||
void startLocalTool();
|
||||
void startRemoteTool();
|
||||
|
||||
QList <QAction *> profilerContextMenuActions() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user