Implement re-enumerate button

This commit is contained in:
BlackMark 2020-07-17 18:35:56 +02:00
parent 45116d8857
commit 42043bcd55

View File

@ -64,13 +64,14 @@ void MainWindow::enumMonitors()
m_mtx.lock();
m_ui.monitorDropdown->clear();
m_monitors.clear();
auto monitors = enumerateMonitors();
for(auto& monitor: monitors) {
const auto currentBrightness = monitor.getBrightness();
m_ui.monitorDropdown->addItem(monitor.getName());
m_monitors.push_back({std::move(monitor), 0.f, 1.f, currentBrightness, false});
m_ui.monitorDropdown->addItem(m_monitors.back().driver.getName());
}
m_mtx.unlock();
@ -114,6 +115,7 @@ void MainWindow::loadIcons()
void MainWindow::setupMonitorsTab()
{
connect(m_ui.monitorDropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::updateCurrentMonitorGUI);
connect(m_ui.monitorEnumerateButton, &QAbstractButton::clicked, [this](bool) { enumMonitors(); });
setupLimitsSlider();
setupOverallLimitsSlider();
@ -265,6 +267,10 @@ void MainWindow::setupCallbackTimer()
void MainWindow::updateCurrentMonitorGUI(int index)
{
if(index == -1) {
return;
}
m_ui.monitorMinBrightnessSlider->setValue(utils::map(m_monitors[index].minBrightness, 0.f, 1.f, 0, 100));
m_ui.monitorMaxBrightnessSlider->setValue(utils::map(m_monitors[index].maxBrightness, 0.f, 1.f, 0, 100));
m_ui.monitorBrightnessSlider->setValue(utils::map(m_monitors[index].brightness, 0.f, 1.f, 0, 100));