Kobo Libra compatibility; new font: Bitter

This commit is contained in:
Nicolas Mailloux 2021-07-11 01:08:38 -04:00
parent 028b0063c6
commit dd8921c859
14 changed files with 113 additions and 22 deletions

View file

@ -21,7 +21,7 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
// I know, Mini and Touch don't have frontlights but that's a template to include others later... // I know, Mini and Touch don't have frontlights but that's a template to include others later...
int value; int value;
if(global::isN705 == true or global::isN905C == true) { if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
value = get_brightness(); value = get_brightness();
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
@ -63,7 +63,7 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
ui->brightnessLabel->setFont(QFont(crimson_bold)); ui->brightnessLabel->setFont(QFont(crimson_bold));
// Saving current brightness value in case we want to go backwards // Saving current brightness value in case we want to go backwards
if(global::isN705 == true or global::isN705 == true) { if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
oldValue = get_brightness(); oldValue = get_brightness();
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
@ -127,7 +127,7 @@ void brightnessDialog::on_okBtn_clicked()
} }
void brightnessDialog::pre_set_brightness(int brightnessValue) { void brightnessDialog::pre_set_brightness(int brightnessValue) {
if(global::isN705 == true or global::isN905C == true) { if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
set_brightness(brightnessValue); set_brightness(brightnessValue);
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {

View file

@ -48,5 +48,8 @@
<file>resources/nightmode-full.png</file> <file>resources/nightmode-full.png</file>
<file>resources/backspace.png</file> <file>resources/backspace.png</file>
<file>resources/x-circle.png</file> <file>resources/x-circle.png</file>
<file>resources/fonts/Bitter-MediumItalic.ttf</file>
<file>resources/fonts/Bitter-Medium.ttf</file>
<file>resources/fonts/Bitter-Bold.ttf</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -72,6 +72,7 @@ namespace global {
inline bool isN705; inline bool isN705;
inline bool isN905C; inline bool isN905C;
inline bool isN613; inline bool isN613;
inline bool isN873;
} }
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534 // https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
@ -402,6 +403,10 @@ namespace {
defaultEpubPageHeight = 450; defaultEpubPageHeight = 450;
defaultEpubPageWidth = 450; defaultEpubPageWidth = 450;
} }
if(checkconfig_str_val == "n873\n") {
defaultEpubPageHeight = 525;
defaultEpubPageWidth = 525;
}
} }
void pre_set_brightness(int brightnessValue) { void pre_set_brightness(int brightnessValue) {
string_checkconfig_ro("/opt/inkbox_device"); string_checkconfig_ro("/opt/inkbox_device");

View file

@ -104,6 +104,9 @@ void koboxAppsDialog::on_launchBtn_clicked()
else if(checkconfig_str_val == "n613\n") { else if(checkconfig_str_val == "n613\n") {
dpiSetting = "175"; dpiSetting = "175";
} }
else if(checkconfig_str_val == "n873\n") {
dpiSetting = "250";
}
else { else {
dpiSetting = "125"; dpiSetting = "125";
} }

View file

@ -44,6 +44,9 @@ koboxSettings::koboxSettings(QWidget *parent) :
else if(checkconfig_str_val == "n613\n") { else if(checkconfig_str_val == "n613\n") {
dpiSetting = "175"; dpiSetting = "175";
} }
else if(checkconfig_str_val == "n873\n") {
dpiSetting = "250";
}
else { else {
dpiSetting = "125"; dpiSetting = "125";
} }

View file

@ -254,7 +254,7 @@ OK
<number>25</number> <number>25</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>250</number> <number>350</number>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<number>25</number> <number>25</number>

View file

@ -78,16 +78,25 @@ int main(int argc, char *argv[])
global::isN705 = true; global::isN705 = true;
global::isN905C = false; global::isN905C = false;
global::isN613 = false; global::isN613 = false;
global::isN873 = false;
} }
else if(checkconfig_str_val == "n905\n") { else if(checkconfig_str_val == "n905\n") {
global::isN705 = false; global::isN705 = false;
global::isN905C = true; global::isN905C = true;
global::isN613 = false; global::isN613 = false;
global::isN873 = false;
} }
else if(checkconfig_str_val == "n613\n") { else if(checkconfig_str_val == "n613\n") {
global::isN705 = false; global::isN705 = false;
global::isN905C = false; global::isN905C = false;
global::isN613 = true; global::isN613 = true;
global::isN873 = false;
}
else if(checkconfig_str_val == "n873\n") {
global::isN705 = false;
global::isN905C = false;
global::isN613 = false;
global::isN873 = true;
} }
else { else {
; ;

View file

@ -719,7 +719,7 @@ void MainWindow::resetIcons() {
void MainWindow::setBatteryIcon() { void MainWindow::setBatteryIcon() {
// Battery // Battery
string_checkconfig_ro("/opt/inkbox_device"); string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n") { if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n" or checkconfig_str_val == "n873\n") {
// Hide brightness controls; they won't be very useful there anyway (for anything but the Glo) ... // Hide brightness controls; they won't be very useful there anyway (for anything but the Glo) ...
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
ui->brightnessBtn->hide(); ui->brightnessBtn->hide();

View file

@ -110,6 +110,24 @@ reader::reader(QWidget *parent) :
ui->text->setFont(crimson); ui->text->setFont(crimson);
ui->fontChooser->setCurrentText(checkconfig_str_val); ui->fontChooser->setCurrentText(checkconfig_str_val);
} }
else if(checkconfig_str_val == "Bitter") {
QString family;
{
int id = QFontDatabase::addApplicationFont(":/resources/fonts/Bitter-Medium.ttf");
family = QFontDatabase::applicationFontFamilies(id).at(0);
}
{
int id = QFontDatabase::addApplicationFont(":/resources/fonts/Bitter-MediumItalic.ttf");
family = QFontDatabase::applicationFontFamilies(id).at(0);
}
{
int id = QFontDatabase::addApplicationFont(":/resources/fonts/Bitter-Bold.ttf");
family = QFontDatabase::applicationFontFamilies(id).at(0);
}
QFont bitter(family);
ui->text->setFont(bitter);
ui->fontChooser->setCurrentText(checkconfig_str_val);
}
else { else {
QFont config_font(checkconfig_str_val); QFont config_font(checkconfig_str_val);
ui->text->setFont(config_font); ui->text->setFont(config_font);
@ -117,17 +135,26 @@ reader::reader(QWidget *parent) :
} }
} }
// Night mode // Night mode
if(checkconfig(".config/10-dark_mode/config") == true) { string_checkconfig_ro("/opt/inkbox_device");
string_writeconfig("/tmp/invertScreen", "y"); if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n") {
ui->nightModeBtn->setText(""); if(checkconfig(".config/10-dark_mode/config") == true) {
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-full.png")); string_writeconfig("/tmp/invertScreen", "y");
isNightModeActive = true; 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;
}
} }
else { else {
string_writeconfig("/tmp/invertScreen", "n"); ui->line_7->hide();
ui->nightModeBtn->setText(""); ui->line_7->deleteLater();
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png")); ui->nightModeBtn->hide();
isNightModeActive = false; ui->nightModeBtn->deleteLater();
} }
// Stylesheet + misc. // Stylesheet + misc.
@ -166,7 +193,7 @@ reader::reader(QWidget *parent) :
// Getting brightness level // Getting brightness level
int brightness_value; int brightness_value;
if(global::isN705 == true or global::isN905C == true) { if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
brightness_value = get_brightness(); brightness_value = get_brightness();
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
@ -904,7 +931,7 @@ void reader::on_hideOptionsBtn_clicked()
void reader::on_brightnessDecBtn_clicked() void reader::on_brightnessDecBtn_clicked()
{ {
int bval; int bval;
if(global::isN705 == true or global::isN905C == true) { if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
bval = get_brightness(); bval = get_brightness();
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
@ -927,7 +954,7 @@ void reader::on_brightnessDecBtn_clicked()
void reader::on_brightnessIncBtn_clicked() void reader::on_brightnessIncBtn_clicked()
{ {
int bval; int bval;
if(global::isN705 == true or global::isN905C == true) { if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
bval = get_brightness(); bval = get_brightness();
} }
else if(global::isN613 == true) { else if(global::isN613 == true) {
@ -1012,6 +1039,11 @@ void reader::on_fontChooser_currentIndexChanged(const QString &arg1)
ui->text->setFont(crimson); ui->text->setFont(crimson);
string_writeconfig(".config/04-book/font", "Crimson Pro"); string_writeconfig(".config/04-book/font", "Crimson Pro");
} }
if(arg1 == "Bitter") {
QFont bitter("Bitter");
ui->text->setFont(bitter);
string_writeconfig(".config/04-book/font", "Bitter");
}
} }
void reader::on_alignLeftBtn_clicked() void reader::on_alignLeftBtn_clicked()

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>490</width> <width>549</width>
<height>750</height> <height>750</height>
</rect> </rect>
</property> </property>
@ -370,12 +370,17 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Crimson Pro</string> <string>Source Serif Pro</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Source Serif Pro</string> <string>Bitter</string>
</property>
</item>
<item>
<property name="text">
<string>Crimson Pro</string>
</property> </property>
</item> </item>
<item> <item>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -80,8 +80,16 @@ settings::settings(QWidget *parent) :
if(checkconfig(".config/05-quote/config") == true) { if(checkconfig(".config/05-quote/config") == true) {
ui->quoteCheckBox->click(); ui->quoteCheckBox->click();
} }
if(checkconfig(".config/10-dark_mode/config") == true) {
ui->darkModeCheckBox->click(); string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n") {
if(checkconfig(".config/10-dark_mode/config") == true) {
ui->darkModeCheckBox->click();
}
}
else {
ui->darkModeCheckBox->hide();
ui->darkModeCheckBox->deleteLater();
} }
// Words number // Words number
@ -172,6 +180,17 @@ settings::settings(QWidget *parent) :
ui->uiScalingSlider->setValue(2); ui->uiScalingSlider->setValue(2);
} }
} }
else if(checkconfig_str_val == "n873\n") {
if(dpi_number == 285) {
ui->uiScalingSlider->setValue(0);
}
if(dpi_number == 300) {
ui->uiScalingSlider->setValue(1);
}
if(dpi_number == 315) {
ui->uiScalingSlider->setValue(2);
}
}
else { else {
if(dpi_number == 187) { if(dpi_number == 187) {
ui->uiScalingSlider->setValue(0); ui->uiScalingSlider->setValue(0);
@ -587,6 +606,9 @@ void settings::on_uiScalingSlider_valueChanged(int value)
if(checkconfig_str_val == "n613\n") { if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "195"); string_writeconfig(".config/09-dpi/config", "195");
} }
if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "285");
}
} }
if(value == 1) { if(value == 1) {
string_checkconfig_ro("/opt/inkbox_device"); string_checkconfig_ro("/opt/inkbox_device");
@ -599,6 +621,9 @@ void settings::on_uiScalingSlider_valueChanged(int value)
if(checkconfig_str_val == "n613\n") { if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "210"); string_writeconfig(".config/09-dpi/config", "210");
} }
if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "300");
}
} }
if(value == 2) { if(value == 2) {
string_checkconfig_ro("/opt/inkbox_device"); string_checkconfig_ro("/opt/inkbox_device");
@ -611,6 +636,9 @@ void settings::on_uiScalingSlider_valueChanged(int value)
if(checkconfig_str_val == "n613\n") { if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "225"); string_writeconfig(".config/09-dpi/config", "225");
} }
if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "315");
}
} }
// Making sense for the user // Making sense for the user
@ -712,6 +740,9 @@ void settings::on_enableUiScalingCheckBox_toggled(bool checked)
else if(checkconfig_str_val == "n613\n") { else if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "195"); string_writeconfig(".config/09-dpi/config", "195");
} }
else if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "285");
}
else { else {
string_writeconfig(".config/09-dpi/config", "187"); string_writeconfig(".config/09-dpi/config", "187");
} }