diff --git a/AdaptiveBrightness/AdaptiveBrightness.ui b/AdaptiveBrightness/AdaptiveBrightness.ui index a958462..c600ec5 100644 --- a/AdaptiveBrightness/AdaptiveBrightness.ui +++ b/AdaptiveBrightness/AdaptiveBrightness.ui @@ -1,7 +1,7 @@ - AdaptiveBrightnessClass - + MainWindow + 0 @@ -17,26 +17,26 @@ :/AdaptiveBrightness/resources/system.ico:/AdaptiveBrightness/resources/system.ico - + - + 0 - + Monitors - + Monitor - + 0 @@ -46,48 +46,48 @@ - + Re-enumerate - + Limits - + Qt::Horizontal - + Minimum - + Qt::Horizontal - + Maximum - + 0% @@ -97,7 +97,7 @@ - + 100% @@ -110,27 +110,27 @@ - + Brightness - + Qt::Horizontal - + Manual override - + 50% @@ -146,27 +146,27 @@ - + Overall limits - + Minimum - + Qt::Horizontal - + 0% @@ -176,21 +176,21 @@ - + Maximum - + Qt::Horizontal - + 100% @@ -203,7 +203,7 @@ - + Qt::Vertical @@ -216,14 +216,14 @@ - + Restore all monitors to defaults - + Qt::Horizontal @@ -236,20 +236,20 @@ - + Overall brightness - + Qt::Horizontal - + 50% @@ -259,7 +259,7 @@ - + Manual override @@ -269,7 +269,7 @@ - + Qt::Vertical @@ -283,26 +283,26 @@ - + Sensors - + Sensor module - + Re-enumerate - + 0 @@ -312,13 +312,13 @@ - + Readout - + 0 @@ -394,20 +394,20 @@ - + Sensor aggregation - + Function - + 0 @@ -417,14 +417,14 @@ - + Module result: - + 50% @@ -440,14 +440,14 @@ - + Restore all sensors to defaults - + Qt::Horizontal @@ -460,20 +460,20 @@ - + Total aggregation - + Function - + 0 @@ -483,14 +483,14 @@ - + Result: - + 50% @@ -503,7 +503,7 @@ - + Qt::Vertical @@ -516,7 +516,7 @@ - + Qt::Vertical diff --git a/AdaptiveBrightness/main_window.cpp b/AdaptiveBrightness/main_window.cpp index f2384d3..cecfd7a 100644 --- a/AdaptiveBrightness/main_window.cpp +++ b/AdaptiveBrightness/main_window.cpp @@ -24,18 +24,12 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) m_ui.setupUi(this); - const auto tabs = m_ui.centralWidget->findChild("tabWidget"); - const auto tab = tabs->findChild("tab"); - m_manualBrightnessSlider = tab->findChild("horizontalSlider"); - - 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)); - m_brightness = newBrightness; - }); - } + 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; + }); loadIcons(); @@ -207,9 +201,7 @@ void MainWindow::updateState() 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)); - } + m_ui.monitorBrightnessSlider->setValue(utils::map(m_brightness, 0.f, 1.f, 0, 100)); } void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason) diff --git a/AdaptiveBrightness/main_window.hpp b/AdaptiveBrightness/main_window.hpp index ebd1112..d87ee2e 100644 --- a/AdaptiveBrightness/main_window.hpp +++ b/AdaptiveBrightness/main_window.hpp @@ -34,7 +34,7 @@ class MainWindow : public QMainWindow { void trayIconClicked(QSystemTrayIcon::ActivationReason reason); - Ui::AdaptiveBrightnessClass m_ui; + Ui::MainWindow m_ui; std::array, 9> m_noSensorStateIcons; std::array, 9> m_sensorStateIcons; @@ -48,8 +48,6 @@ class MainWindow : public QMainWindow { QThread* m_timerThread = nullptr; QTimer* m_timer = nullptr; - QSlider* m_manualBrightnessSlider = nullptr; - float m_brightness = 0.5f; std::vector m_sensors;