mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-27 16:17:21 -08:00
Kobo Glo: methods to set brightness
This commit is contained in:
parent
31367c5357
commit
3b61530507
7 changed files with 69 additions and 5 deletions
|
@ -63,7 +63,7 @@ brightnessDialog::~brightnessDialog()
|
||||||
void brightnessDialog::on_quitBtn_clicked()
|
void brightnessDialog::on_quitBtn_clicked()
|
||||||
{
|
{
|
||||||
// Reverting back to the old value
|
// Reverting back to the old value
|
||||||
set_brightness(oldValue);
|
pre_set_brightness(oldValue);
|
||||||
|
|
||||||
// Just in case ;)
|
// Just in case ;)
|
||||||
brightness_writeconfig(oldValue);
|
brightness_writeconfig(oldValue);
|
||||||
|
@ -74,7 +74,7 @@ void brightnessDialog::on_quitBtn_clicked()
|
||||||
|
|
||||||
void brightnessDialog::on_horizontalSlider_valueChanged(int value)
|
void brightnessDialog::on_horizontalSlider_valueChanged(int value)
|
||||||
{
|
{
|
||||||
set_brightness(value);
|
pre_set_brightness(value);
|
||||||
QString valueStr = QString::number(value);
|
QString valueStr = QString::number(value);
|
||||||
valueStr = valueStr.append("%");
|
valueStr = valueStr.append("%");
|
||||||
ui->valueLabel->setText(valueStr);
|
ui->valueLabel->setText(valueStr);
|
||||||
|
@ -105,3 +105,17 @@ void brightnessDialog::on_okBtn_clicked()
|
||||||
// Leaving
|
// Leaving
|
||||||
brightnessDialog::close();
|
brightnessDialog::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void brightnessDialog::pre_set_brightness(int brightnessValue) {
|
||||||
|
if(deviceChecked == false) {
|
||||||
|
checkDevice();
|
||||||
|
deviceChecked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(device == "n705\n" or device == "n905\n") {
|
||||||
|
set_brightness(brightnessValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_brightness_ntxio(brightnessValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class brightnessDialog : public QDialog
|
||||||
public:
|
public:
|
||||||
QString checkconfig_str_val;
|
QString checkconfig_str_val;
|
||||||
int oldValue;
|
int oldValue;
|
||||||
|
void pre_set_brightness(int brightnessValue);
|
||||||
explicit brightnessDialog(QWidget *parent = nullptr);
|
explicit brightnessDialog(QWidget *parent = nullptr);
|
||||||
~brightnessDialog();
|
~brightnessDialog();
|
||||||
|
|
||||||
|
|
18
functions.h
18
functions.h
|
@ -10,6 +10,10 @@
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
// WoW, global variables and namespaces are awesome
|
// WoW, global variables and namespaces are awesome
|
||||||
namespace global {
|
namespace global {
|
||||||
namespace battery {
|
namespace battery {
|
||||||
|
@ -61,12 +65,14 @@ namespace global {
|
||||||
namespace {
|
namespace {
|
||||||
QString checkconfig_str_val;
|
QString checkconfig_str_val;
|
||||||
QString deviceUID;
|
QString deviceUID;
|
||||||
|
QString device;
|
||||||
QString batt_level;
|
QString batt_level;
|
||||||
QString kernelVersion;
|
QString kernelVersion;
|
||||||
int batt_level_int;
|
int batt_level_int;
|
||||||
int defaultEpubPageWidth;
|
int defaultEpubPageWidth;
|
||||||
int defaultEpubPageHeight;
|
int defaultEpubPageHeight;
|
||||||
bool checked_box = false;
|
bool checked_box = false;
|
||||||
|
bool deviceChecked = false;
|
||||||
bool checkconfig(QString file) {
|
bool checkconfig(QString file) {
|
||||||
QFile config(file);
|
QFile config(file);
|
||||||
config.open(QIODevice::ReadOnly);
|
config.open(QIODevice::ReadOnly);
|
||||||
|
@ -122,6 +128,14 @@ namespace {
|
||||||
fhandler << value;
|
fhandler << value;
|
||||||
fhandler.close();
|
fhandler.close();
|
||||||
}
|
}
|
||||||
|
void set_brightness_ntxio(int value) {
|
||||||
|
// Thanks to Kevin Short for this (GloLight)
|
||||||
|
int light;
|
||||||
|
if ((light = open("/dev/ntx_io", O_RDWR)) == -1) {
|
||||||
|
printf("Error opening ntx_io device");
|
||||||
|
}
|
||||||
|
ioctl(light, 241, value);
|
||||||
|
}
|
||||||
int int_checkconfig(QString file) {
|
int int_checkconfig(QString file) {
|
||||||
QFile int_config(file);
|
QFile int_config(file);
|
||||||
int_config.open(QIODevice::ReadOnly);
|
int_config.open(QIODevice::ReadOnly);
|
||||||
|
@ -342,5 +356,9 @@ namespace {
|
||||||
defaultEpubPageWidth = 425;
|
defaultEpubPageWidth = 425;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QString checkDevice() {
|
||||||
|
string_checkconfig_ro("/opt/inkbox_device");
|
||||||
|
return checkconfig_str_val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // FUNCTIONS_H
|
#endif // FUNCTIONS_H
|
||||||
|
|
|
@ -321,7 +321,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
// We set the brightness level saved in the config file
|
// We set the brightness level saved in the config file
|
||||||
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
int brightness_value = brightness_checkconfig(".config/03-brightness/config");
|
||||||
set_brightness(brightness_value);
|
pre_set_brightness(brightness_value);
|
||||||
|
|
||||||
// Display quote if requested; otherwise, display recent books
|
// Display quote if requested; otherwise, display recent books
|
||||||
string_checkconfig(".config/05-quote/config");
|
string_checkconfig(".config/05-quote/config");
|
||||||
|
@ -759,3 +759,17 @@ void MainWindow::setBatteryIcon() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::pre_set_brightness(int brightnessValue) {
|
||||||
|
if(deviceChecked == false) {
|
||||||
|
checkDevice();
|
||||||
|
deviceChecked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(device == "n705\n" or device == "n905\n") {
|
||||||
|
set_brightness(brightnessValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_brightness_ntxio(brightnessValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
void resetWindow(bool resetStackedWidget);
|
void resetWindow(bool resetStackedWidget);
|
||||||
void resetIcons();
|
void resetIcons();
|
||||||
void setBatteryIcon();
|
void setBatteryIcon();
|
||||||
|
void pre_set_brightness();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ private slots:
|
||||||
void on_brightnessBtn_clicked();
|
void on_brightnessBtn_clicked();
|
||||||
void openUpdateDialog();
|
void openUpdateDialog();
|
||||||
void on_homeBtn_clicked();
|
void on_homeBtn_clicked();
|
||||||
|
void pre_set_brightness(int brightnessValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
18
reader.cpp
18
reader.cpp
|
@ -812,7 +812,7 @@ void reader::on_brightnessDecBtn_clicked()
|
||||||
{
|
{
|
||||||
int bval = get_brightness();
|
int bval = get_brightness();
|
||||||
int set_bval = bval - 1;
|
int set_bval = bval - 1;
|
||||||
set_brightness(set_bval);
|
pre_set_brightness(set_bval);
|
||||||
brightness_writeconfig(set_bval);
|
brightness_writeconfig(set_bval);
|
||||||
|
|
||||||
bval = get_brightness();
|
bval = get_brightness();
|
||||||
|
@ -823,7 +823,7 @@ void reader::on_brightnessIncBtn_clicked()
|
||||||
{
|
{
|
||||||
int bval = get_brightness();
|
int bval = get_brightness();
|
||||||
int set_bval = bval + 1;
|
int set_bval = bval + 1;
|
||||||
set_brightness(set_bval);
|
pre_set_brightness(set_bval);
|
||||||
brightness_writeconfig(set_bval);
|
brightness_writeconfig(set_bval);
|
||||||
|
|
||||||
bval = get_brightness();
|
bval = get_brightness();
|
||||||
|
@ -1353,3 +1353,17 @@ void reader::on_nightModeBtn_clicked()
|
||||||
isNightModeActive = true;
|
isNightModeActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reader::pre_set_brightness(int brightnessValue) {
|
||||||
|
if(deviceChecked == false) {
|
||||||
|
checkDevice();
|
||||||
|
deviceChecked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(device == "n705\n" or device == "n905\n") {
|
||||||
|
set_brightness(brightnessValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_brightness_ntxio(brightnessValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
reader.h
1
reader.h
|
@ -91,6 +91,7 @@ public:
|
||||||
void setPageStyle();
|
void setPageStyle();
|
||||||
void alignText(int alignment);
|
void alignText(int alignment);
|
||||||
void delay(int seconds);
|
void delay(int seconds);
|
||||||
|
void pre_set_brightness(int brightnessValue);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_nextBtn_clicked();
|
void on_nextBtn_clicked();
|
||||||
|
|
Loading…
Reference in a new issue