From 3e0183a1706aaf7036483820a12dc50f4bd82ddc Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Tue, 29 Jun 2021 10:19:21 -0400 Subject: [PATCH] Enable back USBMS prompt Really, I could've just checked the battery state to know whether an USB cable was plugged in... --- mainwindow.cpp | 18 ++++++++---------- mainwindow.h | 1 + reader.cpp | 15 +++++++++++---- usbms_splash.cpp | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index a2844a7..22b0a47 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -316,11 +316,15 @@ MainWindow::MainWindow(QWidget *parent) connect(usbmsPrompt, &QTimer::timeout, [&]() { if(checkconfig("/opt/inkbox_genuine") == true) { if(global::usbms::showUsbmsDialog != true) { - ; + string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status"); + if(usbmsStatus != checkconfig_str_val) { + global::usbms::showUsbmsDialog = true; + } } else { - string_checkconfig_ro("/sys/devices/platform/fsl-usb2-udc/gadget/suspended"); - if(checkconfig_str_val != "0\n") { + string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status"); + usbmsStatus = checkconfig_str_val; + if(usbmsStatus != "Charging\n") { // Loop again... ; } @@ -335,13 +339,7 @@ MainWindow::MainWindow(QWidget *parent) ; } } ); - // **** FEATURE WARNING **** - // Due to the fsl-usb2-udc/gadget/suspended 'file' which really only changes after a real plug/unplug of the USB cable, further development on this feature is no longer possible and is abandoned unless a fix is found. - // Problem encontered: it would prompt to connect after a fresh reboot even if no USB cable was plugged in. - // - // usbmsPrompt->start(); - // - // **** FEATURE WARNING **** + usbmsPrompt->start(); // We set the brightness level saved in the config file QTimer::singleShot(2000, this, SLOT(setInitialBrightness())); diff --git a/mainwindow.h b/mainwindow.h index fd00ea5..04dba0d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -42,6 +42,7 @@ public: bool reboot_after_update = false; int timerTime = 0; QString relative_path; + QString usbmsStatus; void openLowBatteryDialog(); void openCriticalBatteryAlertWindow(); diff --git a/reader.cpp b/reader.cpp index 37a2aa0..d62b9ac 100644 --- a/reader.cpp +++ b/reader.cpp @@ -344,10 +344,17 @@ reader::reader(QWidget *parent) : writeconfig_pagenumber(); } else { - // Retrieve split_total from tmpfs - string_checkconfig("/tmp/inkboxPageNumber"); - split_total = checkconfig_str_val.toInt(); - setup_book(book_file, 0, true); + // TEMPORARY [ + if(global::reader::bookIsEpub == true) { + quit_restart(); + } + // TEMPORARY ] + else { + // Retrieve split_total from tmpfs + string_checkconfig("/tmp/inkboxPageNumber"); + split_total = checkconfig_str_val.toInt(); + setup_book(book_file, 0, true); + } } // Get text; no need to do it multiple times for ePUB books diff --git a/usbms_splash.cpp b/usbms_splash.cpp index ff77aad..5b6fdeb 100644 --- a/usbms_splash.cpp +++ b/usbms_splash.cpp @@ -64,7 +64,7 @@ usbms_splash::usbms_splash(QWidget *parent) : void usbms_splash::usbms_launch() { - zeroBrightness(); + cinematicBrightness(0, 1); QString umount_prog ("umount"); QStringList umount_args;