Advertisement
Guest User

Untitled

a guest
May 4th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 5.14 KB | None | 0 0
  1. import QtQuick 2.9
  2. import QtQuick.Controls 2.2
  3. import QtQuick.VirtualKeyboard 2.2
  4. import QtQuick.VirtualKeyboard.Styles 2.2
  5. import QtQuick.Controls.Material 2.0
  6. import QtQuick.Layouts 1.3
  7. import QtQuick.Shapes 1.0
  8. import QtQuick.Dialogs.qml 1.0
  9. import QtGraphicalEffects 1.0
  10.  
  11. ApplicationWindow {
  12.     id: window
  13.     visible: true
  14.     width: 800
  15.     height: 600
  16.     title: qsTr("Batching Plant")
  17.  
  18.     Material.theme: Material.Dark
  19.     Material.primary: Material.Blue
  20.     Material.accent: Material.color(Material.Cyan, Material.Shade500)
  21.     Material.foreground: Material.LightBlue
  22.  
  23.     header: ToolBar {
  24.         contentHeight: toolButton.implicitHeight
  25.  
  26.         ToolButton {
  27.             id: toolButton
  28.  
  29.             contentItem: Image {
  30.                 fillMode: Image.Pad
  31.                 horizontalAlignment: Image.AlignHCenter
  32.                 verticalAlignment: Image.AlignVCenter
  33.                 source: stackView.depth > 1 ? "images/drawer/back.png" : "images/drawer/drawer.png"
  34.             }
  35.  
  36.             onClicked: {
  37.                 if (stackView.depth > 1) {
  38.                     stackView.pop()
  39.                 } else {
  40.                     drawer.open()
  41.                 }
  42.             }
  43.         }
  44.  
  45.         Label {
  46.             text: stackView.currentItem.title
  47.             anchors.centerIn: parent
  48.         }
  49.     }
  50.  
  51.     Drawer {
  52.         id: drawer
  53.         width: window.width<400 ? window.width * 0.6 : 240
  54.         height: window.height
  55.         dragMargin: 20
  56.         dim: false
  57.         modal: false
  58.  
  59.         background: Rectangle {
  60.             Rectangle {
  61.                 id: background_
  62.                 width: parent.width
  63.                 height: parent.height
  64.                 color: window.color
  65.                 layer.enabled: true
  66.                 layer.effect: DropShadow {
  67.                     horizontalOffset: 3
  68.                     radius: 8.0
  69.                     samples: 17
  70.                     color: "#80000000"
  71.                 }
  72.             }
  73.             Rectangle {
  74.                 x: parent.width
  75.                 width: window.width
  76.                 height: parent.height
  77.                 color: "#000"
  78.                 opacity: drawer.position/1.3
  79.             }
  80.         }
  81.  
  82.         Label {
  83.             id: options
  84.             text: "Options"
  85.             height: header.height
  86.             font.pointSize: 14
  87.             font.bold: true
  88.             anchors.horizontalCenter: parent.horizontalCenter
  89.             horizontalAlignment: Text.AlignHCenter
  90.             verticalAlignment: Text.AlignVCenter
  91.         }
  92.         Shape {
  93.             anchors.top: options.bottom
  94.             ShapePath {
  95.                 strokeColor: "DarkCyan"
  96.                 strokeWidth: 3
  97.                 fillColor: "DarkCyan"
  98.                 PathLine {
  99.                     x: drawer.width - 1
  100.                 }
  101.             }
  102.         }
  103.  
  104.         ListView {
  105.             id: listView
  106.             focus: true
  107.             currentIndex: 0
  108.             anchors.fill: parent
  109.             anchors.topMargin: options.height
  110.  
  111.             delegate: ItemDelegate {
  112.  
  113.                 width: parent.width
  114.                 text: model.title
  115.                 highlighted: ListView.isCurrentItem
  116.  
  117.                 onClicked: {
  118.                     listView.currentIndex = index
  119.                     stackView.clear()
  120.                     stackView.push(model.source)
  121.                     drawer.close()
  122.                 }
  123.             }
  124.  
  125.             model: ListModel {
  126.                 ListElement { title: "Monitoring"; source: "monitoring.ui.qml" }
  127.                 ListElement { title: "Processes"; source: "processes.ui.qml" }
  128.                 ListElement { title: "Configuration"; source: "new_process.ui.qml" }
  129.                 ListElement { title: "Diagnostics"; source: "monitoring.ui.qml" }
  130.                 ListElement { title: "History"; source: "monitoring.ui.qml" }
  131.                 ListElement { title: "About"; source: "monitoring.ui.qml" }
  132.             }
  133.         }
  134.     }
  135.  
  136.     StackView {
  137.         id: stackView
  138.         initialItem: "monitoring.ui.qml"
  139.         anchors.fill: parent
  140.         transform: Translate {
  141.             x: drawer.position*drawer.width
  142.         }
  143.     }
  144.  
  145.     Shortcut {
  146.         sequences: ["Esc", "Back"]
  147.         enabled: stackView.depth > 1
  148.         onActivated: {
  149.             stackView.pop()
  150.             listView.currentIndex = -1
  151.         }
  152.     }
  153.  
  154.     InputPanel {
  155.         id: inputPanel
  156.         z: 99
  157.         x: parent.width/2 - inputPanel.width/2
  158.         y: parent.height
  159.         width: parent.width<800 ? parent.width : 800
  160.  
  161.         states: State {
  162.             name: "visible"
  163.             when: inputPanel.active
  164.             PropertyChanges {
  165.                 target: inputPanel
  166.                 y: parent.height - inputPanel.height
  167.             }
  168.         }
  169.         transitions: Transition {
  170.             from: ""
  171.             to: "visible"
  172.             reversible: true
  173.             ParallelAnimation {
  174.                 NumberAnimation {
  175.                     properties: "y"
  176.                     duration : 250
  177.                     easing.type: Easing.InOutQuad
  178.                 }
  179.             }
  180.         }
  181.     }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement