diff --git a/AdaptiveBrightness/main_window.cpp b/AdaptiveBrightness/main_window.cpp index bbc9522..37dd1ed 100644 --- a/AdaptiveBrightness/main_window.cpp +++ b/AdaptiveBrightness/main_window.cpp @@ -128,17 +128,53 @@ void MainWindow::setupMonitorsTab() m_brightness = newBrightness; }); + setupLimitsSlider(); + setupOverallLimitsSlider(); +} + +void MainWindow::setupLimitsSlider() +{ + connect(m_ui.monitorMinBrightnessSlider, &QSlider::valueChanged, [this](int value) { + m_ui.monitorMinBrightnessValueLabel->setText(tr("%1%").arg(value, 3)); + if(value > m_ui.monitorMaxBrightnessSlider->value()) { + m_ui.monitorMaxBrightnessSlider->setValue(value); + } + const auto curIdx = m_ui.monitorDropdown->currentIndex(); + m_monitors[curIdx].minBrightness = utils::map(value, 0, 100, 0.f, 1.f); + updateCurrentMonitorGUI(curIdx); + }); + connect(m_ui.monitorMaxBrightnessSlider, &QSlider::valueChanged, [this](int value) { + m_ui.monitorMaxBrightnessValueLabel->setText(tr("%1%").arg(value, 3)); + if(value < m_ui.monitorMinBrightnessSlider->value()) { + m_ui.monitorMinBrightnessSlider->setValue(value); + } + const auto curIdx = m_ui.monitorDropdown->currentIndex(); + m_monitors[curIdx].maxBrightness = utils::map(value, 0, 100, 0.f, 1.f); + updateCurrentMonitorGUI(curIdx); + }); +} + +void MainWindow::setupOverallLimitsSlider() +{ connect(m_ui.monitorOverallMinBrightnessSlider, &QSlider::valueChanged, [this](int value) { m_ui.monitorOverallMinBrightnessValueLabel->setText(tr("%1%").arg(value, 3)); if(value > m_ui.monitorOverallMaxBrightnessSlider->value()) { m_ui.monitorOverallMaxBrightnessSlider->setValue(value); } + for(auto& monitor: m_monitors) { + monitor.minBrightness = utils::map(value, 0, 100, 0.f, 1.f); + } + updateCurrentMonitorGUI(m_ui.monitorDropdown->currentIndex()); }); connect(m_ui.monitorOverallMaxBrightnessSlider, &QSlider::valueChanged, [this](int value) { m_ui.monitorOverallMaxBrightnessValueLabel->setText(tr("%1%").arg(value, 3)); if(value < m_ui.monitorOverallMinBrightnessSlider->value()) { m_ui.monitorOverallMinBrightnessSlider->setValue(value); } + for(auto& monitor: m_monitors) { + monitor.maxBrightness = utils::map(value, 0, 100, 0.f, 1.f); + } + updateCurrentMonitorGUI(m_ui.monitorDropdown->currentIndex()); }); } diff --git a/AdaptiveBrightness/main_window.hpp b/AdaptiveBrightness/main_window.hpp index d392462..0ff66cf 100644 --- a/AdaptiveBrightness/main_window.hpp +++ b/AdaptiveBrightness/main_window.hpp @@ -34,6 +34,9 @@ class MainWindow : public QMainWindow { void loadIcons(); void setupMonitorsTab(); + void setupLimitsSlider(); + void setupOverallLimitsSlider(); + void setupTrayIcon(); void setupCallbackTimer();