From 729c1d5b2398caf81b9ca0ccb0f366bd24990d99 Mon Sep 17 00:00:00 2001 From: Yiem <642092830@qq.com> Date: Fri, 1 Aug 2025 15:50:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=20UDP/TCP=20?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=20Client/Server=20=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=97=B6=EF=BC=8C=E6=89=80=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=8E=A7=E4=BB=B6=E5=B1=95=E7=A4=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=B7=B7=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMTool/conn/conn_tcp_udp.py | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/COMTool/conn/conn_tcp_udp.py b/COMTool/conn/conn_tcp_udp.py index 5a3b7d9..cc83f15 100644 --- a/COMTool/conn/conn_tcp_udp.py +++ b/COMTool/conn/conn_tcp_udp.py @@ -174,8 +174,8 @@ def initEvet(self): self.updateClientsSignal.connect(self.updateClients) self.protoclTcpRadioBtn.clicked.connect(lambda: self.changeProtocol("tcp")) self.protoclUdpRadioBtn.clicked.connect(lambda: self.changeProtocol("udp")) - self.modeServerRadioBtn.clicked.connect(lambda: self.changeMode("server")) - self.modeClientRadioBtn.clicked.connect(lambda: self.changeMode("client")) + self.modeServerRadioBtn.clicked.connect(lambda: self.changeMode("server", self.config["protocol"])) + self.modeClientRadioBtn.clicked.connect(lambda: self.changeMode("client", self.config["protocol"])) self.clientsCombobox.currentIndexChanged.connect(self.serverModeClientChanged) self.disconnetClientBtn.clicked.connect(self.serverModeDisconnectClient) self.autoReconnect.stateChanged.connect(lambda x: self.setVar("auto_reconnect", value = x)) @@ -190,46 +190,46 @@ def changeProtocol(self, protocol, init=False): self.modeClientRadioBtn.show() self.modeServerRadioBtn.show() self.modeLabel.show() - self.changeMode(self.config["mode"], init=True) + self.changeMode(self.config["mode"], protocol, init=True) else: - self.targetCombobox.show() - self.targetLabel.show() - self.selfIPandPortLabel.show() - self.selfIPandPort.show() - self.porttEdit.show() - self.portLabel.show() - self.clientsCombobox.hide() - self.disconnetClientBtn.hide() - self.autoReconnect.hide() - self.autoReconnectIntervalEdit.hide() - self.autoReconnetLable.hide() - self.modeClientRadioBtn.hide() - self.modeServerRadioBtn.hide() - self.modeLabel.hide() - self.widget.adjustSize() + self.modeClientRadioBtn.show() + self.modeServerRadioBtn.show() + self.modeLabel.show() + self.changeMode(self.config["mode"], protocol, init=True) self.config["protocol"] = protocol - def changeMode(self, mode, init=False): + def changeMode(self, mode, protocol, init=False): if init or mode != self.config["mode"]: if self.isConnected(): self.openCloseSerial() if mode == "server": + if protocol == "tcp": + self.clientsCombobox.show() + self.disconnetClientBtn.show() + else: + self.clientsCombobox.hide() + self.disconnetClientBtn.hide() + self.targetCombobox.hide() self.targetLabel.hide() self.selfIPandPortLabel.hide() self.selfIPandPort.hide() self.porttEdit.show() self.portLabel.show() - self.clientsCombobox.show() - self.disconnetClientBtn.show() self.autoReconnect.hide() self.autoReconnectIntervalEdit.hide() self.autoReconnetLable.hide() else: + if protocol == "tcp": + self.selfIPandPortLabel.show() + self.selfIPandPort.show() + self.selfIPandPort.setReadOnly(True) + else: + self.selfIPandPortLabel.hide() + self.selfIPandPort.hide() + self.targetCombobox.show() self.targetLabel.show() - self.selfIPandPortLabel.show() - self.selfIPandPort.show() self.porttEdit.hide() self.portLabel.hide() self.clientsCombobox.hide() @@ -308,11 +308,11 @@ def setSerialConfig(self, conf_type, obj, value): elif conf_type == "mode": if value == "client": obj.setChecked(True) - self.changeMode("client", init=True) + self.changeMode("client", self.config["protocol"], init=True) else: obj.setChecked(False) self.modeServerRadioBtn.setChecked(True) - self.changeMode("server", init=True) + self.changeMode("server", self.config["protocol"], init=True) elif conf_type == "target": for i, target in enumerate(self.config["target"][1]): self.targetCombobox.addItem(target) From 4812b1e7ea3c04dcfd2bd47ff467ee25d7e55171 Mon Sep 17 00:00:00 2001 From: Yiem <642092830@qq.com> Date: Fri, 1 Aug 2025 17:09:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=88=97=E8=A1=A8=E5=86=85=E5=AE=B9=E5=A4=AA?= =?UTF-8?q?=E9=95=BF=EF=BC=8C=E5=BC=BA=E5=88=B6=E4=BD=BF=E7=94=A8=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=A4=A7=E5=B0=8F=E5=AF=BC=E8=87=B4=E8=B6=85=E5=87=BA?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E5=90=8E=EF=BC=8C=E5=BC=B9=E7=AA=97=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=B8=B2=E6=9F=93=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=9C=80=E5=A4=A7=E4=B8=8D=E8=B6=85=E8=BF=87?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMTool/Combobox.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/COMTool/Combobox.py b/COMTool/Combobox.py index 923867a..63a9dd8 100644 --- a/COMTool/Combobox.py +++ b/COMTool/Combobox.py @@ -21,12 +21,6 @@ def showPopup(self): pass def _showPopup(self): - max_w = 0 - for i in range(self.count()): - w = self.view().sizeHintForColumn(i) - if w > max_w: - max_w = w - self.view().setMinimumWidth(max_w + 50) super(ComboBox, self).showPopup() def showItems(self): From 2ba760efeba94e0c09160d9626af7f77bff5a3af Mon Sep 17 00:00:00 2001 From: Yiem <642092830@qq.com> Date: Mon, 4 Aug 2025 09:25:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=88=97=E8=A1=A8=E5=86=85=E5=AE=B9=E5=A4=AA?= =?UTF-8?q?=E9=95=BF=EF=BC=8C=E5=BC=BA=E5=88=B6=E4=BD=BF=E7=94=A8=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=A4=A7=E5=B0=8F=E5=AF=BC=E8=87=B4=E8=B6=85=E5=87=BA?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E5=90=8E=EF=BC=8C=E5=BC=B9=E7=AA=97=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=B8=B2=E6=9F=93=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=9C=80=E5=A4=A7=E4=B8=8D?= =?UTF-8?q?=E8=B6=85=E8=BF=87=E5=B1=8F=E5=B9=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMTool/Combobox.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/COMTool/Combobox.py b/COMTool/Combobox.py index 63a9dd8..94e3929 100644 --- a/COMTool/Combobox.py +++ b/COMTool/Combobox.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QComboBox,QListView +from PyQt5.QtWidgets import QComboBox,QListView,QApplication from PyQt5.QtCore import pyqtSignal @@ -21,6 +21,14 @@ def showPopup(self): pass def _showPopup(self): + max_w = 0 + for i in range(self.count()): + w = self.view().sizeHintForColumn(i) + if w > max_w: + max_w = w + + screen_width = QApplication.desktop().availableGeometry().width() + self.view().setMinimumWidth(min(max_w + 50, screen_width)) super(ComboBox, self).showPopup() def showItems(self):