mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Kobo Glo UI/brightness/DPI support
This commit is contained in:
parent
3b61530507
commit
7d03a5b0ff
8 changed files with 153 additions and 16 deletions
|
@ -89,6 +89,7 @@ void alert::on_continueBtn_clicked()
|
|||
// We continue anyway and re-set the ALERT flag
|
||||
string_writeconfig("/external_root/boot/flags/ALERT", "false");
|
||||
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
|
||||
updateReset();
|
||||
QProcess process;
|
||||
process.startDetached("inkbox", QStringList());
|
||||
qApp->quit();
|
||||
|
@ -111,6 +112,7 @@ void alert::on_continue2Btn_clicked()
|
|||
{
|
||||
// We continue anyway and re-set the ALERT flag
|
||||
string_writeconfig("/external_root/boot/flags/ALERT", "false");
|
||||
updateReset();
|
||||
|
||||
if(signatureError == true) {
|
||||
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
|
||||
|
@ -125,3 +127,8 @@ void alert::on_continue2Btn_clicked()
|
|||
qApp->quit();
|
||||
}
|
||||
}
|
||||
|
||||
void alert::updateReset() {
|
||||
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "false");
|
||||
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_update", "false");
|
||||
}
|
||||
|
|
1
alert.h
1
alert.h
|
@ -19,6 +19,7 @@ public:
|
|||
bool signatureError = false;
|
||||
bool downgradeError = false;
|
||||
bool criticalBattery = false;
|
||||
void updateReset();
|
||||
|
||||
private slots:
|
||||
void on_continueBtn_clicked();
|
||||
|
|
|
@ -19,7 +19,18 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
|
|||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
stylesheetFile.close();
|
||||
|
||||
int value = get_brightness();
|
||||
// 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) {
|
||||
value = get_brightness();
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
value = brightness_checkconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
|
||||
// Setting the slider to the appropriate position
|
||||
ui->horizontalSlider->setValue(value);
|
||||
|
@ -52,7 +63,16 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
|
|||
ui->brightnessLabel->setFont(QFont(crimson_bold));
|
||||
|
||||
// Saving current brightness value in case we want to go backwards
|
||||
oldValue = get_brightness();
|
||||
if(global::isN705 == true or global::isN705 == true) {
|
||||
oldValue = get_brightness();
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
oldValue = brightness_checkconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
brightnessDialog::~brightnessDialog()
|
||||
|
@ -112,7 +132,7 @@ void brightnessDialog::pre_set_brightness(int brightnessValue) {
|
|||
deviceChecked = true;
|
||||
}
|
||||
|
||||
if(device == "n705\n" or device == "n905\n") {
|
||||
if(global::isN705 == true or global::isN905C == true) {
|
||||
set_brightness(brightnessValue);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -59,6 +59,9 @@ namespace global {
|
|||
inline QString textBrowserContents;
|
||||
}
|
||||
inline QString systemInfoText;
|
||||
inline bool isN705;
|
||||
inline bool isN905C;
|
||||
inline bool isN613;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
|
||||
|
|
40
main.cpp
40
main.cpp
|
@ -72,6 +72,26 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
string_writeconfig("/inkbox/skip_opendialog", "true");
|
||||
device = checkDevice();
|
||||
if(device == "n705\n") {
|
||||
global::isN705 = true;
|
||||
global::isN905C = false;
|
||||
global::isN613 = false;
|
||||
}
|
||||
else if(device == "n905\n") {
|
||||
global::isN705 = false;
|
||||
global::isN905C = true;
|
||||
global::isN613 = false;
|
||||
}
|
||||
else if(device == "n613\n") {
|
||||
global::isN705 = false;
|
||||
global::isN905C = false;
|
||||
global::isN613 = true;
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
|
||||
QApplication a(argc, argv);
|
||||
reader w;
|
||||
|
||||
|
@ -91,6 +111,26 @@ int main(int argc, char *argv[])
|
|||
w.setStyleSheet(stylesheetFile.readAll());
|
||||
stylesheetFile.close();
|
||||
|
||||
device = checkDevice();
|
||||
if(device == "n705\n") {
|
||||
global::isN705 = true;
|
||||
global::isN905C = false;
|
||||
global::isN613 = false;
|
||||
}
|
||||
else if(device == "n905\n") {
|
||||
global::isN705 = false;
|
||||
global::isN905C = true;
|
||||
global::isN613 = false;
|
||||
}
|
||||
else if(device == "n613\n") {
|
||||
global::isN705 = false;
|
||||
global::isN905C = false;
|
||||
global::isN613 = true;
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
|
||||
const QScreen* screen = qApp->primaryScreen();
|
||||
w.setGeometry(QRect(QPoint(0,0), screen->geometry ().size()));
|
||||
w.show();
|
||||
|
|
|
@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
homeIconWidth = sW / 18;
|
||||
homeIconHeight = sW / 18;
|
||||
}
|
||||
else {
|
||||
else if(checkconfig_str_val == "n905\n") {
|
||||
stdIconWidth = sW / 14;
|
||||
stdIconHeight = sH / 14;
|
||||
brightnessIconWidth = sW / 26;
|
||||
|
@ -82,6 +82,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
homeIconWidth = sW / 20;
|
||||
homeIconHeight = sW / 20;
|
||||
}
|
||||
else if(checkconfig_str_val == "n613\n") {
|
||||
stdIconWidth = sW / 12.5;
|
||||
stdIconHeight = sH / 12.5;
|
||||
brightnessIconWidth = sW / 24.5;
|
||||
brightnessIconHeight = sH / 24.5;
|
||||
homeIconWidth = sW / 18.5;
|
||||
homeIconHeight = sW / 18.5;
|
||||
}
|
||||
|
||||
// Setting icons up
|
||||
ui->pushButton->setIcon(QIcon(":/resources/book.png"));
|
||||
|
@ -123,6 +131,9 @@ 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") {
|
||||
ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px;");
|
||||
}
|
||||
else {
|
||||
ui->batteryIcon->setStyleSheet("font-size: 5pt; padding-bottom: 0px; padding-top: 0px; padding-left: 8px; padding-right: 8px;");
|
||||
}
|
||||
|
@ -692,14 +703,17 @@ 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") {
|
||||
// Hide brightness controls; they won't be very useful there anyway...
|
||||
ui->brightnessBtn->hide();
|
||||
ui->line_7->hide();
|
||||
if(checkconfig_str_val == "n705\n" or checkconfig_str_val == "n905\n" or checkconfig_str_val == "n613\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();
|
||||
ui->line_7->hide();
|
||||
}
|
||||
|
||||
// Setting icons up
|
||||
stdIconWidth = sW / 16;
|
||||
stdIconHeight = sH / 16;
|
||||
|
||||
QPixmap chargingPixmap(":/resources/battery_charging.png");
|
||||
QPixmap scaledChargingPixmap = chargingPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
QPixmap fullPixmap(":/resources/battery_full.png");
|
||||
|
|
41
reader.cpp
41
reader.cpp
|
@ -155,7 +155,17 @@ reader::reader(QWidget *parent) :
|
|||
ui->bookInfoLabel->setFont(crimson);
|
||||
|
||||
// Getting brightness level
|
||||
int brightness_value = get_brightness();
|
||||
int brightness_value;
|
||||
if(global::isN705 == true or global::isN905C == true) {
|
||||
brightness_value = get_brightness();
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
ui->brightnessStatus->setValue(brightness_value);
|
||||
|
||||
// Defining pixmaps
|
||||
|
@ -810,24 +820,43 @@ void reader::on_hideOptionsBtn_clicked()
|
|||
|
||||
void reader::on_brightnessDecBtn_clicked()
|
||||
{
|
||||
int bval = get_brightness();
|
||||
int bval;
|
||||
if(global::isN705 == true or global::isN905C == true) {
|
||||
bval = get_brightness();
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
bval = brightness_checkconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
int set_bval = bval - 1;
|
||||
pre_set_brightness(set_bval);
|
||||
brightness_writeconfig(set_bval);
|
||||
|
||||
bval = get_brightness();
|
||||
ui->brightnessStatus->setValue(bval);
|
||||
ui->brightnessStatus->setValue(set_bval);
|
||||
}
|
||||
|
||||
void reader::on_brightnessIncBtn_clicked()
|
||||
{
|
||||
int bval = get_brightness();
|
||||
int bval;
|
||||
if(global::isN705 == true or global::isN905C == true) {
|
||||
bval = get_brightness();
|
||||
}
|
||||
else if(global::isN613 == true) {
|
||||
setDefaultWorkDir();
|
||||
bval = brightness_checkconfig(".config/03-brightness/config");
|
||||
}
|
||||
else {
|
||||
;
|
||||
}
|
||||
int set_bval = bval + 1;
|
||||
pre_set_brightness(set_bval);
|
||||
brightness_writeconfig(set_bval);
|
||||
|
||||
bval = get_brightness();
|
||||
ui->brightnessStatus->setValue(bval);
|
||||
ui->brightnessStatus->setValue(set_bval);
|
||||
}
|
||||
|
||||
void reader::on_aboutBtn_clicked()
|
||||
|
|
27
settings.cpp
27
settings.cpp
|
@ -131,7 +131,7 @@ settings::settings(QWidget *parent) :
|
|||
}
|
||||
else {
|
||||
int dpi_number = checkconfig_str_val.toInt();
|
||||
// Checking if it's a Mini or a Touch
|
||||
// Checking if it's a Mini, Touch or a Glo
|
||||
string_checkconfig_ro("/opt/inkbox_device");
|
||||
if(checkconfig_str_val == "n705\n") {
|
||||
if(dpi_number == 187) {
|
||||
|
@ -144,7 +144,7 @@ settings::settings(QWidget *parent) :
|
|||
ui->uiScalingSlider->setValue(2);
|
||||
}
|
||||
}
|
||||
if(checkconfig_str_val == "n905\n") {
|
||||
else if(checkconfig_str_val == "n905\n") {
|
||||
if(dpi_number == 160) {
|
||||
ui->uiScalingSlider->setValue(0);
|
||||
}
|
||||
|
@ -155,6 +155,17 @@ settings::settings(QWidget *parent) :
|
|||
ui->uiScalingSlider->setValue(2);
|
||||
}
|
||||
}
|
||||
else if(checkconfig_str_val == "n613\n") {
|
||||
if(dpi_number == 195) {
|
||||
ui->uiScalingSlider->setValue(0);
|
||||
}
|
||||
if(dpi_number == 210) {
|
||||
ui->uiScalingSlider->setValue(1);
|
||||
}
|
||||
if(dpi_number == 225) {
|
||||
ui->uiScalingSlider->setValue(2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(dpi_number == 187) {
|
||||
ui->uiScalingSlider->setValue(0);
|
||||
|
@ -536,6 +547,9 @@ 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") {
|
||||
string_writeconfig(".config/09-dpi/config", "195");
|
||||
}
|
||||
}
|
||||
if(value == 1) {
|
||||
string_checkconfig_ro("/opt/inkbox_device");
|
||||
|
@ -545,6 +559,9 @@ 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") {
|
||||
string_writeconfig(".config/09-dpi/config", "210");
|
||||
}
|
||||
}
|
||||
if(value == 2) {
|
||||
string_checkconfig_ro("/opt/inkbox_device");
|
||||
|
@ -554,6 +571,9 @@ 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") {
|
||||
string_writeconfig(".config/09-dpi/config", "225");
|
||||
}
|
||||
}
|
||||
|
||||
// Making sense for the user
|
||||
|
@ -652,6 +672,9 @@ 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") {
|
||||
string_writeconfig(".config/09-dpi/config", "195");
|
||||
}
|
||||
else {
|
||||
string_writeconfig(".config/09-dpi/config", "187");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue