Commit 04815f45 authored by Edo Friedman's avatar Edo Friedman Committed by Nate Graham
Browse files

Add percentage display next to the brightness and keyboard backlight sliders in KCM

Currently if you were to open System Settings and go to the
Power Management -> Energy Saving KCM, you will see the "Screen Brightness"
and "Keyboard Backlight" sliders, but there will be no way to know the exact
number you selected until you apply the change and look at the "Energy Saving"
applet. This commit changes that by adding percentage labels to the right of
both sliders.

BUG: 440314
FIXED-IN: 5.25
parent 4c031ac8
Pipeline #161549 passed with stage
in 1 minute and 4 seconds
......@@ -60,12 +60,17 @@ QList< QPair< QString, QWidget* > > BrightnessControlConfig::buildUi()
{
m_slider = new QSlider(Qt::Horizontal);
m_slider->setRange(0, 100);
m_text = new QLabel("0%");
connect(m_slider, &QSlider::valueChanged, m_text, [=](int percentage) {
m_text->setText(QString::number(percentage).append("%"));
});
QWidget *tempWidget = new QWidget;
QHBoxLayout *hlay = new QHBoxLayout;
hlay->addWidget(m_slider);
hlay->addWidget(m_text);
tempWidget->setLayout(hlay);
QList< QPair< QString, QWidget* > > retlist;
retlist.append(qMakePair< QString, QWidget* >(i18nc("Brightness level, label for the slider", "Level"), tempWidget));
......
......@@ -24,6 +24,7 @@
#include <powerdevilactionconfig.h>
class QSlider;
class QLabel;
namespace PowerDevil {
namespace BundledActions {
......@@ -42,6 +43,7 @@ public:
private:
QSlider *m_slider;
QLabel *m_text;
};
}
......
......@@ -61,10 +61,16 @@ QList< QPair< QString, QWidget* > > KeyboardBrightnessControlConfig::buildUi()
m_slider = new QSlider(Qt::Horizontal);
m_slider->setRange(0, 100);
m_text = new QLabel("0%");
connect(m_slider, &QSlider::valueChanged, m_text, [=](int percentage) {
m_text->setText(QString::number(percentage).append("%"));
});
QWidget *tempWidget = new QWidget;
QHBoxLayout *hlay = new QHBoxLayout;
hlay->addWidget(m_slider);
hlay->addWidget(m_text);
tempWidget->setLayout(hlay);
QList< QPair< QString, QWidget* > > retlist;
......
......@@ -24,6 +24,7 @@
#include <powerdevilactionconfig.h>
class QSlider;
class QLabel;
namespace PowerDevil {
namespace BundledActions {
......@@ -42,6 +43,7 @@ public:
private:
QSlider *m_slider;
QLabel *m_text;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment