From 035ab14e5fe53d38911327cdb8705267d07e2014 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sat, 19 Feb 2022 19:21:09 -0500 Subject: [PATCH] Kobo Nia (N306) support --- functions.h | 7 ++++--- koboxappsdialog.cpp | 4 ++-- koboxsettings.cpp | 2 +- main.cpp | 28 ++++++++++++++++++++++++++++ mainwindow.cpp | 8 ++++---- reader.cpp | 4 ++-- settings.cpp | 12 ++++++------ settingschooser.cpp | 2 +- 8 files changed, 48 insertions(+), 19 deletions(-) diff --git a/functions.h b/functions.h index 680fce0..3bc0539 100644 --- a/functions.h +++ b/functions.h @@ -120,6 +120,7 @@ namespace global { inline bool isN873; inline bool isN236; inline bool isN437; + inline bool isN306; inline bool runningInstanceIsReaderOnly; } @@ -548,7 +549,7 @@ namespace { defaultEpubPageHeight = 425; defaultEpubPageWidth = 425; } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "emu\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n" or checkconfig_str_val == "emu\n") { defaultEpubPageHeight = 450; defaultEpubPageWidth = 450; } @@ -563,7 +564,7 @@ namespace { defaultPdfPageHeight = 750; defaultPdfPageWidth = 550; } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "emu\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n" or checkconfig_str_val == "emu\n") { defaultPdfPageHeight = 974; defaultPdfPageWidth = 708; } @@ -580,7 +581,7 @@ namespace { void pre_set_brightness(int brightnessValue) { string_checkconfig_ro("/opt/inkbox_device"); - if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n873\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n") { + if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n873\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n") { set_brightness(brightnessValue); } else if(checkconfig_str_val == "n613\n") { diff --git a/koboxappsdialog.cpp b/koboxappsdialog.cpp index 1b86507..3e83a35 100644 --- a/koboxappsdialog.cpp +++ b/koboxappsdialog.cpp @@ -101,7 +101,7 @@ void koboxAppsDialog::on_launchBtn_clicked() if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { dpiSetting = "125"; } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { dpiSetting = "175"; } else if(checkconfig_str_val == "n437\n") { @@ -134,7 +134,7 @@ void koboxAppsDialog::on_launchBtn_clicked() if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { dpiSetting = "175"; } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { dpiSetting = "225"; } else if(checkconfig_str_val == "n437\n") { diff --git a/koboxsettings.cpp b/koboxsettings.cpp index b6f391e..6f415ef 100644 --- a/koboxsettings.cpp +++ b/koboxsettings.cpp @@ -41,7 +41,7 @@ koboxSettings::koboxSettings(QWidget *parent) : if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { dpiSetting = "125"; } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { dpiSetting = "175"; } else if(checkconfig_str_val == "n437\n") { diff --git a/main.cpp b/main.cpp index 5185e9d..6ffa3be 100644 --- a/main.cpp +++ b/main.cpp @@ -105,6 +105,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n905\n") { global::isN705 = false; @@ -113,6 +114,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n613\n") { global::isN705 = false; @@ -137,6 +139,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = true; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n437\n") { global::isN705 = false; @@ -145,6 +148,16 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = true; + global::isN306 = false; + } + else if(checkconfig_str_val == "n306\n") { + global::isN705 = false; + global::isN905C = false; + global::isN613 = false; + global::isN873 = false; + global::isN236 = false; + global::isN437 = false; + global::isN306 = true; } else { ; @@ -184,6 +197,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n905\n") { global::isN705 = false; @@ -192,6 +206,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n613\n") { global::isN705 = false; @@ -200,6 +215,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n873\n") { global::isN705 = false; @@ -208,6 +224,7 @@ int main(int argc, char *argv[]) global::isN873 = true; global::isN236 = false; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n236\n") { global::isN705 = false; @@ -216,6 +233,7 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = true; global::isN437 = false; + global::isN306 = false; } else if(checkconfig_str_val == "n437\n") { global::isN705 = false; @@ -224,6 +242,16 @@ int main(int argc, char *argv[]) global::isN873 = false; global::isN236 = false; global::isN437 = true; + global::isN306 = false; + } + else if(checkconfig_str_val == "n306\n") { + global::isN705 = false; + global::isN905C = false; + global::isN613 = false; + global::isN873 = false; + global::isN236 = false; + global::isN437 = false; + global::isN306 = true; } else { ; diff --git a/mainwindow.cpp b/mainwindow.cpp index 3c5d3b7..49f74f8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -90,7 +90,7 @@ MainWindow::MainWindow(QWidget *parent) wifiIconWidth = sW / 22.5; wifiIconHeight = sH / 22.5; } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "emu\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n" or checkconfig_str_val == "emu\n") { stdIconWidth = sW / 12.5; stdIconHeight = sH / 12.5; brightnessIconWidth = sW / 24.5; @@ -158,7 +158,7 @@ MainWindow::MainWindow(QWidget *parent) if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 1px; padding-right: 1px;"); } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "emu\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n" or checkconfig_str_val == "emu\n") { ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px;"); } else if(checkconfig_str_val == "n873\n") { @@ -776,7 +776,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" or checkconfig_str_val == "n873\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\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" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n") { // Hide brightness controls; they won't be very useful there anyway (for anything but the Glo (HD)/Libra/Aura 2) ... if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n") { ui->brightnessBtn->hide(); @@ -1114,7 +1114,7 @@ void MainWindow::setRecentBooksLabelsTruncateTreshold() { if(readFile("/opt/inkbox_device") == "n705\n" or readFile("/opt/inkbox_device") == "n905b\n" or readFile("/opt/inkbox_device") == "n905c\n") { truncateTreshold = 12; } - else if(readFile("/opt/inkbox_device") == "n613\n" or readFile("/opt/inkbox_device") == "n873\n" or readFile("/opt/inkbox_device") == "n236\n" or readFile("/opt/inkbox_device") == "n437\n"){ + else if(readFile("/opt/inkbox_device") == "n613\n" or readFile("/opt/inkbox_device") == "n873\n" or readFile("/opt/inkbox_device") == "n236\n" or readFile("/opt/inkbox_device") == "n437\n" or readFile("/opt/inkbox_device") == "n306\n"){ truncateTreshold = 20; } else { diff --git a/reader.cpp b/reader.cpp index c89d1c8..0e59c0d 100644 --- a/reader.cpp +++ b/reader.cpp @@ -242,7 +242,7 @@ 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" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n") { + if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n") { if(checkconfig(".config/10-dark_mode/config") == true) { string_writeconfig("/tmp/invertScreen", "y"); ui->nightModeBtn->setText(""); @@ -322,7 +322,7 @@ reader::reader(QWidget *parent) : // Defining what the icons' size will be if(checkconfig("/opt/inkbox_genuine") == 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" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "emu\n") { + if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n" or checkconfig_str_val == "emu\n") { float stdIconWidth = sW / 16; float stdIconHeight = sW / 16; QPixmap chargingPixmap(":/resources/battery_charging.png"); diff --git a/settings.cpp b/settings.cpp index d7741b2..149f12d 100644 --- a/settings.cpp +++ b/settings.cpp @@ -87,7 +87,7 @@ settings::settings(QWidget *parent) : } string_checkconfig_ro("/opt/inkbox_device"); - if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n") { + if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n437\n" or checkconfig_str_val == "n306\n") { if(checkconfig(".config/10-dark_mode/config") == true) { ui->darkModeCheckBox->click(); } @@ -174,7 +174,7 @@ settings::settings(QWidget *parent) : ui->uiScalingSlider->setValue(2); } } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { if(dpi_number == 195) { ui->uiScalingSlider->setValue(0); } @@ -583,7 +583,7 @@ void settings::on_uiScalingSlider_valueChanged(int value) if(checkconfig_str_val == "n905\n") { string_writeconfig(".config/09-dpi/config", "160"); } - if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { string_writeconfig(".config/09-dpi/config", "195"); } if(checkconfig_str_val == "n437\n") { @@ -601,7 +601,7 @@ void settings::on_uiScalingSlider_valueChanged(int value) if(checkconfig_str_val == "n905\n") { string_writeconfig(".config/09-dpi/config", "187"); } - if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { string_writeconfig(".config/09-dpi/config", "210"); } if(checkconfig_str_val == "n437\n") { @@ -619,7 +619,7 @@ void settings::on_uiScalingSlider_valueChanged(int value) if(checkconfig_str_val == "n905\n") { string_writeconfig(".config/09-dpi/config", "200"); } - if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { string_writeconfig(".config/09-dpi/config", "225"); } if(checkconfig_str_val == "n437\n") { @@ -726,7 +726,7 @@ void settings::on_enableUiScalingCheckBox_toggled(bool checked) else if(checkconfig_str_val == "n905\n") { string_writeconfig(".config/09-dpi/config", "160"); } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { string_writeconfig(".config/09-dpi/config", "195"); } else if(checkconfig_str_val == "n437\n") { diff --git a/settingschooser.cpp b/settingschooser.cpp index 34a5b88..2fdda45 100644 --- a/settingschooser.cpp +++ b/settingschooser.cpp @@ -46,7 +46,7 @@ settingsChooser::settingsChooser(QWidget *parent) : ui->inkboxSettingsBtn->setStyleSheet("padding: 20px; Text-align: left"); ui->koboxSettingsBtn->setStyleSheet("padding: 20px; Text-align: left"); } - else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n") { + else if(checkconfig_str_val == "n613\n" or checkconfig_str_val == "n236\n" or checkconfig_str_val == "n306\n") { ui->inkboxSettingsBtn->setStyleSheet("padding: 25px; Text-align: left"); ui->koboxSettingsBtn->setStyleSheet("padding:25px; Text-align: left"); }