Skip to content

Commit

Permalink
增加端口错误的提示
Browse files Browse the repository at this point in the history
  • Loading branch information
rangaofei committed Feb 18, 2021
1 parent 5fbe2b5 commit c403488
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions qml/components/ServerControlView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,21 @@ Column {
width: parent.width
background: Widgets.BgStrokeR5{
}

//标题
label: Label{
x: groupBox.leftPadding
width: groupBox.availableWidth
text: title
color: "black"
font.bold: true
topPadding: 10
font.pixelSize:15
font.pixelSize:14
elide: Text.ElideRight
}

ColumnLayout{
width:parent.width
//IP地址
RowLayout{
Layout.fillWidth: true
Layout.preferredHeight: 30
Expand All @@ -83,9 +85,11 @@ Column {
model: ListModel{ id:addrListModel }
}
}
//空白占位
Item {
height: 15
height: 10
}
//端口
RowLayout{
Layout.fillWidth: true
Layout.preferredHeight: 30
Expand Down Expand Up @@ -113,7 +117,7 @@ Column {


Item {
height: 15
height: 10
}

Button {
Expand Down Expand Up @@ -142,8 +146,10 @@ Column {
}

onToggled: {
console.log("onToggled",checked)
if(!isAccectablePort(portBox.getEditText())){
toggleConnect.checked=false
showMsg(viewType,portTip)
return
}
startConnect(checked,addrBox.editText,portBox.editText)
Expand Down Expand Up @@ -254,8 +260,14 @@ Column {
}
}
}

Component.onCompleted: {
initPortView()
}

//检测端口是否在可用范围内
function isAccectablePort(port){
if(port>1024&&port<65535){
if(port > 1024 && port < 65535){
return true
}
return false
Expand Down Expand Up @@ -294,12 +306,25 @@ Column {
return historyConnect.get(connectList.currentIndex).addr
}

//初始化端口view
function initPortView(){
var ports=SettingTool.getPorts(viewType)
for(var i=0;i<ports.length;i++){
portListModel.append({port:ports[i]})
}
portBox.currentIndex=0
}

function setErrMsg(type,msg,isErr){
if(type===1){
toggleConnect.checked=!isErr
}else if(type===2){
toggleConnect.checked=false
}
showMsg(type,msg)
}

function showMsg(type,msg){
var title = "TCPServer"
if(viewType==1){
title = "TCPServer"
Expand All @@ -312,12 +337,4 @@ Column {
}
showNotification(title,msg)
}

Component.onCompleted: {
var ports=SettingTool.getPorts(viewType)
for(var i=0;i<ports.length;i++){
portListModel.append({port:ports[i]})
}
portBox.currentIndex=0
}
}

0 comments on commit c403488

Please sign in to comment.