mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 15:47:22 -08:00
Remove some deprecated functions
This commit is contained in:
parent
9da168fc7e
commit
11c8c90548
19 changed files with 354 additions and 455 deletions
|
@ -145,7 +145,7 @@ void encryptionManager::on_setupAbortBtn_clicked()
|
|||
{
|
||||
log("Aborting setup", className);
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig(".config/18-encrypted_storage/status", "false");
|
||||
writeFile(".config/18-encrypted_storage/status", "false");
|
||||
quit_restart();
|
||||
}
|
||||
|
||||
|
@ -178,15 +178,15 @@ void encryptionManager::setupEncryptedStorage() {
|
|||
}
|
||||
else {
|
||||
mkEncfsDirs();
|
||||
std::string bootstrapPassphrase = global::encfs::passphrase.toStdString();
|
||||
QString bootstrapPassphrase = global::encfs::passphrase;
|
||||
global::encfs::passphrase = "";
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_create", "true");
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_create", "true");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
|
||||
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
||||
writeFile(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
|
||||
writeFile("/opt/ibxd", "encfs_restart\n");
|
||||
bool exitStatus;
|
||||
ui->activityWidget->setCurrentIndex(3);
|
||||
QTimer * t = new QTimer(this);
|
||||
|
@ -213,21 +213,21 @@ void encryptionManager::unlockEncryptedStorage() {
|
|||
this->setStyleSheet("background-color: white");
|
||||
ui->activityWidget->show();
|
||||
mkEncfsDirs();
|
||||
std::string passphrase = global::encfs::passphrase.toStdString();
|
||||
QString passphrase = global::encfs::passphrase;
|
||||
global::encfs::passphrase = "";
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs");
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/encfs-decrypted");
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bindmount", "/kobo/mnt/onboard/onboard/encfs-decrypted");
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
||||
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/encfs-decrypted");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_bindmount", "/kobo/mnt/onboard/onboard/encfs-decrypted");
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
||||
writeFile("/opt/ibxd", "encfs_restart\n");
|
||||
bool exitStatus;
|
||||
|
||||
string_checkconfig_ro("/inkbox/encryptedStoragePassphraseTries");
|
||||
if(checkconfig_str_val.isEmpty()) {
|
||||
QString passphraseTriesStr = readFile("/inkbox/encryptedStoragePassphraseTries");
|
||||
if(passphraseTriesStr.isEmpty()) {
|
||||
passphraseTries = 0;
|
||||
}
|
||||
else {
|
||||
passphraseTries = checkconfig_str_val.toInt();
|
||||
passphraseTries = passphraseTriesStr.toInt();
|
||||
passphraseTries++;
|
||||
}
|
||||
|
||||
|
@ -245,19 +245,19 @@ void encryptionManager::unlockEncryptedStorage() {
|
|||
int delay = 0;
|
||||
if(passphraseTries <= 3) {
|
||||
if(passphraseTries == 0) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "0");
|
||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "0");
|
||||
delay = 5000;
|
||||
}
|
||||
else if(passphraseTries == 1) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "1");
|
||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "1");
|
||||
delay = 10000;
|
||||
}
|
||||
else if(passphraseTries == 2) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "2");
|
||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "2");
|
||||
delay = 20000;
|
||||
}
|
||||
else if(passphraseTries >= 3) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "3");
|
||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "3");
|
||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||
currentEpoch += 86400;
|
||||
QString unlockTime_str = QString::number(currentEpoch);
|
||||
|
@ -305,7 +305,7 @@ void encryptionManager::mkEncfsDirs() {
|
|||
void encryptionManager::on_exitSuccessBtn_clicked()
|
||||
{
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "true");
|
||||
writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
|
||||
quit_restart();
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ void encryptionManager::setupExitWidget(bool exitStatus) {
|
|||
ui->activityWidget->setCurrentIndex(1);
|
||||
}
|
||||
else {
|
||||
string_writeconfig(".config/18-encrypted_storage/status", "false");
|
||||
writeFile(".config/18-encrypted_storage/status", "false");
|
||||
ui->activityWidget->setCurrentIndex(2);
|
||||
}
|
||||
setupExitWidgetRan = true;
|
||||
|
@ -325,7 +325,7 @@ void encryptionManager::setupExitWidget(bool exitStatus) {
|
|||
void encryptionManager::on_failureContinueBtn_clicked()
|
||||
{
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "true");
|
||||
writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
|
||||
quit_restart();
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ void encryptionManager::setupFailedAuthenticationMessageBox() {
|
|||
|
||||
void encryptionManager::on_acceptBtn_clicked()
|
||||
{
|
||||
string_writeconfig(".config/18-encrypted_storage/status", "false");
|
||||
writeFile(".config/18-encrypted_storage/status", "false");
|
||||
quit_restart();
|
||||
}
|
||||
|
||||
|
@ -363,11 +363,11 @@ void encryptionManager::repackEncryptedStorage() {
|
|||
this->setStyleSheet("background-color: white");
|
||||
ui->activityWidget->show();
|
||||
mkEncfsDirs();
|
||||
std::string passphrase = global::encfs::passphrase.toStdString();
|
||||
QString passphrase = global::encfs::passphrase;
|
||||
global::encfs::passphrase = "";
|
||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_repack_passphrase", passphrase);
|
||||
writeFile("/external_root/run/encfs/encrypted_storage_repack_passphrase", passphrase);
|
||||
QFile::remove("/external_root/run/openrc/started/encfs");
|
||||
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
||||
writeFile("/opt/ibxd", "encfs_restart\n");
|
||||
bool exitStatus;
|
||||
ui->activityWidget->setCurrentIndex(3);
|
||||
QTimer * t = new QTimer(this);
|
||||
|
|
155
src/functions.h
155
src/functions.h
|
@ -212,7 +212,6 @@ namespace global {
|
|||
|
||||
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
|
||||
namespace {
|
||||
QString checkconfig_str_val;
|
||||
QString deviceUID;
|
||||
QString device;
|
||||
QString batt_level;
|
||||
|
@ -275,37 +274,17 @@ namespace {
|
|||
}
|
||||
return 0;
|
||||
};
|
||||
bool checkconfig_rw(QString file) {
|
||||
if(QFile::exists(file)) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
config.close();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
void setDefaultWorkDir() {
|
||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
||||
}
|
||||
int brightness_checkconfig(QString file) {
|
||||
int brightnessCheckconfig(QString file) {
|
||||
if(QFile::exists(file)) {
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
int content_int = content.toInt();
|
||||
return content_int;
|
||||
int contentInt = content.toInt();
|
||||
return contentInt;
|
||||
config.close();
|
||||
}
|
||||
else {
|
||||
|
@ -313,7 +292,7 @@ namespace {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
void set_brightness(int value) {
|
||||
void setBrightness(int value) {
|
||||
if(QFile::exists("/var/run/brightness")) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open("/var/run/brightness");
|
||||
|
@ -321,7 +300,7 @@ namespace {
|
|||
fhandler.close();
|
||||
}
|
||||
}
|
||||
void set_brightness_ntxio(int value) {
|
||||
void setBrightness_ntxio(int value) {
|
||||
// Thanks to Kevin Short for this (GloLight)
|
||||
int light;
|
||||
if((light = open("/dev/ntx_io", O_RDWR)) == -1) {
|
||||
|
@ -330,24 +309,9 @@ namespace {
|
|||
ioctl(light, 241, value);
|
||||
close(light);
|
||||
}
|
||||
int int_checkconfig(QString file) {
|
||||
if(QFile::exists(file)) {
|
||||
QFile int_config(file);
|
||||
int_config.open(QIODevice::ReadOnly);
|
||||
QString valuestr = int_config.readAll();
|
||||
int value = valuestr.toInt();
|
||||
int_config.close();
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int display_quote() {
|
||||
int displayQuote() {
|
||||
int quoteNumber = QRandomGenerator::global()->bounded(1, 6);
|
||||
return quoteNumber;
|
||||
return 0;
|
||||
}
|
||||
bool writeFile(QString filename, QString content) {
|
||||
QFile file(filename);
|
||||
|
@ -361,38 +325,6 @@ namespace {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
void string_writeconfig(std::string file, std::string config_option) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open(file);
|
||||
fhandler << config_option;
|
||||
fhandler.close();
|
||||
}
|
||||
void string_checkconfig(QString file) {
|
||||
if(QFile::exists(file)) {
|
||||
checkconfig_str_val = "";
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadWrite);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
else {
|
||||
checkconfig_str_val = "";
|
||||
}
|
||||
}
|
||||
void string_checkconfig_ro(QString file) {
|
||||
if(QFile::exists(file)) {
|
||||
checkconfig_str_val = "";
|
||||
QFile config(file);
|
||||
config.open(QIODevice::ReadOnly);
|
||||
QTextStream in (&config);
|
||||
checkconfig_str_val = in.readAll();
|
||||
config.close();
|
||||
}
|
||||
else {
|
||||
checkconfig_str_val = "";
|
||||
}
|
||||
}
|
||||
QString readFile(QString file) {
|
||||
if(QFile::exists(file)) {
|
||||
QFile fileToRead(file);
|
||||
|
@ -405,27 +337,27 @@ namespace {
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
void brightness_writeconfig(int value) {
|
||||
void brightnessWriteconfig(int value) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open(".config/03-brightness/config");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
void warmth_writeconfig(int value) {
|
||||
void warmthWriteconfig(int value) {
|
||||
std::ofstream fhandler;
|
||||
fhandler.open(".config/03-brightness/config-warmth");
|
||||
fhandler << value;
|
||||
fhandler.close();
|
||||
}
|
||||
int get_brightness() {
|
||||
int getBrightness() {
|
||||
if(global::deviceID == "n613\n") {
|
||||
string_checkconfig_ro(".config/03-brightness/config");
|
||||
QString brightnessConfig = readFile(".config/03-brightness/config");
|
||||
int brightness;
|
||||
if(checkconfig_str_val == "") {
|
||||
if(brightnessConfig.isEmpty()) {
|
||||
brightness = 0;
|
||||
}
|
||||
else {
|
||||
brightness = checkconfig_str_val.toInt();
|
||||
brightness = brightnessConfig.toInt();
|
||||
}
|
||||
return brightness;
|
||||
}
|
||||
|
@ -444,7 +376,7 @@ namespace {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
void get_battery_level() {
|
||||
void getBatteryLevel() {
|
||||
QString batteryLevelFileQstr;
|
||||
if(global::deviceID == "kt\n") {
|
||||
QFile batt_level_file("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity");
|
||||
|
@ -501,7 +433,7 @@ namespace {
|
|||
};
|
||||
bool isBatteryLow() {
|
||||
// Checks if battery level is under 15% of total capacity.
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
if(batt_level_int <= 15) {
|
||||
return true;
|
||||
}
|
||||
|
@ -512,7 +444,7 @@ namespace {
|
|||
}
|
||||
bool isBatteryCritical() {
|
||||
// Checks if the battery level is critical (i.e. <= 5%)
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
if(batt_level_int <= 5) {
|
||||
QString function = __func__; log(function + ": Battery is at a critical charge level!", "functions");
|
||||
return true;
|
||||
|
@ -524,10 +456,10 @@ namespace {
|
|||
}
|
||||
void zeroBrightness() {
|
||||
if(global::deviceID != "n613\n") {
|
||||
set_brightness(0);
|
||||
setBrightness(0);
|
||||
}
|
||||
else {
|
||||
set_brightness_ntxio(0);
|
||||
setBrightness_ntxio(0);
|
||||
}
|
||||
}
|
||||
void poweroff(bool splash) {
|
||||
|
@ -605,18 +537,16 @@ namespace {
|
|||
proc->deleteLater();
|
||||
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig("/external_root/run/initrd-fifo", "get_kernel_build_id\n");
|
||||
writeFile("/external_root/run/initrd-fifo", "get_kernel_build_id\n");
|
||||
QThread::msleep(100);
|
||||
string_writeconfig("/external_root/run/initrd-fifo", "get_kernel_commit\n");
|
||||
writeFile("/external_root/run/initrd-fifo", "get_kernel_commit\n");
|
||||
QThread::msleep(100);
|
||||
|
||||
string_checkconfig_ro("/external_root/run/kernel_build_id");
|
||||
QString kernelBuildID = checkconfig_str_val.trimmed();
|
||||
QString kernelBuildID = readFile("/external_root/run/kernel_build_id").trimmed();
|
||||
kernelVersion.append(", build ");
|
||||
kernelVersion.append(kernelBuildID);
|
||||
|
||||
string_checkconfig_ro("/external_root/run/kernel_commit");
|
||||
QString kernelCommit = checkconfig_str_val.trimmed();
|
||||
QString kernelCommit = readFile("/external_root/run/kernel_commit").trimmed();
|
||||
kernelVersion.append(", commit ");
|
||||
kernelVersion.append(kernelCommit);
|
||||
}
|
||||
|
@ -645,8 +575,7 @@ namespace {
|
|||
getUID();
|
||||
getKernelVersion();
|
||||
global::systemInfoText = "<b>InkBox OS version ";
|
||||
string_checkconfig_ro("/external_root/opt/isa/version");
|
||||
global::systemInfoText.append(checkconfig_str_val);
|
||||
global::systemInfoText.append(readFile("/external_root/opt/isa/version"));
|
||||
global::systemInfoText.append("</b><br>Copyright <font face='Inter'>©</font> 2021-2023 Nicolas Mailloux and contributors<br>Special thanks to: Szybet, NiLuJe, akemnade, Rain92 (GitHub)");
|
||||
global::systemInfoText.append("<br><b>GUI Git commit:</b> ");
|
||||
global::systemInfoText.append(GIT_VERSION);
|
||||
|
@ -753,15 +682,15 @@ namespace {
|
|||
log(function + "Defined default PDF page width to " + QString::number(defaultPdfPageWidth), "functions");
|
||||
}
|
||||
}
|
||||
void pre_set_brightness(int brightnessValue) {
|
||||
void preSetBrightness(int brightnessValue) {
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n873\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "kt\n") {
|
||||
set_brightness(brightnessValue);
|
||||
setBrightness(brightnessValue);
|
||||
}
|
||||
else if(global::deviceID == "n613\n") {
|
||||
set_brightness_ntxio(brightnessValue);
|
||||
setBrightness_ntxio(brightnessValue);
|
||||
}
|
||||
else {
|
||||
set_brightness(brightnessValue);
|
||||
setBrightness(brightnessValue);
|
||||
}
|
||||
}
|
||||
void cinematicBrightness(int value, int mode) {
|
||||
|
@ -777,69 +706,69 @@ namespace {
|
|||
int brightness = 0;
|
||||
while(brightness != value) {
|
||||
brightness = brightness + 1;
|
||||
pre_set_brightness(brightness);
|
||||
preSetBrightness(brightness);
|
||||
QThread::msleep(30);
|
||||
}
|
||||
}
|
||||
else if(mode == 1) {
|
||||
int brightness = get_brightness();
|
||||
int brightness = getBrightness();
|
||||
while(brightness != 0) {
|
||||
brightness = brightness - 1;
|
||||
pre_set_brightness(brightness);
|
||||
preSetBrightness(brightness);
|
||||
QThread::msleep(30);
|
||||
}
|
||||
}
|
||||
else if(mode == 2) {
|
||||
int brightness = get_brightness();
|
||||
int brightness = getBrightness();
|
||||
if(brightness <= value) {
|
||||
while(brightness != value) {
|
||||
brightness = brightness + 1;
|
||||
pre_set_brightness(brightness);
|
||||
preSetBrightness(brightness);
|
||||
QThread::msleep(30);
|
||||
}
|
||||
}
|
||||
else if(brightness >= value) {
|
||||
while(brightness != value) {
|
||||
brightness = brightness - 1;
|
||||
pre_set_brightness(brightness);
|
||||
preSetBrightness(brightness);
|
||||
QThread::msleep(30);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int get_warmth() {
|
||||
int getWarmth() {
|
||||
QString sysfsWarmthPath;
|
||||
if(global::deviceID == "n873\n") {
|
||||
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
|
||||
}
|
||||
string_checkconfig_ro(sysfsWarmthPath);
|
||||
int warmthValue = checkconfig_str_val.toInt();
|
||||
QString warmthConfig = readFile(sysfsWarmthPath);
|
||||
int warmthValue = warmthConfig.toInt();
|
||||
warmthValue = 10 - warmthValue;
|
||||
return warmthValue;
|
||||
}
|
||||
void set_warmth(int warmthValue) {
|
||||
void setWarmth(int warmthValue) {
|
||||
// Value 0 gives a warmer lighting than value 10
|
||||
warmthValue = 10 - warmthValue;
|
||||
std::string warmthValueStr = std::to_string(warmthValue);
|
||||
std::string sysfsWarmthPath;
|
||||
QString warmthValueStr = QString::number(warmthValue);
|
||||
QString sysfsWarmthPath;
|
||||
if(global::deviceID == "n873\n") {
|
||||
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
|
||||
}
|
||||
string_writeconfig(sysfsWarmthPath, warmthValueStr);
|
||||
writeFile(sysfsWarmthPath, warmthValueStr);
|
||||
}
|
||||
void cinematicWarmth(int warmthValue) {
|
||||
int currentWarmth = get_warmth();
|
||||
int currentWarmth = getWarmth();
|
||||
if(warmthValue < currentWarmth) {
|
||||
while(warmthValue < currentWarmth) {
|
||||
currentWarmth--;
|
||||
set_warmth(currentWarmth);
|
||||
setWarmth(currentWarmth);
|
||||
QThread::msleep(30);
|
||||
}
|
||||
}
|
||||
else if(warmthValue > currentWarmth) {
|
||||
while(warmthValue > currentWarmth) {
|
||||
currentWarmth++;
|
||||
set_warmth(currentWarmth);
|
||||
setWarmth(currentWarmth);
|
||||
QThread::msleep(30);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,10 +187,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// Dark mode; write to the Kobo Nightmode FIFO
|
||||
if(checkconfig(".config/10-dark_mode/config") == true) {
|
||||
string_writeconfig("/tmp/invertScreen", "y");
|
||||
writeFile("/tmp/invertScreen", "y");
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/tmp/invertScreen", "n");
|
||||
writeFile("/tmp/invertScreen", "n");
|
||||
}
|
||||
|
||||
// Clock setting to show seconds
|
||||
|
@ -199,7 +199,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
t->setInterval(500);
|
||||
connect(t, &QTimer::timeout, [&]() {
|
||||
QString time = QTime::currentTime().toString("hh:mm:ss");
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
ui->timeLabel->setText(time);
|
||||
ui->batteryLabel->setText(batt_level);
|
||||
} );
|
||||
|
@ -210,7 +210,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
t->setInterval(500);
|
||||
connect(t, &QTimer::timeout, [&]() {
|
||||
QString time = QTime::currentTime().toString("hh:mm");
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
ui->timeLabel->setText(time);
|
||||
ui->batteryLabel->setText(batt_level);
|
||||
} );
|
||||
|
@ -272,8 +272,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
}
|
||||
|
||||
// Global reading settings
|
||||
string_checkconfig(".config/16-global_reading_settings/config");
|
||||
if(checkconfig_str_val == "") {
|
||||
if(readFile(".config/16-global_reading_settings/config").isEmpty()) {
|
||||
checked_box = false;
|
||||
writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings=");
|
||||
}
|
||||
|
@ -281,7 +280,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
if(checkconfig(".config/05-quote/config") == false) {
|
||||
stdIconWidth = sW / 2;
|
||||
stdIconHeight = sH / 2;
|
||||
int quote_value = display_quote();
|
||||
int quote_value = displayQuote();
|
||||
if(quote_value == 1) {
|
||||
QPixmap pixmap(":/resources/chesterton.jpg");
|
||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
@ -321,17 +320,17 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
// Check if it's the first boot since an update and confirm that it installed successfully
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
|
||||
string_checkconfig_ro("/external_root/opt/isa/version");
|
||||
QString version = readFile("/external_root/opt/isa/version");
|
||||
QString updatemsg = "<font face='u001'>InkBox update to version ";
|
||||
updatemsg = updatemsg.append(checkconfig_str_val);
|
||||
updatemsg = updatemsg.append(version);
|
||||
updatemsg = updatemsg.remove(QRegExp("[\n]"));
|
||||
updatemsg = updatemsg.append(" completed successfully.<br><br>Changelog:<br>");
|
||||
string_checkconfig_ro("/external_root/opt/isa/changelog");
|
||||
updatemsg = updatemsg.append(checkconfig_str_val);
|
||||
QString changelog = readFile("/external_root/opt/isa/changelog");
|
||||
updatemsg = updatemsg.append(changelog);
|
||||
updatemsg = updatemsg.append("</font>");
|
||||
log("Showing update changelog", className);
|
||||
QMessageBox::information(this, tr("Information"), updatemsg);
|
||||
string_writeconfig("/external_root/opt/update/inkbox_updated", "false");
|
||||
writeFile("/external_root/opt/update/inkbox_updated", "false");
|
||||
|
||||
// Trigger Gutenberg re-sync, because we deleted the .inkbox folder ;)
|
||||
if(QFile::exists("/external_root/opt/storage/gutenberg/last_sync")) {
|
||||
|
@ -390,8 +389,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// If the DEVKEY file is present, install a developer key
|
||||
if(QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY") == true && QFile::exists("/mnt/onboard/onboard/.inkbox/DEVKEY.dgst") == true) {
|
||||
string_checkconfig_ro("/mnt/onboard/onboard/.inkbox/DEVKEY");
|
||||
QString developerKey = checkconfig_str_val.left(256);
|
||||
QString developerKey = readFile("/mnt/onboard/onboard/.inkbox/DEVKEY").left(256);
|
||||
|
||||
setDefaultWorkDir();
|
||||
QString prog ("sh");
|
||||
|
@ -411,7 +409,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// Write version control info to file in tmpfs
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
string_writeconfig("/external_root/run/inkbox_gui_git_commit", GIT_COMMIT);
|
||||
writeFile("/external_root/run/inkbox_gui_git_commit", GIT_COMMIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,7 +422,7 @@ 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");
|
||||
writeFile("/inkbox/updateDialog", "true");
|
||||
|
||||
// Setup the dialog
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
|
@ -667,7 +665,7 @@ void MainWindow::setBatteryIcon() {
|
|||
ui->batteryIcon->setPixmap(scaledChargingPixmap);
|
||||
}
|
||||
else {
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
if(batt_level_int >= 75 && batt_level_int <= 100) {
|
||||
ui->batteryIcon->setPixmap(scaledFullPixmap);
|
||||
}
|
||||
|
@ -697,7 +695,7 @@ void MainWindow::setBatteryIcon() {
|
|||
ui->batteryIcon->setPixmap(scaledChargingPixmap);
|
||||
}
|
||||
else {
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
if(batt_level_int >= 75 && batt_level_int <= 100) {
|
||||
ui->batteryIcon->setPixmap(scaledFullPixmap);
|
||||
}
|
||||
|
@ -714,23 +712,23 @@ void MainWindow::setBatteryIcon() {
|
|||
void MainWindow::setInitialBrightness() {
|
||||
if(global::deviceID == "n873\n") {
|
||||
int warmth;
|
||||
string_checkconfig_ro(".config/03-brightness/config-warmth");
|
||||
if(checkconfig_str_val == "") {
|
||||
QString warmthConfig = readFile(".config/03-brightness/config-warmth");
|
||||
if(warmthConfig.isEmpty()) {
|
||||
warmth = 0;
|
||||
}
|
||||
else {
|
||||
warmth = checkconfig_str_val.toInt();
|
||||
warmth = warmthConfig.toInt();
|
||||
}
|
||||
cinematicWarmth(warmth);
|
||||
}
|
||||
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||
int brightness_value = brightnessCheckconfig(".config/03-brightness/config");
|
||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
||||
log("Setting initial brightness to " + QString::number(brightness_value), className);
|
||||
}
|
||||
if(checkconfig("/tmp/oobe-inkbox_completed") == true) {
|
||||
// Coming from OOBE setup; not doing that fancy stuff again ;p
|
||||
QFile::remove("/tmp/oobe-inkbox_completed");
|
||||
pre_set_brightness(brightness_value);
|
||||
preSetBrightness(brightness_value);
|
||||
log("Ignoring cinematic brightness call because it has already been done", className);
|
||||
}
|
||||
else {
|
||||
|
@ -741,7 +739,7 @@ void MainWindow::setInitialBrightness() {
|
|||
}
|
||||
else {
|
||||
if(checkconfig("/tmp/inkbox-cinematicBrightness_ran") == false) {
|
||||
string_writeconfig("/tmp/inkbox-cinematicBrightness_ran", "true");
|
||||
writeFile("/tmp/inkbox-cinematicBrightness_ran", "true");
|
||||
cinematicBrightness(brightness_value, 0);
|
||||
}
|
||||
else {
|
||||
|
@ -1023,10 +1021,10 @@ void MainWindow::resetFullWindow() {
|
|||
|
||||
void MainWindow::checkForOtaUpdate() {
|
||||
if(global::wifi::isConnected == true) {
|
||||
string_checkconfig_ro("/external_root/opt/storage/update/last_sync");
|
||||
if(!checkconfig_str_val.isEmpty()) {
|
||||
QString lastSync = readFile("/external_root/opt/storage/update/last_sync");
|
||||
if(!lastSync.isEmpty()) {
|
||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||
unsigned long syncEpoch = checkconfig_str_val.toULong();
|
||||
unsigned long syncEpoch = lastSync.toULong();
|
||||
unsigned long allowSyncEpoch = syncEpoch + 86400;
|
||||
if(currentEpoch > allowSyncEpoch) {
|
||||
launchOtaUpdater();
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
|||
log("Running on device " + global::deviceID, "main", true);
|
||||
|
||||
// Tell the OS that we're currently running
|
||||
string_writeconfig("/tmp/inkbox_running", "true");
|
||||
writeFile("/tmp/inkbox_running", "true");
|
||||
|
||||
setDefaultWorkDir();
|
||||
if(checkconfig("/run/wifi_able") == true) {
|
||||
|
@ -65,9 +65,9 @@ int main(int argc, char *argv[])
|
|||
if(QFile::exists("/tmp/rescan_userapps")) {
|
||||
QFile::remove("/tmp/rescan_userapps");
|
||||
log("Re-scanning user applications from explicit request", "main");
|
||||
string_writeconfig("/opt/ibxd", "gui_apps_stop\n");
|
||||
writeFile("/opt/ibxd", "gui_apps_stop\n");
|
||||
QThread::msleep(1000);
|
||||
string_writeconfig("/opt/ibxd", "gui_apps_start\n");
|
||||
writeFile("/opt/ibxd", "gui_apps_start\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/tmp/gui_apps_started")) {
|
||||
if(checkconfig("/tmp/gui_apps_started") == true) {
|
||||
|
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
|
|||
global::reader::startUsbmsPrompt = true;
|
||||
global::reader::skipOpenDialog = true;
|
||||
|
||||
string_writeconfig("/inkbox/skip_opendialog", "true");
|
||||
writeFile("/inkbox/skip_opendialog", "true");
|
||||
if(global::deviceID == "n705\n") {
|
||||
global::isN705 = true;
|
||||
}
|
||||
|
|
|
@ -166,10 +166,10 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
|||
sH = QGuiApplication::screens()[0]->size().height();
|
||||
|
||||
// Prevent abusive sync
|
||||
string_checkconfig_ro("/external_root/opt/storage/gutenberg/last_sync");
|
||||
if(!checkconfig_str_val.isEmpty()) {
|
||||
QString lastSync = readFile("/external_root/opt/storage/gutenberg/last_sync");
|
||||
if(!lastSync.isEmpty()) {
|
||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||
unsigned long syncEpoch = checkconfig_str_val.toULong();
|
||||
unsigned long syncEpoch = lastSync.toULong();
|
||||
unsigned long allowSyncEpoch = syncEpoch + 86400;
|
||||
if(currentEpoch > allowSyncEpoch) {
|
||||
syncCatalog();
|
||||
|
@ -278,7 +278,7 @@ void libraryWidget::syncCatalog() {
|
|||
|
||||
void libraryWidget::syncCatalogSlot() {
|
||||
bool syncDone = false;
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
||||
writeFile("/opt/ibxd", "gutenberg_sync\n");
|
||||
while(true) {
|
||||
if(syncDone == false) {
|
||||
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
||||
|
|
|
@ -14,7 +14,7 @@ otaManager::otaManager(QWidget *parent) :
|
|||
QThread::msleep(500);
|
||||
if(global::otaUpdate::downloadOta == false) {
|
||||
log("Checking for available OTA update", className);
|
||||
string_writeconfig("/opt/ibxd", "ota_update_check\n");
|
||||
writeFile("/opt/ibxd", "ota_update_check\n");
|
||||
QTimer * otaCheckTimer = new QTimer(this);
|
||||
otaCheckTimer->setInterval(100);
|
||||
connect(otaCheckTimer, &QTimer::timeout, [&]() {
|
||||
|
@ -28,7 +28,7 @@ otaManager::otaManager(QWidget *parent) :
|
|||
emit canOtaUpdate(false);
|
||||
}
|
||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||
string_writeconfig("/external_root/opt/storage/update/last_sync", std::to_string(currentEpoch));
|
||||
writeFile("/external_root/opt/storage/update/last_sync", QString::number(currentEpoch));
|
||||
QFile::remove("/run/can_ota_update");
|
||||
otaManager::close();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ otaManager::otaManager(QWidget *parent) :
|
|||
else {
|
||||
log("Downloading OTA update", className);
|
||||
QFile::remove("/run/can_install_ota_update");
|
||||
string_writeconfig("/opt/ibxd", "ota_update_download\n");
|
||||
writeFile("/opt/ibxd", "ota_update_download\n");
|
||||
QTimer * otaDownloadTimer = new QTimer(this);
|
||||
otaDownloadTimer->setInterval(100);
|
||||
connect(otaDownloadTimer, &QTimer::timeout, [&]() {
|
||||
|
|
|
@ -149,7 +149,7 @@ reader::reader(QWidget *parent) :
|
|||
if(checkconfig("/tmp/suspendBook") == true) {
|
||||
wakeFromSleep = true;
|
||||
// Prevent from opening the Reader framework next time unless the condition is reset
|
||||
string_writeconfig("/tmp/suspendBook", "false");
|
||||
writeFile("/tmp/suspendBook", "false");
|
||||
book_file = "/inkbox/book/book.txt";
|
||||
}
|
||||
else if(global::reader::bookFile.isEmpty() == false) {
|
||||
|
@ -219,14 +219,13 @@ reader::reader(QWidget *parent) :
|
|||
log("Opening file '" + book_file + "'", className);
|
||||
|
||||
// Writing book path to file
|
||||
std::string book_file_str = book_file.toStdString();
|
||||
string_writeconfig("/tmp/inkboxBookPath", book_file_str);
|
||||
writeFile("/tmp/inkboxBookPath", book_file);
|
||||
|
||||
// Calling InkBox daemon (ibxd) via FIFO interface to run bookconfig_mount
|
||||
if(!book_file.isEmpty()) {
|
||||
if(checkconfig(".config/16-global_reading_settings/config") == false) {
|
||||
global::reader::globalReadingSettings = false;
|
||||
string_writeconfig("/opt/ibxd", "bookconfig_mount\n");
|
||||
writeFile("/opt/ibxd", "bookconfig_mount\n");
|
||||
// Callback handler to wait until bookconfig_mount has finished execution
|
||||
while(true) {
|
||||
if(QFile::exists("/inkbox/bookConfigSetUp")) {
|
||||
|
@ -256,14 +255,14 @@ reader::reader(QWidget *parent) :
|
|||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n") {
|
||||
if(checkconfig(".config/10-dark_mode/config") == true) {
|
||||
log("Setting night mode to ON", className);
|
||||
string_writeconfig("/tmp/invertScreen", "y");
|
||||
writeFile("/tmp/invertScreen", "y");
|
||||
ui->nightModeBtn->setText("");
|
||||
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png"));
|
||||
isNightModeActive = true;
|
||||
}
|
||||
else {
|
||||
log("Setting night mode to OFF", className);
|
||||
string_writeconfig("/tmp/invertScreen", "n");
|
||||
writeFile("/tmp/invertScreen", "n");
|
||||
ui->nightModeBtn->setText("");
|
||||
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
|
||||
isNightModeActive = false;
|
||||
|
@ -375,25 +374,19 @@ reader::reader(QWidget *parent) :
|
|||
}
|
||||
|
||||
// Checking if there is a page refresh setting set
|
||||
string_checkconfig(".config/04-book/refresh");
|
||||
if(checkconfig_str_val == "") {
|
||||
if(readFile(".config/04-book/refresh").isEmpty()) {
|
||||
// Writing the default, refresh every 3 pages
|
||||
string_writeconfig(".config/04-book/refresh", "3");
|
||||
string_checkconfig(".config/04-book/refresh");
|
||||
writeFile(".config/04-book/refresh", "3");
|
||||
}
|
||||
else {
|
||||
// A config option was set, continuing after the Else statement...
|
||||
;
|
||||
}
|
||||
pageRefreshSetting = checkconfig_str_val.toInt();
|
||||
pageRefreshSetting = readFile(".config/04-book/refresh").toInt();
|
||||
// Checking if that config option was set to "Never refresh"...
|
||||
if(pageRefreshSetting == -1) {
|
||||
log("Setting page refresh to 'disabled'", className);
|
||||
neverRefresh = true;
|
||||
}
|
||||
else {
|
||||
log("Setting page refresh to each " + QString::number(pageRefreshSetting) + " pages", className);
|
||||
// Safety measure
|
||||
log("Setting page refresh to each " + checkconfig_str_val + " pages", className);
|
||||
neverRefresh = false;
|
||||
}
|
||||
|
||||
|
@ -403,7 +396,7 @@ reader::reader(QWidget *parent) :
|
|||
t->setInterval(500);
|
||||
connect(t, &QTimer::timeout, [&]() {
|
||||
QString time = QTime::currentTime().toString("hh:mm:ss");
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
ui->batteryLabel->setText(batt_level);
|
||||
ui->timeLabel->setText(time);
|
||||
} );
|
||||
|
@ -414,7 +407,7 @@ reader::reader(QWidget *parent) :
|
|||
t->setInterval(500);
|
||||
connect(t, &QTimer::timeout, [&]() {
|
||||
QString time = QTime::currentTime().toString("hh:mm");
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
ui->batteryLabel->setText(batt_level);
|
||||
ui->timeLabel->setText(time);
|
||||
} );
|
||||
|
@ -424,7 +417,7 @@ reader::reader(QWidget *parent) :
|
|||
// Checking if we're waking from sleep and have lockscreen enabled; if so, do nothing there because the book should already have been parsed
|
||||
if(wakeFromSleep != true) {
|
||||
// Remount tmpfs
|
||||
string_writeconfig("/inkbox/remount", "true");
|
||||
writeFile("/inkbox/remount", "true");
|
||||
|
||||
// Counting number of parsed files
|
||||
split_total = setup_book(book_file, 0, true);
|
||||
|
@ -435,8 +428,7 @@ reader::reader(QWidget *parent) :
|
|||
}
|
||||
else {
|
||||
// Retrieve split_total from tmpfs
|
||||
string_checkconfig("/tmp/inkboxPageNumber");
|
||||
split_total = checkconfig_str_val.toInt();
|
||||
split_total = readFile("/tmp/inkboxPageNumber").toInt();
|
||||
setup_book(book_file, 0, true);
|
||||
}
|
||||
|
||||
|
@ -444,9 +436,9 @@ reader::reader(QWidget *parent) :
|
|||
if(is_epub == false && is_pdf == false && is_image == false) {
|
||||
setDefaultWorkDir();
|
||||
if(global::reader::globalReadingSettings == false) {
|
||||
string_checkconfig_ro(".config/A-page_number/config");
|
||||
if(checkconfig_str_val != "") {
|
||||
split_total = checkconfig_str_val.toInt();
|
||||
QString splitTotalPageNumber = readFile(".config/A-page_number/config");
|
||||
if(!splitTotalPageNumber.isEmpty()) {
|
||||
split_total = splitTotalPageNumber.toInt();
|
||||
}
|
||||
}
|
||||
setup_book(book_file, split_total, true);
|
||||
|
@ -561,8 +553,7 @@ reader::reader(QWidget *parent) :
|
|||
else {
|
||||
QString bookReadRelativePath;
|
||||
if(wakeFromSleep == true) {
|
||||
string_checkconfig_ro("/tmp/inkboxBookPath");
|
||||
bookReadRelativePath = checkconfig_str_val.split("/").last();
|
||||
bookReadRelativePath = readFile("/tmp/inkboxBookPath").split("/").last();
|
||||
}
|
||||
else {
|
||||
bookReadRelativePath = book_file.split("/").last();
|
||||
|
@ -589,10 +580,10 @@ reader::reader(QWidget *parent) :
|
|||
}
|
||||
|
||||
// Clean up
|
||||
string_writeconfig("/inkbox/remount", "true");
|
||||
writeFile("/inkbox/remount", "true");
|
||||
|
||||
// Way to tell shell scripts that we're in the Reader framework
|
||||
string_writeconfig("/tmp/inkboxReading", "true");
|
||||
writeFile("/tmp/inkboxReading", "true");
|
||||
|
||||
// Maintain a 'Recent books' list
|
||||
QJsonObject recentBooksObject;
|
||||
|
@ -747,7 +738,7 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
|||
remount = false;
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/inkbox/remount", "false");
|
||||
writeFile("/inkbox/remount", "false");
|
||||
QString mount_prog ("sh");
|
||||
QStringList mount_args;
|
||||
mount_args << "split.sh";
|
||||
|
@ -791,8 +782,8 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
|||
ui->line->deleteLater();
|
||||
ui->line_3->deleteLater();
|
||||
|
||||
string_writeconfig("/tmp/inkboxImagePath", book.toStdString());
|
||||
string_writeconfig("/opt/ibxd", "inkbox_convert_image\n");
|
||||
writeFile("/tmp/inkboxImagePath", book);
|
||||
writeFile("/opt/ibxd", "inkbox_convert_image\n");
|
||||
|
||||
while(true) {
|
||||
if(QFile::exists("/inkbox/convertImageDone")) {
|
||||
|
@ -825,11 +816,10 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
|||
// Checking whether or not the user has defined an option for the number of words per page; if not, then setting the default.
|
||||
// NOTE: This is only for plain text files.
|
||||
setDefaultWorkDir();
|
||||
string_checkconfig(".config/07-words_number/config");
|
||||
if(checkconfig_str_val == "") {
|
||||
string_writeconfig(".config/07-words_number/config", "100");
|
||||
string_checkconfig(".config/07-words_number/config");
|
||||
if(readFile(".config/07-words_number/config").isEmpty()) {
|
||||
writeFile(".config/07-words_number/config", "100");
|
||||
}
|
||||
QString wordsNumberConfig = readFile(".config/07-words_number/config");
|
||||
|
||||
// Parsing file
|
||||
if(is_epub == true) {
|
||||
|
@ -867,7 +857,7 @@ int reader::setup_book(QString book, int i, bool run_parser) {
|
|||
else {
|
||||
QString parse_prog ("/mnt/onboard/.adds/inkbox/system/bin/split-txt");
|
||||
QStringList parse_args;
|
||||
parse_args << checkconfig_str_val;
|
||||
parse_args << wordsNumberConfig;
|
||||
QProcess * parse_proc = new QProcess();
|
||||
parse_proc->start(parse_prog, parse_args);
|
||||
parse_proc->waitForFinished();
|
||||
|
@ -919,11 +909,11 @@ bool reader::epub_file_match(QString file) {
|
|||
|
||||
if(fileExt == "epub" or fileExt == "EPUB") {
|
||||
log("Book file format: ePUB", className);
|
||||
string_writeconfig("/inkbox/bookIsEpub", "true");
|
||||
writeFile("/inkbox/bookIsEpub", "true");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/inkbox/bookIsEpub", "false");
|
||||
writeFile("/inkbox/bookIsEpub", "false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1166,11 +1156,11 @@ void reader::on_homeBtn_clicked()
|
|||
{
|
||||
log("Returning to Home screen", className);
|
||||
// We're leaving reading mode
|
||||
string_writeconfig("/tmp/inkboxReading", "false");
|
||||
writeFile("/tmp/inkboxReading", "false");
|
||||
// Remount tmpfs
|
||||
string_writeconfig("/inkbox/remount", "true");
|
||||
writeFile("/inkbox/remount", "true");
|
||||
// Specify cinematic brightness mode
|
||||
string_writeconfig("/tmp/inkbox-cinematicBrightness_auto", "true");
|
||||
writeFile("/tmp/inkbox-cinematicBrightness_auto", "true");
|
||||
|
||||
// Relaunching process
|
||||
quit_restart();
|
||||
|
@ -1188,7 +1178,7 @@ void reader::on_alignLeftBtn_clicked()
|
|||
log("Setting text alignment to 'Left'", className);
|
||||
global::reader::textAlignment = 0;
|
||||
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
|
||||
string_writeconfig(".config/04-book/alignment", "Left");
|
||||
writeFile(".config/04-book/alignment", "Left");
|
||||
}
|
||||
|
||||
void reader::on_alignCenterBtn_clicked()
|
||||
|
@ -1196,7 +1186,7 @@ void reader::on_alignCenterBtn_clicked()
|
|||
log("Setting text alignment to 'Center'", className);
|
||||
global::reader::textAlignment = 1;
|
||||
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
|
||||
string_writeconfig(".config/04-book/alignment", "Center");
|
||||
writeFile(".config/04-book/alignment", "Center");
|
||||
}
|
||||
|
||||
void reader::on_alignRightBtn_clicked()
|
||||
|
@ -1204,7 +1194,7 @@ void reader::on_alignRightBtn_clicked()
|
|||
log("Setting text alignment to 'Right'", className);
|
||||
global::reader::textAlignment = 2;
|
||||
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
|
||||
string_writeconfig(".config/04-book/alignment", "Right");
|
||||
writeFile(".config/04-book/alignment", "Right");
|
||||
}
|
||||
|
||||
void reader::on_alignJustifyBtn_clicked()
|
||||
|
@ -1212,7 +1202,7 @@ void reader::on_alignJustifyBtn_clicked()
|
|||
log("Setting text alignment to 'Justify'", className);
|
||||
global::reader::textAlignment = 3;
|
||||
setTextProperties(global::reader::textAlignment, global::reader::lineSpacing, global::reader::margins, global::reader::font, global::reader::fontSize);
|
||||
string_writeconfig(".config/04-book/alignment", "Justify");
|
||||
writeFile(".config/04-book/alignment", "Justify");
|
||||
}
|
||||
|
||||
void reader::setTextProperties(int alignment, int lineSpacing, int margins, QString font, int fontSize) {
|
||||
|
@ -1369,7 +1359,7 @@ void reader::menubar_show() {
|
|||
ui->batteryIconLabel->setPixmap(scaledChargingPixmap);
|
||||
}
|
||||
else {
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
if(batt_level_int >= 75 && batt_level_int <= 100) {
|
||||
ui->batteryIconLabel->setPixmap(scaledFullPixmap);
|
||||
}
|
||||
|
@ -1531,30 +1521,30 @@ void reader::on_sizeSlider_valueChanged(int value)
|
|||
void reader::writeconfig_pagenumber(bool persistent) {
|
||||
// Saving the page number in tmpfs and in persistent storage if requested
|
||||
if(is_epub == true) {
|
||||
std::string epubPageNumber_str = std::to_string(mupdf::epub::epubPageNumber);
|
||||
string_writeconfig("/tmp/inkboxPageNumber", epubPageNumber_str);
|
||||
QString epubPageNumberStr = QString::number(mupdf::epub::epubPageNumber);
|
||||
writeFile("/tmp/inkboxPageNumber", epubPageNumberStr);
|
||||
if(persistent == true) {
|
||||
log("Writing page number config for page '" + QString::number(mupdf::epub::epubPageNumber) + "'", className);
|
||||
epubPageNumber_str.append("\n");
|
||||
string_writeconfig(".config/A-page_number/config", epubPageNumber_str);
|
||||
epubPageNumberStr.append("\n");
|
||||
writeFile(".config/A-page_number/config", epubPageNumberStr);
|
||||
}
|
||||
}
|
||||
else if(is_pdf == true) {
|
||||
std::string pdfPageNumber_str = std::to_string(mupdf::pdf::pdfPageNumber);
|
||||
string_writeconfig("/tmp/inkboxPageNumber", pdfPageNumber_str);
|
||||
QString pdfPageNumberStr = QString::number(mupdf::pdf::pdfPageNumber);
|
||||
writeFile("/tmp/inkboxPageNumber", pdfPageNumberStr);
|
||||
if(persistent == true) {
|
||||
log("Writing page number config for page '" + QString::number(mupdf::pdf::pdfPageNumber) + "'", className);
|
||||
pdfPageNumber_str.append("\n");
|
||||
string_writeconfig(".config/A-page_number/config", pdfPageNumber_str);
|
||||
log("Writing page number config for page '" + pdfPageNumberStr + "'", className);
|
||||
pdfPageNumberStr.append("\n");
|
||||
writeFile(".config/A-page_number/config", pdfPageNumberStr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::string split_total_str = std::to_string(split_total);
|
||||
string_writeconfig("/tmp/inkboxPageNumber", split_total_str);
|
||||
QString splitTotalStr = QString::number(split_total);
|
||||
writeFile("/tmp/inkboxPageNumber", splitTotalStr);
|
||||
if(persistent == true) {
|
||||
log("Writing page number config for split total '" + QString::number(split_total) + "'", className);
|
||||
split_total_str.append("\n");
|
||||
string_writeconfig(".config/A-page_number/config", split_total_str);
|
||||
log("Writing page number config for split total '" + splitTotalStr + "'", className);
|
||||
splitTotalStr.append("\n");
|
||||
writeFile(".config/A-page_number/config", splitTotalStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1566,7 +1556,7 @@ void reader::quit_restart() {
|
|||
saveReadingSettings();
|
||||
|
||||
// Cleaning bookconfig_mount mountpoint
|
||||
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
|
||||
writeFile("/opt/ibxd", "bookconfig_unmount\n");
|
||||
|
||||
// Restarting InkBox
|
||||
QProcess process;
|
||||
|
@ -1636,8 +1626,7 @@ void reader::convertMuPdfVars(int fileType, bool convertAll) {
|
|||
}
|
||||
if(global::reader::globalReadingSettings == false) {
|
||||
if(goToSavedPageDone == false) {
|
||||
string_checkconfig_ro(".config/A-page_number/config");
|
||||
mupdf::pdf::pdfPageNumber = checkconfig_str_val.toInt();
|
||||
mupdf::pdf::pdfPageNumber = readFile(".config/A-page_number/config").toInt();
|
||||
goToSavedPageDone = true;
|
||||
}
|
||||
}
|
||||
|
@ -1664,29 +1653,19 @@ void reader::setPageStyle(int fileType) {
|
|||
// General page size
|
||||
defineDefaultPageSize(0);
|
||||
|
||||
string_checkconfig_ro(".config/13-epub_page_size/width");
|
||||
if(checkconfig_str_val != "") {
|
||||
;
|
||||
if(readFile(".config/13-epub_page_size/width").isEmpty()) {
|
||||
QString pageWidth = QString::number(defaultEpubPageWidth);
|
||||
writeFile(".config/13-epub_page_size/width", pageWidth);
|
||||
writeFile(".config/13-epub_page_size/set", "true");
|
||||
}
|
||||
else {
|
||||
std::string pageWidth = std::to_string(defaultEpubPageWidth);
|
||||
string_writeconfig(".config/13-epub_page_size/width", pageWidth);
|
||||
string_writeconfig(".config/13-epub_page_size/set", "true");
|
||||
string_checkconfig_ro(".config/13-epub_page_size/width");
|
||||
}
|
||||
mupdf::epub::width = checkconfig_str_val.toInt();
|
||||
mupdf::epub::width = readFile(".config/13-epub_page_size/width").toInt();
|
||||
|
||||
string_checkconfig_ro(".config/13-epub_page_size/height");
|
||||
if(checkconfig_str_val != "") {
|
||||
;
|
||||
if(readFile(".config/13-epub_page_size/height").isEmpty()) {
|
||||
QString pageHeight = QString::number(defaultEpubPageHeight);
|
||||
writeFile(".config/13-epub_page_size/height", pageHeight);
|
||||
writeFile(".config/13-epub_page_size/set", "true");
|
||||
}
|
||||
else {
|
||||
std::string pageHeight = std::to_string(defaultEpubPageHeight);
|
||||
string_writeconfig(".config/13-epub_page_size/height", pageHeight);
|
||||
string_writeconfig(".config/13-epub_page_size/set", "true");
|
||||
string_checkconfig_ro(".config/13-epub_page_size/height");
|
||||
}
|
||||
mupdf::epub::height = checkconfig_str_val.toInt();
|
||||
mupdf::epub::height = readFile(".config/13-epub_page_size/height").toInt();
|
||||
}
|
||||
else if(fileType == 1) {
|
||||
defineDefaultPageSize(1);
|
||||
|
@ -1765,16 +1744,16 @@ void reader::on_nightModeBtn_clicked()
|
|||
if(isNightModeActive == true) {
|
||||
// Disabling night/dark mode
|
||||
log("Setting night mode to OFF", className);
|
||||
string_writeconfig("/tmp/invertScreen", "n");
|
||||
string_writeconfig(".config/10-dark_mode/config", "false");
|
||||
writeFile("/tmp/invertScreen", "n");
|
||||
writeFile(".config/10-dark_mode/config", "false");
|
||||
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
|
||||
isNightModeActive = false;
|
||||
}
|
||||
else {
|
||||
// Enabling night/dark mode
|
||||
log("Setting night mode to ON", className);
|
||||
string_writeconfig("/tmp/invertScreen", "y");
|
||||
string_writeconfig(".config/10-dark_mode/config", "true");
|
||||
writeFile("/tmp/invertScreen", "y");
|
||||
writeFile(".config/10-dark_mode/config", "true");
|
||||
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png"));
|
||||
isNightModeActive = true;
|
||||
}
|
||||
|
@ -1844,9 +1823,9 @@ void reader::getTotalEpubPagesNumber() {
|
|||
epubProc->waitForFinished();
|
||||
epubProc->deleteLater();
|
||||
|
||||
string_checkconfig_ro("/run/epub_total_pages_number");
|
||||
totalPagesInt = checkconfig_str_val.toInt();
|
||||
log("ePUB total pages number: " + checkconfig_str_val, className);
|
||||
QString totalPages = readFile("/run/epub_total_pages_number");
|
||||
totalPagesInt = totalPages.toInt();
|
||||
log("ePUB total pages number: " + totalPages, className);
|
||||
QFile::remove("/run/epub_total_pages_number");
|
||||
}
|
||||
|
||||
|
@ -1996,11 +1975,11 @@ bool reader::pdf_file_match(QString file) {
|
|||
|
||||
if(fileExt == "pdf" or fileExt == "PDF") {
|
||||
log("Book file format: PDF", className);
|
||||
string_writeconfig("/inkbox/bookIsPdf", "true");
|
||||
writeFile("/inkbox/bookIsPdf", "true");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/inkbox/bookIsPdf", "false");
|
||||
writeFile("/inkbox/bookIsPdf", "false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2008,16 +1987,16 @@ bool reader::pdf_file_match(QString file) {
|
|||
bool reader::image_file_match(QString file) {
|
||||
if(file.right(3) == "png" or file.right(3) == "PNG" or file.right(3) == "jpg" or file.right(3) == "JPG" or file.right(3) == "bmp" or file.right(3) == "BMP" or file.right(3) == "tif" or file.right(3) == "TIF") {
|
||||
log("File format: image", className);
|
||||
string_writeconfig("/inkbox/bookIsImage", "true");
|
||||
writeFile("/inkbox/bookIsImage", "true");
|
||||
return true;
|
||||
}
|
||||
else if(file.right(4) == "jpeg" or file.right(4) == "JPEG" or file.right(4) == "tiff" or file.right(4) == "TIFF") {
|
||||
log("File format: image", className);
|
||||
string_writeconfig("/inkbox/bookIsImage", "true");
|
||||
writeFile("/inkbox/bookIsImage", "true");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/inkbox/bookIsImage", "false");
|
||||
writeFile("/inkbox/bookIsImage", "false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2032,9 +2011,9 @@ void reader::getTotalPdfPagesNumber() {
|
|||
epubProc->waitForFinished();
|
||||
epubProc->deleteLater();
|
||||
|
||||
string_checkconfig_ro("/run/pdf_total_pages_number");
|
||||
totalPagesInt = checkconfig_str_val.toInt();
|
||||
log("Total PDF pages number: " + checkconfig_str_val, className);
|
||||
QString totalPages = readFile("/run/pdf_total_pages_number");
|
||||
totalPagesInt = totalPages.toInt();
|
||||
log("Total PDF pages number: " + totalPages, className);
|
||||
QFile::remove("/run/pdf_total_pages_number");
|
||||
}
|
||||
|
||||
|
@ -2131,8 +2110,8 @@ void reader::closeIndefiniteToast() {
|
|||
|
||||
void reader::getPdfOrientation(QString file) {
|
||||
log("Getting viewport orientation for PDF file '" + file + "'", className);
|
||||
string_writeconfig("/inkbox/pdf_orientation_file_request", file.toStdString());
|
||||
string_writeconfig("/opt/ibxd", "get_pdf_orientation\n");
|
||||
writeFile("/inkbox/pdf_orientation_file_request", file);
|
||||
writeFile("/opt/ibxd", "get_pdf_orientation\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/inkbox/pdf_orientation_result")) {
|
||||
QString result = readFile("/inkbox/pdf_orientation_result").trimmed();
|
||||
|
@ -2273,7 +2252,7 @@ void reader::on_brightnessBtn_clicked()
|
|||
void reader::setCinematicBrightnessWarmthSlot() {
|
||||
if(global::reader::globalReadingSettings == false) {
|
||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
||||
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||
int brightness_value = brightnessCheckconfig(".config/03-brightness/config");
|
||||
log("Local Reading Settings: Setting brightness to " + QString::number(brightness_value), className);
|
||||
cinematicBrightness(brightness_value, 2);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ koboxSettings::koboxSettings(QWidget *parent) :
|
|||
|
||||
// DPI setting
|
||||
QString dpiSetting;
|
||||
string_checkconfig(".config/00-kobox/dpiSetting");
|
||||
if(checkconfig_str_val == "") {
|
||||
QString dpiSettingStr = readFile(".config/00-kobox/dpiSetting");
|
||||
if(dpiSettingStr.isEmpty()) {
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
dpiSetting = "125";
|
||||
}
|
||||
|
@ -57,12 +57,11 @@ koboxSettings::koboxSettings(QWidget *parent) :
|
|||
else {
|
||||
dpiSetting = "125";
|
||||
}
|
||||
std::string dpiSetting_str = dpiSetting.toStdString();
|
||||
string_writeconfig(".config/00-kobox/dpiSetting", dpiSetting_str);
|
||||
writeFile(".config/00-kobox/dpiSetting", dpiSetting);
|
||||
}
|
||||
|
||||
string_checkconfig(".config/00-kobox/dpiSetting");
|
||||
int dpi_setting = checkconfig_str_val.toInt();
|
||||
readFile(".config/00-kobox/dpiSetting");
|
||||
int dpi_setting = dpiSettingStr.toInt();
|
||||
ui->spinBox->setValue(dpi_setting);
|
||||
}
|
||||
|
||||
|
@ -112,8 +111,7 @@ void koboxSettings::openResetKoboxDialog() {
|
|||
void koboxSettings::on_spinBox_valueChanged(int arg1)
|
||||
{
|
||||
QString number = QString::number(arg1);
|
||||
string number_str = number.toStdString();
|
||||
string_writeconfig(".config/00-kobox/dpiSetting", number_str);
|
||||
writeFile(".config/00-kobox/dpiSetting", number);
|
||||
log("X11 DPI set to " + number, className);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ settings::settings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// Words number
|
||||
string_checkconfig(".config/07-words_number/config");
|
||||
if(checkconfig_str_val == "") {
|
||||
QString wordsNumberConfigStr = readFile(".config/07-words_number/config");
|
||||
if(wordsNumberConfigStr.isEmpty()) {
|
||||
if(global::deviceID == "n705\n") {
|
||||
wordsNumberSaved = 120;
|
||||
}
|
||||
|
@ -130,17 +130,17 @@ settings::settings(QWidget *parent) :
|
|||
}
|
||||
}
|
||||
else {
|
||||
QString words_number = checkconfig_str_val;
|
||||
wordsNumberSaved = checkconfig_str_val.toInt();
|
||||
QString words_number = wordsNumberConfigStr;
|
||||
wordsNumberSaved = wordsNumberConfigStr.toInt();
|
||||
}
|
||||
ui->wordsNumberValueLabel->setText(QString::number(wordsNumberSaved));
|
||||
|
||||
|
||||
// ePUB page size
|
||||
if(checkconfig(".config/13-epub_page_size/set") == true) {
|
||||
string_checkconfig_ro(".config/13-epub_page_size/width");
|
||||
if(checkconfig_str_val != "") {
|
||||
QString pageWidth = checkconfig_str_val;
|
||||
QString epubPageWidthSettingStr = readFile(".config/13-epub_page_size/width");
|
||||
if(!epubPageWidthSettingStr.isEmpty()) {
|
||||
QString pageWidth = epubPageWidthSettingStr;
|
||||
ui->pageSizeWidthLabel->setText(pageWidth);
|
||||
pageSizeWidthSaved = pageWidth.toInt();
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ settings::settings(QWidget *parent) :
|
|||
ui->pageSizeWidthLabel->setText(QString::number(defaultEpubPageWidth));
|
||||
pageSizeWidthSaved = defaultEpubPageWidth;
|
||||
}
|
||||
string_checkconfig_ro(".config/13-epub_page_size/height");
|
||||
if(checkconfig_str_val != "") {
|
||||
QString pageHeight = checkconfig_str_val;
|
||||
QString epubPageHeightSettingStr = readFile(".config/13-epub_page_size/height");
|
||||
if(!epubPageHeightSettingStr.isEmpty()) {
|
||||
QString pageHeight = epubPageHeightSettingStr;
|
||||
ui->pageSizeHeightLabel->setText(pageHeight);
|
||||
pageSizeHeightSaved = pageHeight.toInt();
|
||||
}
|
||||
|
@ -179,30 +179,30 @@ settings::settings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// Scaling
|
||||
string_checkconfig(".config/09-dpi/config");
|
||||
if(checkconfig_str_val == "") {
|
||||
QString dpiSettingStr = readFile(".config/09-dpi/config");
|
||||
if(dpiSettingStr.isEmpty()) {
|
||||
// Writing default value depending on the device
|
||||
if(global::deviceID == "n705\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "187");
|
||||
writeFile(".config/09-dpi/config", "187");
|
||||
}
|
||||
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "160");
|
||||
writeFile(".config/09-dpi/config", "160");
|
||||
}
|
||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "195");
|
||||
writeFile(".config/09-dpi/config", "195");
|
||||
}
|
||||
else if(global::deviceID == "n437\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "275");
|
||||
writeFile(".config/09-dpi/config", "275");
|
||||
}
|
||||
else if(global::deviceID == "n873\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "285");
|
||||
writeFile(".config/09-dpi/config", "285");
|
||||
}
|
||||
else {
|
||||
string_writeconfig(".config/09-dpi/config", "187");
|
||||
writeFile(".config/09-dpi/config", "187");
|
||||
}
|
||||
}
|
||||
else {
|
||||
int dpi_number = checkconfig_str_val.toInt();
|
||||
int dpi_number = dpiSettingStr.toInt();
|
||||
// Checking if it's a Mini, Touch or a Glo
|
||||
if(global::deviceID == "n705\n") {
|
||||
if(dpi_number == 187) {
|
||||
|
@ -284,14 +284,14 @@ settings::settings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// Refresh
|
||||
string_checkconfig_ro(".config/04-book/refresh");
|
||||
if(checkconfig_str_val == "") {
|
||||
QString refreshSettingStr = readFile(".config/04-book/refresh");
|
||||
if(refreshSettingStr.isEmpty()) {
|
||||
// Set default option, 3
|
||||
string_writeconfig(".config/04-book/refresh", "3");
|
||||
writeFile(".config/04-book/refresh", "3");
|
||||
ui->comboBox->setCurrentText("3 pages");
|
||||
}
|
||||
else {
|
||||
int refreshInt = checkconfig_str_val.toInt();
|
||||
int refreshInt = refreshSettingStr.toInt();
|
||||
if(refreshInt == -1) {
|
||||
ui->comboBox->setCurrentText("Never refresh");
|
||||
}
|
||||
|
@ -474,9 +474,8 @@ void settings::on_aboutBtn_clicked()
|
|||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
QString aboutmsg = "InkBox is an open-source, Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive.";
|
||||
aboutmsg.prepend("<font face='u001'>");
|
||||
string_checkconfig_ro("/external_root/opt/isa/version");
|
||||
aboutmsg.append("<br><br>InkBox ");
|
||||
aboutmsg.append(checkconfig_str_val);
|
||||
aboutmsg.append(readFile("/external_root/opt/isa/version"));
|
||||
aboutmsg.append("</font>");
|
||||
QMessageBox::information(this, tr("Information"), aboutmsg);
|
||||
}
|
||||
|
@ -647,13 +646,13 @@ void settings::on_darkModeCheckBox_toggled(bool checked)
|
|||
QString settingString = "dark mode";
|
||||
if(checked == true) {
|
||||
logEnabled(settingString, className);
|
||||
string_writeconfig(".config/10-dark_mode/config", "true");
|
||||
string_writeconfig("/tmp/invertScreen", "y");
|
||||
writeFile(".config/10-dark_mode/config", "true");
|
||||
writeFile("/tmp/invertScreen", "y");
|
||||
}
|
||||
else {
|
||||
logDisabled(settingString, className);
|
||||
string_writeconfig(".config/10-dark_mode/config", "false");
|
||||
string_writeconfig("/tmp/invertScreen", "n");
|
||||
writeFile(".config/10-dark_mode/config", "false");
|
||||
writeFile("/tmp/invertScreen", "n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -662,62 +661,62 @@ void settings::on_uiScalingSlider_valueChanged(int value)
|
|||
log("Setting DPI level to " + QString::number(value), className);
|
||||
if(value == 0) {
|
||||
if(global::deviceID == "n705\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "187");
|
||||
writeFile(".config/09-dpi/config", "187");
|
||||
}
|
||||
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "160");
|
||||
writeFile(".config/09-dpi/config", "160");
|
||||
}
|
||||
if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "195");
|
||||
writeFile(".config/09-dpi/config", "195");
|
||||
}
|
||||
if(global::deviceID == "n306\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "212");
|
||||
writeFile(".config/09-dpi/config", "212");
|
||||
}
|
||||
if(global::deviceID == "n437\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "275");
|
||||
writeFile(".config/09-dpi/config", "275");
|
||||
}
|
||||
if(global::deviceID == "n873\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "285");
|
||||
writeFile(".config/09-dpi/config", "285");
|
||||
}
|
||||
}
|
||||
if(value == 1) {
|
||||
if(global::deviceID == "n705\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "214");
|
||||
writeFile(".config/09-dpi/config", "214");
|
||||
}
|
||||
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "187");
|
||||
writeFile(".config/09-dpi/config", "187");
|
||||
}
|
||||
if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "210");
|
||||
writeFile(".config/09-dpi/config", "210");
|
||||
}
|
||||
if(global::deviceID == "n306\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "227");
|
||||
writeFile(".config/09-dpi/config", "227");
|
||||
}
|
||||
if(global::deviceID == "n437\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "290");
|
||||
writeFile(".config/09-dpi/config", "290");
|
||||
}
|
||||
if(global::deviceID == "n873\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "300");
|
||||
writeFile(".config/09-dpi/config", "300");
|
||||
}
|
||||
}
|
||||
if(value == 2) {
|
||||
if(global::deviceID == "n705\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "227");
|
||||
writeFile(".config/09-dpi/config", "227");
|
||||
}
|
||||
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "200");
|
||||
writeFile(".config/09-dpi/config", "200");
|
||||
}
|
||||
if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "emu\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "225");
|
||||
writeFile(".config/09-dpi/config", "225");
|
||||
}
|
||||
if(global::deviceID == "n306\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "242");
|
||||
writeFile(".config/09-dpi/config", "242");
|
||||
}
|
||||
if(global::deviceID == "n437\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "305");
|
||||
writeFile(".config/09-dpi/config", "305");
|
||||
}
|
||||
if(global::deviceID == "n873\n") {
|
||||
string_writeconfig(".config/09-dpi/config", "315");
|
||||
writeFile(".config/09-dpi/config", "315");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -756,28 +755,28 @@ void settings::on_comboBox_currentIndexChanged(const QString &arg1)
|
|||
{
|
||||
log("Setting page refresh setting to " + arg1, className);
|
||||
if(arg1 == "Every page") {
|
||||
string_writeconfig(".config/04-book/refresh", "0");
|
||||
writeFile(".config/04-book/refresh", "0");
|
||||
}
|
||||
if(arg1 == "1 page") {
|
||||
string_writeconfig(".config/04-book/refresh", "1");
|
||||
writeFile(".config/04-book/refresh", "1");
|
||||
}
|
||||
if(arg1 == "2 pages") {
|
||||
string_writeconfig(".config/04-book/refresh", "2");
|
||||
writeFile(".config/04-book/refresh", "2");
|
||||
}
|
||||
if(arg1 == "3 pages") {
|
||||
string_writeconfig(".config/04-book/refresh", "3");
|
||||
writeFile(".config/04-book/refresh", "3");
|
||||
}
|
||||
if(arg1 == "4 pages") {
|
||||
string_writeconfig(".config/04-book/refresh", "4");
|
||||
writeFile(".config/04-book/refresh", "4");
|
||||
}
|
||||
if(arg1 == "5 pages") {
|
||||
string_writeconfig(".config/04-book/refresh", "5");
|
||||
writeFile(".config/04-book/refresh", "5");
|
||||
}
|
||||
if(arg1 == "6 pages") {
|
||||
string_writeconfig(".config/04-book/refresh", "6");
|
||||
writeFile(".config/04-book/refresh", "6");
|
||||
}
|
||||
if(arg1 == "Never refresh") {
|
||||
string_writeconfig(".config/04-book/refresh", "-1");
|
||||
writeFile(".config/04-book/refresh", "-1");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,7 +784,7 @@ void settings::on_resetBtn_clicked()
|
|||
{
|
||||
log("'Reset' button clicked", className);
|
||||
// We write to a temporary file to show a "Reset" prompt
|
||||
string_writeconfig("/inkbox/resetDialog", "true");
|
||||
writeFile("/inkbox/resetDialog", "true");
|
||||
|
||||
// We setup the dialog
|
||||
log("Showing reset dialog", className);
|
||||
|
@ -798,7 +797,7 @@ void settings::on_setPasscodeBtn_clicked()
|
|||
log("'Set passcode' button clicked", className);
|
||||
log("Launching lockscreen binary", className);
|
||||
saveDeferredSettings();
|
||||
string_writeconfig("/tmp/setPasscode", "true");
|
||||
writeFile("/tmp/setPasscode", "true");
|
||||
QProcess process;
|
||||
process.startDetached("lockscreen", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -842,11 +841,11 @@ void settings::on_readerScrollBarCheckBox_toggled(bool checked)
|
|||
QString settingString = "scrollbar display if necessary";
|
||||
if(checked == true) {
|
||||
logEnabled(settingString, className);
|
||||
string_writeconfig(".config/14-reader_scrollbar/config", "true");
|
||||
writeFile(".config/14-reader_scrollbar/config", "true");
|
||||
}
|
||||
else {
|
||||
logDisabled(settingString, className);
|
||||
string_writeconfig(".config/14-reader_scrollbar/config", "false");
|
||||
writeFile(".config/14-reader_scrollbar/config", "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -884,7 +883,7 @@ void settings::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");
|
||||
writeFile("/inkbox/updateDialog", "true");
|
||||
|
||||
// Show the dialog
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
|
@ -935,7 +934,7 @@ void settings::usbms_launch()
|
|||
|
||||
void settings::quit_restart() {
|
||||
// If existing, cleaning bookconfig_mount mountpoint
|
||||
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
|
||||
writeFile("/opt/ibxd", "bookconfig_unmount\n");
|
||||
|
||||
// Restarting InkBox
|
||||
QProcess process;
|
||||
|
@ -950,8 +949,8 @@ void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked)
|
|||
if(enableEncryptedStorageUserChange == true) {
|
||||
logEnabled(settingString, className);
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "false");
|
||||
string_writeconfig(".config/18-encrypted_storage/status", "true");
|
||||
writeFile(".config/18-encrypted_storage/initial_setup_done", "false");
|
||||
writeFile(".config/18-encrypted_storage/status", "true");
|
||||
if(QFile::exists(".config/18-encrypted_storage/storage_list")) {
|
||||
QFile::remove(".config/18-encrypted_storage/storage_list");
|
||||
}
|
||||
|
@ -977,11 +976,11 @@ void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked)
|
|||
void settings::disableStorageEncryption() {
|
||||
log("Disabling encrypted storage", className);
|
||||
setDefaultWorkDir();
|
||||
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true");
|
||||
string_writeconfig("/opt/ibxd", "encfs_stop\n");
|
||||
writeFile("/external_root/run/encfs_stop_cleanup", "true");
|
||||
writeFile("/opt/ibxd", "encfs_stop\n");
|
||||
QThread::msleep(5000);
|
||||
|
||||
string_writeconfig(".config/18-encrypted_storage/status", "false");
|
||||
writeFile(".config/18-encrypted_storage/status", "false");
|
||||
QFile::remove(".config/18-encrypted_storage/initial_setup_done");
|
||||
QFile::remove(".config/18-encrypted_storage/storage_list");
|
||||
QFile::remove("/mnt/onboard/onboard/data.encfs");
|
||||
|
@ -1013,7 +1012,7 @@ void settings::on_repackBtn_clicked()
|
|||
}
|
||||
else {
|
||||
log("Showing encrypted storage repack dialog", className);
|
||||
string_writeconfig("/external_root/run/encfs_repack", "true");
|
||||
writeFile("/external_root/run/encfs_repack", "true");
|
||||
quit_restart();
|
||||
}
|
||||
}
|
||||
|
@ -1022,7 +1021,7 @@ void settings::on_generateSystemReportBtn_clicked()
|
|||
{
|
||||
log("'Generate system report' button clicked", className);
|
||||
log("Generating system report", className);
|
||||
string_writeconfig("/opt/ibxd", "generate_system_report\n");
|
||||
writeFile("/opt/ibxd", "generate_system_report\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/inkbox/systemReportDone")) {
|
||||
if(checkconfig("/inkbox/systemReportDone") == true) {
|
||||
|
@ -1049,8 +1048,8 @@ void settings::on_tzComboBox_currentTextChanged(const QString &arg1)
|
|||
// Preventing unnecessary (e)MMC writes
|
||||
if(readFile(".config/19-timezone/config-name") != arg1) {
|
||||
QProcess::execute("ln", QStringList() << "-sf" << "/usr/share/zoneinfo/" + arg1 << ".config/19-timezone/config");
|
||||
string_writeconfig(".config/19-timezone/config-name", arg1.toStdString());
|
||||
string_writeconfig("/opt/ibxd", "gui_remount_localtime\n");
|
||||
writeFile(".config/19-timezone/config-name", arg1);
|
||||
writeFile("/opt/ibxd", "gui_remount_localtime\n");
|
||||
QThread::msleep(500);
|
||||
}
|
||||
}
|
||||
|
@ -1127,11 +1126,11 @@ void settings::on_usbmsDialogBox_clicked(bool checked)
|
|||
QString settingString = "USB Mass Storage dialog display";
|
||||
if(checked == true) {
|
||||
logEnabled(settingString, className);
|
||||
string_writeconfig(".config/22-usb/show-dialog", "true");
|
||||
writeFile(".config/22-usb/show-dialog", "true");
|
||||
}
|
||||
else {
|
||||
logDisabled(settingString, className);
|
||||
string_writeconfig(".config/22-usb/show-dialog", "false");
|
||||
writeFile(".config/22-usb/show-dialog", "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1140,11 +1139,11 @@ void settings::on_autoCheckUpdatesBox_clicked(bool checked)
|
|||
QString settingString = "automatic updates checking";
|
||||
if(checked == true) {
|
||||
logEnabled(settingString, className);
|
||||
string_writeconfig(".config/23-updates/check-updates", "true");
|
||||
writeFile(".config/23-updates/check-updates", "true");
|
||||
}
|
||||
else {
|
||||
logDisabled(settingString, className);
|
||||
string_writeconfig(".config/23-updates/check-updates", "false");
|
||||
writeFile(".config/23-updates/check-updates", "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,25 +67,25 @@ usbmsSplash::usbmsSplash(QWidget *parent) :
|
|||
void usbmsSplash::usbmsLaunch()
|
||||
{
|
||||
log("Entering USBMS session", className);
|
||||
string_writeconfig("/tmp/in_usbms", "true");
|
||||
writeFile("/tmp/in_usbms", "true");
|
||||
QTimer::singleShot(1500, this, SLOT(brightnessDown()));
|
||||
|
||||
if(global::usbms::koboxExportExtensions == true) {
|
||||
string_writeconfig("/opt/ibxd", "kobox_extensions_storage_unmount\n");
|
||||
writeFile("/opt/ibxd", "kobox_extensions_storage_unmount\n");
|
||||
}
|
||||
if(checkconfig("/external_root/run/encfs_mounted") == true) {
|
||||
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true");
|
||||
string_writeconfig("/opt/ibxd", "encfs_stop\n");
|
||||
writeFile("/external_root/run/encfs_stop_cleanup", "true");
|
||||
writeFile("/opt/ibxd", "encfs_stop\n");
|
||||
QThread::msleep(1500);
|
||||
}
|
||||
|
||||
string_writeconfig("/opt/ibxd", "onboard_unmount\n");
|
||||
writeFile("/opt/ibxd", "onboard_unmount\n");
|
||||
QThread::msleep(1000);
|
||||
|
||||
string_writeconfig("/opt/ibxd", "usbnet_stop\n");
|
||||
writeFile("/opt/ibxd", "usbnet_stop\n");
|
||||
QThread::msleep(1000);
|
||||
|
||||
string_writeconfig("/opt/ibxd", "gui_apps_stop\n");
|
||||
writeFile("/opt/ibxd", "gui_apps_stop\n");
|
||||
QThread::msleep(1000);
|
||||
|
||||
if(global::deviceID == "n306\n" or global::deviceID == "n873\n") {
|
||||
|
@ -181,7 +181,7 @@ void usbmsSplash::brightnessDown() {
|
|||
|
||||
void usbmsSplash::quit_restart() {
|
||||
// If existing, cleaning bookconfig_mount mountpoint
|
||||
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
|
||||
writeFile("/opt/ibxd", "bookconfig_unmount\n");
|
||||
|
||||
// Restarting InkBox
|
||||
QProcess process;
|
||||
|
@ -192,17 +192,17 @@ void usbmsSplash::quit_restart() {
|
|||
void usbmsSplash::restartServices() {
|
||||
// Restarting USBNet
|
||||
// NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet)
|
||||
string_writeconfig("/opt/ibxd", "usbnet_start\n");
|
||||
writeFile("/opt/ibxd", "usbnet_start\n");
|
||||
QThread::msleep(1000);
|
||||
// Mounting onboard storage
|
||||
string_writeconfig("/opt/ibxd", "onboard_mount\n");
|
||||
writeFile("/opt/ibxd", "onboard_mount\n");
|
||||
QThread::msleep(1000);
|
||||
// Checking for updates
|
||||
string_writeconfig("/opt/ibxd", "update_inkbox_restart\n");
|
||||
writeFile("/opt/ibxd", "update_inkbox_restart\n");
|
||||
QThread::msleep(2500);
|
||||
QFile::remove("/tmp/in_usbms");
|
||||
// GUI apps: update main JSON file
|
||||
string_writeconfig("/opt/ibxd", "gui_apps_start\n");
|
||||
writeFile("/opt/ibxd", "gui_apps_start\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/tmp/gui_apps_started")) {
|
||||
if(checkconfig("/tmp/gui_apps_started") == true) {
|
||||
|
|
|
@ -73,18 +73,18 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
|
|||
int value;
|
||||
int warmthValue;
|
||||
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
|
||||
value = get_brightness();
|
||||
value = getBrightness();
|
||||
if(global::isN873 == true) {
|
||||
warmthValue = get_warmth();
|
||||
warmthValue = getWarmth();
|
||||
ui->warmthSlider->setValue(warmthValue);
|
||||
}
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
value = brightness_checkconfig(".config/03-brightness/config");
|
||||
value = brightnessCheckconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
value = get_brightness();
|
||||
value = getBrightness();
|
||||
}
|
||||
|
||||
// Setting the slider to the appropriate position
|
||||
|
@ -96,24 +96,24 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
|
|||
ui->valueLabel->setText(valueStr);
|
||||
// Warmth value label
|
||||
if(global::isN873 == true) {
|
||||
warmthValue = get_warmth();
|
||||
warmthValue = getWarmth();
|
||||
QString warmthValueStr = QString::number(warmthValue);
|
||||
ui->warmthValueLabel->setText(warmthValueStr);
|
||||
}
|
||||
|
||||
// Saving current brightness value in case we want to go backwards
|
||||
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
|
||||
oldValue = get_brightness();
|
||||
oldValue = getBrightness();
|
||||
if(global::isN873 == true) {
|
||||
oldWarmthValue = get_warmth();
|
||||
oldWarmthValue = getWarmth();
|
||||
}
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
oldValue = brightness_checkconfig(".config/03-brightness/config");
|
||||
oldValue = brightnessCheckconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
oldValue = get_brightness();
|
||||
oldValue = getBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,15 +125,15 @@ brightnessDialog::~brightnessDialog()
|
|||
void brightnessDialog::on_quitBtn_clicked()
|
||||
{
|
||||
// Reverting back to the old value
|
||||
brightnessDialog::pre_set_brightness(oldValue);
|
||||
brightnessDialog::preSetBrightness(oldValue);
|
||||
if(global::isN873 == true) {
|
||||
set_warmth(oldWarmthValue);
|
||||
setWarmth(oldWarmthValue);
|
||||
}
|
||||
|
||||
// Just in case ;)
|
||||
brightness_writeconfig(oldValue);
|
||||
brightnessWriteconfig(oldValue);
|
||||
if(global::isN873 == true) {
|
||||
warmth_writeconfig(oldWarmthValue);
|
||||
warmthWriteconfig(oldWarmthValue);
|
||||
}
|
||||
|
||||
// Leaving
|
||||
|
@ -142,7 +142,7 @@ void brightnessDialog::on_quitBtn_clicked()
|
|||
|
||||
void brightnessDialog::on_horizontalSlider_valueChanged(int value)
|
||||
{
|
||||
brightnessDialog::pre_set_brightness(value);
|
||||
brightnessDialog::preSetBrightness(value);
|
||||
QString valueStr = QString::number(value);
|
||||
valueStr = valueStr.append("%");
|
||||
ui->valueLabel->setText(valueStr);
|
||||
|
@ -170,32 +170,32 @@ void brightnessDialog::on_okBtn_clicked()
|
|||
|
||||
// Write brightness config
|
||||
log("Display brightness set to " + QString::number(brightnessValue), className);
|
||||
brightness_writeconfig(brightnessValue);
|
||||
brightnessWriteconfig(brightnessValue);
|
||||
if(global::isN873 == true) {
|
||||
warmthValue = ui->warmthSlider->value();
|
||||
log("Display warmth set to " + QString::number(warmthValue), className);
|
||||
warmth_writeconfig(warmthValue);
|
||||
warmthWriteconfig(warmthValue);
|
||||
}
|
||||
|
||||
// Leaving
|
||||
brightnessDialog::close();
|
||||
}
|
||||
|
||||
void brightnessDialog::pre_set_brightness(int brightnessValue) {
|
||||
void brightnessDialog::preSetBrightness(int brightnessValue) {
|
||||
if(global::isN705 == true or global::isN905C == true or global::isKT == true or global::isN873 == true) {
|
||||
set_brightness(brightnessValue);
|
||||
setBrightness(brightnessValue);
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
set_brightness_ntxio(brightnessValue);
|
||||
setBrightness_ntxio(brightnessValue);
|
||||
}
|
||||
else {
|
||||
set_brightness(brightnessValue);
|
||||
setBrightness(brightnessValue);
|
||||
}
|
||||
}
|
||||
|
||||
void brightnessDialog::on_warmthSlider_valueChanged(int value)
|
||||
{
|
||||
set_warmth(value);
|
||||
setWarmth(value);
|
||||
QString valueStr = QString::number(value);
|
||||
ui->warmthValueLabel->setText(valueStr);
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@ class brightnessDialog : public QDialog
|
|||
|
||||
public:
|
||||
QString className = this->metaObject()->className();
|
||||
QString checkconfig_str_val;
|
||||
int oldValue;
|
||||
int oldWarmthValue;
|
||||
void pre_set_brightness(int brightnessValue);
|
||||
void preSetBrightness(int brightnessValue);
|
||||
explicit brightnessDialog(QWidget *parent = nullptr);
|
||||
~brightnessDialog();
|
||||
|
||||
|
|
|
@ -57,14 +57,14 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
}
|
||||
|
||||
if(QFile::exists("/inkbox/searchComboBoxFunction") == true) {
|
||||
string_checkconfig_ro("/inkbox/searchComboBoxFunction");
|
||||
if(checkconfig_str_val == "Dictionary") {
|
||||
QString searchComboBoxFunction = readFile("/inkbox/searchComboBoxFunction");
|
||||
if(searchComboBoxFunction == "Dictionary") {
|
||||
ui->searchComboBox->setCurrentIndex(0);
|
||||
}
|
||||
else if(checkconfig_str_val == "Local storage") {
|
||||
else if(searchComboBoxFunction == "Local storage") {
|
||||
ui->searchComboBox->setCurrentIndex(1);
|
||||
}
|
||||
else if(checkconfig_str_val == "Online library") {
|
||||
else if(searchComboBoxFunction == "Online library") {
|
||||
ui->searchComboBox->setCurrentIndex(2);
|
||||
}
|
||||
else {
|
||||
|
@ -85,7 +85,7 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
}
|
||||
ui->headerLabel->setText("Warning");
|
||||
QTimer::singleShot(50, this, SLOT(adjust_size()));
|
||||
string_writeconfig("/inkbox/resetDialog", "false");
|
||||
writeFile("/inkbox/resetDialog", "false");
|
||||
}
|
||||
else {
|
||||
resetDialog = true;
|
||||
|
@ -94,7 +94,7 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
ui->bodyLabel->setText("Settings will be reset.");
|
||||
ui->headerLabel->setText("Warning");
|
||||
QTimer::singleShot(50, this, SLOT(adjust_size()));
|
||||
string_writeconfig("/inkbox/resetDialog", "false");
|
||||
writeFile("/inkbox/resetDialog", "false");
|
||||
}
|
||||
}
|
||||
else if(checkconfig("/inkbox/updateDialog") == true) {
|
||||
|
@ -104,7 +104,7 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
ui->bodyLabel->setText("<font face='u001'>Do you want to update InkBox now</font><font face='Inter'>?</font>"); // Because I hate Univers/U001's question mark ...
|
||||
ui->headerLabel->setText("Update available");
|
||||
QTimer::singleShot(50, this, SLOT(adjust_size()));
|
||||
string_writeconfig("/inkbox/updateDialog", "false");
|
||||
writeFile("/inkbox/updateDialog", "false");
|
||||
}
|
||||
else if(global::settings::settingsRebootDialog == true) {
|
||||
settingsRebootDialog = true;
|
||||
|
@ -122,13 +122,13 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
else if(global::mainwindow::lowBatteryDialog == true) {
|
||||
lowBatteryDialog = true;
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
get_battery_level();
|
||||
getBatteryLevel();
|
||||
QString message = "The battery's level is low.\nPlease charge your eReader.\nCurrent level: ";
|
||||
message.append(batt_level);
|
||||
ui->bodyLabel->setText(message);
|
||||
ui->headerLabel->setText("Low battery");
|
||||
QTimer::singleShot(50, this, SLOT(adjust_size()));
|
||||
string_writeconfig("/inkbox/lowBatteryDialog", "false");
|
||||
writeFile("/inkbox/lowBatteryDialog", "false");
|
||||
}
|
||||
else if(global::usbms::usbmsDialog == true) {
|
||||
usbmsDialog = true;
|
||||
|
@ -238,7 +238,7 @@ void generalDialog::on_cancelBtn_clicked()
|
|||
{
|
||||
log("Cancel button clicked", className);
|
||||
if(updateDialog == true) {
|
||||
string_writeconfig("/tmp/cancelUpdateDialog", "true");
|
||||
writeFile("/tmp/cancelUpdateDialog", "true");
|
||||
generalDialog::close();
|
||||
}
|
||||
else if(usbmsDialog == true) {
|
||||
|
@ -367,7 +367,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
if(global::keyboard::searchDialog == true) {
|
||||
if(!global::keyboard::keyboardText.isEmpty()) {
|
||||
if(ui->searchComboBox->currentText() == "Dictionary") {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Dictionary");
|
||||
writeFile("/inkbox/searchComboBoxFunction", "Dictionary");
|
||||
for(int i = ui->mainStackedWidget->count(); i >= 0; i--) {
|
||||
QWidget * widget = ui->mainStackedWidget->widget(i);
|
||||
ui->mainStackedWidget->removeWidget(widget);
|
||||
|
@ -382,7 +382,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
ui->mainStackedWidget->insertWidget(1, dictionaryWidgetWindow);
|
||||
}
|
||||
else if(ui->searchComboBox->currentText() == "Local storage") {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Local storage");
|
||||
writeFile("/inkbox/searchComboBoxFunction", "Local storage");
|
||||
QString onboardPath;
|
||||
QStringList storageSearchResults;
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
|
@ -432,7 +432,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
}
|
||||
else if(ui->searchComboBox->currentText() == "Online library") {
|
||||
if(testPing() == 0 or global::deviceID == "emu\n") {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
|
||||
writeFile("/inkbox/searchComboBoxFunction", "Online library");
|
||||
log("Searching online library for '" + global::keyboard::keyboardText + "'", className);
|
||||
|
||||
if(!readFile("/external_root/opt/storage/gutenberg/last_sync").isEmpty()) {
|
||||
|
@ -456,8 +456,8 @@ void generalDialog::on_okBtn_clicked()
|
|||
if(noGutenbergSyncToDo == true or (gutenbergSyncDone == true && gutenbergSyncStatus == true)) {
|
||||
if(searchTimerDone == false) {
|
||||
searchTimerDone = true;
|
||||
string_writeconfig("/inkbox/gutenberg_search_request", global::keyboard::keyboardText.toStdString());
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_search\n");
|
||||
writeFile("/inkbox/gutenberg_search_request", global::keyboard::keyboardText);
|
||||
writeFile("/opt/ibxd", "gutenberg_search\n");
|
||||
global::toast::modalToast = true;
|
||||
global::toast::indefiniteToast = true;
|
||||
emit showToast("Searching");
|
||||
|
@ -546,7 +546,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
if(global::encfs::repackDialog == true) {
|
||||
global::encfs::repackDialog = false;
|
||||
log("Encrypted storage repack requested", className);
|
||||
string_writeconfig("/external_root/run/encfs_repack", "true");
|
||||
writeFile("/external_root/run/encfs_repack", "true");
|
||||
quit_restart();
|
||||
}
|
||||
else if(global::userApps::appCompatibilityDialog == true) {
|
||||
|
@ -655,13 +655,10 @@ void generalDialog::refreshScreenNative() {
|
|||
|
||||
void generalDialog::startVNC(QString server, QString password, QString port) {
|
||||
log("Launching VNC viewer", className);
|
||||
std::string server_str = server.toStdString();
|
||||
std::string password_str = password.toStdString();
|
||||
std::string port_str = port.toStdString();
|
||||
string_writeconfig("/external_root/tmp/app_vnc_server", server_str);
|
||||
string_writeconfig("/external_root/tmp/app_vnc_password", password_str);
|
||||
string_writeconfig("/external_root/tmp/app_vnc_port", port_str);
|
||||
string_writeconfig("/opt/ibxd", "app_start_vnc\n");
|
||||
writeFile("/external_root/tmp/app_vnc_server", server);
|
||||
writeFile("/external_root/tmp/app_vnc_password", password);
|
||||
writeFile("/external_root/tmp/app_vnc_port", port);
|
||||
writeFile("/opt/ibxd", "app_start_vnc\n");
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
@ -694,7 +691,7 @@ void generalDialog::closeIndefiniteToastNative() {
|
|||
void generalDialog::quit_restart() {
|
||||
log("Restarting InkBox", className);
|
||||
// If existing, cleaning bookconfig_mount mountpoint
|
||||
string_writeconfig("/opt/ibxd", "bookconfig_unmount\n");
|
||||
writeFile("/opt/ibxd", "bookconfig_unmount\n");
|
||||
|
||||
// Restarting InkBox
|
||||
QProcess process;
|
||||
|
@ -708,7 +705,7 @@ void generalDialog::syncGutenbergCatalog() {
|
|||
global::toast::indefiniteToast = true;
|
||||
emit showToast("Sync in progress");
|
||||
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
||||
writeFile("/opt/ibxd", "gutenberg_sync\n");
|
||||
QTimer * syncCheckTimer = new QTimer(this);
|
||||
syncCheckTimer->setInterval(500);
|
||||
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
||||
|
|
|
@ -88,8 +88,8 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
}
|
||||
else {
|
||||
// DPI setting
|
||||
string_checkconfig(".config/00-kobox/dpiSetting");
|
||||
if(checkconfig_str_val == "") {
|
||||
QString initialDpiSetting = readFile(".config/00-kobox/dpiSetting");
|
||||
if(initialDpiSetting.isEmpty()) {
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
dpiSetting = "125";
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
|
||||
}
|
||||
else {
|
||||
dpiSetting = checkconfig_str_val.toStdString();
|
||||
dpiSetting = initialDpiSetting;
|
||||
}
|
||||
|
||||
// Fullscreen or windowed (i3)
|
||||
|
@ -118,11 +118,11 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
if(itemText == "Netsurf") {
|
||||
log("Launching KoBox app: NetSurf", className);
|
||||
// Bypass standard shell script launch shenanigans
|
||||
string_writeconfig("/external_root/tmp/X_program", "!netsurf");
|
||||
writeFile("/external_root/tmp/X_program", "!netsurf");
|
||||
}
|
||||
else if(itemText == "KTerm") {
|
||||
log("Launching KoBox app: KTerm", className);
|
||||
string_writeconfig("/external_root/tmp/X_program", "/usr/local/bin/kterm -l /usr/local/share/kterm/layouts/keyboard-kt.xml -k 1");
|
||||
writeFile("/external_root/tmp/X_program", "/usr/local/bin/kterm -l /usr/local/share/kterm/layouts/keyboard-kt.xml -k 1");
|
||||
dpModeSetting = "fullscreen";
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
dpiSetting = "175";
|
||||
|
@ -142,17 +142,16 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
}
|
||||
else if(itemText == "Geany") {
|
||||
log("Launching KoBox app: Geany", className);
|
||||
string_writeconfig("/external_root/tmp/X_program", "geany");
|
||||
writeFile("/external_root/tmp/X_program", "geany");
|
||||
}
|
||||
else {
|
||||
log("Launching KoBox app: " + itemText, className);
|
||||
QString itemTextLower = itemText.toLower();
|
||||
std::string app = itemTextLower.toStdString();
|
||||
string_writeconfig("/external_root/tmp/X_program", app);
|
||||
QString app = itemText.toLower();
|
||||
writeFile("/external_root/tmp/X_program", app);
|
||||
}
|
||||
|
||||
string_writeconfig("/external_root/tmp/X_dpmode", dpModeSetting);
|
||||
string_writeconfig("/external_root/tmp/X_dpi", dpiSetting);
|
||||
writeFile("/external_root/tmp/X_dpmode", dpModeSetting);
|
||||
writeFile("/external_root/tmp/X_dpi", dpiSetting);
|
||||
|
||||
/* Wheeee! */
|
||||
global::kobox::showKoboxSplash = true;
|
||||
|
@ -167,11 +166,11 @@ void koboxAppsDialog::on_launchBtn_clicked()
|
|||
|
||||
// Stop EncFS/Encrypted storage
|
||||
if(checkconfig("/external_root/run/encfs_mounted") == true) {
|
||||
string_writeconfig("/external_root/run/encfs_stop_cleanup", "true");
|
||||
string_writeconfig("/opt/ibxd", "encfs_stop\n");
|
||||
writeFile("/external_root/run/encfs_stop_cleanup", "true");
|
||||
writeFile("/opt/ibxd", "encfs_stop\n");
|
||||
}
|
||||
|
||||
// Write to FIFO to start X11
|
||||
string_writeconfig("/opt/ibxd", "x_start_gui\n");
|
||||
writeFile("/opt/ibxd", "x_start_gui\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
|
||||
QString apps;
|
||||
QString itemText;
|
||||
std::string dpiSetting;
|
||||
std::string dpModeSetting;
|
||||
QString dpiSetting;
|
||||
QString dpModeSetting;
|
||||
QModelIndex index;
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -9,6 +9,7 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
|||
ui(new Ui::bookInfoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
using global::bookInfoDialog::localInfoDialog;
|
||||
|
||||
// Preventing outside interaction
|
||||
this->setModal(true);
|
||||
|
@ -58,8 +59,8 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
|||
|
||||
QDir gutenbergDir;
|
||||
gutenbergDir.mkpath("/inkbox/gutenberg");
|
||||
string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString());
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_get_cover\n");
|
||||
writeFile("/inkbox/gutenberg/bookid", QString::number(global::library::bookId));
|
||||
writeFile("/opt/ibxd", "gutenberg_get_cover\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/inkbox/gutenberg/getCoverDone")) {
|
||||
if(checkconfig("/inkbox/gutenberg/getCoverDone") == true) {
|
||||
|
@ -148,9 +149,9 @@ void bookInfoDialog::on_getBtn_clicked()
|
|||
{
|
||||
QDir gutenbergDir;
|
||||
gutenbergDir.mkpath("/inkbox/gutenberg");
|
||||
string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString());
|
||||
string_writeconfig("/inkbox/gutenberg/booktitle", global::library::bookTitle.toStdString());
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_get_book\n");
|
||||
writeFile("/inkbox/gutenberg/bookid", QString::number(global::library::bookId));
|
||||
writeFile("/inkbox/gutenberg/booktitle", global::library::bookTitle);
|
||||
writeFile("/opt/ibxd", "gutenberg_get_book\n");
|
||||
|
||||
global::toast::modalToast = true;
|
||||
global::toast::indefiniteToast = true;
|
||||
|
|
|
@ -343,7 +343,7 @@ void connectiondialog::on_connectBtn_clicked()
|
|||
|
||||
ui->cancelBtn->setEnabled(false);
|
||||
if(checkWifiState() == global::wifi::wifiState::configured) {
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
writeFile("/opt/ibxd", "stop_wifi_operations\n");
|
||||
}
|
||||
writeFile("/run/wifi_network_essid", connectedNetworkData.name);
|
||||
writeFile("/run/wifi_network_passphrase", finalPassphrase);
|
||||
|
@ -354,11 +354,11 @@ void connectiondialog::finalConnectWait() {
|
|||
if(checkIfWifiBusy() == true) {
|
||||
// To be sure
|
||||
if(waitTry == 10) {
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
writeFile("/opt/ibxd", "stop_wifi_operations\n");
|
||||
}
|
||||
// Wait for everything to shut down; 10 seconds timeout
|
||||
if(waitTry == 20) {
|
||||
string_writeconfig("/opt/ibxd", "stop_wifi_operations\n");
|
||||
writeFile("/opt/ibxd", "stop_wifi_operations\n");
|
||||
emit showToastSignal("Failed to stop other Wi-Fi processes");
|
||||
ui->cancelBtn->setEnabled(true);
|
||||
}
|
||||
|
@ -368,12 +368,12 @@ void connectiondialog::finalConnectWait() {
|
|||
}
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n");
|
||||
writeFile("/opt/ibxd", "connect_to_wifi_network\n");
|
||||
|
||||
// This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script.
|
||||
log("Writing to configuration directory with connection information data", className);
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString());
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting.toStdString());
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name);
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting);
|
||||
|
||||
this->deleteLater();
|
||||
this->close();
|
||||
|
|
|
@ -314,7 +314,7 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
|
|||
log("Turning Wi-Fi off", className);
|
||||
QTimer::singleShot(0, this, SLOT(turnOffWifi()));
|
||||
// To inform the Wi-Fi icon updater to not show the connected/failed to connect message
|
||||
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped", "true");
|
||||
ui->stopBtn->setStyleSheet(ui->stopBtn->styleSheet() + "background-color: lightGray;");
|
||||
ui->stopBtn->setEnabled(false);
|
||||
}
|
||||
|
@ -338,13 +338,13 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
|
|||
}
|
||||
|
||||
void wifiDialog::turnOnWifi() {
|
||||
string_writeconfig("/opt/ibxd", "toggle_wifi_on\n");
|
||||
writeFile("/opt/ibxd", "toggle_wifi_on\n");
|
||||
// No one will notice this freeze :>
|
||||
waitToScan();
|
||||
}
|
||||
|
||||
void wifiDialog::turnOffWifi() {
|
||||
string_writeconfig("/opt/ibxd", "toggle_wifi_off\n");
|
||||
writeFile("/opt/ibxd", "toggle_wifi_off\n");
|
||||
}
|
||||
|
||||
void wifiDialog::on_logBtn_clicked()
|
||||
|
|
|
@ -129,7 +129,7 @@ void wifilogger::getWifiInformation() {
|
|||
if(waitingForFile == false) {
|
||||
wifiInformationPath.remove();
|
||||
log("Sending get_wifi_information ibxd call", className);
|
||||
string_writeconfig("/opt/ibxd", "get_wifi_information\n");
|
||||
writeFile("/opt/ibxd", "get_wifi_information\n");
|
||||
waitingForFile = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue