Refactor monitor tab GUI setup

This commit is contained in:
BlackMark 2020-07-12 19:06:19 +02:00
parent afd6de62a0
commit 69a68ce67c
2 changed files with 16 additions and 9 deletions

View File

@ -24,19 +24,14 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
m_ui.setupUi(this);
connect(m_ui.monitorBrightnessSlider, &QSlider::valueChanged, [this](int value) {
const auto mappedBrightness = utils::map(value, 0, 100, 0.f, 1.f);
const auto newBrightness = std::clamp(mappedBrightness, 0.f, 1.f);
qDebug(ltr("Overriding brightness with %1").arg(newBrightness));
m_brightness = newBrightness;
});
m_sensors = enumerateSensors();
m_monitors = enumerateMonitors();
setupMonitorsTab();
setupTrayIcon();
setupCallbackTimer();
m_sensors = enumerateSensors();
m_monitors = enumerateMonitors();
}
MainWindow::~MainWindow()
@ -90,6 +85,16 @@ void MainWindow::loadIcons()
qDebug(ltr("Icons loaded"));
}
void MainWindow::setupMonitorsTab()
{
connect(m_ui.monitorBrightnessSlider, &QSlider::valueChanged, [this](int value) {
const auto mappedBrightness = utils::map(value, 0, 100, 0.f, 1.f);
const auto newBrightness = std::clamp(mappedBrightness, 0.f, 1.f);
qDebug(ltr("Overriding brightness with %1").arg(newBrightness));
m_brightness = newBrightness;
});
}
void MainWindow::setupTrayIcon()
{
loadIcons();

View File

@ -29,6 +29,8 @@ class MainWindow : public QMainWindow {
void closeEvent(QCloseEvent* event) override;
void loadIcons();
void setupMonitorsTab();
void setupTrayIcon();
void setupCallbackTimer();