Add --disable-telemetry command-line option

This commit is contained in:
Floris Bos 2020-12-07 13:57:21 +01:00
parent 0f2561cf13
commit 78276cffb7
3 changed files with 26 additions and 15 deletions

View file

@ -128,18 +128,18 @@ The download counts are retained for 90 days and the last 1,500 requests to the
On Windows, you can opt out of telemetry by disabling it in the Registry:
```
reg add "HKCU\Software\Raspberry Pi\Imager\General" /v telemetry /t REG_DWORD /d 0
reg add "HKCU\Software\Raspberry Pi\Imager" /v telemetry /t REG_DWORD /d 0
```
On Linux, add the following to `~/.config/Raspberry Pi/Imager.conf`:
On Linux, run `rpi-imager --disable-telemetry` or add the following to `~/.config/Raspberry Pi/Imager.conf`:
```ini
[%General]
telemetry=0
[General]
telemetry=false
```
On macOS, disable it by editing the property list for the application:
```
defaults write org.raspberrypi.Imager.plist General.telemetry -bool NO
defaults write org.raspberrypi.Imager.plist telemetry -bool NO
```

View file

@ -431,7 +431,7 @@ void ImageWriter::openFileDialog()
{
#ifndef QT_NO_WIDGETS
QSettings settings;
QString path = settings.value("General/lastpath").toString();
QString path = settings.value("lastpath").toString();
QFileInfo fi(path);
if (path.isEmpty() || !fi.exists() || !fi.isReadable() )
@ -466,9 +466,9 @@ void ImageWriter::onFileSelected(QString filename)
if (fi.isFile())
{
QString path = fi.path();
if (path != settings.value("General/lastpath"))
if (path != settings.value("lastpath"))
{
settings.setValue("General/lastpath", path);
settings.setValue("lastpath", path);
settings.sync();
}

View file

@ -61,6 +61,7 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
QTranslator translator;
QString customQm;
QSettings settings;
/* Parse commandline arguments (if any) */
QString customRepo;
@ -144,7 +145,7 @@ int main(int argc, char *argv[])
}
else if (args[i] == "--help")
{
cerr << args[0] << " [--debug] [--version] [--repo <repository URL>] [--qm <custom qm translation file>] [<image file to write>]" << endl;
cerr << args[0] << " [--debug] [--version] [--repo <repository URL>] [--qm <custom qm translation file>] [--disable-telemetry] [<image file to write>]" << endl;
return 0;
}
else if (args[i] == "--version")
@ -153,6 +154,18 @@ int main(int argc, char *argv[])
cerr << "Repository: " << imageWriter.constantOsListUrl().toString() << endl;
return 0;
}
else if (args[i] == "--disable-telemetry")
{
cerr << "Disabled telemetry" << endl;
settings.setValue("telemetry", false);
settings.sync();
}
else if (args[i] == "--enable-telemetry")
{
cerr << "Using default telemetry setting" << endl;
settings.remove("telemetry");
settings.sync();
}
else
{
cerr << "Ignoring unknown argument: " << args[i] << endl;
@ -193,12 +206,10 @@ int main(int argc, char *argv[])
qmlwindow->connect(&imageWriter, SIGNAL(networkOnline()), qmlwindow, SLOT(fetchOSlist()));
#ifndef QT_NO_WIDGETS
QSettings settings;
/* Set window position */
auto screensize = app.primaryScreen()->geometry();
int x = settings.value("General/x", -1).toInt();
int y = settings.value("General/y", -1).toInt();
int x = settings.value("x", -1).toInt();
int y = settings.value("y", -1).toInt();
int w = qmlwindow->property("width").toInt();
int h = qmlwindow->property("height").toInt();
@ -228,8 +239,8 @@ int main(int argc, char *argv[])
int newY = qmlwindow->property("y").toInt();
if (x != newX || y != newY)
{
settings.setValue("General/x", newX);
settings.setValue("General/y", newY);
settings.setValue("x", newX);
settings.setValue("y", newY);
settings.sync();
}
#endif