Replace fan group highlighting with warning icon

Highlighting is too confusing
This commit is contained in:
atse 2023-07-07 15:36:17 +08:00
parent 8045d8c93d
commit 47dbe95045
3 changed files with 27 additions and 6 deletions

View File

@ -1,4 +1,4 @@
from PyQt6 import QtWidgets from PyQt6 import QtWidgets, QtGui
from PyQt6.QtCore import pyqtSignal, QObject, QSignalBlocker, pyqtSlot from PyQt6.QtCore import pyqtSignal, QObject, QSignalBlocker, pyqtSlot
from pyqtgraph import PlotWidget from pyqtgraph import PlotWidget
from pyqtgraph.parametertree import Parameter, ParameterTree, ParameterItem, registerParameterType from pyqtgraph.parametertree import Parameter, ParameterTree, ParameterItem, registerParameterType
@ -97,18 +97,21 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.connect_btn.setText("Disconnect" if result else "Connect") self.connect_btn.setText("Disconnect" if result else "Connect")
if not result: if not result:
self.hw_rev_lbl.setText("Thermostat vX.Y") self.hw_rev_lbl.setText("Thermostat vX.Y")
self.fan_group.setStyleSheet("") self.fan_pwm_warning.setPixmap(QtGui.QPixmap())
self.fan_pwm_warning.setToolTip("")
def _hw_rev(self, hw_rev_d: dict): def _hw_rev(self, hw_rev_d: dict):
logging.debug(hw_rev_d) logging.debug(hw_rev_d)
self.hw_rev_lbl.setText(f"Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}") self.hw_rev_lbl.setText(f"Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}")
self.fan_group.setEnabled(hw_rev_d["settings"]["fan_available"]) self.fan_group.setEnabled(hw_rev_d["settings"]["fan_available"])
if hw_rev_d["settings"]["fan_pwm_recommended"]: if hw_rev_d["settings"]["fan_pwm_recommended"]:
self.fan_group.setStyleSheet("") self.fan_pwm_warning.setPixmap(QtGui.QPixmap())
self.fan_group.setToolTip("") self.fan_pwm_warning.setToolTip("")
else: else:
self.fan_group.setStyleSheet("background-color: yellow") pixmapi = getattr(QtWidgets.QStyle.StandardPixmap, "SP_MessageBoxWarning")
self.fan_group.setToolTip("fan_pwm not recommended on this hardware revision") icon = self.style().standardIcon(pixmapi)
self.fan_pwm_warning.setPixmap(icon.pixmap(16, 16))
self.fan_pwm_warning.setToolTip("Fan power adjustment not recommended on this hardware revision!")
def fan_update(self, fan_settings): def fan_update(self, fan_settings):
logging.debug(fan_settings) logging.debug(fan_settings)

View File

@ -503,6 +503,19 @@
<property name="spacing"> <property name="spacing">
<number>9</number> <number>9</number>
</property> </property>
<item>
<widget class="QLabel" name="fan_pwm_warning">
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="fan_lbl"> <widget class="QLabel" name="fan_lbl">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -227,6 +227,11 @@ class Ui_MainWindow(object):
self.gan_layout = QtWidgets.QHBoxLayout() self.gan_layout = QtWidgets.QHBoxLayout()
self.gan_layout.setSpacing(9) self.gan_layout.setSpacing(9)
self.gan_layout.setObjectName("gan_layout") self.gan_layout.setObjectName("gan_layout")
self.fan_pwm_warning = QtWidgets.QLabel(parent=self.fan_group)
self.fan_pwm_warning.setMinimumSize(QtCore.QSize(16, 0))
self.fan_pwm_warning.setText("")
self.fan_pwm_warning.setObjectName("fan_pwm_warning")
self.gan_layout.addWidget(self.fan_pwm_warning)
self.fan_lbl = QtWidgets.QLabel(parent=self.fan_group) self.fan_lbl = QtWidgets.QLabel(parent=self.fan_group)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)