2021-03-26 16:10:26 -07:00
|
|
|
/*
|
|
|
|
InkBox: Open-source Qt-based eBook reader
|
|
|
|
Copyright (C) 2021 Nicolas Mailloux <nicolecrivain@gmail.com>
|
|
|
|
SPDX-License-Identifier: GPL-3.0-only
|
2021-04-29 20:36:25 -07:00
|
|
|
|
2021-03-26 16:10:26 -07:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation.
|
2021-04-29 20:36:25 -07:00
|
|
|
|
2021-03-26 16:10:26 -07:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-03-25 05:00:19 -07:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "alert.h"
|
2021-04-01 05:58:37 -07:00
|
|
|
#include "generaldialog.h"
|
2021-04-05 06:50:58 -07:00
|
|
|
#include "functions.h"
|
2021-04-05 12:35:25 -07:00
|
|
|
#include "reader.h"
|
2021-04-23 05:47:05 -07:00
|
|
|
|
2021-03-25 05:00:19 -07:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QTextStream>
|
2021-03-26 15:53:02 -07:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QScreen>
|
2021-03-25 05:00:19 -07:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2021-06-28 09:26:04 -07:00
|
|
|
// Tell scripts that we're currently running
|
|
|
|
string_writeconfig("/tmp/inkbox_running", "true");
|
|
|
|
|
2021-06-29 09:26:30 -07:00
|
|
|
// Variables
|
|
|
|
global::reader::startBatteryWatchdog = false;
|
|
|
|
global::reader::startUsbmsPrompt = false;
|
|
|
|
|
2021-04-22 04:38:54 -07:00
|
|
|
// 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");
|
|
|
|
if(checkconfig_str_val == "Charging\n") {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else {
|
2021-04-22 10:56:29 -07:00
|
|
|
global::battery::showCriticalBatteryAlert = true;
|
2021-04-22 04:38:54 -07:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
alert w;
|
|
|
|
|
|
|
|
const QScreen* screen = qApp->primaryScreen();
|
|
|
|
w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
|
|
|
|
w.show();
|
|
|
|
return a.exec();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 05:00:19 -07:00
|
|
|
// Checking if there has been an ALERT flag set up, and if there is, show a big warning
|
2021-04-05 06:50:58 -07:00
|
|
|
if(checkconfig("/external_root/boot/flags/ALERT") == true) {
|
2021-03-25 05:00:19 -07:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
alert w;
|
|
|
|
|
2021-09-05 08:47:09 -07:00
|
|
|
const QScreen * screen = qApp->primaryScreen();
|
2021-04-05 12:35:25 -07:00
|
|
|
w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
|
|
|
|
w.show();
|
|
|
|
return a.exec();
|
|
|
|
}
|
|
|
|
// If we're waking from sleep and we have the lockscreen enabled, we'll "resume" the book from scratch
|
2021-06-29 09:26:30 -07:00
|
|
|
else if(checkconfig("/tmp/suspendBook") == true && checkconfig("/inkbox/bookIsEpub") == false) {
|
2021-04-23 16:22:53 -07:00
|
|
|
// Start the low/critical battery alert timer from the Reader framework since MainWindow is not going to be shown
|
2021-09-05 08:47:09 -07:00
|
|
|
global::runningInstanceIsReaderOnly = true;
|
2021-04-23 16:22:53 -07:00
|
|
|
global::reader::startBatteryWatchdog = true;
|
2021-06-29 09:26:30 -07:00
|
|
|
global::reader::startUsbmsPrompt = true;
|
2021-04-23 16:22:53 -07:00
|
|
|
global::reader::skipOpenDialog = true;
|
|
|
|
|
2021-04-05 12:35:25 -07:00
|
|
|
string_writeconfig("/inkbox/skip_opendialog", "true");
|
2021-06-27 10:28:41 -07:00
|
|
|
string_checkconfig_ro("/opt/inkbox_device");
|
|
|
|
if(checkconfig_str_val == "n705\n") {
|
2021-06-26 07:09:51 -07:00
|
|
|
global::isN705 = true;
|
|
|
|
global::isN905C = false;
|
|
|
|
global::isN613 = false;
|
2021-07-10 22:08:38 -07:00
|
|
|
global::isN873 = false;
|
2021-06-26 07:09:51 -07:00
|
|
|
}
|
2021-06-27 10:28:41 -07:00
|
|
|
else if(checkconfig_str_val == "n905\n") {
|
2021-06-26 07:09:51 -07:00
|
|
|
global::isN705 = false;
|
|
|
|
global::isN905C = true;
|
|
|
|
global::isN613 = false;
|
2021-07-10 22:08:38 -07:00
|
|
|
global::isN873 = false;
|
2021-06-26 07:09:51 -07:00
|
|
|
}
|
2021-06-27 10:28:41 -07:00
|
|
|
else if(checkconfig_str_val == "n613\n") {
|
2021-06-26 07:09:51 -07:00
|
|
|
global::isN705 = false;
|
|
|
|
global::isN905C = false;
|
|
|
|
global::isN613 = true;
|
2021-07-10 22:08:38 -07:00
|
|
|
global::isN873 = false;
|
|
|
|
}
|
|
|
|
else if(checkconfig_str_val == "n873\n") {
|
|
|
|
global::isN705 = false;
|
|
|
|
global::isN905C = false;
|
|
|
|
global::isN613 = false;
|
|
|
|
global::isN873 = true;
|
2021-06-26 07:09:51 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2021-04-05 12:35:25 -07:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
reader w;
|
|
|
|
|
|
|
|
const QScreen* screen = qApp->primaryScreen();
|
|
|
|
w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
|
2021-03-25 05:00:19 -07:00
|
|
|
w.show();
|
|
|
|
return a.exec();
|
2021-04-23 05:47:05 -07:00
|
|
|
|
2021-03-25 05:00:19 -07:00
|
|
|
}
|
|
|
|
else {
|
2021-06-29 09:26:30 -07:00
|
|
|
if(checkconfig("/inkbox/bookIsEpub") == true) {
|
|
|
|
global::reader::bookIsEpub = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
global::reader::bookIsEpub = false;
|
|
|
|
}
|
|
|
|
|
2021-03-25 05:00:19 -07:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
MainWindow w;
|
|
|
|
|
|
|
|
QApplication::setStyle("windows");
|
|
|
|
QFile stylesheetFile(":/resources/eink.qss");
|
|
|
|
stylesheetFile.open(QFile::ReadOnly);
|
|
|
|
w.setStyleSheet(stylesheetFile.readAll());
|
|
|
|
stylesheetFile.close();
|
|
|
|
|
2021-06-27 10:28:41 -07:00
|
|
|
string_checkconfig_ro("/opt/inkbox_device");
|
|
|
|
if(checkconfig_str_val == "n705\n") {
|
2021-06-26 07:09:51 -07:00
|
|
|
global::isN705 = true;
|
|
|
|
global::isN905C = false;
|
|
|
|
global::isN613 = false;
|
|
|
|
}
|
2021-06-27 10:28:41 -07:00
|
|
|
else if(checkconfig_str_val == "n905\n") {
|
2021-06-26 07:09:51 -07:00
|
|
|
global::isN705 = false;
|
|
|
|
global::isN905C = true;
|
|
|
|
global::isN613 = false;
|
|
|
|
}
|
2021-06-27 10:28:41 -07:00
|
|
|
else if(checkconfig_str_val == "n613\n") {
|
2021-06-26 07:09:51 -07:00
|
|
|
global::isN705 = false;
|
|
|
|
global::isN905C = false;
|
|
|
|
global::isN613 = true;
|
|
|
|
}
|
2021-07-16 13:41:36 -07:00
|
|
|
else if(checkconfig_str_val == "n873\n") {
|
|
|
|
global::isN705 = false;
|
|
|
|
global::isN905C = false;
|
|
|
|
global::isN613 = false;
|
|
|
|
global::isN873 = true;
|
|
|
|
}
|
2021-06-26 07:09:51 -07:00
|
|
|
else {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2021-09-05 08:47:09 -07:00
|
|
|
const QScreen * screen = qApp->primaryScreen();
|
2021-03-26 15:53:02 -07:00
|
|
|
w.setGeometry(QRect(QPoint(0,0), screen->geometry ().size()));
|
2021-03-25 05:00:19 -07:00
|
|
|
w.show();
|
|
|
|
return a.exec();
|
|
|
|
}
|
|
|
|
}
|