diff --git a/mainwindow.cpp b/mainwindow.cpp index 6e59456..a2844a7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -344,17 +344,7 @@ MainWindow::MainWindow(QWidget *parent) // **** FEATURE WARNING **** // We set the brightness level saved in the config file - int brightness_value = brightness_checkconfig(".config/03-brightness/config"); - if(checkconfig("/tmp/oobe-inkbox_completed") == true or checkconfig("/tmp/inkbox-cinematicBrightness_ran") == true) { - // Coming from OOBE setup; not doing that fancy stuff again ;p - QFile::remove("/tmp/oobe-inkbox_completed"); - pre_set_brightness(brightness_value); - } - else { - // Fancy brightness fade-in - string_writeconfig("/tmp/inkbox-cinematicBrightness_ran", "true"); - cinematicBrightness(brightness_value, 0); - } + QTimer::singleShot(2000, this, SLOT(setInitialBrightness())); // Display quote if requested; otherwise, display recent books string_checkconfig(".config/05-quote/config"); @@ -795,3 +785,17 @@ void MainWindow::setBatteryIcon() { } } } + +void MainWindow::setInitialBrightness() { + int brightness_value = brightness_checkconfig(".config/03-brightness/config"); + if(checkconfig("/tmp/oobe-inkbox_completed") == true or checkconfig("/tmp/inkbox-cinematicBrightness_ran") == true) { + // Coming from OOBE setup; not doing that fancy stuff again ;p + QFile::remove("/tmp/oobe-inkbox_completed"); + pre_set_brightness(brightness_value); + } + else { + // Fancy brightness fade-in + string_writeconfig("/tmp/inkbox-cinematicBrightness_ran", "true"); + cinematicBrightness(brightness_value, 0); + } +} diff --git a/mainwindow.h b/mainwindow.h index 05a1c23..fd00ea5 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -64,6 +64,7 @@ private slots: void on_book4Btn_clicked(); void on_brightnessBtn_clicked(); void openUpdateDialog(); + void setInitialBrightness(); void on_homeBtn_clicked(); private: diff --git a/settings.cpp b/settings.cpp index 906f017..d7dd7ba 100644 --- a/settings.cpp +++ b/settings.cpp @@ -40,6 +40,7 @@ settings::settings(QWidget *parent) : ui->resetBtn->setStyleSheet("font-size: 9pt"); ui->showSystemInfoBtn->setStyleSheet("font-size: 9pt"); ui->comboBox->setStyleSheet("font-size: 9pt"); + ui->sleepTimeoutComboBox->setStyleSheet("font-size: 9pt"); ui->setPasscodeBtn->setStyleSheet("font-size: 9pt"); ui->previousBtn->setText(""); @@ -185,11 +186,10 @@ settings::settings(QWidget *parent) : } // Refresh - string_checkconfig(".config/04-book/refresh"); + string_checkconfig_ro(".config/04-book/refresh"); if(checkconfig_str_val == "") { // Set default option, 3 string_writeconfig(".config/04-book/refresh", "3"); - string_checkconfig(".config/04-book/refresh"); ui->comboBox->setCurrentText("3 pages"); } else { @@ -218,8 +218,37 @@ settings::settings(QWidget *parent) : if(refreshInt == 6) { ui->comboBox->setCurrentText("6 pages"); } - else { - // Something bad (or not ;p) has happened + } + + // Sleep mode timeout + string_checkconfig_ro(".config/15-sleep_timeout/config"); + if(checkconfig_str_val == "") { + // Set default option, '15 minutes' + string_writeconfig(".config/15-sleep_timeout/config", "15"); + ui->sleepTimeoutComboBox->setCurrentText("15 minutes"); + } + else { + int sleepTimeoutInt = checkconfig_str_val.toInt(); + if(sleepTimeoutInt == -1) { + ui->sleepTimeoutComboBox->setCurrentText("Never"); + } + if(sleepTimeoutInt == 2) { + ui->sleepTimeoutComboBox->setCurrentText("2 minutes"); + } + if(sleepTimeoutInt == 5) { + ui->sleepTimeoutComboBox->setCurrentText("5 minutes"); + } + if(sleepTimeoutInt == 10) { + ui->sleepTimeoutComboBox->setCurrentText("10 minutes"); + } + if(sleepTimeoutInt == 15) { + ui->sleepTimeoutComboBox->setCurrentText("15 minutes"); + } + if(sleepTimeoutInt == 30) { + ui->sleepTimeoutComboBox->setCurrentText("30 minutes"); + } + if(sleepTimeoutInt == 60) { + ui->sleepTimeoutComboBox->setCurrentText("60 minutes"); } } @@ -741,3 +770,29 @@ void settings::on_readerScrollBarCheckBox_toggled(bool checked) string_writeconfig(".config/14-reader_scrollbar/config", "false"); } } + +void settings::on_sleepTimeoutComboBox_currentIndexChanged(const QString &arg1) +{ + setDefaultWorkDir(); + if(arg1 == "Never") { + string_writeconfig(".config/15-sleep_timeout/config", "-1"); + } + if(arg1 == "2 minutes") { + string_writeconfig(".config/15-sleep_timeout/config", "2"); + } + if(arg1 == "5 minutes") { + string_writeconfig(".config/15-sleep_timeout/config", "5"); + } + if(arg1 == "10 minutes") { + string_writeconfig(".config/15-sleep_timeout/config", "10"); + } + if(arg1 == "15 minutes") { + string_writeconfig(".config/15-sleep_timeout/config", "15"); + } + if(arg1 == "30 minutes") { + string_writeconfig(".config/15-sleep_timeout/config", "30"); + } + if(arg1 == "60 minutes") { + string_writeconfig(".config/15-sleep_timeout/config", "60"); + } +} diff --git a/settings.h b/settings.h index 1734124..4e5bf9f 100644 --- a/settings.h +++ b/settings.h @@ -51,6 +51,8 @@ private slots: void on_pageSizeHeightSpinBox_valueChanged(int arg1); void on_readerScrollBarCheckBox_toggled(bool checked); + void on_sleepTimeoutComboBox_currentIndexChanged(const QString &arg1); + private: Ui::settings *ui; usbms_splash *usbmsWindow; diff --git a/settings.ui b/settings.ui index e830252..d6647a6 100644 --- a/settings.ui +++ b/settings.ui @@ -47,7 +47,7 @@ 0 - -105 + 0 442 474 @@ -59,6 +59,9 @@ 0 + + 0 + 0 @@ -516,178 +519,6 @@ - - - - - Chivo - true - - - - Security - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - 0 - - - 0 - - - - - System info - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Show - - - - - - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Update InkBox - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 75 - true - - - - Update - - - - - - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - 0 - - - - - Reset this device - - - - - - - - 75 - true - - - - Reset - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -740,6 +571,56 @@ + + + + Enable night mode + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Update InkBox + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 75 + true + + + + Update + + + + + @@ -753,14 +634,33 @@ - - + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Chivo + true + + - Enable night mode + Security - + 0 @@ -800,13 +700,66 @@ - + + + + 0 + + + 0 + + + + + System info + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Show + + + + + + Enable lock screen and passcode + + + + QFrame::Plain + + + Qt::Horizontal + + + @@ -814,6 +767,125 @@ + + + + 0 + + + + + Reset this device + + + + + + + + 75 + true + + + + Reset + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Sleep when idle + + + + + + + + Never + + + + + 2 minutes + + + + + 5 minutes + + + + + 10 minutes + + + + + 15 minutes + + + + + 30 minutes + + + + + 60 minutes + + + + + +