Guest User

Untitled

a guest
Dec 24th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Page {
  2.     id: page
  3.  
  4.     SilicaFlickable {
  5.         id: settings
  6.         width: page.width
  7.  
  8.         //contentHeight: column.height
  9.  
  10.         VerticalScrollDecorator { flickable: settings }
  11.  
  12.         function changeConnectionType(index) {
  13.             if(index === 0) {
  14.                 x509cert.visible = true;
  15.             }
  16.         }
  17.  
  18.         function initPage() {
  19.             changeConnectionType(connectionType.currentIndex);
  20.         }
  21.  
  22.         Column {
  23.             width: page.width
  24.             spacing: Theme.paddingSmall
  25.             PageHeader {
  26.                 title: "Required Settings"
  27.             }
  28.  
  29.             Button {
  30.                 anchors.right: parent.right
  31.                 text: "Save"
  32.             }
  33.  
  34.             Label {
  35.                 font.pixelSize: Theme.fontSizeSmall
  36.                 text: "Connection Name"
  37.             }
  38.             TextField {
  39.                 id: conname
  40.                 width: page.width
  41.                 placeholderText: "Enter connection name here"
  42.             }
  43.  
  44.             Label {
  45.                 font.pixelSize: Theme.fontSizeSmall
  46.                 text: "Gateway"
  47.             }
  48.             TextField {
  49.                 id: gateway
  50.                 width: page.width
  51.                 placeholderText: "Enter gateway here"
  52.                 // regex for checking valid hostname or ip address
  53.                 validator: RegExpValidator { regExp: /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$|^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/ }
  54.             }
  55.  
  56.             Label {
  57.                 font.pixelSize: Theme.fontSizeSmall
  58.                 text: "Connection type"
  59.             }
  60.             ComboBox {
  61.                 id: connectionType
  62.                 width: page.width
  63.  
  64.                 menu: ContextMenu {
  65.                     MenuItem { text: "X.509 Certificates" }
  66.                     //MenuItem { text: "X.509 With Password" } TODO
  67.                 }
  68.  
  69.                 onCurrentIndexChanged: {
  70.                     changeConnectionType(currentIndex);
  71.                 }
  72.             }
  73.  
  74.             Column {
  75.                 id: x509cert
  76.                 width: page.width
  77.                 visible: false
  78.                 spacing: Theme.paddingSmall
  79.  
  80.                 Label {
  81.                     font.pixelSize: Theme.fontSizeSmall
  82.                     text: "CA file"
  83.                 }
  84.                 Row {
  85.                     width: page.width
  86.                     TextField {
  87.                         width: page.width - 64;
  88.                         id: caFile
  89.                         placeholderText: "CA file"
  90.                     }
  91.                     Button {
  92.                         width: 64
  93.                         text: "..."
  94.                         onClicked: {
  95.                             var dialog = pageStack.push("FileChooser.qml", {"file": caFile.text})
  96.                             dialog.accepted.connect(function() {
  97.                                 caFile.text = dialog.file;
  98.                             })
  99.                         }
  100.                     }
  101.                 }
  102.                 Label {
  103.                     font.pixelSize: Theme.fontSizeSmall
  104.                     text: "Certificate"
  105.                 }
  106.                 Row {
  107.                     TextField {
  108.                         width: page.width - 64;
  109.                         id: certFile
  110.                         placeholderText: "Certificate"
  111.                     }
  112.                     Button {
  113.                         width: 64
  114.                         text: "..."
  115.                         onClicked: {
  116.                             var dialog = pageStack.push("FileChooser.qml", {"file": certFile.text})
  117.                             dialog.accepted.connect(function() {
  118.                                 certFile.text = dialog.file;
  119.                             })
  120.                         }
  121.                     }
  122.                 }
  123.                 Label {
  124.                     font.pixelSize: Theme.fontSizeSmall
  125.                     text: "Key"
  126.                 }
  127.                 Row {
  128.                     TextField {
  129.                         width: page.width - 64;
  130.                         id: keyFile
  131.                         placeholderText: "Key"
  132.                     }
  133.                     Button {
  134.                         width: 64
  135.                         text: "..."
  136.                         onClicked: {
  137.                             var dialog = pageStack.push("FileChooser.qml", {"file": keyFile.text})
  138.                             dialog.accepted.connect(function() {
  139.                                 keyFile.text = dialog.file;
  140.                             })
  141.                         }
  142.                     }
  143.                 }
  144.  
  145.                 Label {
  146.                     font.pixelSize: Theme.fontSizeSmall
  147.                     text: "Advanced Settings"
  148.                 }
  149.                 TextSwitch {
  150.                     id: showAdvanced
  151.                     width: page.width
  152.                     text: "Show advanced settings"
  153.                 }
  154.  
  155.             }
  156.         }
  157.  
  158.         Component.onCompleted: initPage();
  159.     }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment