mirror of
https://github.com/Quill-OS/quill.git
synced 2024-11-01 05:43:21 -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 int bookNumber;
|
||||||
inline bool skipOpenDialog;
|
inline bool skipOpenDialog;
|
||||||
inline bool startBatteryWatchdog;
|
inline bool startBatteryWatchdog;
|
||||||
|
inline bool startUsbmsPrompt;
|
||||||
inline bool bookIsEpub;
|
inline bool bookIsEpub;
|
||||||
}
|
}
|
||||||
namespace kobox {
|
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
|
// Tell scripts that we're currently running
|
||||||
string_writeconfig("/tmp/inkbox_running", "true");
|
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.
|
// 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) {
|
if(isBatteryCritical() == true) {
|
||||||
string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status");
|
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();
|
return a.exec();
|
||||||
}
|
}
|
||||||
// If we're waking from sleep and we have the lockscreen enabled, we'll "resume" the book from scratch
|
// 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
|
// 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::startBatteryWatchdog = true;
|
||||||
|
global::reader::startUsbmsPrompt = true;
|
||||||
global::reader::skipOpenDialog = 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_writeconfig("/inkbox/skip_opendialog", "true");
|
||||||
string_checkconfig_ro("/opt/inkbox_device");
|
string_checkconfig_ro("/opt/inkbox_device");
|
||||||
if(checkconfig_str_val == "n705\n") {
|
if(checkconfig_str_val == "n705\n") {
|
||||||
|
@ -105,6 +103,13 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(checkconfig("/inkbox/bookIsEpub") == true) {
|
||||||
|
global::reader::bookIsEpub = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
global::reader::bookIsEpub = false;
|
||||||
|
}
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
// USB mass storage prompt
|
// USB mass storage prompt
|
||||||
QTimer *usbmsPrompt = new QTimer(this);
|
QTimer *usbmsPrompt = new QTimer(this);
|
||||||
usbmsPrompt->setInterval(2000);
|
usbmsPrompt->setInterval(500);
|
||||||
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
connect(usbmsPrompt, &QTimer::timeout, [&]() {
|
||||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
if(global::usbms::showUsbmsDialog != true) {
|
if(global::usbms::showUsbmsDialog != true) {
|
||||||
|
|
69
reader.cpp
69
reader.cpp
|
@ -344,17 +344,10 @@ reader::reader(QWidget *parent) :
|
||||||
writeconfig_pagenumber();
|
writeconfig_pagenumber();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TEMPORARY [
|
// Retrieve split_total from tmpfs
|
||||||
if(global::reader::bookIsEpub == true) {
|
string_checkconfig("/tmp/inkboxPageNumber");
|
||||||
quit_restart();
|
split_total = checkconfig_str_val.toInt();
|
||||||
}
|
setup_book(book_file, 0, true);
|
||||||
// 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
|
// Get text; no need to do it multiple times for ePUB books
|
||||||
|
@ -472,7 +465,14 @@ reader::reader(QWidget *parent) :
|
||||||
ui->bookInfoLabel->setText(infoLabelContent);
|
ui->bookInfoLabel->setText(infoLabelContent);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
ui->bookInfoLabel->setText(bookReadRelativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,6 +519,39 @@ reader::reader(QWidget *parent) :
|
||||||
string_writeconfig(".config/08-recent_books/4", str_book_3);
|
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
|
// Battery watchdog
|
||||||
if(global::reader::startBatteryWatchdog == true) {
|
if(global::reader::startBatteryWatchdog == true) {
|
||||||
QTimer *t = new QTimer(this);
|
QTimer *t = new QTimer(this);
|
||||||
|
@ -691,9 +724,11 @@ bool reader::epub_file_match(QString file) {
|
||||||
QString fileExt = file.right(4);
|
QString fileExt = file.right(4);
|
||||||
|
|
||||||
if(fileExt == "epub" or fileExt == "EPUB") {
|
if(fileExt == "epub" or fileExt == "EPUB") {
|
||||||
|
string_writeconfig("/inkbox/bookIsEpub", "true");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
string_writeconfig("/inkbox/bookIsEpub", "false");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1412,3 +1447,13 @@ void reader::on_nightModeBtn_clicked()
|
||||||
isNightModeActive = true;
|
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;
|
QPixmap scaledEmptyPixmap;
|
||||||
QList<QString> content;
|
QList<QString> content;
|
||||||
QString epubPageContent;
|
QString epubPageContent;
|
||||||
|
QString usbmsStatus;
|
||||||
|
|
||||||
int setup_book(QString book, int i, bool run_parser);
|
int setup_book(QString book, int i, bool run_parser);
|
||||||
void checkwords();
|
void checkwords();
|
||||||
|
@ -91,6 +92,7 @@ public:
|
||||||
void setPageStyle();
|
void setPageStyle();
|
||||||
void alignText(int alignment);
|
void alignText(int alignment);
|
||||||
void delay(int seconds);
|
void delay(int seconds);
|
||||||
|
void openUsbmsDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_nextBtn_clicked();
|
void on_nextBtn_clicked();
|
||||||
|
|
Loading…
Reference in a new issue