diff --git a/src/functions.h b/src/functions.h index 335ee2a..17818a8 100644 --- a/src/functions.h +++ b/src/functions.h @@ -199,36 +199,40 @@ namespace global { }; } namespace audio { - inline bool enabled = false; - struct musicFile { - QString path; - QString name; // Cut path for easier use in names - int lengths; // length Seconds - QString length; // In minutes:seconds - int id; - }; - // 'None' is when 'currentAction' is empty - enum class Action { // Function will be called with this enum - Play, - Next, - Previous, - Pause, - Continue, - Stop, // Sets 'paused' to false, 'isSomethingCurrentlyPlaying' to false, and 'itemCurrentlyPlaying' to -1; also stops playing - SetVolume, - }; - inline QVector currentAction; - inline QVector queue; - inline QVector fileList; - inline int itemCurrentlyPlaying = -1; // Also indicates in the queue menu which a gray color which is playing - inline QMutex audioMutex; // These variables will be shared between threads, so here, it's to protect it - inline int progressSeconds = -5; // -5 at default to avoid cutting song too early... yea - inline bool paused = false; - inline bool isSomethingCurrentlyPlaying = false; // Pause and continue - inline bool firstScan = true; - inline int volumeLevel = 40; // Default save value - inline bool songChanged = false; - } + inline bool enabled = false; + struct musicFile { + QString path; + QString name; // Cut path for easier use in names + int lengths; // length Seconds + QString length; // In minutes:seconds + int id; + }; + // 'None' is when 'currentAction' is empty + enum class Action { // Function will be called with this enum + Play, + Next, + Previous, + Pause, + Continue, + Stop, // Sets 'paused' to false, 'isSomethingCurrentlyPlaying' to false, and 'itemCurrentlyPlaying' to -1; also stops playing + SetVolume, + }; + inline QVector currentAction; + inline QVector queue; + inline QVector fileList; + inline int itemCurrentlyPlaying = -1; // Also indicates in the queue menu which a gray color which is playing + inline QMutex audioMutex; // These variables will be shared between threads, so here, it's to protect it + inline int progressSeconds = -5; // -5 at default to avoid cutting song too early... yea + inline bool paused = false; + inline bool isSomethingCurrentlyPlaying = false; // Pause and continue + inline bool firstScan = true; + 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; diff --git a/src/homeWidget/mainwindow.cpp b/src/homeWidget/mainwindow.cpp index e85ec58..b612d7d 100644 --- a/src/homeWidget/mainwindow.cpp +++ b/src/homeWidget/mainwindow.cpp @@ -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(); +} diff --git a/src/homeWidget/mainwindow.h b/src/homeWidget/mainwindow.h index 4409298..676fcbb 100644 --- a/src/homeWidget/mainwindow.h +++ b/src/homeWidget/mainwindow.h @@ -103,6 +103,7 @@ private slots: void setupHomePageWidget(); void launchOnlineLibrary(); void on_audioBtn_clicked(); + void openTelemetryDialog(); private: Ui::MainWindow * ui; diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index ef38bbc..96b3e6b 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -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); } diff --git a/src/widgets/dialogs/generaldialog.cpp b/src/widgets/dialogs/generaldialog.cpp index 3834ebb..f20dd5d 100644 --- a/src/widgets/dialogs/generaldialog.cpp +++ b/src/widgets/dialogs/generaldialog.cpp @@ -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("We, InkBox OS developers, would like to know a bit more about our userbase.
We will be extremely grateful if you allow us to collect some information about your device.
Would you like to send it to us
?
No personal data will be transmitted.
"); + 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(); diff --git a/src/widgets/dialogs/generaldialog.h b/src/widgets/dialogs/generaldialog.h index ae592fb..500602e 100644 --- a/src/widgets/dialogs/generaldialog.h +++ b/src/widgets/dialogs/generaldialog.h @@ -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;