123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- import QtQuick 2.6
- import QtQuick.Window 2.2
- import QtQuick.Controls 2.0
- //import QtQuick.Controls 1.5
- import QtQuick.Controls 1.4 as Ctrl14
- import QtQuick.Controls.Styles 1.4
- import com.gfa.ipc.appctrl 1.0
- import "globals.js" as Globals
- import QtQuick.FreeVirtualKeyboard 1.0
- Rectangle {
- id: idEdit
- width: Screen.width
- height: Screen.height
- property bool isDirty: false
- property bool ifUpDownInProgress: false
-
- function updateUI(sel)
- {
- if(sel >= 0)
- {
- switch(qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].method)
- {
- case QInterface.IM_Static:
- idStatic.visible = true;
- idDhcp.visible = false;
- idMethStatic.checked = true;
- idIfUpDownOutput.visible = true;
- break;
- case QInterface.IM_Dhcp:
- idStatic.visible = false;
- idDhcp.visible = true;
- idMethDhcp.checked = true;
- idIfUpDownOutput.visible = true;
- break;
- default:
- idStatic.visible = false;
- idDhcp.visible = false;
- idMethStatic.checked = false;
- idMethDhcp.checked = false;
- idIfUpDownOutput.visible = false;
- break;
- }
- if(sel > 0)
- {
- idAddrS.address = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].inet.stat.ipAddress.addr;
- idSubnetS.address = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].inet.stat.netMask.addr;
- idGateS.address = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].inet.stat.gateway.addr;
- idDnsS1.address = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].inet.stat.dnsServer[0].addr;
- idDnsS2.address = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].inet.stat.dnsServer[1].addr;
- idDnsS3.address = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[sel].inet.stat.dnsServer[2].addr;
- }
- }
- }
- Connections {
- target: qGfaAppCtrl.sysInfo.netInterfaceInfo
- onIfUpDown: {
- console.log("IfUpDown: " + msg);
- idIfUpDownText.append(msg.trim());
- }
- onIfUpDownCompleted: {
- switch(ctx)
- {
- case QNetworkInterfaces.UDC_Start:
- console.log("ifup: " + code);
- ifUpDownInProgress = false;
- break;
- case QNetworkInterfaces.UDC_Stop:
- console.log("ifdown: " + code);
- ifUpDownInProgress = false;
- break;
- case QNetworkInterfaces.UDC_Restart:
- console.log("ifupdown: " + code);
- ifUpDownInProgress = false;
- break;
- }
- }
- onError: {
- console.log("Error: " + msg);
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- TabBar {
- id: idTabBar
- width: parent.width
- currentIndex: 2
- Repeater {
- id: idRep
- model: Globals.tabBarModel
- NavButton {
- text: modelData[0]
- onClicked: { idPageLoader.source = modelData[1]; }
- width: idTabBar.width / idRep.count
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- Ctrl14.TableView {
- id: idItfList
- height: 420
- width: 180
- x: 10
- y: 50
- headerVisible: false
- style: TableViewStyle {
- itemDelegate: idTableViewItemStyle
- }
- model: qGfaAppCtrl.sysInfo.netInterfaceInfo.schemaModel
- selection.onSelectionChanged:
- {
- idIfUpDownText.text = "";
- updateUI(idItfList.currentRow);
- }
- Ctrl14.TableViewColumn {
- role: "name"
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- Ctrl14.ExclusiveGroup { id: idMethExGroup }
- Rectangle {
- id: idMethGroup
- x: 200
- y: 50
- width: 590
- height: 45
- radius: 5
- border.width: 1
- border.color: "black"
- visible: (idItfList.currentRow > 0)
-
- property int method: (idItfList.currentRow > 0) ? qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].method : 0
- Ctrl14.RadioButton {
- x: 10
- y: 10
- id: idMethStatic
- exclusiveGroup: idMethExGroup
- style: RadioButtonStyle {
- label: Text {
- text: qsTr("Static")
- font.pointSize: 8
- }
- }
- onClicked: {
- if(idItfList.currentRow > 0)
- {
- if(checked)
- {
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].method = QInterface.IM_Static;
- idStatic.visible = true;
- idDhcp.visible = false;
- isDirty = true;
- }
- }
- }
- }
- Ctrl14.RadioButton {
- x: 100
- y: 10
- id: idMethDhcp
- exclusiveGroup: idMethExGroup
- style: RadioButtonStyle {
- label: Text {
- text: qsTr("DHCP")
- font.pointSize: 8
- }
- }
- onClicked: {
- if(idItfList.currentRow > 0)
- {
- if(checked)
- {
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].method = QInterface.IM_Dhcp;
- idStatic.visible = false;
- idDhcp.visible = true;
- isDirty = true;
- }
- }
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- Rectangle {
- id: idStatic
- x: 200
- y: 105
- width: 590
- height: 115
- radius: 5
- border.width: 1
- border.color: "black"
- visible: false
- Text {
- x: 10
- y: 10
- font.pointSize: 8
- verticalAlignment: Text.AlignVCenter
- text: "Address:"
- }
- Ip4Address {
- id: idAddrS
- x: 90
- y: 10
- address: 0
- onAddressModified: {
- isDirty = true;
- console.log("Address modified: " + address);
- if(idItfList.currentRow > 0)
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].inet.stat.ipAddress.addr = idAddrS.address;
- }
- }
- Text {
- x: 10
- y: 45
- font.pointSize: 8
- verticalAlignment: Text.AlignVCenter
- text: "Netmask:"
- }
- Ip4Address {
- id: idSubnetS
- x: 90
- y: 45
- address: 0
- onAddressModified: {
- isDirty = true;
- console.log("Netmask modified: " + address);
- if(idItfList.currentRow > 0)
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].inet.stat.netMask.addr = idSubnetS.address;
- }
- }
- Text {
- x: 10
- y: 80
- font.pointSize: 8
- verticalAlignment: Text.AlignVCenter
- text: "Gateway:"
- }
- Ip4Address {
- id: idGateS
- x: 90
- y: 80
- address: 0
- onAddressModified: {
- isDirty = true;
- console.log("Gateway modified: " + address);
- if(idItfList.currentRow > 0)
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].inet.stat.gateway.addr = idGateS.address;
- }
- }
- Text {
- x: 330
- y: 10
- font.pointSize: 8
- verticalAlignment: Text.AlignVCenter
- text: "DNS 1:"
- }
- Ip4Address {
- id: idDnsS1
- x: 390
- y: 10
- address: 0
- onAddressModified: {
- isDirty = true;
- console.log("DNS 1 modified: " + address);
- if(idItfList.currentRow > 0)
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].inet.stat.dnsServer[0].addr = idDnsS1.address;
- }
- }
- Text {
- x: 330
- y: 45
- font.pointSize: 8
- verticalAlignment: Text.AlignVCenter
- text: "DNS 2:"
- }
- Ip4Address {
- id: idDnsS2
- x: 390
- y: 45
- address: 0
- onAddressModified: {
- isDirty = true;
- console.log("DNS 2 modified: " + address);
- if(idItfList.currentRow > 0)
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].inet.stat.dnsServer[1].addr = idDnsS2.address;
- }
- }
- Text {
- x: 330
- y: 80
- font.pointSize: 8
- verticalAlignment: Text.AlignVCenter
- text: "DNS 3:"
- }
- Ip4Address {
- id: idDnsS3
- x: 390
- y: 80
- address: 0
- onAddressModified: {
- isDirty = true;
- console.log("DNS 3 modified: " + address);
- if(idItfList.currentRow > 0)
- qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow].inet.stat.dnsServer[2].addr = idDnsS3.address;
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- Rectangle {
- id: idDhcp
- x: 200
- y: 105
- width: 590
- height: 115
- radius: 5
- border.width: 1
- border.color: "black"
- visible: false
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- Rectangle {
- id: idIfUpDownOutput
- x: 200
- y: 230
- width: 590
- height: 180
- visible: false
- TextArea {
- id: idIfUpDownText
- anchors.fill: parent
- readOnly: true
- selectByMouse: false
- selectByKeyboard: false
- font.pointSize: 8
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- Rectangle {
- id: idButtons
- x: 200
- y: 420
- width: 590
- height: 50
- radius: 5
- border.width: 1
- border.color: "black"
- Ctrl14.Button {
- x: 10
- y: 10
- width: 100
- text: "Save"
- enabled: isDirty && !ifUpDownInProgress
- onClicked: {
- var itf = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow];
- isDirty = false;
- console.log("Save");
- qGfaAppCtrl.sysInfo.netInterfaceInfo.save();
- }
- style: idButtonStyle
- }
- Ctrl14.Button {
- x: 120
- y: 10
- width: 100
- text: "Cancel"
- enabled: isDirty && !ifUpDownInProgress
- onClicked: {
- isDirty = false;
- console.log("Cancel");
- qGfaAppCtrl.sysInfo.netInterfaceInfo.reload();
- updateUI(idItfList.currentRow);
- }
- style: idButtonStyle
- }
- Ctrl14.Button {
- x: 260
- y: 10
- width: 100
- text: "Start"
- enabled: !isDirty && !ifUpDownInProgress && (idItfList.currentRow > 0)
- onClicked: {
- var itf = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow];
- console.log("Start");
- ifUpDownInProgress = true;
- idIfUpDownText.text = "";
- qGfaAppCtrl.sysInfo.netInterfaceInfo.startInterface(itf);
- }
- style: idButtonStyle
- }
- Ctrl14.Button {
- x: 370
- y: 10
- width: 100
- text: "Stop"
- enabled: !isDirty && !ifUpDownInProgress && (idItfList.currentRow > 0)
- onClicked: {
- var itf = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow];
- console.log("Stop");
- ifUpDownInProgress = true;
- idIfUpDownText.text = "";
- qGfaAppCtrl.sysInfo.netInterfaceInfo.stopInterface(itf);
- }
- style: idButtonStyle
- }
- Ctrl14.Button {
- x: 480
- y: 10
- width: 100
- text: "Restart"
- enabled: !isDirty && !ifUpDownInProgress && (idItfList.currentRow > 0)
- onClicked: {
- var itf = qGfaAppCtrl.sysInfo.netInterfaceInfo.interfaces[idItfList.currentRow];
- console.log("Restart");
- ifUpDownInProgress = true;
- idIfUpDownText.text = "";
- qGfaAppCtrl.sysInfo.netInterfaceInfo.restartInterface(itf);
- }
- style: idButtonStyle
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- InputPanel {
- id: inputPanel
- z: 99
- y: idEdit.height
- anchors.left: parent.left
- anchors.right: parent.right
- states: State {
- name: "visible"
- when: Qt.inputMethod.visible
- PropertyChanges {
- target: inputPanel
- y: idEdit.height - inputPanel.height
- }
- }
- transitions: Transition {
- from: ""
- to: "visible"
- reversible: true
- ParallelAnimation {
- NumberAnimation {
- properties: "y"
- duration: 150
- easing.type: Easing.InOutQuad
- }
- }
- }
- }
- }
|