From f9a1fe6931c03906ad7888fbc08b323b945500db Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Mon, 19 Jun 2023 20:55:26 -0400 Subject: [PATCH] `cinematicWarmth` (Libra H2O) --- src/functions.h | 17 +++++++++++++++++ src/homeWidget/mainwindow.cpp | 2 +- src/reader/reader.cpp | 23 ++++++++++++++++------- src/reader/reader.h | 1 + 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/functions.h b/src/functions.h index 5376607..76fa052 100644 --- a/src/functions.h +++ b/src/functions.h @@ -827,6 +827,23 @@ namespace { } string_writeconfig(sysfsWarmthPath, warmthValueStr); } + void cinematicWarmth(int warmthValue) { + int currentWarmth = get_warmth(); + if(warmthValue < currentWarmth) { + while(warmthValue < currentWarmth) { + currentWarmth--; + set_warmth(currentWarmth); + QThread::msleep(30); + } + } + else if(warmthValue > currentWarmth) { + while(warmthValue > currentWarmth) { + currentWarmth++; + set_warmth(currentWarmth); + QThread::msleep(30); + } + } + } void installUpdate() { log("Installing update package", "functions"); writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n"); diff --git a/src/homeWidget/mainwindow.cpp b/src/homeWidget/mainwindow.cpp index 4a60cbf..65108c5 100644 --- a/src/homeWidget/mainwindow.cpp +++ b/src/homeWidget/mainwindow.cpp @@ -721,7 +721,7 @@ void MainWindow::setInitialBrightness() { else { warmth = checkconfig_str_val.toInt(); } - set_warmth(warmth); + cinematicWarmth(warmth); } int brightness_value = brightness_checkconfig(".config/03-brightness/config"); if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") { diff --git a/src/reader/reader.cpp b/src/reader/reader.cpp index 77da514..33797af 100644 --- a/src/reader/reader.cpp +++ b/src/reader/reader.cpp @@ -243,13 +243,7 @@ reader::reader(QWidget *parent) : // Custom settings // Brightness - 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"); - log("Local Reading Settings: Setting brightness to " + QString::number(brightness_value), className); - cinematicBrightness(brightness_value, 2); - } - } + QTimer::singleShot(0, this, SLOT(setCinematicBrightnessWarmthSlot())); // Font global::reader::font = readFile(".config/04-book/font"); if(global::reader::font == "u001") { @@ -2275,3 +2269,18 @@ void reader::on_brightnessBtn_clicked() brightnessDialogWindow->setAttribute(Qt::WA_DeleteOnClose); brightnessDialogWindow->show(); } + +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"); + log("Local Reading Settings: Setting brightness to " + QString::number(brightness_value), className); + cinematicBrightness(brightness_value, 2); + } + if(global::deviceID == "n873\n") { + int warmthValue = readFile(".config/03-brightness/config-warmth").toInt(); + log("Local Reading Settings: Setting warmth to " + QString::number(warmthValue), className); + cinematicWarmth(warmthValue); + } + } +} diff --git a/src/reader/reader.h b/src/reader/reader.h index 6587e2b..0aab69b 100644 --- a/src/reader/reader.h +++ b/src/reader/reader.h @@ -169,6 +169,7 @@ private slots: void on_lineSpacingSlider_valueChanged(int value); void on_marginsSlider_valueChanged(int value); void on_brightnessBtn_clicked(); + void setCinematicBrightnessWarmthSlot(); signals: void openBookFile(QString book, bool relativePath);