ipd improvements

This commit is contained in:
Nicolas Mailloux 2022-07-26 21:08:25 -04:00
parent 3262c7945f
commit dfd89c5531
7 changed files with 133 additions and 163 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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;

View file

@ -87,16 +87,6 @@
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Line" name="line_6">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="CBSIncreaseBtn">
<property name="sizePolicy">
@ -110,16 +100,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="CBSDecreaseBtn">
<property name="sizePolicy">
@ -133,16 +113,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="CBSLabel">
<property name="font">
@ -156,6 +126,29 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Cinematic brightness speed</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -169,19 +162,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Cinematic brightness speed</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -189,7 +169,7 @@
<item>
<widget class="QCheckBox" name="wifiReconnectBtn">
<property name="text">
<string>Reconnect to Wi-Fi after suspending</string>
<string>Reconnect to Wi-Fi on wake-up</string>
</property>
</widget>
</item>
@ -234,16 +214,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="Line" name="line_8">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="idleSleepIncreaseBtn">
<property name="sizePolicy">
@ -257,16 +227,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="idleSleepDecreaseBtn">
<property name="sizePolicy">
@ -280,16 +240,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_9">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="idleSleepLabel">
<property name="font">
@ -303,6 +253,29 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Sleep when idle</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
@ -316,19 +289,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Sleep when idle</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

View file

@ -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);
}

View file

@ -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);