Compare commits
2 Commits
c930e316c4
...
42043bcd55
Author | SHA1 | Date | |
---|---|---|---|
42043bcd55 | |||
45116d8857 |
@ -61,15 +61,20 @@ void MainWindow::enumSensors()
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void MainWindow::loadIcons()
|
||||
@ -110,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();
|
||||
@ -261,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));
|
||||
@ -269,6 +279,8 @@ void MainWindow::updateCurrentMonitorGUI(int index)
|
||||
|
||||
void MainWindow::updateState()
|
||||
{
|
||||
m_mtx.lock();
|
||||
|
||||
qDebug(ltr("Updating state"));
|
||||
|
||||
bool sensorError = false;
|
||||
@ -322,6 +334,8 @@ void MainWindow::updateState()
|
||||
if(m_trayIcon) {
|
||||
m_trayIcon->setToolTip(tr("AdaptiveBrightness - %1%").arg(brightness * 100, 0, 'f', 0));
|
||||
}
|
||||
|
||||
m_mtx.unlock();
|
||||
}
|
||||
|
||||
bool MainWindow::setMonitorBrightness(float& brightness)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QIcon>
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QMutex>
|
||||
#include <QSlider>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QThread>
|
||||
@ -63,6 +64,7 @@ class MainWindow : public QMainWindow {
|
||||
|
||||
QThread* m_timerThread = nullptr;
|
||||
QTimer* m_timer = nullptr;
|
||||
QMutex m_mtx;
|
||||
|
||||
struct SensorData {
|
||||
Sensor driver;
|
||||
|
Loading…
Reference in New Issue
Block a user