QmlDesigner: Edit splash screen for Telemetry and Insight

- Change also affects crash reporting

Fixes: QDS-13585
Change-Id: Ia5587016bcb75bab111056166db2a848f0d94682
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Shrief Gabr
2024-09-09 11:43:00 +03:00
parent d9ad1dbac0
commit 2dc3c87758
2 changed files with 8 additions and 57 deletions

View File

@@ -6,7 +6,6 @@ import QtQuick.Layouts 1.15
import StudioFonts 1.0 import StudioFonts 1.0
import projectmodel 1.0 import projectmodel 1.0
import usagestatistics 1.0 import usagestatistics 1.0
import studiousagestatistics 1.0
import QtQuick.Shapes 1.0 import QtQuick.Shapes 1.0
Rectangle { Rectangle {
@@ -160,10 +159,6 @@ Rectangle {
UsageStatisticModel { UsageStatisticModel {
id: usageStatisticModel id: usageStatisticModel
} }
StudioUsageStatisticModel {
id: studioUsageStatisticModel
}
} }
//DOF seems to do nothing, we should probably just remove it. //DOF seems to do nothing, we should probably just remove it.
@@ -207,9 +202,7 @@ Rectangle {
text: qsTr("Turn Off") text: qsTr("Turn Off")
fontpixelSize: 14 fontpixelSize: 14
onClicked: { onClicked: {
studioUsageStatisticModel.setInsightEnabled(false)
usageStatisticModel.setTelemetryEnabled(false) usageStatisticModel.setTelemetryEnabled(false)
usageStatisticModel.setCrashReporterEnabled(false)
welcome_splash.closeClicked() welcome_splash.closeClicked()
} }
} }
@@ -219,9 +212,7 @@ Rectangle {
forceHover: false forceHover: false
fontpixelSize: 14 fontpixelSize: 14
onClicked: { onClicked: {
studioUsageStatisticModel.setInsightEnabled(true)
usageStatisticModel.setTelemetryEnabled(true) usageStatisticModel.setTelemetryEnabled(true)
usageStatisticModel.setCrashReporterEnabled(true)
welcome_splash.closeClicked() welcome_splash.closeClicked()
} }
} }

View File

@@ -87,9 +87,7 @@ static void openOpenProjectDialog()
const char DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY[] = "StudioSplashScreen"; const char DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY[] = "StudioSplashScreen";
const char DETAILED_USAGE_STATISTICS[] = "DetailedUsageStatistics"; const char TELEMETRY_INSIGHT_SETTING[] = "Telemetry";
const char STATISTICS_COLLECTION_MODE[] = "StatisticsCollectionMode";
const char NO_TELEMETRY[] = "NoTelemetry";
const char CRASH_REPORTER_SETTING[] = "CrashReportingEnabled"; const char CRASH_REPORTER_SETTING[] = "CrashReportingEnabled";
QPointer<QQuickView> s_viewWindow = nullptr; QPointer<QQuickView> s_viewWindow = nullptr;
@@ -157,40 +155,24 @@ public:
void setupModel() void setupModel()
{ {
auto settings = makeUserFeedbackSettings(); m_usageStatisticEnabled = Core::ICore::settings()->value(TELEMETRY_INSIGHT_SETTING, false).toBool();
QVariant value = settings->value(STATISTICS_COLLECTION_MODE);
m_usageStatisticEnabled = value.isValid() && value.toString() == DETAILED_USAGE_STATISTICS;
m_crashReporterEnabled = Core::ICore::settings()->value(CRASH_REPORTER_SETTING, false).toBool(); m_crashReporterEnabled = Core::ICore::settings()->value(CRASH_REPORTER_SETTING, false).toBool();
emit usageStatisticChanged(); emit usageStatisticChanged();
emit crashReporterEnabledChanged(); emit crashReporterEnabledChanged();
} }
Q_INVOKABLE void setCrashReporterEnabled(bool b)
{
if (m_crashReporterEnabled == b)
return;
Core::ICore::settings()->setValue(CRASH_REPORTER_SETTING, b);
Core::ICore::askForRestart(tr("The change will take effect after restart."));
setupModel();
}
Q_INVOKABLE void setTelemetryEnabled(bool b) Q_INVOKABLE void setTelemetryEnabled(bool b)
{ {
if (m_usageStatisticEnabled == b) if (m_usageStatisticEnabled == b && m_crashReporterEnabled == b)
return; return;
auto settings = makeUserFeedbackSettings(); bool restartPending = ICore::askForRestart(tr("The change will take effect after restart."));
settings->setValue(STATISTICS_COLLECTION_MODE, b ? DETAILED_USAGE_STATISTICS : NO_TELEMETRY); ICore::settings()->setValue(TELEMETRY_INSIGHT_SETTING, b);
ICore::settings()->setValue(CRASH_REPORTER_SETTING, b);
Core::ICore::askForRestart(tr("The change will take effect after restart.")); if (restartPending)
ICore::restart();
setupModel();
} }
signals: signals:
@@ -203,27 +185,6 @@ private:
QString m_versionString; QString m_versionString;
}; };
class StudioUsageStatisticPluginModel : public QObject
{
Q_OBJECT
public:
explicit StudioUsageStatisticPluginModel(QObject *parent = nullptr)
: QObject(parent)
{
}
Q_INVOKABLE void setInsightEnabled(bool b)
{
bool currentTrackingStatus = Core::ICore::settings()->value("InsightTracking", false).toBool();
if (currentTrackingStatus == b)
return;
Core::ICore::settings()->setValue("InsightTracking", b);
Core::ICore::askForRestart(tr("The change will take effect after restart."));
}
};
class ProjectModel : public QAbstractListModel class ProjectModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
@@ -599,7 +560,6 @@ void StudioWelcomePlugin::initialize()
{ {
qmlRegisterType<ProjectModel>("projectmodel", 1, 0, "ProjectModel"); qmlRegisterType<ProjectModel>("projectmodel", 1, 0, "ProjectModel");
qmlRegisterType<UsageStatisticPluginModel>("usagestatistics", 1, 0, "UsageStatisticModel"); qmlRegisterType<UsageStatisticPluginModel>("usagestatistics", 1, 0, "UsageStatisticModel");
qmlRegisterType<StudioUsageStatisticPluginModel>("studiousagestatistics", 1, 0, "StudioUsageStatisticModel");
m_welcomeMode = new WelcomeMode; m_welcomeMode = new WelcomeMode;
} }