From a1a94a9c99e6f77b1807b7637bf80b35196291c4 Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 26 Jul 2023 16:01:57 +0800 Subject: [PATCH] Move host selection into menu too --- pytec/tec_qt.py | 23 ++++++++++++++++++++++- pytec/tec_qt.ui | 34 ---------------------------------- pytec/ui_tec_qt.py | 14 -------------- 3 files changed, 22 insertions(+), 49 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 4b258fe..8e21c52 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -195,9 +195,31 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.connect_btn.click() def _set_up_context_menu(self): + _translate = QtCore.QCoreApplication.translate + self.menu = QtWidgets.QMenu() self.menu.setTitle('Thermostat settings') + self.ip_set_line = QtWidgets.QLineEdit() + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.ip_set_line.sizePolicy().hasHeightForWidth()) + self.ip_set_line.setSizePolicy(sizePolicy) + self.ip_set_line.setMinimumSize(QtCore.QSize(160, 0)) + self.ip_set_line.setMaximumSize(QtCore.QSize(160, 16777215)) + self.ip_set_line.setMaxLength(15) + self.ip_set_line.setClearButtonEnabled(True) + self.ip_set_line.setObjectName("ip_set_line") + + self.ip_set_line.setText(_translate("MainWindow", "192.168.1.26")) + self.ip_set_line.setPlaceholderText(_translate("MainWindow", "IP:port for the Thermostat")) + + host = QtWidgets.QWidgetAction(self.menu) + host.setDefaultWidget(self.ip_set_line) + self.menu.addAction(host) + self.menu.host = host + self.port_set_spin = QtWidgets.QSpinBox() sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -268,7 +290,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.gan_layout.addWidget(self.fan_pwm_warning) self.horizontalLayout_6.addLayout(self.gan_layout) - _translate = QtCore.QCoreApplication.translate self.fan_lbl.setToolTip(_translate("MainWindow", "Adjust the fan")) self.fan_lbl.setText(_translate("MainWindow", "Fan:")) self.fan_auto_box.setText(_translate("MainWindow", "Auto")) diff --git a/pytec/tec_qt.ui b/pytec/tec_qt.ui index a59870e..9006243 100644 --- a/pytec/tec_qt.ui +++ b/pytec/tec_qt.ui @@ -178,40 +178,6 @@ - - - - - 0 - 0 - - - - - 160 - 0 - - - - - 160 - 16777215 - - - - 192.168.1.26 - - - 15 - - - IP:port for the Thermostat - - - true - - - diff --git a/pytec/ui_tec_qt.py b/pytec/ui_tec_qt.py index 2967d36..31c4c83 100644 --- a/pytec/ui_tec_qt.py +++ b/pytec/ui_tec_qt.py @@ -92,18 +92,6 @@ class Ui_MainWindow(object): self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.settings_layout = QtWidgets.QHBoxLayout() self.settings_layout.setObjectName("settings_layout") - self.ip_set_line = QtWidgets.QLineEdit(parent=self.bottom_settings_group) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.ip_set_line.sizePolicy().hasHeightForWidth()) - self.ip_set_line.setSizePolicy(sizePolicy) - self.ip_set_line.setMinimumSize(QtCore.QSize(160, 0)) - self.ip_set_line.setMaximumSize(QtCore.QSize(160, 16777215)) - self.ip_set_line.setMaxLength(15) - self.ip_set_line.setClearButtonEnabled(True) - self.ip_set_line.setObjectName("ip_set_line") - self.settings_layout.addWidget(self.ip_set_line) self.connect_btn = QtWidgets.QPushButton(parent=self.bottom_settings_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) @@ -216,8 +204,6 @@ class Ui_MainWindow(object): self.ch0_t_graph.setTitle(_translate("MainWindow", "Channel 0 Temperature")) self.ch0_i_graph.setTitle(_translate("MainWindow", "Channel 0 Current")) self.ch1_i_graph.setTitle(_translate("MainWindow", "Channel 1 Current")) - self.ip_set_line.setText(_translate("MainWindow", "192.168.1.26")) - self.ip_set_line.setPlaceholderText(_translate("MainWindow", "IP:port for the Thermostat")) self.connect_btn.setText(_translate("MainWindow", "Connect")) self.status_lbl.setText(_translate("MainWindow", "Disconnected")) self.toolButton_2.setText(_translate("MainWindow", "..."))