better idle time choosing

This commit is contained in:
Szybet 2022-08-08 00:28:15 +02:00
parent d27f1d31bc
commit 94c42ad201
3 changed files with 137 additions and 71 deletions

View file

@ -50,16 +50,26 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png")); ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png"));
ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedLength); ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedLength);
ui->idleSleepDecreaseBtn->setIcon(QIcon(":/resources/minus.png"));
ui->idleSleepDecreaseBtn->setFixedWidth(controlBtnFixedLength); int idleButtonsWidth;
ui->idleSleepIncreaseBtn->setIcon(QIcon(":/resources/plus.png")); if(global::deviceID == "n306\n") {
ui->idleSleepIncreaseBtn->setFixedWidth(controlBtnFixedLength); idleButtonsWidth = 100;
}
else {
idleButtonsWidth = 100;
}
ui->idleSleepDecreaseBtn->setFixedWidth(idleButtonsWidth);
ui->idleSleepIncreaseBtn->setFixedWidth(idleButtonsWidth);
ui->idleSleepDecreaseMBtn->setFixedWidth(idleButtonsWidth);
ui->idleSleepIncreaseMBtn->setFixedWidth(idleButtonsWidth);
// Padding // Padding
ui->CBSDecreaseBtn->setStyleSheet("padding: 10px"); ui->CBSDecreaseBtn->setStyleSheet("padding: 10px");
ui->CBSIncreaseBtn->setStyleSheet("padding: 10px"); ui->CBSIncreaseBtn->setStyleSheet("padding: 10px");
ui->idleSleepDecreaseBtn->setStyleSheet("padding: 10px"); ui->idleSleepDecreaseBtn->setStyleSheet("padding: 10px");
ui->idleSleepIncreaseBtn->setStyleSheet("padding: 10px"); ui->idleSleepIncreaseBtn->setStyleSheet("padding: 10px");
ui->idleSleepDecreaseMBtn->setStyleSheet("padding: 10px");
ui->idleSleepIncreaseMBtn->setStyleSheet("padding: 10px");
// Stylesheet // Stylesheet
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss"); QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
@ -87,6 +97,13 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
ui->idleSleepIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay); ui->idleSleepIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
ui->idleSleepIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval); 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 // Hide items
ui->hLabel_3->hide(); ui->hLabel_3->hide();
@ -339,7 +356,7 @@ void powerDaemonSettings::convertIdleSleepInt()
ui->idleSleepLabel->setText("Never"); ui->idleSleepLabel->setText("Never");
return; return;
} }
while(copiedIdleSleepInt > 60) { while(copiedIdleSleepInt >= 60) {
minutes = minutes + 1; minutes = minutes + 1;
copiedIdleSleepInt = copiedIdleSleepInt - 60; copiedIdleSleepInt = copiedIdleSleepInt - 60;
} }
@ -347,9 +364,10 @@ void powerDaemonSettings::convertIdleSleepInt()
QString text; QString text;
if(minutes != 0) { if(minutes != 0) {
text.append(QString::number(minutes) + "m "); text.append(QString::number(minutes) + "m");
} }
if(seconds != 0) { if(seconds != 0) {
text.append(" ");
text.append(QString::number(seconds) + "s"); text.append(QString::number(seconds) + "s");
} }
ui->idleSleepLabel->setText(text); ui->idleSleepLabel->setText(text);
@ -387,3 +405,29 @@ void powerDaemonSettings::convertCinematicInt() {
text.append("ms"); text.append("ms");
ui->CBSLabel->setText(text); 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 convertIdleSleepInt();
void convertCinematicInt(); void convertCinematicInt();
void on_idleSleepIncreaseMBtn_clicked();
void on_idleSleepDecreaseMBtn_clicked();
private: private:
Ui::powerDaemonSettings * ui; Ui::powerDaemonSettings * ui;
bool whenChargerSleepBool; bool whenChargerSleepBool;

View file

@ -75,7 +75,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>680</width> <width>680</width>
<height>545</height> <height>553</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
@ -113,6 +113,19 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QLabel" name="CBSLabel"> <widget class="QLabel" name="CBSLabel">
<property name="font"> <property name="font">
@ -126,29 +139,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@ -215,28 +205,79 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QPushButton" name="idleSleepIncreaseBtn"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <layout class="QHBoxLayout" name="horizontalLayout_11">
<horstretch>0</horstretch> <item>
<verstretch>0</verstretch> <widget class="QPushButton" name="idleSleepIncreaseBtn">
</sizepolicy> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<property name="text"> <horstretch>0</horstretch>
<string/> <verstretch>0</verstretch>
</property> </sizepolicy>
</widget> </property>
<property name="text">
<string>+1s</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="idleSleepDecreaseBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<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="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="text">
<string>-1m</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="idleSleepDecreaseBtn"> <widget class="QLabel" name="label_5">
<property name="sizePolicy"> <property name="font">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <font>
<horstretch>0</horstretch> <weight>50</weight>
<verstretch>0</verstretch> <bold>false</bold>
</sizepolicy> </font>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>Sleep when idle |</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -253,29 +294,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<spacer name="horizontalSpacer_9"> <spacer name="horizontalSpacer_9">
<property name="orientation"> <property name="orientation">