diff --git a/src/functions.h b/src/functions.h index fb53277..1e5c866 100644 --- a/src/functions.h +++ b/src/functions.h @@ -217,6 +217,12 @@ namespace { logFile.close(); } } + void logEnabled(QString configOption, QString className) { + log("Enabling " + configOption + " setting", className); + } + void logDisabled(QString configOption, QString className) { + log("Disabling " + configOption + " setting", className); + } bool checkconfig(QString file) { if(QFile::exists(file)) { QFile config(file); diff --git a/src/powerDaemon/sleepthread.cpp b/src/powerDaemon/sleepthread.cpp index 009bb07..3c433b9 100644 --- a/src/powerDaemon/sleepthread.cpp +++ b/src/powerDaemon/sleepthread.cpp @@ -13,8 +13,8 @@ void sleepThread::start() QThread::sleep(1); if(pipePath.exists() == true) { log("Looking for messages in pipe", className); - char * myfifo = "/run/ipd/fifo"; - int fd = ::open(myfifo, O_RDONLY); + char * pipe = "/dev/ipd/fifo"; + int fd = ::open(pipe, O_RDONLY); char * readchar[5]; ::read(fd, readchar, 5); diff --git a/src/settings/powerdaemonsettings.cpp b/src/settings/powerdaemonsettings.cpp index c4717f2..c84aaa2 100644 --- a/src/settings/powerdaemonsettings.cpp +++ b/src/settings/powerdaemonsettings.cpp @@ -11,8 +11,11 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->setupUi(this); powerDaemonSettings::setFont(QFont("u001")); ui->mainLabel->setFont(QFont("Inter")); - ui->CBSLabel->setFont(QFont("Inter")); - ui->idleSleepLabel->setFont(QFont("Inter")); + + // Avoid some display issues (label moving because width of text would change with a proportional font) + ui->CBSLabel->setFont(QFont("Noto Sans Mono")); + ui->idleSleepLabel->setFont(QFont("Noto Sans Mono")); + ui->label_2->setFont(QFont("Inter")); ui->exitBtn->setFont(QFont("Inter")); @@ -25,10 +28,6 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->ledUsageBtn->setProperty("type", "borderless"); ui->hCustomCaseBtn->setProperty("type", "borderless"); ui->deepSleepBtn->setProperty("type", "borderless"); - ui->CBSDecreaseBtn->setProperty("type", "borderless"); - ui->CBSIncreaseBtn->setProperty("type", "borderless"); - ui->idleSleepDecreaseBtn->setProperty("type", "borderless"); - ui->idleSleepIncreaseBtn->setProperty("type", "borderless"); ui->mainLabel->setStyleSheet("font-weight: bold"); ui->CBSLabel->setStyleSheet("font-weight: bold"); @@ -73,7 +72,6 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : // 1 - cinematicBrightnessDelayMs QString cinematicBrightnessMs = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs"); - log("cinematicBrightnessDelayMs setting is: " + cinematicBrightnessMs, className); ui->CBSLabel->setText(cinematicBrightnessMs); @@ -103,13 +101,11 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->hCpuFreqComboBox->addItems(cpuGovernorList); ui->hCpuFreqComboBox->setCurrentIndex(0); - log("cpuGovernor setting is: " + cpuGovernor, className); - // 3 - whenChargerSleep QString whenChargerSleep = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep"); if(whenChargerSleep == "true") { whenChargerSleepBool = true; - ui->hWhenChargerSleepBtn->click(); + ui->hWhenChargerSleepBtn->click(); } else { whenChargerSleepBool = false; @@ -119,7 +115,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : QString chargerWakeUp = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp"); if(chargerWakeUp == "true") { chargerWakeUpBool = true; - ui->hChargerWakeUpBtn->click(); + ui->hChargerWakeUpBtn->click(); } else { chargerWakeUpBool = false; @@ -128,7 +124,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : // 5 - wifiReconnect QString wifiReconnect = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect"); if(wifiReconnect == "true") { - ui->wifiReconnectBtn->click(); + ui->wifiReconnectBtn->click(); wifiReconnectBool = true; } else { @@ -138,7 +134,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : // 6 - ledUsage QString ledUsagePath = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage"); if(ledUsagePath == "true") { - ui->ledUsageBtn->click(); + ui->ledUsageBtn->click(); ledUsageBool = true; } else { @@ -153,7 +149,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : // 8 - customCase QString customCaseString = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase"); if(customCaseString == "true") { - ui->hCustomCaseBtn->click(); + ui->hCustomCaseBtn->click(); customCaseBool = true; } else { @@ -163,7 +159,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : // 9 - deepSleep QString deepSleepString = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep"); if(deepSleepString == "true") { - ui->deepSleepBtn->click(); + ui->deepSleepBtn->click(); deepSleepBool = true; } else { @@ -232,42 +228,54 @@ void powerDaemonSettings::on_expBtn_clicked() ui->expBtn->hide(); } -void powerDaemonSettings::on_hWhenChargerSleepBtn_clicked() +void powerDaemonSettings::on_hWhenChargerSleepBtn_clicked(bool checked) { - if(whenChargerSleepBool == false) { + QString settingString = "suspend when charging"; + if(checked == true) { + logEnabled(settingString, className); whenChargerSleepBool = true; } else { + logDisabled(settingString, className); whenChargerSleepBool = false; } } -void powerDaemonSettings::on_hChargerWakeUpBtn_clicked() +void powerDaemonSettings::on_hChargerWakeUpBtn_clicked(bool checked) { - if(chargerWakeUpBool == false) { + QString settingString = "ignore charger wake-up events"; + if(checked == true) { + logEnabled(settingString, className); chargerWakeUpBool = true; } else { + logDisabled(settingString, className); chargerWakeUpBool = false; } } -void powerDaemonSettings::on_wifiReconnectBtn_clicked() +void powerDaemonSettings::on_wifiReconnectBtn_clicked(bool checked) { - if(wifiReconnectBool == false) { + QString settingString = "Wi-Fi reconnection on wake-up"; + if(checked == true) { + logEnabled(settingString, className); wifiReconnectBool = true; } else { + logDisabled(settingString, className); wifiReconnectBool = false; } } -void powerDaemonSettings::on_ledUsageBtn_clicked() +void powerDaemonSettings::on_ledUsageBtn_clicked(bool checked) { - if(ledUsageBool == false) { + QString settingString = "use LED"; + if(checked == true) { + logEnabled(settingString, className); ledUsageBool = true; } else { + logDisabled(settingString, className); ledUsageBool = false; } } @@ -317,28 +325,34 @@ void powerDaemonSettings::convertIdleSleepInt() text.append(QString::number(minutes) + "m"); } if(seconds != 0) { - text.append(" " + QString::number(seconds) + "s"); + text.append(QString::number(seconds) + "s"); } ui->idleSleepLabel->setText(text); } -void powerDaemonSettings::on_hCustomCaseBtn_clicked() +void powerDaemonSettings::on_hCustomCaseBtn_clicked(bool checked) { - if(customCaseBool == false) { + QString settingString = "custom case"; + if(checked == true) { + logEnabled(settingString, className); customCaseBool = true; } else { + logDisabled(settingString, className); customCaseBool = false; } } -void powerDaemonSettings::on_deepSleepBtn_clicked() +void powerDaemonSettings::on_deepSleepBtn_clicked(bool checked) { - if(deepSleepBool == false) { + QString settingString = "deep sleep"; + if(checked == true) { + logEnabled(settingString, className); deepSleepBool = true; } else { + logDisabled(settingString, className); deepSleepBool = false; } } diff --git a/src/settings/powerdaemonsettings.h b/src/settings/powerdaemonsettings.h index eb2dc72..c8a9df5 100644 --- a/src/settings/powerdaemonsettings.h +++ b/src/settings/powerdaemonsettings.h @@ -22,15 +22,15 @@ private slots: void on_CBSDecreaseBtn_clicked(); void on_exitBtn_clicked(); void on_expBtn_clicked(); - void on_hWhenChargerSleepBtn_clicked(); - void on_hChargerWakeUpBtn_clicked(); - void on_wifiReconnectBtn_clicked(); - void on_ledUsageBtn_clicked(); + void on_hWhenChargerSleepBtn_clicked(bool checked); + void on_hChargerWakeUpBtn_clicked(bool checked); + void on_wifiReconnectBtn_clicked(bool checked); + void on_ledUsageBtn_clicked(bool checked); void on_idleSleepIncreaseBtn_clicked(); void on_idleSleepDecreaseBtn_clicked(); void convertIdleSleepInt(); - void on_hCustomCaseBtn_clicked(); - void on_deepSleepBtn_clicked(); + void on_hCustomCaseBtn_clicked(bool checked); + void on_deepSleepBtn_clicked(bool checked); private: Ui::powerDaemonSettings * ui; diff --git a/src/settings/powerdaemonsettings.ui b/src/settings/powerdaemonsettings.ui index d5795a0..ac74100 100644 --- a/src/settings/powerdaemonsettings.ui +++ b/src/settings/powerdaemonsettings.ui @@ -87,16 +87,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - @@ -110,16 +100,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - @@ -133,16 +113,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - @@ -156,6 +126,29 @@ + + + + QFrame::Plain + + + Qt::Vertical + + + + + + + + 50 + false + + + + Cinematic brightness speed + + + @@ -169,19 +162,6 @@ - - - - - 50 - false - - - - Cinematic brightness speed - - - @@ -189,7 +169,7 @@ - Reconnect to Wi-Fi after suspending + Reconnect to Wi-Fi on wake-up @@ -234,16 +214,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - @@ -257,16 +227,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - @@ -280,16 +240,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - @@ -303,6 +253,29 @@ + + + + QFrame::Plain + + + Qt::Vertical + + + + + + + + 50 + false + + + + Sleep when idle + + + @@ -316,19 +289,6 @@ - - - - - 50 - false - - - - Sleep when idle - - - diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 50ebb26..845a1ad 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -401,15 +401,15 @@ void settings::on_aboutBtn_clicked() void settings::on_demoCheckBox_toggled(bool checked) { - QString settingString = "demo setting (change MainWindow label)"; + QString settingString = "change MainWindow label demo"; // Write to config file if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); checked_box = true; writeconfig(".config/01-demo/config", "InkboxChangeLabel="); } else { - logDisabled(settingString); + logDisabled(settingString, className); checked_box = false; writeconfig(".config/01-demo/config", "InkboxChangeLabel="); } @@ -417,15 +417,15 @@ void settings::on_demoCheckBox_toggled(bool checked) void settings::on_clockCheckBox_toggled(bool checked) { - QString settingString = "clock with seconds setting"; + QString settingString = "clock with seconds"; // Write to config file if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); checked_box = true; writeconfig(".config/02-clock/config", "ClockShowSeconds="); } else { - logDisabled(settingString); + logDisabled(settingString, className); checked_box = false; writeconfig(".config/02-clock/config", "ClockShowSeconds="); } @@ -433,14 +433,14 @@ void settings::on_clockCheckBox_toggled(bool checked) void settings::on_quoteCheckBox_toggled(bool checked) { - QString settingString = "show quotes setting"; + QString settingString = "disable show quotes"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); checked_box = true; writeconfig(".config/05-quote/config", "DisableQuote="); } else { - logDisabled(settingString); + logDisabled(settingString, className); checked_box = false; writeconfig(".config/05-quote/config", "DisableQuote="); } @@ -566,14 +566,14 @@ void settings::on_updateBtn_clicked() void settings::on_darkModeCheckBox_toggled(bool checked) { - QString settingString = "dark mode setting"; + QString settingString = "dark mode"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); string_writeconfig(".config/10-dark_mode/config", "true"); string_writeconfig("/tmp/invertScreen", "y"); } else { - logDisabled(settingString); + logDisabled(settingString, className); string_writeconfig(".config/10-dark_mode/config", "false"); string_writeconfig("/tmp/invertScreen", "n"); } @@ -652,14 +652,14 @@ void settings::on_uiScalingSlider_valueChanged(int value) void settings::on_menuBarCheckBox_toggled(bool checked) { - QString settingString = "sticky menu bar setting"; + QString settingString = "sticky menu bar"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); checked_box = true; writeconfig(".config/11-menubar/sticky", "StickyMenuBar="); } else { - logDisabled(settingString); + logDisabled(settingString, className); checked_box = false; writeconfig(".config/11-menubar/sticky", "StickyMenuBar="); } @@ -718,22 +718,22 @@ void settings::on_setPasscodeBtn_clicked() void settings::on_enableLockscreenCheckBox_toggled(bool checked) { - QString settingString = "lockscreen setting"; + QString settingString = "lockscreen"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); string_writeconfig(".config/12-lockscreen/config", "true"); } else { - logDisabled(settingString); + logDisabled(settingString, className); string_writeconfig(".config/12-lockscreen/config", "false"); } } void settings::on_enableUiScalingCheckBox_toggled(bool checked) { - QString settingString = "UI scaling setting"; + QString settingString = "UI scaling"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); // Writing default value depending on the device if(global::deviceID == "n705\n") { string_writeconfig(".config/09-dpi/config", "187"); @@ -766,7 +766,7 @@ void settings::on_enableUiScalingCheckBox_toggled(bool checked) } } else { - logDisabled(settingString); + logDisabled(settingString, className); string_writeconfig(".config/09-dpi/config", "false"); string_writeconfig(".config/09-dpi/config-enabled", "false"); ui->uiScaleNumberLabel->hide(); @@ -811,13 +811,13 @@ void settings::on_pageSizeHeightSpinBox_valueChanged(int arg1) void settings::on_readerScrollBarCheckBox_toggled(bool checked) { - QString settingString = "scrollbar display if necessary setting"; + QString settingString = "scrollbar display if necessary"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); string_writeconfig(".config/14-reader_scrollbar/config", "true"); } else { - logDisabled(settingString); + logDisabled(settingString, className); string_writeconfig(".config/14-reader_scrollbar/config", "false"); } } @@ -828,14 +828,14 @@ void settings::brightnessDown() { void settings::on_globalReadingSettingsCheckBox_toggled(bool checked) { - QString settingString = "global reading settings setting"; + QString settingString = "global reading settings"; if(checked == true) { - logEnabled(settingString); + logEnabled(settingString, className); checked_box = true; writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings="); } else { - logDisabled(settingString); + logDisabled(settingString, className); checked_box = false; writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings="); } @@ -917,10 +917,10 @@ void settings::quit_restart() { void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked) { - QString settingString = "encrypted storage setting"; + QString settingString = "encrypted storage"; if(checked == true) { if(enableEncryptedStorageUserChange == true) { - logEnabled(settingString); + logEnabled(settingString, className); setDefaultWorkDir(); string_writeconfig(".config/18-encrypted_storage/initial_setup_done", "false"); string_writeconfig(".config/18-encrypted_storage/status", "true"); @@ -937,7 +937,7 @@ void settings::on_enableEncryptedStorageCheckBox_toggled(bool checked) } } else { - logDisabled(settingString); + logDisabled(settingString, className); global::encfs::disableStorageEncryptionDialog = true; generalDialogWindow = new generalDialog(this); generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); @@ -1027,11 +1027,3 @@ void settings::on_tzComboBox_currentTextChanged(const QString &arg1) } } } - -void settings::logEnabled(QString settingString) { - log("Enabling " + settingString, className); -} - -void settings::logDisabled(QString settingString) { - log("Disabling " + settingString, className); -} diff --git a/src/settings/settings.h b/src/settings/settings.h index 4bf5680..2d27431 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -71,8 +71,6 @@ private slots: void on_repackBtn_clicked(); void on_generateSystemReportBtn_clicked(); void on_tzComboBox_currentTextChanged(const QString &arg1); - void logEnabled(QString settingString); - void logDisabled(QString settingString); signals: void showToast(QString messageToDisplay);