Compare commits

..

3 Commits

Author SHA1 Message Date
5943b72fef Implement limits slider 2020-07-17 16:28:15 +02:00
8f4dec0bff Implement overall limit sliders 2020-07-17 16:15:52 +02:00
78f3daf1ff Remove paramater that matches the default 2020-07-17 16:10:10 +02:00
2 changed files with 55 additions and 3 deletions

View File

@ -127,6 +127,55 @@ void MainWindow::setupMonitorsTab()
qDebug(ltr("Overriding brightness with %1").arg(newBrightness));
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());
});
}
void MainWindow::setupTrayIcon()
@ -187,13 +236,13 @@ void MainWindow::updateCurrentMonitorGUI(int index)
const auto maximum = utils::map(m_monitors[index].maxBrightness, 0.f, 1.f, 0, 100);
m_ui.monitorMinBrightnessSlider->setValue(minimum);
m_ui.monitorMinBrightnessValueLabel->setText(QString("%1%").arg(minimum, 3, 10));
m_ui.monitorMinBrightnessValueLabel->setText(QString("%1%").arg(minimum, 3));
m_ui.monitorMaxBrightnessSlider->setValue(maximum);
m_ui.monitorMaxBrightnessValueLabel->setText(QString("%1%").arg(maximum, 3, 10));
m_ui.monitorMaxBrightnessValueLabel->setText(QString("%1%").arg(maximum, 3));
m_ui.monitorBrightnessSlider->setValue(brightness);
m_ui.monitorBrightnessValueLabel->setText(QString("%1%").arg(brightness, 3, 10));
m_ui.monitorBrightnessValueLabel->setText(QString("%1%").arg(brightness, 3));
m_ui.monitorOverrideCheck->setChecked(m_monitors[index].manualOverride);
}

View File

@ -34,6 +34,9 @@ class MainWindow : public QMainWindow {
void loadIcons();
void setupMonitorsTab();
void setupLimitsSlider();
void setupOverallLimitsSlider();
void setupTrayIcon();
void setupCallbackTimer();