diff --git a/brightnessdialog.cpp b/brightnessdialog.cpp
index d4b622b..68e063d 100644
--- a/brightnessdialog.cpp
+++ b/brightnessdialog.cpp
@@ -19,10 +19,64 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
+ ui->quitBtn->setProperty("type", "borderless");
+ ui->quitBtn->setText("");
+ ui->quitBtn->setIcon(QIcon(":/resources/close.png"));
+ ui->okBtn->setProperty("type", "borderless");
+ ui->okBtn->setText("");
+ ui->okBtn->setIcon(QIcon(":/resources/check.png"));
+ ui->decBtn->setProperty("type", "borderless");
+ ui->decBtn->setText("");
+ ui->decBtn->setIcon(QIcon(":/resources/minus.png"));
+ ui->incBtn->setProperty("type", "borderless");
+ ui->incBtn->setText("");
+ ui->incBtn->setIcon(QIcon(":/resources/plus.png"));
+ ui->brightnessLabel->setStyleSheet("font-size: 11pt; padding-left: 125px; padding-right: 125px; font:bold");
+ ui->valueLabel->setStyleSheet("font-size: 9pt");
+ ui->warmthValueLabel->setStyleSheet("font-size: 9pt");
+
+ if(global::isN705 == true or global::isN905C == true or global::isN613 == true) {
+ ui->warmthSlider->hide();
+ ui->warmthDecBtn->hide();
+ ui->warmthIncBtn->hide();
+ ui->warmthValueLabel->hide();
+ ui->warmthSlider->deleteLater();
+ ui->warmthDecBtn->deleteLater();
+ ui->warmthIncBtn->deleteLater();
+ ui->gridLayout_5->deleteLater();
+ ui->warmthValueLabel->deleteLater();
+ this->adjustSize();
+ }
+ else if (global::isN873 == true){
+ ui->warmthDecBtn->setProperty("type", "borderless");
+ ui->warmthIncBtn->setProperty("type", "borderless");
+ ui->warmthDecBtn->setText("");
+ ui->warmthIncBtn->setText("");
+ ui->warmthDecBtn->setIcon(QIcon(":/resources/nightmode-empty.png"));
+ ui->warmthIncBtn->setIcon(QIcon(":/resources/nightmode-full.png"));
+ }
+ else {
+ ui->warmthSlider->hide();
+ ui->warmthDecBtn->hide();
+ ui->warmthIncBtn->hide();
+ ui->warmthValueLabel->hide();
+ ui->warmthSlider->deleteLater();
+ ui->warmthDecBtn->deleteLater();
+ ui->warmthIncBtn->deleteLater();
+ ui->gridLayout_5->deleteLater();
+ ui->warmthValueLabel->deleteLater();
+ this->adjustSize();
+ }
+
// I know, Mini and Touch don't have frontlights but that's a template to include others later...
int value;
+ int warmthValue;
if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
value = get_brightness();
+ if(global::isN873 == true) {
+ warmthValue = get_warmth();
+ ui->warmthSlider->setValue(warmthValue);
+ }
}
else if(global::isN613 == true) {
setDefaultWorkDir();
@@ -39,21 +93,12 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
QString valueStr = QString::number(value);
valueStr = valueStr.append("%");
ui->valueLabel->setText(valueStr);
-
- ui->quitBtn->setProperty("type", "borderless");
- ui->quitBtn->setText("");
- ui->quitBtn->setIcon(QIcon(":/resources/close.png"));
- ui->okBtn->setProperty("type", "borderless");
- ui->okBtn->setText("");
- ui->okBtn->setIcon(QIcon(":/resources/check.png"));
- ui->decBtn->setProperty("type", "borderless");
- ui->decBtn->setText("");
- ui->decBtn->setIcon(QIcon(":/resources/minus.png"));
- ui->incBtn->setProperty("type", "borderless");
- ui->incBtn->setText("");
- ui->incBtn->setIcon(QIcon(":/resources/plus.png"));
- ui->brightnessLabel->setStyleSheet("font-size: 11pt; padding-left: 125px; padding-right: 125px; font:bold");
- ui->valueLabel->setStyleSheet("font-size: 9pt");
+ // Warmth value label
+ if(global::isN873 == true) {
+ warmthValue = get_warmth();
+ QString warmthValueStr = QString::number(warmthValue);
+ ui->warmthValueLabel->setText(warmthValueStr);
+ }
// UI fonts
int id = QFontDatabase::addApplicationFont(":/resources/fonts/CrimsonPro-Bold.ttf");
@@ -65,6 +110,9 @@ brightnessDialog::brightnessDialog(QWidget *parent) :
// Saving current brightness value in case we want to go backwards
if(global::isN705 == true or global::isN905C == true or global::isN873 == true) {
oldValue = get_brightness();
+ if(global::isN873 == true) {
+ oldWarmthValue = get_warmth();
+ }
}
else if(global::isN613 == true) {
setDefaultWorkDir();
@@ -84,9 +132,15 @@ void brightnessDialog::on_quitBtn_clicked()
{
// Reverting back to the old value
brightnessDialog::pre_set_brightness(oldValue);
+ if(global::isN873 == true) {
+ set_warmth(oldWarmthValue);
+ }
// Just in case ;)
brightness_writeconfig(oldValue);
+ if(global::isN873 == true) {
+ warmth_writeconfig(oldWarmthValue);
+ }
// Leaving
brightnessDialog::close();
@@ -117,10 +171,15 @@ void brightnessDialog::on_decBtn_clicked()
void brightnessDialog::on_okBtn_clicked()
{
// Get set brightness value
- int value = ui->horizontalSlider->value();
+ int brightnessValue = ui->horizontalSlider->value();
+ int warmthValue;
// Write brightness config
- brightness_writeconfig(value);
+ brightness_writeconfig(brightnessValue);
+ if(global::isN873 == true) {
+ warmthValue = ui->warmthSlider->value();
+ warmth_writeconfig(warmthValue);
+ }
// Leaving
brightnessDialog::close();
@@ -137,3 +196,27 @@ void brightnessDialog::pre_set_brightness(int brightnessValue) {
set_brightness(brightnessValue);
}
}
+
+void brightnessDialog::on_warmthSlider_valueChanged(int value)
+{
+ set_warmth(value);
+ QString valueStr = QString::number(value);
+ ui->warmthValueLabel->setText(valueStr);
+}
+
+
+void brightnessDialog::on_warmthDecBtn_clicked()
+{
+ int value = ui->warmthSlider->value();
+ value = value - 1;
+ ui->warmthSlider->setValue(value);
+}
+
+
+void brightnessDialog::on_warmthIncBtn_clicked()
+{
+ int value = ui->warmthSlider->value();
+ value = value + 1;
+ ui->warmthSlider->setValue(value);
+}
+
diff --git a/brightnessdialog.h b/brightnessdialog.h
index ab339e9..93bad63 100644
--- a/brightnessdialog.h
+++ b/brightnessdialog.h
@@ -16,6 +16,7 @@ class brightnessDialog : public QDialog
public:
QString checkconfig_str_val;
int oldValue;
+ int oldWarmthValue;
void pre_set_brightness(int brightnessValue);
explicit brightnessDialog(QWidget *parent = nullptr);
~brightnessDialog();
@@ -26,6 +27,9 @@ private slots:
void on_incBtn_clicked();
void on_decBtn_clicked();
void on_okBtn_clicked();
+ void on_warmthSlider_valueChanged(int value);
+ void on_warmthDecBtn_clicked();
+ void on_warmthIncBtn_clicked();
private:
Ui::brightnessDialog *ui;
diff --git a/brightnessdialog.ui b/brightnessdialog.ui
index 18756bb..ef5a5f4 100644
--- a/brightnessdialog.ui
+++ b/brightnessdialog.ui
@@ -7,7 +7,7 @@
0
0
400
- 128
+ 216
@@ -25,8 +25,93 @@
-
-
-
-
+
-
+
+
+ 0
+
+
-
+
+
+ 0
+
+
-
+
+
+ Down
+
+
+
+ -
+
+
+ 100
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Up
+
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ 10
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Colder
+
+
+
+ -
+
+
+ Warmer
+
+
+
+
+
+ -
+
+
+ Brightness Value
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
Qt::Vertical
@@ -38,16 +123,6 @@
- -
-
-
- Brightness Value
-
-
- Qt::AlignCenter
-
-
-
-
@@ -111,42 +186,8 @@
- -
-
-
- 0
-
-
-
-
-
- 100
-
-
- 1
-
-
- Qt::Horizontal
-
-
-
- -
-
-
- Up
-
-
-
- -
-
-
- Down
-
-
-
-
-
- -
-
+
-
+
Qt::Vertical
@@ -158,6 +199,16 @@
+ -
+
+
+ Warmth Value
+
+
+ Qt::AlignCenter
+
+
+
diff --git a/functions.h b/functions.h
index 7d4a834..373b75d 100644
--- a/functions.h
+++ b/functions.h
@@ -75,6 +75,9 @@ namespace global {
inline bool modalToast;
inline bool indefiniteToast;
}
+ namespace device {
+ inline bool isWifiAble;
+ }
inline QString systemInfoText;
inline bool forbidOpenSearchDialog;
inline bool isN705;
@@ -202,6 +205,12 @@ namespace {
fhandler << value;
fhandler.close();
}
+ void warmth_writeconfig(int value) {
+ std::ofstream fhandler;
+ fhandler.open(".config/03-brightness/config-warmth");
+ fhandler << value;
+ fhandler.close();
+ }
int get_brightness() {
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val == "n613\n") {
@@ -478,5 +487,28 @@ namespace {
}
}
}
+ int get_warmth() {
+ QString sysfsWarmthPath;
+ string_checkconfig_ro("/opt/inkbox_device");
+ if(checkconfig_str_val == "n873\n") {
+ sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
+ }
+ string_checkconfig_ro(sysfsWarmthPath);
+ int warmthValue = checkconfig_str_val.toInt();
+ warmthValue = 10 - warmthValue;
+ return warmthValue;
+ }
+ void set_warmth(int warmthValue) {
+ // Value 0 gives a warmer lighting than value 10
+ warmthValue = 10 - warmthValue;
+ std::string warmthValueStr = std::to_string(warmthValue);
+ std::string sysfsWarmthPath;
+ string_checkconfig_ro("/opt/inkbox_device");
+ if(checkconfig_str_val == "n873\n") {
+ sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
+ }
+ string_writeconfig(sysfsWarmthPath, warmthValueStr);
+ }
}
+
#endif // FUNCTIONS_H
diff --git a/main.cpp b/main.cpp
index b6dcb60..be25490 100644
--- a/main.cpp
+++ b/main.cpp
@@ -144,6 +144,12 @@ int main(int argc, char *argv[])
global::isN905C = false;
global::isN613 = true;
}
+ else if(checkconfig_str_val == "n873\n") {
+ global::isN705 = false;
+ global::isN905C = false;
+ global::isN613 = false;
+ global::isN873 = true;
+ }
else {
;
}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8f9e146..af16432 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -127,7 +127,9 @@ MainWindow::MainWindow(QWidget *parent)
ui->brightnessBtn->setIconSize(QSize(brightnessIconWidth, brightnessIconHeight));
setWifiIcon();
- updateWifiIcon(0);
+ if(global::device::isWifiAble == true) {
+ updateWifiIcon(0);
+ }
setBatteryIcon();
int id = QFontDatabase::addApplicationFont(":/resources/fonts/CrimsonPro-Regular.ttf");
@@ -742,10 +744,6 @@ void MainWindow::setBatteryIcon() {
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") {
- ui->wifiBtn->hide();
- ui->line_9->hide();
- }
// Setting icons up
stdIconWidth = sW / 16;
@@ -823,6 +821,18 @@ void MainWindow::setInitialBrightness() {
string_writeconfig("/tmp/inkbox-cinematicBrightness_ran", "true");
cinematicBrightness(brightness_value, 0);
}
+ string_checkconfig_ro("/opt/inkbox_device");
+ if(checkconfig_str_val == "n873\n") {
+ int warmth;
+ string_checkconfig_ro(".config/03-brightness/config-warmth");
+ if(checkconfig_str_val == "") {
+ warmth = 0;
+ }
+ else {
+ warmth = checkconfig_str_val.toInt();
+ }
+ set_warmth(warmth);
+ }
}
void MainWindow::refreshScreen() {
@@ -897,19 +907,27 @@ bool MainWindow::checkWifiState() {
}
void MainWindow::setWifiIcon() {
- if(checkWifiState() == true) {
- if(testPing() == 0) {
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ if(checkconfig("/run/wifi_able") == true) {
+ global::device::isWifiAble = true;
+ if(checkWifiState() == true) {
+ if(testPing() == 0) {
+ ui->wifiBtn->setIcon(QIcon(":/resources/wifi-connected.png"));
+ ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ }
+ else {
+ ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
+ ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ }
}
else {
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-standby.png"));
+ ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
}
}
else {
- ui->wifiBtn->setIcon(QIcon(":/resources/wifi-off.png"));
- ui->wifiBtn->setIconSize(QSize(wifiIconWidth, wifiIconHeight));
+ global::device::isWifiAble = false;
+ ui->wifiBtn->hide();
+ ui->line_9->hide();
}
}