Fine-tune Kobo Mini ePUB rendering, new nightmode switch

This commit is contained in:
Nicolas Mailloux 2021-06-22 22:51:28 -04:00
parent f8decc2a5d
commit 1539f9fe0d
7 changed files with 77 additions and 15 deletions

View file

@ -44,5 +44,7 @@
<file>resources/kobox-icon.png</file>
<file>resources/X11.png</file>
<file>resources/info.png</file>
<file>resources/nightmode-empty.png</file>
<file>resources/nightmode-full.png</file>
</qresource>
</RCC>

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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;

View file

@ -801,16 +801,13 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="5">
<widget class="QLabel" name="batteryLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
<item row="0" column="1">
<widget class="Line" name="line_15">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Battery</string>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
@ -821,7 +818,14 @@
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="4">
<widget class="QPushButton" name="nightModeBtn">
<property name="text">
<string>Night mode</string>
</property>
</widget>
</item>
<item row="0" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -834,7 +838,20 @@
</property>
</spacer>
</item>
<item row="0" column="6">
<item row="0" column="9">
<widget class="QLabel" name="batteryLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Battery</string>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QLabel" name="batteryIconLabel">
<property name="text">
<string>Battery Icon</string>
@ -848,7 +865,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="3">
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB