forked from qt-creator/qt-creator
QmlProject: Add trace point to qmlproject
We use the qmldesignerplugin, if the qmldesigner plugin is disabled then nothing is traced. Task-number: QDS-10010 Change-Id: Ifa7f7719efca6a757e69b75937368d7a69a5e460 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -19,6 +19,10 @@
|
||||
#include <qmlprojectmanager/qmlproject.h>
|
||||
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QAction>
|
||||
@@ -36,6 +40,27 @@ namespace QmlProjectManager {
|
||||
|
||||
namespace GenerateCmake {
|
||||
|
||||
static bool isQmlDesigner(const ExtensionSystem::PluginSpec *spec)
|
||||
{
|
||||
if (!spec)
|
||||
return false;
|
||||
|
||||
return spec->name().contains("QmlDesigner");
|
||||
}
|
||||
|
||||
static void trackUsage(const QString &id)
|
||||
{
|
||||
const auto plugins = ExtensionSystem::PluginManager::plugins();
|
||||
const auto it = std::find_if(plugins.begin(), plugins.end(), &isQmlDesigner);
|
||||
if (it != plugins.end()) {
|
||||
QObject *qmlDesignerPlugin = (*it)->plugin();
|
||||
QMetaObject::invokeMethod(qmlDesignerPlugin,
|
||||
"usageStatisticsNotifier",
|
||||
Qt::DirectConnection,
|
||||
Q_ARG(QString, id));
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const GeneratableFile &left, const GeneratableFile &right)
|
||||
{
|
||||
return (left.filePath == right.filePath && left.content == right.content);
|
||||
@@ -99,6 +124,8 @@ void generateMenuEntry(QObject *parent)
|
||||
|
||||
void onGenerateCmakeLists()
|
||||
{
|
||||
trackUsage("generateCMakeProjectDialogOpened");
|
||||
|
||||
FilePath rootDir = ProjectExplorer::SessionManager::startupProject()->projectDirectory();
|
||||
|
||||
int projectDirErrors = isProjectCorrectlyFormed(rootDir);
|
||||
@@ -121,6 +148,8 @@ void onGenerateCmakeLists()
|
||||
cmakeGen.filterFileQueue(confirmedFiles);
|
||||
cmakeGen.execute();
|
||||
}
|
||||
|
||||
trackUsage("generateCMakeProjectExecuted");
|
||||
}
|
||||
|
||||
bool isErrorFatal(int error)
|
||||
|
||||
Reference in New Issue
Block a user