diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 8e21c52..523ff42 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -197,8 +197,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): def _set_up_context_menu(self): _translate = QtCore.QCoreApplication.translate - self.menu = QtWidgets.QMenu() - self.menu.setTitle('Thermostat settings') + self.connection_menu = QtWidgets.QMenu() + self.connection_menu.setTitle('Connection Settings') self.ip_set_line = QtWidgets.QLineEdit() sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding) @@ -215,10 +215,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): 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 = QtWidgets.QWidgetAction(self.connection_menu) host.setDefaultWidget(self.ip_set_line) - self.menu.addAction(host) - self.menu.host = host + self.connection_menu.addAction(host) + self.connection_menu.host = host self.port_set_spin = QtWidgets.QSpinBox() sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) @@ -232,10 +232,15 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.port_set_spin.setProperty("value", 23) self.port_set_spin.setObjectName("port_set_spin") - port = QtWidgets.QWidgetAction(self.menu) + port = QtWidgets.QWidgetAction(self.connection_menu) port.setDefaultWidget(self.port_set_spin) - self.menu.addAction(port) - self.menu.port = port + self.connection_menu.addAction(port) + self.connection_menu.port = port + + self.connect_btn.setMenu(self.connection_menu) + + self.menu = QtWidgets.QMenu() + self.menu.setTitle('Thermostat settings') self.fan_group = QtWidgets.QWidget() self.fan_group.setEnabled(False) diff --git a/pytec/tec_qt.ui b/pytec/tec_qt.ui index 9006243..a9e45be 100644 --- a/pytec/tec_qt.ui +++ b/pytec/tec_qt.ui @@ -179,7 +179,7 @@ - + 0 @@ -207,6 +207,12 @@ Connect + + QToolButton::MenuButtonPopup + + + Qt::ToolButtonFollowStyle + diff --git a/pytec/ui_tec_qt.py b/pytec/ui_tec_qt.py index 31c4c83..8c5a61d 100644 --- a/pytec/ui_tec_qt.py +++ b/pytec/ui_tec_qt.py @@ -92,7 +92,7 @@ class Ui_MainWindow(object): self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.settings_layout = QtWidgets.QHBoxLayout() self.settings_layout.setObjectName("settings_layout") - self.connect_btn = QtWidgets.QPushButton(parent=self.bottom_settings_group) + self.connect_btn = QtWidgets.QToolButton(parent=self.bottom_settings_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -101,6 +101,8 @@ class Ui_MainWindow(object): self.connect_btn.setMinimumSize(QtCore.QSize(100, 0)) self.connect_btn.setMaximumSize(QtCore.QSize(100, 16777215)) self.connect_btn.setBaseSize(QtCore.QSize(100, 0)) + self.connect_btn.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.MenuButtonPopup) + self.connect_btn.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonFollowStyle) self.connect_btn.setObjectName("connect_btn") self.settings_layout.addWidget(self.connect_btn) self.status_lbl = QtWidgets.QLabel(parent=self.bottom_settings_group)