Give UI elements proper names

This commit is contained in:
BlackMark 2020-07-12 18:44:38 +02:00
parent 200ad19d95
commit 395e58f94d
3 changed files with 62 additions and 72 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>AdaptiveBrightnessClass</class> <class>MainWindow</class>
<widget class="QMainWindow" name="AdaptiveBrightnessClass"> <widget class="QMainWindow" name="MainWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -17,26 +17,26 @@
<iconset resource="AdaptiveBrightness.qrc"> <iconset resource="AdaptiveBrightness.qrc">
<normaloff>:/AdaptiveBrightness/resources/system.ico</normaloff>:/AdaptiveBrightness/resources/system.ico</iconset> <normaloff>:/AdaptiveBrightness/resources/system.ico</normaloff>:/AdaptiveBrightness/resources/system.ico</iconset>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="mainWidget">
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabs">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="monitorTab">
<attribute name="title"> <attribute name="title">
<string>Monitors</string> <string>Monitors</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_12"> <layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="monitorGroup">
<property name="title"> <property name="title">
<string>Monitor</string> <string>Monitor</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_11"> <layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QComboBox" name="comboBox"> <widget class="QComboBox" name="monitorDropdown">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -46,48 +46,48 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="monitorEnumerateButton">
<property name="text"> <property name="text">
<string>Re-enumerate</string> <string>Re-enumerate</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_7"> <widget class="QGroupBox" name="monitorLimitsGroup">
<property name="title"> <property name="title">
<string>Limits</string> <string>Limits</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_9"> <layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSlider" name="horizontalSlider_3"> <widget class="QSlider" name="monitorMaxBrightnessSlider">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="monitorMinBrightnessLabel">
<property name="text"> <property name="text">
<string>Minimum</string> <string>Minimum</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSlider" name="horizontalSlider_2"> <widget class="QSlider" name="monitorMinBrightnessSlider">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="monitorMaxBrightnessLabel">
<property name="text"> <property name="text">
<string>Maximum</string> <string>Maximum</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="monitorMinBrightnessValueLabel">
<property name="text"> <property name="text">
<string>0%</string> <string>0%</string>
</property> </property>
@ -97,7 +97,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="monitorMaxBrightnessValueLabel">
<property name="text"> <property name="text">
<string>100%</string> <string>100%</string>
</property> </property>
@ -110,27 +110,27 @@
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="monitorBrightnessGroup">
<property name="title"> <property name="title">
<string>Brightness</string> <string>Brightness</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QSlider" name="horizontalSlider"> <widget class="QSlider" name="monitorBrightnessSlider">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="checkBox"> <widget class="QCheckBox" name="monitorOverrideCheck">
<property name="text"> <property name="text">
<string>Manual override</string> <string>Manual override</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="monitorBrightnessValueLabel">
<property name="text"> <property name="text">
<string>50%</string> <string>50%</string>
</property> </property>
@ -146,27 +146,27 @@
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_8"> <widget class="QGroupBox" name="monitorOverallLimitsGroup">
<property name="title"> <property name="title">
<string>Overall limits</string> <string>Overall limits</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_10"> <layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="monitorOverallMinBrightnessLabel">
<property name="text"> <property name="text">
<string>Minimum</string> <string>Minimum</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSlider" name="horizontalSlider_4"> <widget class="QSlider" name="monitorOverallMinBrightnessSlider">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="monitorOverallMinBrightnessValueLabel">
<property name="text"> <property name="text">
<string>0%</string> <string>0%</string>
</property> </property>
@ -176,21 +176,21 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="monitorOverallMaxBrightnessLabel">
<property name="text"> <property name="text">
<string>Maximum</string> <string>Maximum</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSlider" name="horizontalSlider_5"> <widget class="QSlider" name="monitorOverallMaxBrightnessSlider">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="monitorOverallMaxBrightnessValueLabel">
<property name="text"> <property name="text">
<string>100%</string> <string>100%</string>
</property> </property>
@ -203,7 +203,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<spacer name="verticalSpacer_4"> <spacer name="monitorBottomSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -216,14 +216,14 @@
</spacer> </spacer>
</item> </item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QPushButton" name="pushButton_2"> <widget class="QPushButton" name="monitorResetButton">
<property name="text"> <property name="text">
<string>Restore all monitors to defaults</string> <string>Restore all monitors to defaults</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">
<spacer name="horizontalSpacer"> <spacer name="monitorResetSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -236,20 +236,20 @@
</spacer> </spacer>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_9"> <widget class="QGroupBox" name="monitorOverallBrightnessGroup">
<property name="title"> <property name="title">
<string>Overall brightness</string> <string>Overall brightness</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QSlider" name="horizontalSlider_6"> <widget class="QSlider" name="monitorOverallBrightnessSlider">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_16"> <widget class="QLabel" name="monitorOverallBrightnessValueLabel">
<property name="text"> <property name="text">
<string>50%</string> <string>50%</string>
</property> </property>
@ -259,7 +259,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="checkBox_2"> <widget class="QCheckBox" name="monitorOverallOverrideCheck">
<property name="text"> <property name="text">
<string>Manual override</string> <string>Manual override</string>
</property> </property>
@ -269,7 +269,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<spacer name="verticalSpacer_2"> <spacer name="monitorTopSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -283,26 +283,26 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="sensorsTab">
<attribute name="title"> <attribute name="title">
<string>Sensors</string> <string>Sensors</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="sensorGroup">
<property name="title"> <property name="title">
<string>Sensor module</string> <string>Sensor module</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QPushButton" name="pushButton_3"> <widget class="QPushButton" name="sensorEnumerateButton">
<property name="text"> <property name="text">
<string>Re-enumerate</string> <string>Re-enumerate</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QComboBox" name="comboBox_2"> <widget class="QComboBox" name="sensorDropdown">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -312,13 +312,13 @@
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_4"> <widget class="QGroupBox" name="sensorReadoutGroup">
<property name="title"> <property name="title">
<string>Readout</string> <string>Readout</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget"> <widget class="QTreeWidget" name="sensorReadoutValues">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -394,20 +394,20 @@
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_5"> <widget class="QGroupBox" name="sensorAggregationGroup">
<property name="title"> <property name="title">
<string>Sensor aggregation</string> <string>Sensor aggregation</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="sensorAggregationFunctionLabel">
<property name="text"> <property name="text">
<string>Function</string> <string>Function</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QComboBox" name="comboBox_3"> <widget class="QComboBox" name="sensorAggregationFunctionDropdown">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -417,14 +417,14 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label"> <widget class="QLabel" name="sensorAggregationResultLabel">
<property name="text"> <property name="text">
<string>Module result:</string> <string>Module result:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="sensorAggregationValueLabel">
<property name="text"> <property name="text">
<string>50%</string> <string>50%</string>
</property> </property>
@ -440,14 +440,14 @@
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QPushButton" name="pushButton_4"> <widget class="QPushButton" name="sensorResetButton">
<property name="text"> <property name="text">
<string>Restore all sensors to defaults</string> <string>Restore all sensors to defaults</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<spacer name="horizontalSpacer_2"> <spacer name="sensorResetSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -460,20 +460,20 @@
</spacer> </spacer>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="sensorTotalAggregationGroup">
<property name="title"> <property name="title">
<string>Total aggregation</string> <string>Total aggregation</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="sensorTotalAggregationFunctionLabel">
<property name="text"> <property name="text">
<string>Function</string> <string>Function</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QComboBox" name="comboBox_4"> <widget class="QComboBox" name="sensorTotalAggregationFunctionDropdown">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -483,14 +483,14 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="sensorTotalAggregationResultLabel">
<property name="text"> <property name="text">
<string>Result:</string> <string>Result:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="sensorTotalAggregationValueLabel">
<property name="text"> <property name="text">
<string>50%</string> <string>50%</string>
</property> </property>
@ -503,7 +503,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<spacer name="verticalSpacer"> <spacer name="sensorTopSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -516,7 +516,7 @@
</spacer> </spacer>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<spacer name="verticalSpacer_3"> <spacer name="sensorBottomSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>

