Remove unnecessary circular updates

This commit is contained in:
BlackMark 2020-07-17 16:34:01 +02:00
parent 5943b72fef
commit 756bb9b6a7

View File

@ -141,7 +141,6 @@ void MainWindow::setupLimitsSlider()
} }
const auto curIdx = m_ui.monitorDropdown->currentIndex(); const auto curIdx = m_ui.monitorDropdown->currentIndex();
m_monitors[curIdx].minBrightness = utils::map(value, 0, 100, 0.f, 1.f); m_monitors[curIdx].minBrightness = utils::map(value, 0, 100, 0.f, 1.f);
updateCurrentMonitorGUI(curIdx);
}); });
connect(m_ui.monitorMaxBrightnessSlider, &QSlider::valueChanged, [this](int value) { connect(m_ui.monitorMaxBrightnessSlider, &QSlider::valueChanged, [this](int value) {
m_ui.monitorMaxBrightnessValueLabel->setText(tr("%1%").arg(value, 3)); m_ui.monitorMaxBrightnessValueLabel->setText(tr("%1%").arg(value, 3));
@ -150,7 +149,6 @@ void MainWindow::setupLimitsSlider()
} }
const auto curIdx = m_ui.monitorDropdown->currentIndex(); const auto curIdx = m_ui.monitorDropdown->currentIndex();
m_monitors[curIdx].maxBrightness = utils::map(value, 0, 100, 0.f, 1.f); m_monitors[curIdx].maxBrightness = utils::map(value, 0, 100, 0.f, 1.f);
updateCurrentMonitorGUI(curIdx);
}); });
} }
@ -232,14 +230,9 @@ void MainWindow::setupCallbackTimer()
void MainWindow::updateCurrentMonitorGUI(int index) void MainWindow::updateCurrentMonitorGUI(int index)
{ {
const auto brightness = utils::map(m_monitors[index].brightness, 0.f, 1.f, 0, 100); const auto brightness = utils::map(m_monitors[index].brightness, 0.f, 1.f, 0, 100);
const auto minimum = utils::map(m_monitors[index].minBrightness, 0.f, 1.f, 0, 100);
const auto maximum = utils::map(m_monitors[index].maxBrightness, 0.f, 1.f, 0, 100);
m_ui.monitorMinBrightnessSlider->setValue(minimum); m_ui.monitorMinBrightnessSlider->setValue(utils::map(m_monitors[index].minBrightness, 0.f, 1.f, 0, 100));
m_ui.monitorMinBrightnessValueLabel->setText(QString("%1%").arg(minimum, 3)); m_ui.monitorMaxBrightnessSlider->setValue(utils::map(m_monitors[index].maxBrightness, 0.f, 1.f, 0, 100));
m_ui.monitorMaxBrightnessSlider->setValue(maximum);
m_ui.monitorMaxBrightnessValueLabel->setText(QString("%1%").arg(maximum, 3));
m_ui.monitorBrightnessSlider->setValue(brightness); m_ui.monitorBrightnessSlider->setValue(brightness);
m_ui.monitorBrightnessValueLabel->setText(QString("%1%").arg(brightness, 3)); m_ui.monitorBrightnessValueLabel->setText(QString("%1%").arg(brightness, 3));