1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qdseventshandler.h"
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <qmldesigner/qmldesignerplugin.h>
namespace UsageStatistic::Internal {
static bool isQmlDesigner(const ExtensionSystem::PluginSpec *spec)
{
if (!spec)
return false;
return spec->name().contains("QmlDesigner");
}
QDSEventsHandler::QDSEventsHandler(QInsightTracker* tracker)
{
using QmlDesigner::QmlDesignerPlugin;
const auto plugins = ExtensionSystem::PluginManager::plugins();
const auto it = std::find_if(plugins.begin(), plugins.end(), &isQmlDesigner);
const QmlDesignerPlugin* qmlDesignerPlugin = qobject_cast<QmlDesignerPlugin*>((*it)->plugin());
connect(qmlDesignerPlugin,
&QmlDesignerPlugin::usageStatisticsNotifier,
this,
[&](QString identifier){
tracker->interaction(identifier);
});
connect(qmlDesignerPlugin,
&QmlDesignerPlugin::usageStatisticsUsageTimer,
this,
[&](QString identifier, int elapsed){
tracker->transition(identifier);
});
connect(qmlDesignerPlugin,
&QmlDesignerPlugin::usageStatisticsUsageDuration,
this,
[&](QString identifier){
tracker->interaction(identifier);
});
connect(qmlDesignerPlugin,
&QmlDesignerPlugin::usageStatisticsInsertFeedback,
this,
[&](QString identifier, QString feedback, int rating){
QString textFeedback = "Feedback: ";
if (feedback.isEmpty())
textFeedback += "empty";
else
textFeedback += feedback;
tracker->interaction(identifier, textFeedback, rating);
});
}
} // namespace UsageStatistic::Internal
|