Merge pull request #32 from Szybet/master

Better idle sleep time selection
This commit is contained in:
Nicolas Mailloux 2022-08-08 22:23:19 -04:00 committed by GitHub
commit 9c085d1b2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 170 additions and 79 deletions

View file

@ -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,29 +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);
ui->idleSleepDecreaseBtn->setIcon(QIcon(":/resources/minus.png"));
ui->idleSleepDecreaseBtn->setFixedWidth(controlBtnFixedLength);
ui->idleSleepIncreaseBtn->setIcon(QIcon(":/resources/plus.png"));
ui->idleSleepIncreaseBtn->setFixedWidth(controlBtnFixedLength);
int idleBtnsFixedWidth;
if(global::deviceID == "n705\n") {
idleBtnsFixedWidth = 80;
}
else {
idleBtnsFixedWidth = 100;
}
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->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");
@ -87,6 +98,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 +357,7 @@ void powerDaemonSettings::convertIdleSleepInt()
ui->idleSleepLabel->setText("Never");
return;
}
while(copiedIdleSleepInt > 60) {
while(copiedIdleSleepInt >= 60) {
minutes = minutes + 1;
copiedIdleSleepInt = copiedIdleSleepInt - 60;
}
@ -347,9 +365,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 +406,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();
}

View file

@ -34,6 +34,10 @@ private slots:
void convertIdleSleepInt();
void convertCinematicInt();
void on_idleSleepIncreaseMBtn_clicked();
void on_idleSleepDecreaseMBtn_clicked();
private:
Ui::powerDaemonSettings * ui;
bool whenChargerSleepBool;

View file

@ -113,6 +113,19 @@
</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>
<widget class="QLabel" name="CBSLabel">
<property name="font">
@ -126,29 +139,6 @@
</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">
@ -214,6 +204,10 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QPushButton" name="idleSleepIncreaseBtn">
<property name="sizePolicy">
@ -222,8 +216,14 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
<string>+1s</string>
</property>
</widget>
</item>
@ -235,8 +235,73 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
<string>-1s</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPushButton" name="idleSleepIncreaseMBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>+1m</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="idleSleepDecreaseMBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>-1m</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</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>
@ -253,29 +318,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="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">