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...
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) {
@ -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) {
@ -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) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -110,6 +110,24 @@ 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);
@ -117,6 +135,8 @@ reader::reader(QWidget *parent) :
}
}
// Night mode
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("");
@ -129,6 +149,13 @@ reader::reader(QWidget *parent) :
ui->nightModeBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
isNightModeActive = false;
}
}
else {
ui->line_7->hide();
ui->line_7->deleteLater();
ui->nightModeBtn->hide();
ui->nightModeBtn->deleteLater();
}
// Stylesheet + misc.
QFile stylesheetFile(":/resources/eink.qss");
@ -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) {
@ -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) {
@ -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) {
@ -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()

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<width>549</width>
<height>750</height>
</rect>
</property>
@ -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>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -80,9 +80,17 @@ settings::settings(QWidget *parent) :
if(checkconfig(".config/05-quote/config") == true) {
ui->quoteCheckBox->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
string_checkconfig(".config/07-words_number/config");
@ -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);
@ -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");
@ -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");
@ -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
@ -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");
}