From 71076510a2f11aeca3129dfe7ef4e533e6874a06 Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 19 Jul 2023 12:49:15 +0800 Subject: [PATCH] Steal fan group and port??? Somehow --- pytec/tec_qt.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 6dff78f..ab694c1 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -73,8 +73,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.setupUi(self) - menu = QtWidgets.QMenu(self) - self.thermostat_settings.setMenu(menu) + self._set_up_context_menu() self.fan_power_slider.valueChanged.connect(self.fan_set) self.fan_auto_box.stateChanged.connect(self.fan_auto_set) @@ -95,6 +94,22 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.port_set_spin.setValue(int(args.PORT)) self.connect_btn.click() + def _set_up_context_menu(self): + self.menu = QtWidgets.QMenu() + self.menu.setTitle('Thermostat settings') + + fan = QtWidgets.QWidgetAction(self.menu) + fan.setDefaultWidget(self.fan_group) + self.menu.addAction(fan) + self.menu.fan = fan + + port = QtWidgets.QWidgetAction(self.menu) + port.setDefaultWidget(self.port_set_spin) + self.menu.addAction(port) + self.menu.port = port + + self.thermostat_settings.setMenu(self.menu) + async def _on_connection_changed(self, result): self.graph_group.setEnabled(result) self.fan_group.setEnabled(result)