Optional telemetry support: First steps

This commit is contained in:
Nicolas Mailloux 2024-01-09 10:18:12 -05:00
parent 84dcce45bb
commit 7c2c2ed5c9
6 changed files with 87 additions and 38 deletions

View file

@ -229,6 +229,10 @@ namespace global {
inline int volumeLevel = 40; // Default save value
inline bool songChanged = false;
}
namespace telemetry {
inline bool enabled = false;
inline bool telemetryDialog = false;
}
inline QString systemInfoText;
inline bool forbidOpenSearchDialog;
inline bool isN705 = false;

View file

@ -433,6 +433,13 @@ MainWindow::MainWindow(QWidget *parent)
if(checkconfig("/opt/inkbox_genuine") == true) {
writeFile("/external_root/run/inkbox_gui_git_commit", GIT_COMMIT);
}
// Telemetry
if(checkconfig(".config/24-telemetry/enabled") == false && checkconfig(".config/24-telemetry/asked") == false) {
if(testPing() == 0) {
QTimer::singleShot(1000, this, SLOT(openTelemetryDialog()));
}
}
}
MainWindow::~MainWindow()
@ -1083,3 +1090,12 @@ void MainWindow::on_audioBtn_clicked()
QDialog* newAudioDialog = new audioDialog(this);
newAudioDialog->exec();
}
void MainWindow::openTelemetryDialog() {
log("Showing telemetry request dialog", className);
global::telemetry::telemetryDialog = true;
generalDialogWindow = new generalDialog(this);
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
QApplication::processEvents();
}

View file

@ -103,6 +103,7 @@ private slots:
void setupHomePageWidget();
void launchOnlineLibrary();
void on_audioBtn_clicked();
void openTelemetryDialog();
private:
Ui::MainWindow * ui;

View file

@ -1117,36 +1117,42 @@ void settings::on_settingsStackedWidget_currentChanged(int arg1)
void settings::on_readingSettingsBtn_clicked()
{
log("'Reading settings' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(1);
}
void settings::on_homeSettingsBtn_clicked()
{
log("'Home settings' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(2);
}
void settings::on_librarySettingsBtn_clicked()
{
log("'Library settings' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(3);
}
void settings::on_storageSettingsBtn_clicked()
{
log("'Storage settings' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(4);
}
void settings::on_systemSettingsBtn_clicked()
{
log("'System settings' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(5);
}
void settings::on_securitySettingsBtn_clicked()
{
log("'Security settings' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(6);
}
@ -1154,5 +1160,6 @@ void settings::on_securitySettingsBtn_clicked()
void settings::on_headerBtn_clicked()
{
// "Home" button
log("'Home' button clicked", className);
ui->settingsStackedWidget->setCurrentIndex(0);
}

View file

@ -226,16 +226,19 @@ generalDialog::generalDialog(QWidget *parent) :
ui->headerLabel->setText("Sync required");
QTimer::singleShot(50, this, SLOT(adjust_size()));
}
else if(global::telemetry::telemetryDialog == true) {
telemetryDialog = true;
ui->stackedWidget->setCurrentIndex(0);
ui->okBtn->setText("Send");
ui->cancelBtn->setText("Don't send");
ui->bodyLabel->setText("<font face='u001'>We, InkBox OS developers, would like to know a bit more about our userbase.<br>We will be extremely grateful if you allow us to collect some information about your device.<br>Would you like to send it to us</font><font face='Inter'>?</font><font face='u001'><br>No personal data will be transmitted.</font>");
ui->headerLabel->setText("Telemetry request");
QTimer::singleShot(50, this, SLOT(adjust_size()));
}
else {
// We shouldn't be there ;)
log("Launched without settings", className);
}
// Centering dialog
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
int x = (screenGeometry.width() - this->width()) / 2;
int y = (screenGeometry.height() - this->height()) / 2;
this->move(x, y);
}
generalDialog::~generalDialog()
@ -301,6 +304,11 @@ void generalDialog::on_cancelBtn_clicked()
emit noSyncOnlineLibrary();
global::library::librarySyncDialog = false;
}
else if(global::telemetry::telemetryDialog == true) {
global::telemetry::telemetryDialog = false;
log("User declined telemetry request", className);
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
}
generalDialog::close();
}
}
@ -570,6 +578,11 @@ void generalDialog::on_okBtn_clicked()
global::library::librarySyncDialog = false;
generalDialog::close();
}
else if(global::telemetry::telemetryDialog == true) {
global::telemetry::telemetryDialog = false;
generalDialog::close();
}
}
void generalDialog::on_acceptBtn_clicked()
{
@ -608,10 +621,17 @@ void generalDialog::on_acceptBtn_clicked()
}
void generalDialog::adjust_size() {
float widthProportion = 2;
float heightProportion = 2;
if(telemetryDialog) {
widthProportion = 2.8;
heightProportion = 2.6;
}
this->adjustSize();
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
int x = (screenGeometry.width() - this->width()) / 2;
int y = (screenGeometry.height() - this->height()) / 2;
int x = (screenGeometry.width() - this->width()) / widthProportion;
int y = (screenGeometry.height() - this->height()) / heightProportion;
this->move(x, y);
this->show();
emit refreshScreen();

View file

@ -38,6 +38,7 @@ public:
bool keyboardDialog = false;
bool keypadDialog = false;
bool librarySyncDialog = false;
bool telemetryDialog = false;
bool dictionaryResults = false;
bool vncServerSet = false;
bool vncPasswordSet = false;