Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions COMTool/Combobox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QComboBox,QListView
from PyQt5.QtWidgets import QComboBox,QListView,QApplication
from PyQt5.QtCore import pyqtSignal


Expand Down Expand Up @@ -26,7 +26,9 @@ def _showPopup(self):
w = self.view().sizeHintForColumn(i)
if w > max_w:
max_w = w
self.view().setMinimumWidth(max_w + 50)

screen_width = QApplication.desktop().availableGeometry().width()
self.view().setMinimumWidth(min(max_w + 50, screen_width))
super(ComboBox, self).showPopup()

def showItems(self):
Expand Down
50 changes: 25 additions & 25 deletions COMTool/conn/conn_tcp_udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Loading