mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Give something to say to logger; implement local settings brightness
This commit is contained in:
parent
55bddcdbf6
commit
8589ee36eb
9 changed files with 87 additions and 15 deletions
9
apps.cpp
9
apps.cpp
|
@ -78,6 +78,7 @@ void apps::exitSlot() {
|
|||
|
||||
void apps::on_scribbleLaunchBtn_clicked()
|
||||
{
|
||||
log("Launching external Scribble app ...", className);
|
||||
QProcess process;
|
||||
process.startDetached("scribble", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -85,6 +86,7 @@ void apps::on_scribbleLaunchBtn_clicked()
|
|||
|
||||
void apps::on_lightmapsLaunchBtn_clicked()
|
||||
{
|
||||
log("Launching external LightMaps app ...", className);
|
||||
QProcess process;
|
||||
process.startDetached("lightmaps", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -92,6 +94,7 @@ void apps::on_lightmapsLaunchBtn_clicked()
|
|||
|
||||
void apps::on_savedWordsLaunchBtn_clicked()
|
||||
{
|
||||
log("Launching Saved Words app ...", className);
|
||||
savedWordsWindow = new savedwords();
|
||||
savedWordsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
savedWordsWindow->showFullScreen();
|
||||
|
@ -99,6 +102,7 @@ void apps::on_savedWordsLaunchBtn_clicked()
|
|||
|
||||
void apps::on_calendarLaunchBtn_clicked()
|
||||
{
|
||||
log("Launching Calendar app ...", className);
|
||||
calendarWindow = new calendarApp();
|
||||
calendarWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
calendarWindow->showFullScreen();
|
||||
|
@ -106,6 +110,7 @@ void apps::on_calendarLaunchBtn_clicked()
|
|||
|
||||
void apps::on_calculatorLaunchBtn_clicked()
|
||||
{
|
||||
log("Launching external Calculator app ...", className);
|
||||
QProcess process;
|
||||
process.startDetached("calculator", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -113,6 +118,7 @@ void apps::on_calculatorLaunchBtn_clicked()
|
|||
|
||||
void apps::on_koboxAppsOpenButton_clicked()
|
||||
{
|
||||
log("Showing KoBox Apps Dialog ...", className);
|
||||
koboxAppsDialogWindow = new koboxAppsDialog();
|
||||
connect(koboxAppsDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
||||
koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -121,6 +127,7 @@ void apps::on_koboxAppsOpenButton_clicked()
|
|||
|
||||
void apps::on_vncLaunchBtn_clicked()
|
||||
{
|
||||
log("Showing VNC dialog ...", className);
|
||||
global::keyboard::keyboardDialog = true;
|
||||
global::keyboard::vncDialog = true;
|
||||
global::keyboard::keyboardText = "";
|
||||
|
@ -136,6 +143,7 @@ void apps::refreshScreenNative() {
|
|||
|
||||
void apps::on_reversiLaunchBtn_clicked()
|
||||
{
|
||||
log("Launching external Reversi app ...", className);
|
||||
QProcess process;
|
||||
process.startDetached("qreversi", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -143,6 +151,7 @@ void apps::on_reversiLaunchBtn_clicked()
|
|||
|
||||
void apps::on_g2048LaunchBtn_clicked()
|
||||
{
|
||||
log("Launching external 2048 app ...", className);
|
||||
QProcess process;
|
||||
process.startDetached("2048", QStringList());
|
||||
qApp->quit();
|
||||
|
|
22
functions.h
22
functions.h
|
@ -213,11 +213,13 @@ namespace {
|
|||
return 0;
|
||||
}
|
||||
void set_brightness(int value) {
|
||||
if(QFile::exists("/var/run/brightness")) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open("/var/run/brightness");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
}
|
||||
void set_brightness_ntxio(int value) {
|
||||
// Thanks to Kevin Short for this (GloLight)
|
||||
int light;
|
||||
|
@ -315,6 +317,7 @@ namespace {
|
|||
return brightness;
|
||||
}
|
||||
else {
|
||||
if(QFile::exists("/var/run/brightness")) {
|
||||
QFile brightness("/var/run/brightness");
|
||||
brightness.open(QIODevice::ReadOnly);
|
||||
QString valuestr = brightness.readAll();
|
||||
|
@ -322,6 +325,10 @@ namespace {
|
|||
brightness.close();
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void get_battery_level() {
|
||||
|
@ -380,6 +387,7 @@ namespace {
|
|||
// Checks if the battery level is critical (i.e. <= 5%)
|
||||
get_battery_level();
|
||||
if(batt_level_int <= 5) {
|
||||
QString function = __func__; log(function + ": Battery is at a critical charge level!", "functions");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -396,6 +404,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
void poweroff(bool splash) {
|
||||
log("Powering off ...", "functions");
|
||||
if(splash == true) {
|
||||
QString prog ("/sbin/poweroff");
|
||||
QStringList args;
|
||||
|
@ -415,6 +424,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
void reboot(bool splash) {
|
||||
log("Rebooting ...", "functions");
|
||||
if(splash == true) {
|
||||
QString prog ("/sbin/reboot");
|
||||
QStringList args;
|
||||
|
@ -526,10 +536,12 @@ namespace {
|
|||
|
||||
}
|
||||
void resetKoboxUserData() {
|
||||
log("Resetting KoBox user data ...", "functions");
|
||||
global::kobox::resetKoboxUserDataBool = true;
|
||||
reboot(true);
|
||||
}
|
||||
QString findEpubMetadata(QString book_file, QString metadata) {
|
||||
log("Finding ePUB metadata ...", "functions");
|
||||
setDefaultWorkDir();
|
||||
QString prog ("sh");
|
||||
QStringList args;
|
||||
|
@ -539,6 +551,7 @@ namespace {
|
|||
proc->waitForFinished();
|
||||
|
||||
QString returnedMetadata = proc->readAllStandardOutput();
|
||||
QString function = __func__; log(function + ": ePUB metadata is: " + returnedMetadata, "functions");
|
||||
return returnedMetadata;
|
||||
}
|
||||
void defineDefaultPageSize(int fileType) {
|
||||
|
@ -563,6 +576,9 @@ namespace {
|
|||
defaultEpubPageHeight = 525;
|
||||
defaultEpubPageWidth = 525;
|
||||
}
|
||||
QString function = __func__;
|
||||
log(function + ": Defined default ePUB page height to " + QString::number(defaultEpubPageHeight), "functions");
|
||||
log(function + ": Defined default ePUB page width to " + QString::number(defaultEpubPageWidth), "functions");
|
||||
}
|
||||
else if(fileType == 1) {
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
|
||||
|
@ -581,6 +597,9 @@ namespace {
|
|||
defaultPdfPageHeight = 1630;
|
||||
defaultPdfPageWidth = 1214;
|
||||
}
|
||||
QString function = __func__;
|
||||
log(function + "Defined default PDF page height to " + QString::number(defaultPdfPageHeight), "functions");
|
||||
log(function + "Defined default PDF page width to " + QString::number(defaultPdfPageWidth), "functions");
|
||||
}
|
||||
}
|
||||
void pre_set_brightness(int brightnessValue) {
|
||||
|
@ -617,6 +636,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
bool connectToNetwork(QString essid, QString passphrase) {
|
||||
log("Connecting to network " + essid + " ...", "functions");
|
||||
std::string essid_str = essid.toStdString();
|
||||
std::string passphrase_str = passphrase.toStdString();
|
||||
string_writeconfig("/run/wifi_network_essid", essid_str);
|
||||
|
@ -634,12 +654,14 @@ namespace {
|
|||
setDefaultWorkDir();
|
||||
string_writeconfig(".config/17-wifi_connection_information/essid", essid_str);
|
||||
string_writeconfig(".config/17-wifi_connection_information/passphrase", passphrase_str);
|
||||
QString function = __func__; log(function + ": Connection successful", "functions");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
QFile::remove("/run/wifi_connected_successfully");
|
||||
connectionSuccessful = 0;
|
||||
global::network::isConnected = false;
|
||||
QString function = __func__; log(function + ": Connection failed", "functions");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
5
main.cpp
5
main.cpp
|
@ -25,19 +25,18 @@
|
|||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
global::deviceID = readFile("/opt/inkbox_device");
|
||||
|
||||
if(char * debug = std::getenv("DEBUG")) {
|
||||
if(std::atoi(debug) == 1) {
|
||||
global::logger::status = true;
|
||||
}
|
||||
}
|
||||
global::deviceID = readFile("/opt/inkbox_device");
|
||||
log("Running on device " + global::deviceID, "main");
|
||||
|
||||
setDefaultWorkDir();
|
||||
if(checkconfig(".config/18-encrypted_storage/status") == true and checkconfig("/external_root/run/encfs_mounted") == false) {
|
||||
|
|
|
@ -506,6 +506,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
string_checkconfig_ro("/external_root/opt/isa/changelog");
|
||||
updatemsg = updatemsg.append(checkconfig_str_val);
|
||||
updatemsg = updatemsg.append("</font>");
|
||||
log("Showing update changelog ...", className);
|
||||
QMessageBox::information(this, tr("Information"), updatemsg);
|
||||
string_writeconfig("/external_root/opt/update/inkbox_updated", "false");
|
||||
|
||||
|
@ -584,6 +585,7 @@ MainWindow::~MainWindow()
|
|||
}
|
||||
|
||||
void MainWindow::openUpdateDialog() {
|
||||
log("Showing Update dialog ...", className);
|
||||
global::mainwindow::updateDialog = true;
|
||||
// Write to a temporary file to show an "Update" prompt
|
||||
string_writeconfig("/inkbox/updateDialog", "true");
|
||||
|
@ -597,6 +599,7 @@ void MainWindow::openUpdateDialog() {
|
|||
}
|
||||
|
||||
void MainWindow::openLowBatteryDialog() {
|
||||
log("Showing Low Battery Dialog ...", className);
|
||||
global::mainwindow::lowBatteryDialog = true;
|
||||
global::battery::batteryAlertLock = true;
|
||||
|
||||
|
@ -606,6 +609,7 @@ void MainWindow::openLowBatteryDialog() {
|
|||
}
|
||||
|
||||
void MainWindow::openUsbmsDialog() {
|
||||
log("Showing USB Mass Storage dialog ...", className);
|
||||
global::usbms::showUsbmsDialog = false;
|
||||
global::usbms::usbmsDialog = true;
|
||||
|
||||
|
@ -626,6 +630,7 @@ void MainWindow::openCriticalBatteryAlertWindow() {
|
|||
|
||||
void MainWindow::on_settingsBtn_clicked()
|
||||
{
|
||||
log("Opening Settings Chooser widget ...", className);
|
||||
resetFullWindowException = true;
|
||||
resetWindow(false);
|
||||
if(global::mainwindow::tabSwitcher::settingsChooserWidgetSelected != true) {
|
||||
|
@ -653,6 +658,7 @@ void MainWindow::on_settingsBtn_clicked()
|
|||
|
||||
void MainWindow::on_appsBtn_clicked()
|
||||
{
|
||||
log("Opening Apps widget ...", className);
|
||||
resetFullWindowException = true;
|
||||
resetWindow(false);
|
||||
if(global::mainwindow::tabSwitcher::appsWidgetSelected != true) {
|
||||
|
@ -691,6 +697,7 @@ void MainWindow::on_searchBtn_clicked()
|
|||
|
||||
void MainWindow::on_quitBtn_clicked()
|
||||
{
|
||||
log("Opening Quit widget ...", className);
|
||||
quitWindow = new quit();
|
||||
quitWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
quitWindow->showFullScreen();
|
||||
|
@ -730,6 +737,7 @@ void MainWindow::on_book4Btn_clicked()
|
|||
|
||||
void MainWindow::on_brightnessBtn_clicked()
|
||||
{
|
||||
log("Showing Brightness Dialog ...", className);
|
||||
brightnessDialogWindow = new brightnessDialog();
|
||||
brightnessDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
brightnessDialogWindow->show();
|
||||
|
@ -737,6 +745,7 @@ void MainWindow::on_brightnessBtn_clicked()
|
|||
|
||||
void MainWindow::on_homeBtn_clicked()
|
||||
{
|
||||
log("Showing home screen ...", className);
|
||||
global::mainwindow::tabSwitcher::repaint = true;
|
||||
resetFullWindowException = true;
|
||||
resetWindow(true);
|
||||
|
@ -867,6 +876,9 @@ void MainWindow::setInitialBrightness() {
|
|||
set_warmth(warmth);
|
||||
}
|
||||
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n") {
|
||||
log("Setting initial brightness to " + QString::number(brightness_value), className);
|
||||
}
|
||||
if(checkconfig("/tmp/oobe-inkbox_completed") == true or checkconfig("/tmp/inkbox-cinematicBrightness_ran") == true) {
|
||||
// Coming from OOBE setup; not doing that fancy stuff again ;p
|
||||
QFile::remove("/tmp/oobe-inkbox_completed");
|
||||
|
@ -884,6 +896,7 @@ void MainWindow::refreshScreen() {
|
|||
}
|
||||
|
||||
void MainWindow::setupSearchDialog() {
|
||||
log("Launching Search dialog ...", className);
|
||||
if(global::forbidOpenSearchDialog == false) {
|
||||
global::keyboard::keyboardDialog = true;
|
||||
global::keyboard::searchDialog = true;
|
||||
|
@ -988,6 +1001,7 @@ void MainWindow::setWifiIcon() {
|
|||
}
|
||||
|
||||
void MainWindow::openWifiDialog() {
|
||||
log("Opening Wi-Fi connection interface ...", className);
|
||||
if(checkconfig("/external_root/run/was_connected_to_wifi") == true and wifiIconClickedWhileReconnecting == false) {
|
||||
showToast("Reconnection in progress\nTap again to cancel");
|
||||
wifiIconClickedWhileReconnecting = true;
|
||||
|
@ -1039,6 +1053,7 @@ void MainWindow::closeIndefiniteToast() {
|
|||
}
|
||||
|
||||
void MainWindow::openUpdateDialogOTA(bool open) {
|
||||
QString function = __func__; log(function + ": Showing update dialog (OTA)", className);
|
||||
if(open == true) {
|
||||
global::otaUpdate::isUpdateOta = true;
|
||||
openUpdateDialog();
|
||||
|
@ -1049,6 +1064,7 @@ void MainWindow::openUpdateDialogOTA(bool open) {
|
|||
}
|
||||
|
||||
void MainWindow::launchOtaUpdater() {
|
||||
log("Launching OTA updater ...", className);
|
||||
otaManagerWindow = new otaManager(this);
|
||||
connect(otaManagerWindow, SIGNAL(canOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool)));
|
||||
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -1070,6 +1086,7 @@ void MainWindow::openBookFile(QString book, bool relativePath) {
|
|||
}
|
||||
|
||||
void MainWindow::openReaderFramework() {
|
||||
log("Launching Reader Framework ...", className);
|
||||
readerWindow = new reader();
|
||||
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(readerWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool)));
|
||||
|
@ -1077,19 +1094,24 @@ void MainWindow::openReaderFramework() {
|
|||
}
|
||||
|
||||
void MainWindow::checkForUpdate() {
|
||||
log("Checking for available updates ...", className);
|
||||
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
|
||||
if(checkconfig("/tmp/cancelUpdateDialog") == false) {
|
||||
// I'm sorry.
|
||||
log("An update is available.", className);
|
||||
QString function = __func__; log(function + ": An update is available.", className);
|
||||
QTimer::singleShot(2000, this, SLOT(openUpdateDialog()));
|
||||
}
|
||||
else {
|
||||
log("Not showing update dialog, user dismissed it ...", className);
|
||||
QString function = __func__; log(function + ": Not showing update dialog, user dismissed it ...", className);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QString function = __func__; log(function + ": No update available.", className);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::openEncfsRepackDialog() {
|
||||
log("Showing encrypted storage repack dialog ...", className);
|
||||
global::encfs::repackDialog = true;
|
||||
global::usbms::showUsbmsDialog = false;
|
||||
global::usbms::usbmsDialog = false;
|
||||
|
@ -1099,6 +1121,7 @@ void MainWindow::openEncfsRepackDialog() {
|
|||
|
||||
void MainWindow::on_libraryButton_clicked()
|
||||
{
|
||||
log("Launching Online Library ...", className);
|
||||
if(testPing() == 0 or global::deviceID == "emu\n") {
|
||||
resetFullWindowException = false;
|
||||
resetWindow(false);
|
||||
|
|
2
quit.cpp
2
quit.cpp
|
@ -66,6 +66,7 @@ void quit::on_pushButton_2_clicked()
|
|||
|
||||
void quit::on_pushButton_4_clicked()
|
||||
{
|
||||
log("Restarting InkBox ...", className);
|
||||
QProcess process;
|
||||
process.startDetached("inkbox", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -78,6 +79,7 @@ void quit::on_backBtn_clicked()
|
|||
|
||||
void quit::on_pushButton_3_clicked()
|
||||
{
|
||||
log("Suspending ...", className);
|
||||
// inotifywait waits for a MODIFY event, so we just do it instead of evtest and the power button
|
||||
string_writeconfig("/external_root/tmp/power", "KEY_POWER");
|
||||
}
|
||||
|
|
13
reader.cpp
13
reader.cpp
|
@ -245,6 +245,14 @@ reader::reader(QWidget *parent) :
|
|||
}
|
||||
|
||||
// Custom settings
|
||||
// Brightness
|
||||
if(global::reader::globalReadingSettings == false) {
|
||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n") {
|
||||
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||
log("Local Reading Settings: setting brightness to " + QString::number(brightness_value), className);
|
||||
pre_set_brightness(brightness_value);
|
||||
}
|
||||
}
|
||||
// Font
|
||||
string_checkconfig(".config/04-book/font");
|
||||
if(checkconfig_str_val == "") {
|
||||
|
@ -2222,3 +2230,8 @@ void reader::on_quitBtn_clicked()
|
|||
quitWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
quitWindow->showFullScreen();
|
||||
}
|
||||
|
||||
void reader::closeIndefiniteToast() {
|
||||
// Warning: use with caution
|
||||
toastWindow->close();
|
||||
}
|
||||
|
|
1
reader.h
1
reader.h
|
@ -161,6 +161,7 @@ private slots:
|
|||
void openBookFileNative(QString book, bool relativePath);
|
||||
void showToast(QString messageToDisplay);
|
||||
void on_quitBtn_clicked();
|
||||
void closeIndefiniteToast();
|
||||
|
||||
signals:
|
||||
void openBookFile(QString book, bool relativePath);
|
||||
|
|
|
@ -69,6 +69,7 @@ settingsChooser::~settingsChooser()
|
|||
|
||||
void settingsChooser::on_inkboxSettingsBtn_clicked()
|
||||
{
|
||||
log("Launching InkBox Settings ...", className);
|
||||
settingsWindow = new settings();
|
||||
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(settingsWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
||||
|
@ -78,6 +79,7 @@ void settingsChooser::on_inkboxSettingsBtn_clicked()
|
|||
|
||||
void settingsChooser::on_koboxSettingsBtn_clicked()
|
||||
{
|
||||
log("Launching KoBox Settings ...", className);
|
||||
koboxSettingsWindow = new koboxSettings();
|
||||
koboxSettingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
koboxSettingsWindow->showFullScreen();
|
||||
|
|
|
@ -11,6 +11,7 @@ toast::toast(QWidget *parent) :
|
|||
ui(new Ui::toast)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
log("Displaying message " + global::toast::message, className);
|
||||
|
||||
if(global::toast::modalToast == true) {
|
||||
global::toast::modalToast = false;
|
||||
|
|
Loading…
Reference in a new issue