mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Misc fixes
This commit is contained in:
parent
3e0183a170
commit
81f179af49
5 changed files with 74 additions and 21 deletions
|
@ -26,6 +26,7 @@ namespace global {
|
|||
inline int bookNumber;
|
||||
inline bool skipOpenDialog;
|
||||
inline bool startBatteryWatchdog;
|
||||
inline bool startUsbmsPrompt;
|
||||
inline bool bookIsEpub;
|
||||
}
|
||||
namespace kobox {
|
||||
|
|
21
main.cpp
21
main.cpp
|
@ -33,6 +33,10 @@ int main(int argc, char *argv[])
|
|||
// Tell scripts that we're currently running
|
||||
string_writeconfig("/tmp/inkbox_running", "true");
|
||||
|
||||
// Variables
|
||||
global::reader::startBatteryWatchdog = false;
|
||||
global::reader::startUsbmsPrompt = false;
|
||||
|
||||
// Checking if battery level is critical; if true (and if it is not charging), then display a "Please charge your eReader" splash and power off.
|
||||
if(isBatteryCritical() == true) {
|
||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
||||
|
@ -62,18 +66,12 @@ int main(int argc, char *argv[])
|
|||
return a.exec();
|
||||
}
|
||||
// If we're waking from sleep and we have the lockscreen enabled, we'll "resume" the book from scratch
|
||||
else if(checkconfig("/tmp/suspendBook") == true) {
|
||||
else if(checkconfig("/tmp/suspendBook") == true && checkconfig("/inkbox/bookIsEpub") == false) {
|
||||
// Start the low/critical battery alert timer from the Reader framework since MainWindow is not going to be shown
|
||||
global::reader::startBatteryWatchdog = true;
|
||||
global::reader::startUsbmsPrompt = true;
|
||||
global::reader::skipOpenDialog = true;
|
||||
|
||||
if(checkconfig("/inkbox/bookIsEpub") == true) {
|
||||
global::reader::bookIsEpub = true;
|
||||
}
|
||||
else {
|
||||
global::reader::bookIsEpub = false;
|
||||
}
|
||||
|
||||
string_writeconfig("/inkbox/skip_opendialog", "true");
|
||||
string_checkconfig_ro("/opt/inkbox_device");
|
||||
if(checkconfig_str_val == "n705\n") {
|
||||
|
@ -105,6 +103,13 @@ int main(int argc, char *argv[])
|
|||
|
||||
}
|
||||
else {
|
||||
if(checkconfig("/inkbox/bookIsEpub") == true) {
|
||||
global::reader::bookIsEpub = true;
|
||||
}
|
||||
else {
|
||||
global::reader::bookIsEpub = false;
|
||||
}
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// USB mass storage prompt
|
||||
QTimer *usbmsPrompt = new QTimer(this);
|
||||
usbmsPrompt->setInterval(2000);
|
||||
usbmsPrompt->setInterval(500);
|
||||
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
if(global::usbms::showUsbmsDialog != true) {
|
||||
|
|
69
reader.cpp
69
reader.cpp
|
@ -344,17 +344,10 @@ reader::reader(QWidget *parent) :
|
|||
writeconfig_pagenumber();
|
||||
}
|
||||
else {
|
||||
// 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);
|
||||
}
|
||||
// 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
|
||||
|
@ -472,7 +465,14 @@ reader::reader(QWidget *parent) :
|
|||
ui->bookInfoLabel->setText(infoLabelContent);
|
||||
}
|
||||
else {
|
||||
QString bookReadRelativePath = book_file.split("/").last();
|
||||
QString bookReadRelativePath;
|
||||
if(wakeFromSleep == true) {
|
||||
string_checkconfig_ro("/tmp/inkboxBookPath");
|
||||
bookReadRelativePath = checkconfig_str_val.split("/").last();
|
||||
}
|
||||
else {
|
||||
bookReadRelativePath = book_file.split("/").last();
|
||||
}
|
||||
ui->bookInfoLabel->setText(bookReadRelativePath);
|
||||
}
|
||||
|
||||
|
@ -519,6 +519,39 @@ reader::reader(QWidget *parent) :
|
|||
string_writeconfig(".config/08-recent_books/4", str_book_3);
|
||||
}
|
||||
|
||||
// USB mass storage prompt
|
||||
if(global::reader::startUsbmsPrompt == true) {
|
||||
QTimer *usbmsPrompt = new QTimer(this);
|
||||
usbmsPrompt->setInterval(500);
|
||||
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/pmic_battery.1/power_supply/mc13892_bat/status");
|
||||
usbmsStatus = checkconfig_str_val;
|
||||
if(usbmsStatus != "Charging\n") {
|
||||
// Loop again...
|
||||
;
|
||||
}
|
||||
else {
|
||||
// An USB cable is connected!
|
||||
openUsbmsDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Do nothing, we're running along with Nickel & friends...
|
||||
;
|
||||
}
|
||||
} );
|
||||
usbmsPrompt->start();
|
||||
}
|
||||
|
||||
// Battery watchdog
|
||||
if(global::reader::startBatteryWatchdog == true) {
|
||||
QTimer *t = new QTimer(this);
|
||||
|
@ -691,9 +724,11 @@ bool reader::epub_file_match(QString file) {
|
|||
QString fileExt = file.right(4);
|
||||
|
||||
if(fileExt == "epub" or fileExt == "EPUB") {
|
||||
string_writeconfig("/inkbox/bookIsEpub", "true");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/inkbox/bookIsEpub", "false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1412,3 +1447,13 @@ void reader::on_nightModeBtn_clicked()
|
|||
isNightModeActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
void reader::openUsbmsDialog() {
|
||||
global::usbms::showUsbmsDialog = false;
|
||||
global::usbms::usbmsDialog = true;
|
||||
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
generalDialogWindow->show();
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
|
2
reader.h
2
reader.h
|
@ -74,6 +74,7 @@ public:
|
|||
QPixmap scaledEmptyPixmap;
|
||||
QList<QString> content;
|
||||
QString epubPageContent;
|
||||
QString usbmsStatus;
|
||||
|
||||
int setup_book(QString book, int i, bool run_parser);
|
||||
void checkwords();
|
||||
|
@ -91,6 +92,7 @@ public:
|
|||
void setPageStyle();
|
||||
void alignText(int alignment);
|
||||
void delay(int seconds);
|
||||
void openUsbmsDialog();
|
||||
|
||||
private slots:
|
||||
void on_nextBtn_clicked();
|
||||
|
|
Loading…
Reference in a new issue