Make manual override slider bidirectional
This commit is contained in:
parent
1e3596a230
commit
e43629d0c0
@ -7,7 +7,6 @@
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QGroupBox>
|
||||
#include <QSlider>
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
@ -21,10 +20,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||
qDebug(ltr("Creating main window"));
|
||||
|
||||
m_ui.setupUi(this);
|
||||
auto slider = m_ui.centralWidget->findChild<QGroupBox*>("groupBox")->findChild<QSlider*>("horizontalSlider");
|
||||
m_manualBrightnessSlider = m_ui.centralWidget->findChild<QGroupBox*>("groupBox")->findChild<QSlider*>("horizontalSlider");
|
||||
|
||||
if(slider) {
|
||||
connect(slider, &QSlider::valueChanged, [this](int value) {
|
||||
if(m_manualBrightnessSlider) {
|
||||
connect(m_manualBrightnessSlider, &QSlider::valueChanged, [this](int value) {
|
||||
const auto mappedBrightness = utils::map(value, 0, 100, 0.f, 1.f);
|
||||
const auto newBrightness = std::clamp(mappedBrightness, 0.f, 1.f);
|
||||
qDebug(ltr("Overriding brightness with %1").arg(newBrightness));
|
||||
@ -201,6 +200,10 @@ void MainWindow::updateState()
|
||||
if(m_trayIcon) {
|
||||
m_trayIcon->setToolTip(tr("AdaptiveBrightness - %1%").arg(m_brightness * 100, 0, 'f', 0));
|
||||
}
|
||||
|
||||
if(m_manualBrightnessSlider) {
|
||||
m_manualBrightnessSlider->setValue(utils::map(m_brightness, 0.f, 1.f, 0, 100));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QIcon>
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QSlider>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
@ -47,6 +48,8 @@ class MainWindow : public QMainWindow {
|
||||
QThread* m_timerThread = nullptr;
|
||||
QTimer* m_timer = nullptr;
|
||||
|
||||
QSlider* m_manualBrightnessSlider = nullptr;
|
||||
|
||||
float m_brightness = 0.5f;
|
||||
|
||||
std::vector<Sensor> m_sensors;
|
||||
|
Loading…
Reference in New Issue
Block a user