View File

@ -24,18 +24,12 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
m_ui.setupUi(this); m_ui.setupUi(this);
const auto tabs = m_ui.centralWidget->findChild<QTabWidget*>("tabWidget"); connect(m_ui.monitorBrightnessSlider, &QSlider::valueChanged, [this](int value) {
const auto tab = tabs->findChild<QWidget*>("tab"); const auto mappedBrightness = utils::map(value, 0, 100, 0.f, 1.f);
m_manualBrightnessSlider = tab->findChild<QSlider*>("horizontalSlider"); const auto newBrightness = std::clamp(mappedBrightness, 0.f, 1.f);
qDebug(ltr("Overriding brightness with %1").arg(newBrightness));
if(m_manualBrightnessSlider) { m_brightness = newBrightness;
connect(m_manualBrightnessSlider, &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;
});
}
loadIcons(); loadIcons();
@ -207,9 +201,7 @@ void MainWindow::updateState()
m_trayIcon->setToolTip(tr("AdaptiveBrightness - %1%").arg(m_brightness * 100, 0, 'f', 0)); m_trayIcon->setToolTip(tr("AdaptiveBrightness - %1%").arg(m_brightness * 100, 0, 'f', 0));
} }
if(m_manualBrightnessSlider) { m_ui.monitorBrightnessSlider->setValue(utils::map(m_brightness, 0.f, 1.f, 0, 100));
m_manualBrightnessSlider->setValue(utils::map(m_brightness, 0.f, 1.f, 0, 100));
}
} }
void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason) void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason)

View File

@ -34,7 +34,7 @@ class MainWindow : public QMainWindow {
void trayIconClicked(QSystemTrayIcon::ActivationReason reason); void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
Ui::AdaptiveBrightnessClass m_ui; Ui::MainWindow m_ui;
std::array<std::unique_ptr<QIcon>, 9> m_noSensorStateIcons; std::array<std::unique_ptr<QIcon>, 9> m_noSensorStateIcons;
std::array<std::unique_ptr<QIcon>, 9> m_sensorStateIcons; std::array<std::unique_ptr<QIcon>, 9> m_sensorStateIcons;
@ -48,8 +48,6 @@ class MainWindow : public QMainWindow {
QThread* m_timerThread = nullptr; QThread* m_timerThread = nullptr;
QTimer* m_timer = nullptr; QTimer* m_timer = nullptr;
QSlider* m_manualBrightnessSlider = nullptr;
float m_brightness = 0.5f; float m_brightness = 0.5f;
std::vector<Sensor> m_sensors; std::vector<Sensor> m_sensors;