From 69a68ce67c7f186ab3ddbba4d57522e5ed5db0ab Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 12 Jul 2020 19:06:19 +0200 Subject: [PATCH] Refactor monitor tab GUI setup --- AdaptiveBrightness/main_window.cpp | 23 ++++++++++++++--------- AdaptiveBrightness/main_window.hpp | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/AdaptiveBrightness/main_window.cpp b/AdaptiveBrightness/main_window.cpp index d0fd6e8..30c4521 100644 --- a/AdaptiveBrightness/main_window.cpp +++ b/AdaptiveBrightness/main_window.cpp @@ -24,19 +24,14 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) m_ui.setupUi(this); - connect(m_ui.monitorBrightnessSlider, &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)); - m_brightness = newBrightness; - }); + m_sensors = enumerateSensors(); + m_monitors = enumerateMonitors(); + + setupMonitorsTab(); setupTrayIcon(); setupCallbackTimer(); - - m_sensors = enumerateSensors(); - m_monitors = enumerateMonitors(); } MainWindow::~MainWindow() @@ -90,6 +85,16 @@ void MainWindow::loadIcons() qDebug(ltr("Icons loaded")); } +void MainWindow::setupMonitorsTab() +{ + connect(m_ui.monitorBrightnessSlider, &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)); + m_brightness = newBrightness; + }); +} + void MainWindow::setupTrayIcon() { loadIcons(); diff --git a/AdaptiveBrightness/main_window.hpp b/AdaptiveBrightness/main_window.hpp index 04006d5..3665cc9 100644 --- a/AdaptiveBrightness/main_window.hpp +++ b/AdaptiveBrightness/main_window.hpp @@ -29,6 +29,8 @@ class MainWindow : public QMainWindow { void closeEvent(QCloseEvent* event) override; void loadIcons(); + + void setupMonitorsTab(); void setupTrayIcon(); void setupCallbackTimer();