forked from qt-creator/qt-creator
Analyzer: Add prepare step to tool starting.
The toolPreparer can do a last minute check and stop the execution of the actual tool. The QML profiler uses this to check for unsaved notes. Change-Id: I5185430f50ffb01e9854cafa442f0eaaad27fa5d Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -97,6 +97,9 @@ void AnalyzerAction::startTool()
|
||||
|
||||
TaskHub::clearTasks(Constants::ANALYZERTASK_ID);
|
||||
|
||||
if (m_toolPreparer && !m_toolPreparer())
|
||||
return;
|
||||
|
||||
// Custom start.
|
||||
if (m_toolStarter) {
|
||||
m_toolStarter();
|
||||
|
@@ -110,6 +110,10 @@ public:
|
||||
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; }
|
||||
|
||||
protected:
|
||||
bool m_useStartupProject;
|
||||
Core::Id m_menuGroup;
|
||||
@@ -120,6 +124,7 @@ protected:
|
||||
WidgetCreator m_widgetCreator;
|
||||
RunControlCreator m_runControlCreator;
|
||||
ToolStarter m_toolStarter;
|
||||
ToolPreparer m_toolPreparer;
|
||||
};
|
||||
|
||||
} // namespace Analyzer
|
||||
|
@@ -70,7 +70,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action->setToolId(QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter([tool] { tool->startLocalTool(); });
|
||||
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler"));
|
||||
action->setToolTip(description);
|
||||
@@ -83,6 +83,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter([tool] { tool->startRemoteTool(); });
|
||||
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
action->setToolTip(description);
|
||||
|
@@ -433,29 +433,21 @@ void QmlProfilerTool::clearDisplay()
|
||||
updateTimeDisplay();
|
||||
}
|
||||
|
||||
void QmlProfilerTool::startLocalTool()
|
||||
bool QmlProfilerTool::prepareTool()
|
||||
{
|
||||
if (d->m_recordButton->isChecked()) {
|
||||
if (!checkForUnsavedNotes())
|
||||
return;
|
||||
if (checkForUnsavedNotes()) {
|
||||
clearData(); // clear right away to suppress second warning on server recording change
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure mode is shown.
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
ProjectExplorerPlugin::runStartupProject(QmlProfilerRunMode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@@ -58,7 +58,7 @@ public:
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
|
||||
QWidget *createWidgets();
|
||||
void startLocalTool();
|
||||
bool prepareTool();
|
||||
void startRemoteTool();
|
||||
|
||||
QList <QAction *> profilerContextMenuActions() const;
|
||||
|
Reference in New Issue
Block a user