Skip to content

Commit

Permalink
Kobo Libra compatibility; new font: Bitter
Browse files Browse the repository at this point in the history
  • Loading branch information
tux-linux committed Jul 11, 2021
1 parent 028b006 commit dd8921c
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 22 deletions.
6 changes: 3 additions & 3 deletions brightnessdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
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();
}
else if(global::isN613 == true) {
Expand Down Expand Up @@ -63,7 +63,7 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
ui->brightnessLabel->setFont(QFont(crimson_bold));

// 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();
}
else if(global::isN613 == true) {
Expand Down Expand Up @@ -127,7 +127,7 @@ void brightnessDialog::on_okBtn_clicked()
}

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);
}
else if(global::isN613 == true) {
Expand Down
3 changes: 3 additions & 0 deletions eink.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@
<file>resources/nightmode-full.png</file>
<file>resources/backspace.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>
</RCC>
5 changes: 5 additions & 0 deletions functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace global {
inline bool isN705;
inline bool isN905C;
inline bool isN613;
inline bool isN873;
}

// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
Expand Down Expand Up @@ -402,6 +403,10 @@ namespace {
defaultEpubPageHeight = 450;
defaultEpubPageWidth = 450;
}
if(checkconfig_str_val == "n873\n") {
defaultEpubPageHeight = 525;
defaultEpubPageWidth = 525;
}
}
void pre_set_brightness(int brightnessValue) {
string_checkconfig_ro("/opt/inkbox_device");
Expand Down
3 changes: 3 additions & 0 deletions koboxappsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ void koboxAppsDialog::on_launchBtn_clicked()
else if(checkconfig_str_val == "n613\n") {
dpiSetting = "175";
}
else if(checkconfig_str_val == "n873\n") {
dpiSetting = "250";
}
else {
dpiSetting = "125";
}
Expand Down
3 changes: 3 additions & 0 deletions koboxsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ koboxSettings::koboxSettings(QWidget *parent) :
else if(checkconfig_str_val == "n613\n") {
dpiSetting = "175";
}
else if(checkconfig_str_val == "n873\n") {
dpiSetting = "250";
}
else {
dpiSetting = "125";
}
Expand Down
2 changes: 1 addition & 1 deletion koboxsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ OK
<number>25</number>
</property>
<property name="maximum">
<number>250</number>
<number>350</number>
</property>
<property name="singleStep">
<number>25</number>
Expand Down
9 changes: 9 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,25 @@ int main(int argc, char *argv[])
global::isN705 = true;
global::isN905C = false;
global::isN613 = false;
global::isN873 = false;
}
else if(checkconfig_str_val == "n905\n") {
global::isN705 = false;
global::isN905C = true;
global::isN613 = false;
global::isN873 = false;
}
else if(checkconfig_str_val == "n613\n") {
global::isN705 = false;
global::isN905C = false;
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 {
;
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void MainWindow::resetIcons() {
void MainWindow::setBatteryIcon() {
// Battery
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) ...
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") {
ui->brightnessBtn->hide();
Expand Down
56 changes: 44 additions & 12 deletions reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,51 @@ reader::reader(QWidget *parent) :
ui->text->setFont(crimson);
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 {
QFont config_font(checkconfig_str_val);
ui->text->setFont(config_font);
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;
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) {
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;
}
}
else {
string_writeconfig("/tmp/invertScreen", "n");
ui->nightModeBtn->setText("");
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
isNightModeActive = false;
ui->line_7->hide();
ui->line_7->deleteLater();
ui->nightModeBtn->hide();
ui->nightModeBtn->deleteLater();
}

// Stylesheet + misc.
Expand Down Expand Up @@ -166,7 +193,7 @@ reader::reader(QWidget *parent) :

// Getting brightness level
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();
}
else if(global::isN613 == true) {
Expand Down Expand Up @@ -904,7 +931,7 @@ void reader::on_hideOptionsBtn_clicked()
void reader::on_brightnessDecBtn_clicked()
{
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();
}
else if(global::isN613 == true) {
Expand All @@ -927,7 +954,7 @@ void reader::on_brightnessDecBtn_clicked()
void reader::on_brightnessIncBtn_clicked()
{
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();
}
else if(global::isN613 == true) {
Expand Down Expand Up @@ -1012,6 +1039,11 @@ void reader::on_fontChooser_currentIndexChanged(const QString &arg1)
ui->text->setFont(crimson);
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()
Expand Down
11 changes: 8 additions & 3 deletions reader.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<width>549</width>
<height>750</height>
</rect>
</property>
Expand Down Expand Up @@ -370,12 +370,17 @@
</item>
<item>
<property name="text">
<string>Crimson Pro</string>
<string>Source Serif Pro</string>
</property>
</item>
<item>
<property name="text">
<string>Source Serif Pro</string>
<string>Bitter</string>
</property>
</item>
<item>
<property name="text">
<string>Crimson Pro</string>
</property>
</item>
<item>
Expand Down
Binary file added resources/fonts/Bitter-Bold.ttf
Binary file not shown.
Binary file added resources/fonts/Bitter-Medium.ttf
Binary file not shown.
Binary file added resources/fonts/Bitter-MediumItalic.ttf
Binary file not shown.
35 changes: 33 additions & 2 deletions settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@ settings::settings(QWidget *parent) :
if(checkconfig(".config/05-quote/config") == true) {
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
Expand Down Expand Up @@ -172,6 +180,17 @@ settings::settings(QWidget *parent) :
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 {
if(dpi_number == 187) {
ui->uiScalingSlider->setValue(0);
Expand Down Expand Up @@ -587,6 +606,9 @@ void settings::on_uiScalingSlider_valueChanged(int value)
if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "195");
}
if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "285");
}
}
if(value == 1) {
string_checkconfig_ro("/opt/inkbox_device");
Expand All @@ -599,6 +621,9 @@ void settings::on_uiScalingSlider_valueChanged(int value)
if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "210");
}
if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "300");
}
}
if(value == 2) {
string_checkconfig_ro("/opt/inkbox_device");
Expand All @@ -611,6 +636,9 @@ void settings::on_uiScalingSlider_valueChanged(int value)
if(checkconfig_str_val == "n613\n") {
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
Expand Down Expand Up @@ -712,6 +740,9 @@ void settings::on_enableUiScalingCheckBox_toggled(bool checked)
else if(checkconfig_str_val == "n613\n") {
string_writeconfig(".config/09-dpi/config", "195");
}
else if(checkconfig_str_val == "n873\n") {
string_writeconfig(".config/09-dpi/config", "285");
}
else {
string_writeconfig(".config/09-dpi/config", "187");
}
Expand Down

0 comments on commit dd8921c

Please sign in to comment.