diff --git a/eink.qrc b/eink.qrc index d279313..5a8eb14 100644 --- a/eink.qrc +++ b/eink.qrc @@ -44,5 +44,7 @@ resources/kobox-icon.png resources/X11.png resources/info.png + resources/nightmode-empty.png + resources/nightmode-full.png diff --git a/functions.h b/functions.h index 38342fa..d90e81e 100644 --- a/functions.h +++ b/functions.h @@ -323,8 +323,8 @@ namespace { void defineDefaultPageSize() { string_checkconfig_ro("/opt/inkbox_device"); if(checkconfig_str_val == "n705\n") { - defaultEpubPageWidth = 425; - defaultEpubPageHeight = 425; + defaultEpubPageWidth = 365; + defaultEpubPageHeight = 365; } if(checkconfig_str_val == "n905\n") { defaultEpubPageHeight = 425; diff --git a/reader.cpp b/reader.cpp index 56db373..b314a11 100644 --- a/reader.cpp +++ b/reader.cpp @@ -49,6 +49,7 @@ reader::reader(QWidget *parent) : ui->saveWordBtn->setProperty("type", "borderless"); ui->previousDefinitionBtn->setProperty("type", "borderless"); ui->nextDefinitionBtn->setProperty("type", "borderless"); + ui->nightModeBtn->setProperty("type", "borderless"); // Icons ui->alignLeftBtn->setText(""); @@ -108,6 +109,19 @@ reader::reader(QWidget *parent) : ui->fontChooser->setCurrentText(checkconfig_str_val); } } + // Night mode + if(checkconfig(".config/10-dark_mode/config") == true) { + string_writeconfig("/tmp/invertScreen", "y"); + ui->nightModeBtn->setText(""); + ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png")); + isNightModeActive = true; + } + else { + string_writeconfig("/tmp/invertScreen", "n"); + ui->nightModeBtn->setText(""); + ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png")); + isNightModeActive = false; + } // Stylesheet + misc. QFile stylesheetFile(":/resources/eink.qss"); @@ -407,7 +421,16 @@ reader::reader(QWidget *parent) : infoLabelContent.append(" ― "); infoLabelContent.append(bookTitle); int infoLabelLength = infoLabelContent.length(); - if(infoLabelLength <= 50) { + int infoLabelDefinedLength; + string_checkconfig_ro("/opt/inkbox_device"); + if(checkconfig_str_val == "n705\n") { + infoLabelDefinedLength = 35; + } + if(checkconfig_str_val == "n905\n") { + infoLabelDefinedLength = 50; + } + + if(infoLabelLength <= infoLabelDefinedLength) { ui->bookInfoLabel->setWordWrap(false); } else { @@ -1312,3 +1335,21 @@ void reader::on_text_selectionChanged() { } } } + +void reader::on_nightModeBtn_clicked() +{ + if(isNightModeActive == true) { + // Disabling night/dark mode + string_writeconfig("/tmp/invertScreen", "n"); + string_writeconfig(".config/10-dark_mode/config", "false"); + ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png")); + isNightModeActive = false; + } + else { + // Enabling night/dark mode + string_writeconfig("/tmp/invertScreen", "y"); + string_writeconfig(".config/10-dark_mode/config", "true"); + ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png")); + isNightModeActive = true; + } +} diff --git a/reader.h b/reader.h index b74a1c6..d13d073 100644 --- a/reader.h +++ b/reader.h @@ -54,6 +54,7 @@ public: bool remount = true; bool showTopbarWidget; bool wordwidgetLock; + bool isNightModeActive; QString book_1; QString book_2; QString book_3; @@ -113,6 +114,7 @@ private slots: void writeconfig_pagenumber(); void quit_restart(); void on_text_selectionChanged(); + void on_nightModeBtn_clicked(); private: Ui::reader *ui; diff --git a/reader.ui b/reader.ui index e04b548..4fbde53 100644 --- a/reader.ui +++ b/reader.ui @@ -801,16 +801,13 @@ 0 - - - - - 75 - true - + + + + QFrame::Plain - - Battery + + Qt::Vertical @@ -821,7 +818,14 @@ - + + + + Night mode + + + + Qt::Horizontal @@ -834,7 +838,20 @@ - + + + + + 75 + true + + + + Battery + + + + Battery Icon @@ -848,7 +865,7 @@ - + QFrame::Plain diff --git a/resources/nightmode-empty.png b/resources/nightmode-empty.png new file mode 100644 index 0000000..3ce6cea Binary files /dev/null and b/resources/nightmode-empty.png differ diff --git a/resources/nightmode-full.png b/resources/nightmode-full.png new file mode 100644 index 0000000..527bf89 Binary files /dev/null and b/resources/nightmode-full.png differ