From 4f104c6ca393acd849e114da980c23461e7106a8 Mon Sep 17 00:00:00 2001 From: Szybet <53944559+Szybet@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:37:47 +0100 Subject: [PATCH] lost code - option to disable automatic updates and showing usb mass dialog --- src/homeWidget/mainwindow.cpp | 71 +- src/settings/settings.cpp | 39 ++ src/settings/settings.h | 4 + src/settings/settings.ui | 1224 +++++++++++++++++---------------- 4 files changed, 708 insertions(+), 630 deletions(-) diff --git a/src/homeWidget/mainwindow.cpp b/src/homeWidget/mainwindow.cpp index 4b3406f..93fffe2 100644 --- a/src/homeWidget/mainwindow.cpp +++ b/src/homeWidget/mainwindow.cpp @@ -340,40 +340,55 @@ MainWindow::MainWindow(QWidget *parent) } } - // Check for an update and ask if the user wants to install it - checkForUpdate(); - // Check for an OTA update - QTimer::singleShot(1000, this, SLOT(checkForOtaUpdate())); + // OTA updates + QString checkConfigPath = ".config/23-updates/check-updates"; + if(QFile(checkConfigPath).exists() == false) { + string_writeconfig(checkConfigPath.toStdString(), "true"); + } + + if(checkconfig(checkConfigPath) == true) { + // Check for an update and ask if the user wants to install it + checkForUpdate(); + // Check for an OTA update + QTimer::singleShot(1000, this, SLOT(checkForOtaUpdate())); + } // USB mass storage prompt - QTimer *usbmsPrompt = new QTimer(this); - usbmsPrompt->setInterval(500); - connect(usbmsPrompt, &QTimer::timeout, [&]() { - if(checkconfig("/opt/inkbox_genuine") == true) { - if(global::usbms::showUsbmsDialog != true) { - if(isUsbPluggedIn() != usbmsStatus) { - global::usbms::showUsbmsDialog = true; + QString usbConfigPath = ".config/22-usb/show-dialog"; + if(QFile(usbConfigPath).exists() == false) { + string_writeconfig(usbConfigPath.toStdString(), "true"); + } + + if(checkconfig(usbConfigPath) == true) { + QTimer *usbmsPrompt = new QTimer(this); + usbmsPrompt->setInterval(500); + connect(usbmsPrompt, &QTimer::timeout, [&]() { + if(checkconfig("/opt/inkbox_genuine") == true) { + if(global::usbms::showUsbmsDialog != true) { + if(isUsbPluggedIn() != usbmsStatus) { + global::usbms::showUsbmsDialog = true; + } + } + else { + usbmsStatus = isUsbPluggedIn(); + if(usbmsStatus == false) { + // Loop again... + ; + } + else { + // An USB cable is connected! + setBatteryIcon(); + openUsbmsDialog(); + } } } else { - usbmsStatus = isUsbPluggedIn(); - if(usbmsStatus == false) { - // Loop again... - ; - } - else { - // An USB cable is connected! - setBatteryIcon(); - openUsbmsDialog(); - } + // Do nothing, we're running along with Nickel & friends... + ; } - } - else { - // Do nothing, we're running along with Nickel & friends... - ; - } - } ); - usbmsPrompt->start(); + } ); + usbmsPrompt->start(); + } // If the DEVKEY file is present, install a developer key if(QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY") == true && QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY.dgst") == true) { diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index fd6ff55..deaef05 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -60,6 +60,9 @@ settings::settings(QWidget *parent) : ui->repackBtn->setStyleSheet("font-size: 9pt"); ui->exportHighlightsBtn->setStyleSheet("font-size: 9pt"); ui->uiScaleNumberLabel->setStyleSheet("font-size: 9pt; font-weight: bold"); + ui->autoCheckUpdatesBox->setStyleSheet("font-size: 9pt"); + ui->usbMsDialogBox->setStyleSheet("font-size: 9pt"); + if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") { ui->previousBtn->setStyleSheet("padding: 7.5px;"); ui->nextBtn->setStyleSheet("padding: 7.5px;"); @@ -343,6 +346,16 @@ settings::settings(QWidget *parent) : ui->localLibraryShowFoldersCheckBox->click(); } + // USB show dialog + if(checkconfig(".config/22-usb/show-dialog") == true) { + ui->usbMsDialogBox->click(); + } + + // Automatic updates + if(checkconfig(".config/23-updates/check-updates") == true) { + ui->autoCheckUpdatesBox->click(); + } + if(checkconfig("/opt/inkbox_genuine") == true) { // Enforcing security policy if the user has not rooted the device if(checkconfig("/external_root/opt/root/rooted") == true) { @@ -1110,3 +1123,29 @@ void settings::on_localLibraryShowFoldersCheckBox_toggled(bool checked) } } + +void settings::on_usbMsDialogBox_clicked(bool checked) +{ + QString settingString = "Show USB Mass storage dialog"; + if(checked == true) { + logEnabled(settingString, className); + string_writeconfig(".config/22-usb/show-dialog", "true"); + } + else { + logDisabled(settingString, className); + string_writeconfig(".config/22-usb/show-dialog", "false"); + } +} + +void settings::on_autoCheckUpdatesBox_clicked(bool checked) +{ + QString settingString = "Automatically check updates"; + if(checked == true) { + logEnabled(settingString, className); + string_writeconfig(".config/23-updates/check-updates", "true"); + } + else { + logDisabled(settingString, className); + string_writeconfig(".config/23-updates/check-updates", "false"); + } +} diff --git a/src/settings/settings.h b/src/settings/settings.h index 0fa66e4..5e94731 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -78,6 +78,10 @@ private slots: void on_localLibraryShowFoldersCheckBox_toggled(bool checked); + void on_usbMsDialogBox_clicked(bool checked); + + void on_autoCheckUpdatesBox_clicked(bool checked); + signals: void showToast(QString messageToDisplay); void closeIndefiniteToast(); diff --git a/src/settings/settings.ui b/src/settings/settings.ui index 64d1939..c8c36fb 100644 --- a/src/settings/settings.ui +++ b/src/settings/settings.ui @@ -68,8 +68,8 @@ 0 0 - 463 - 632 + 457 + 667 @@ -118,6 +118,418 @@ 0 + + + + Clock: Show seconds + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 0 + 0 + + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + Global reading settings + + + + + + + Disable authors quotes + + + + + + + 0 + + + + + Export highlights + + + + + + + + 75 + true + + + + Export + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Show scroll bar if needed + + + + + + + + Chivo + 50 + true + false + + + + Storage + + + + + + + 0 + + + + + + + + + :/resources/plus.png:/resources/plus.png + + + + + + + 30 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Words number/page (plain text files) + + + + + + + + + + + :/resources/minus.png:/resources/minus.png + + + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + + Chivo + true + + + + Local library + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + Show folders + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Enter USB Mass Storage session + + + + + + + + 75 + true + + + + Go + + + + + + + Show USB Mass Storage dialog + + + + + + + + + + Chivo + 50 + true + false + + + + Home + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Request DHCP lease + + + + + + + + 75 + true + + + + Request + + + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + Always show status bar + + + + + + + 0 + + + + + Screen refresh + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Every page + + + + + 1 page + + + + + 2 pages + + + + + 3 pages + + + + + 4 pages + + + + + 5 pages + + + + + 6 pages + + + + + Never refresh + + + + + + + + + + Disable "Welcome to InkBox" message + + + @@ -245,374 +657,6 @@ - - - - Clock: Show seconds - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - - Chivo - true - - - - Local library - - - - - - - Show scroll bar if needed - - - - - - - Global reading settings - - - - - - - 0 - - - - - - 75 - true - - - - Go - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Enter USB Mass Storage session - - - - - - - - - Always show status bar - - - - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Request DHCP lease - - - - - - - - 75 - true - - - - Request - - - - - - - - - 0 - - - - - Export highlights - - - - - - - - 75 - true - - - - Export - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Disable authors quotes - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 0 - 0 - - - - - - - - - Chivo - 50 - true - false - - - - Home - - - - - - - 0 - - - - - - - - - :/resources/plus.png:/resources/plus.png - - - - - - - 30 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Words number/page (plain text files) - - - - - - - - - - - :/resources/minus.png:/resources/minus.png - - - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - 0 - - - - - Screen refresh - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Every page - - - - - 1 page - - - - - 2 pages - - - - - 3 pages - - - - - 4 pages - - - - - 5 pages - - - - - 6 pages - - - - - Never refresh - - - - - - - - - - - Chivo - 50 - true - false - - - - Storage - - - - - - - Disable "Welcome to InkBox" message - - - @@ -626,43 +670,6 @@ - - - - Show folders - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - @@ -686,8 +693,8 @@ 0 - - + + QFrame::Plain @@ -696,100 +703,7 @@ - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Repack - - - - - - - - 75 - true - - - - Repack - - - - - - - - - 0 - - - - - Check for updates - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Check - - - - - - - - - - Chivo - true - - - - System - - - - + 0 @@ -829,7 +743,14 @@ - + + + + Enable + + + + @@ -842,21 +763,7 @@ - - - - Enable - - - - - - - Enable UI scaling - - - - + @@ -869,57 +776,10 @@ - - - - 0 - - - - - Timezone - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - + + - Enable night mode - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - Enable lock screen and passcode + Enable UI scaling @@ -963,13 +823,23 @@ - - + + + + QFrame::Plain + + + Qt::Horizontal + + + + + 0 - + Qt::Horizontal @@ -982,17 +852,14 @@ - + - Update InkBox - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Check for updates - + 75 @@ -1000,35 +867,12 @@ - Update + Check - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1112,6 +956,93 @@ + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Repack + + + + + + + + 75 + true + + + + Repack + + + + + + + + + Enable lock screen and passcode + + + + + + + 0 + + + + + Timezone + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -1164,6 +1095,95 @@ + + + + + Chivo + true + + + + System + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Enable night mode + + + + + + + 0 + + + + + Update InkBox + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Update + + + + + + + + + + 0 + 0 + + + + Check for updates automatically + + +