diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 8ece05b..24058f4 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -324,6 +324,11 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.host_set_line.setMaxLength(15) self.host_set_line.setClearButtonEnabled(True) + def connect_on_enter_press(): + self.connect_btn.click() + self.connection_menu.hide() + self.host_set_line.returnPressed.connect(connect_on_enter_press) + self.host_set_line.setText("192.168.1.26") self.host_set_line.setPlaceholderText("IP for the Thermostat") @@ -338,6 +343,12 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.port_set_spin.setMaximum(65535) self.port_set_spin.setValue(23) + def connect_only_if_enter_pressed(): + if not self.port_set_spin.hasFocus(): # Don't connect if the spinbox only lost focus + return; + connect_on_enter_press() + self.port_set_spin.editingFinished.connect(connect_only_if_enter_pressed) + port = QtWidgets.QWidgetAction(self.connection_menu) port.setDefaultWidget(self.port_set_spin) self.connection_menu.addAction(port)