From 94c42ad20129aa13261508ad2404960e47ed33a4 Mon Sep 17 00:00:00 2001 From: Szybet <53944559+Szybet@users.noreply.github.com> Date: Mon, 8 Aug 2022 00:28:15 +0200 Subject: [PATCH 1/2] better idle time choosing --- src/settings/powerdaemonsettings.cpp | 56 ++++++++-- src/settings/powerdaemonsettings.h | 4 + src/settings/powerdaemonsettings.ui | 148 +++++++++++++++------------ 3 files changed, 137 insertions(+), 71 deletions(-) diff --git a/src/settings/powerdaemonsettings.cpp b/src/settings/powerdaemonsettings.cpp index 4864c62..5deb5ee 100644 --- a/src/settings/powerdaemonsettings.cpp +++ b/src/settings/powerdaemonsettings.cpp @@ -50,16 +50,26 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png")); ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedLength); - ui->idleSleepDecreaseBtn->setIcon(QIcon(":/resources/minus.png")); - ui->idleSleepDecreaseBtn->setFixedWidth(controlBtnFixedLength); - ui->idleSleepIncreaseBtn->setIcon(QIcon(":/resources/plus.png")); - ui->idleSleepIncreaseBtn->setFixedWidth(controlBtnFixedLength); + + int idleButtonsWidth; + if(global::deviceID == "n306\n") { + idleButtonsWidth = 100; + } + else { + idleButtonsWidth = 100; + } + ui->idleSleepDecreaseBtn->setFixedWidth(idleButtonsWidth); + ui->idleSleepIncreaseBtn->setFixedWidth(idleButtonsWidth); + ui->idleSleepDecreaseMBtn->setFixedWidth(idleButtonsWidth); + ui->idleSleepIncreaseMBtn->setFixedWidth(idleButtonsWidth); // Padding ui->CBSDecreaseBtn->setStyleSheet("padding: 10px"); ui->CBSIncreaseBtn->setStyleSheet("padding: 10px"); ui->idleSleepDecreaseBtn->setStyleSheet("padding: 10px"); ui->idleSleepIncreaseBtn->setStyleSheet("padding: 10px"); + ui->idleSleepDecreaseMBtn->setStyleSheet("padding: 10px"); + ui->idleSleepIncreaseMBtn->setStyleSheet("padding: 10px"); // Stylesheet QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss"); @@ -87,6 +97,13 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->idleSleepIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay); ui->idleSleepIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval); + ui->idleSleepDecreaseMBtn->setAutoRepeat(true); + ui->idleSleepDecreaseMBtn->setAutoRepeatDelay(autoRepeatDelay); + ui->idleSleepDecreaseMBtn->setAutoRepeatInterval(autoRepeatInterval); + + ui->idleSleepIncreaseMBtn->setAutoRepeat(true); + ui->idleSleepIncreaseMBtn->setAutoRepeatDelay(autoRepeatDelay); + ui->idleSleepIncreaseMBtn->setAutoRepeatInterval(autoRepeatInterval); // Hide items ui->hLabel_3->hide(); @@ -339,7 +356,7 @@ void powerDaemonSettings::convertIdleSleepInt() ui->idleSleepLabel->setText("Never"); return; } - while(copiedIdleSleepInt > 60) { + while(copiedIdleSleepInt >= 60) { minutes = minutes + 1; copiedIdleSleepInt = copiedIdleSleepInt - 60; } @@ -347,9 +364,10 @@ void powerDaemonSettings::convertIdleSleepInt() QString text; if(minutes != 0) { - text.append(QString::number(minutes) + "m "); + text.append(QString::number(minutes) + "m"); } if(seconds != 0) { + text.append(" "); text.append(QString::number(seconds) + "s"); } ui->idleSleepLabel->setText(text); @@ -387,3 +405,29 @@ void powerDaemonSettings::convertCinematicInt() { text.append("ms"); ui->CBSLabel->setText(text); } + +void powerDaemonSettings::on_idleSleepIncreaseMBtn_clicked() +{ + if(idleSleepInt >= 15) { + idleSleepInt = idleSleepInt + 60; + } + else { + idleSleepInt = 60; + } + convertIdleSleepInt(); +} + +void powerDaemonSettings::on_idleSleepDecreaseMBtn_clicked() +{ + if(idleSleepInt >= 60) { + idleSleepInt = idleSleepInt - 60; + if(idleSleepInt < 14) { + idleSleepInt = 0; + } + } + else { + idleSleepInt = 0; + } + + convertIdleSleepInt(); +} diff --git a/src/settings/powerdaemonsettings.h b/src/settings/powerdaemonsettings.h index e69e054..e95ccff 100644 --- a/src/settings/powerdaemonsettings.h +++ b/src/settings/powerdaemonsettings.h @@ -34,6 +34,10 @@ private slots: void convertIdleSleepInt(); void convertCinematicInt(); + void on_idleSleepIncreaseMBtn_clicked(); + + void on_idleSleepDecreaseMBtn_clicked(); + private: Ui::powerDaemonSettings * ui; bool whenChargerSleepBool; diff --git a/src/settings/powerdaemonsettings.ui b/src/settings/powerdaemonsettings.ui index 2bd80b4..d8ba07e 100644 --- a/src/settings/powerdaemonsettings.ui +++ b/src/settings/powerdaemonsettings.ui @@ -75,7 +75,7 @@ 0 0 680 - 545 + 553 @@ -113,6 +113,19 @@ + + + + + 50 + false + + + + Cinematic brightness speed | + + + @@ -126,29 +139,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - - - - - - 50 - false - - - - Cinematic brightness speed - - - @@ -215,28 +205,79 @@ - - - - 0 - 0 - - - - - - + + + + + + + + 0 + 0 + + + + +1s + + + + + + + + 0 + 0 + + + + -1s + + + + + + + + + + + + 0 + 0 + + + + +1m + + + + + + + + 0 + 0 + + + + -1m + + + + + + - - - - 0 - 0 - + + + + 50 + false + - + Sleep when idle | @@ -253,29 +294,6 @@ - - - - QFrame::Plain - - - Qt::Vertical - - - - - - - - 50 - false - - - - Sleep when idle - - - From 5b726657ce911f23eee095be3016bad4ca2ab660 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Mon, 8 Aug 2022 22:22:36 -0400 Subject: [PATCH 2/2] Style fix --- src/settings/powerdaemonsettings.cpp | 39 ++++++++++++++-------------- src/settings/powerdaemonsettings.ui | 26 ++++++++++++++++++- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/settings/powerdaemonsettings.cpp b/src/settings/powerdaemonsettings.cpp index 5deb5ee..0011f70 100644 --- a/src/settings/powerdaemonsettings.cpp +++ b/src/settings/powerdaemonsettings.cpp @@ -16,6 +16,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->CBSLabel->setFont(QFont("Noto Sans Mono")); ui->idleSleepLabel->setFont(QFont("Noto Sans Mono")); + // Font tweaks ui->label_2->setFont(QFont("Inter")); ui->exitBtn->setFont(QFont("Inter")); @@ -37,39 +38,39 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) : ui->label_2->setStyleSheet("font-weight: bold"); // Icons - int controlBtnFixedLength; + int controlBtnFixedWidth; if(global::deviceID == "n705\n") { - controlBtnFixedLength = 50; + controlBtnFixedWidth = 50; } else { - controlBtnFixedLength = 80; + controlBtnFixedWidth = 80; } ui->CBSDecreaseBtn->setIcon(QIcon(":/resources/minus.png")); - ui->CBSDecreaseBtn->setFixedWidth(controlBtnFixedLength); + ui->CBSDecreaseBtn->setFixedWidth(controlBtnFixedWidth); ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png")); - ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedLength); + ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedWidth); - int idleButtonsWidth; - if(global::deviceID == "n306\n") { - idleButtonsWidth = 100; + int idleBtnsFixedWidth; + if(global::deviceID == "n705\n") { + idleBtnsFixedWidth = 80; } else { - idleButtonsWidth = 100; + idleBtnsFixedWidth = 100; } - ui->idleSleepDecreaseBtn->setFixedWidth(idleButtonsWidth); - ui->idleSleepIncreaseBtn->setFixedWidth(idleButtonsWidth); - ui->idleSleepDecreaseMBtn->setFixedWidth(idleButtonsWidth); - ui->idleSleepIncreaseMBtn->setFixedWidth(idleButtonsWidth); + ui->idleSleepDecreaseBtn->setFixedWidth(idleBtnsFixedWidth); + ui->idleSleepIncreaseBtn->setFixedWidth(idleBtnsFixedWidth); + ui->idleSleepDecreaseMBtn->setFixedWidth(idleBtnsFixedWidth); + ui->idleSleepIncreaseMBtn->setFixedWidth(idleBtnsFixedWidth); // Padding - ui->CBSDecreaseBtn->setStyleSheet("padding: 10px"); - ui->CBSIncreaseBtn->setStyleSheet("padding: 10px"); - ui->idleSleepDecreaseBtn->setStyleSheet("padding: 10px"); - ui->idleSleepIncreaseBtn->setStyleSheet("padding: 10px"); - ui->idleSleepDecreaseMBtn->setStyleSheet("padding: 10px"); - ui->idleSleepIncreaseMBtn->setStyleSheet("padding: 10px"); + ui->CBSDecreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt"); + ui->CBSIncreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt"); + ui->idleSleepDecreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt"); + ui->idleSleepIncreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt"); + ui->idleSleepDecreaseMBtn->setStyleSheet("padding: 10px; font-size: 10pt"); + ui->idleSleepIncreaseMBtn->setStyleSheet("padding: 10px; font-size: 10pt"); // Stylesheet QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss"); diff --git a/src/settings/powerdaemonsettings.ui b/src/settings/powerdaemonsettings.ui index d8ba07e..b682d4b 100644 --- a/src/settings/powerdaemonsettings.ui +++ b/src/settings/powerdaemonsettings.ui @@ -75,7 +75,7 @@ 0 0 680 - 553 + 545 @@ -216,6 +216,12 @@ 0 + + + 75 + true + + +1s @@ -229,6 +235,12 @@ 0 + + + 75 + true + + -1s @@ -246,6 +258,12 @@ 0 + + + 75 + true + + +1m @@ -259,6 +277,12 @@ 0 + + + 75 + true + + -1m