Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 10.07 KB | None | 0 0
  1. /*
  2.   Icon Credit:
  3.      ----------Power.png -------------------
  4.          Author: http://www.freepik.com
  5.          License: Creative Commons BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
  6.          Source (from): https://www.flaticon.com/free-icon/power_840513
  7.      ----------Power-off.png----------------
  8.          Author: http://www.freepik.com
  9.          License: Creative Commons BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
  10.          Source (from): https://www.flaticon.com/free-icon/power_840513
  11.      ---------------------------------------
  12.   */
  13.  
  14.  
  15. import QtQuick 2.6
  16. import QtQuick.Window 2.2
  17. import QtQuick.Controls 1.4
  18. import QtQuick.Controls.Styles 1.2
  19.  
  20. Window {
  21.     id: mainWindow
  22.     visible: true
  23.     width: 1024
  24.     height: 600
  25.     color: "black"
  26.     Column {
  27.         id: mainColumn
  28.         spacing: 20
  29.         anchors.centerIn: parent
  30.         TextField {
  31.             width: 265
  32.             height: 50
  33.             x: x+125
  34.             id: inputBox
  35.             font.pixelSize: 26;font.bold: true
  36.             text: ""
  37.             font.weight: Font.Bold
  38.             //transformOrigin: Item.Center
  39.             focus: true
  40.         }
  41.         Row {
  42.             id: mainRow
  43.             spacing: 25
  44.             Column {
  45.                 id: column1
  46.                 Grid {
  47.                     id: grid
  48.                     columns: 3
  49.                     columnSpacing: 30
  50.                     rowSpacing: 32
  51.                     Button {
  52.                         id: numPadGod
  53.                         width: 185
  54.                         height: 85
  55.                         style: numPadStyle
  56.                         text: "7";onClicked: {
  57.                             checkInputBox("7")
  58.                         }
  59.                     }
  60.                     Button {
  61.                         width: numPadGod.width; height: numPadGod.height
  62.                         style: numPadStyle
  63.                         text: "8";onClicked: {
  64.                             checkInputBox("8")
  65.                         }
  66.                     }
  67.                     Button {
  68.                         width: numPadGod.width; height: numPadGod.height
  69.                         style: numPadStyle
  70.                         text: "9"; transformOrigin: Item.Center; clip: false; opacity: 1;onClicked: {
  71.                             checkInputBox("9")
  72.                         }
  73.                     }
  74.                     Button {
  75.                         width: numPadGod.width; height: numPadGod.height
  76.                         style: numPadStyle
  77.                         text: "4";onClicked: {
  78.                             checkInputBox("4")
  79.                         }
  80.                     }
  81.                     Button {
  82.                         width: numPadGod.width; height: numPadGod.height
  83.                         style: numPadStyle
  84.                         text: "5";onClicked: {
  85.                             checkInputBox("5")
  86.                         }
  87.                     }
  88.                     Button {
  89.                         width: numPadGod.width; height: numPadGod.height
  90.                         style: numPadStyle
  91.                         text: "6";onClicked: {
  92.                             checkInputBox("6")
  93.                         }
  94.                     }
  95.                     Button {
  96.                         text: "1"
  97.                         width: numPadGod.width; height: numPadGod.height
  98.                         style: numPadStyle
  99.                         onClicked: {
  100.                             checkInputBox("1")
  101.                         }
  102.                     }
  103.                     Button {
  104.                         text: "2"
  105.                         width: numPadGod.width; height: numPadGod.height
  106.                         style: numPadStyle
  107.                         onClicked: {
  108.                             checkInputBox("2")
  109.                         }
  110.                     }
  111.                     Button {
  112.                         text: "3"
  113.                         width: numPadGod.width; height: numPadGod.height
  114.                         style: numPadStyle
  115.                         onClicked: {
  116.                             checkInputBox("3")
  117.                         }
  118.                     }
  119.                     Button {
  120.                         text: "0"
  121.                         width: numPadGod.width; height: numPadGod.height
  122.                         style: numPadStyle
  123.                         onClicked: {
  124.                             checkInputBox("0")
  125.                         }
  126.                     }
  127.                     Button {
  128.                         width: numPadGod.width; height: numPadGod.height
  129.                         style: numPadStyle
  130.                         iconSource: "/images/backspace-arrow.png";onClicked: {
  131.                             onDelete()
  132.                         }
  133.                     }
  134.  
  135.                     Button {
  136.  
  137.                         width: numPadGod.width; height: numPadGod.height
  138.                         text: "Enter";
  139.                         style: numPadStyle
  140.                         onClicked: {
  141.                             inputCatch();
  142.                             NiesDriver.sendMessage(inputBox.text);
  143.                         }
  144.                     }
  145.  
  146.                 }
  147.  
  148.             }
  149.  
  150.  
  151.             Column {
  152.                 spacing: 60
  153.                 y: y-70
  154.                 Text {
  155.                     id: dataText
  156.                     anchors.horizontalCenter: parent.horizontalCenter
  157.                     font.pixelSize: 40
  158.                     color: "white"
  159.                     text: "Enter Amount"
  160.                 }
  161.                 Button {
  162.                     id: startButton
  163.                     width: 376; height: 160;
  164.                     text: "Start"
  165.                     style: startStyle
  166.                     MouseArea {
  167.                         anchors.fill:parent
  168.                         onPressed: {
  169.                             parent.opacity = .7
  170.                         }
  171.                         onReleased: {
  172.                             parent.opacity = 1
  173.                         }
  174.                     }
  175.  
  176.                 }
  177.                 Button {
  178.                     id: stopButton
  179.                     width: startButton.width; height: startButton.height
  180.                     text: "Stop"
  181.  
  182.                     style: stopStyle
  183.                     MouseArea {
  184.                         anchors.fill:parent
  185.                         onPressed: {
  186.                             parent.opacity = .7
  187.                         }
  188.                         onReleased: {
  189.                             parent.opacity = 1
  190.                         }
  191.                     }
  192.  
  193.  
  194.  
  195.                 }
  196.             }
  197.  
  198.         }
  199.  
  200.  
  201.     }
  202.  
  203.     function checkInputBox(mystring) {
  204.         if (!inputBox.text.localeCompare("Scan or Select Amount"))
  205.             inputBox.text = mystring;
  206.         else
  207.             inputBox.text = inputBox.text + mystring;
  208.     }
  209.  
  210.     function onDelete() {
  211.         // Something to be careful about if the scanner ends up having more tghan just digets could be probelmatic
  212.         if (inputCatch())
  213.             inputBox.text = inputBox.text.substring(0, inputBox.text.length - 1);
  214.         else {
  215.             inputBox.text = "";
  216.         }
  217.     }
  218.  
  219.     function inputCatch() {
  220.         var reg = /^\d+$/;
  221.         if (!reg.test(inputBox.text)) {
  222.             inputBox.text = "Error Enter Again";
  223.             return false
  224.         }
  225.         return true;
  226.     }
  227.     Connections {
  228.         target: NiesDriver
  229.         onCardUpdate: {
  230.             dataText.text = count
  231.         }
  232.     }
  233.  
  234.     Component {
  235.         id: startStyle
  236.         ButtonStyle {
  237.             background: Rectangle {
  238.                 gradient: Gradient {
  239.                     GradientStop {
  240.                         position: 0
  241.                         color: "green"
  242.                     }
  243.                     GradientStop {
  244.                         position: 1.4
  245.                         color: "white"
  246.                     }
  247.                 }
  248.  
  249.                 border.color: "grey"
  250.                 border.width: height * 0.04
  251.                 radius: height / 5
  252.             }
  253.             label: Label {
  254.                 text: "Start"
  255.                 color: "black"
  256.                 font.pixelSize: startButton.height * 0.5
  257.                 horizontalAlignment: Text.AlignHCenter
  258.                 verticalAlignment: Text.AlignVCenter
  259.             }
  260.         }
  261.  
  262.  
  263.     }
  264.     Component {
  265.         id: stopStyle
  266.         ButtonStyle {
  267.             background: Rectangle {
  268.                 gradient: Gradient {
  269.                     GradientStop {
  270.                         position: 0
  271.                         color: "red"
  272.                     }
  273.                     GradientStop {
  274.                         position: 1.8
  275.                         color: "white"
  276.                     }
  277.                 }
  278.  
  279.                 border.color: "grey"
  280.                 border.width: height * 0.04
  281.                 radius: height / 5
  282.             }
  283.             label: Label {
  284.                 text: "Stop"
  285.                 color: "black"
  286.                 font.pixelSize: startButton.height * 0.5
  287.                 horizontalAlignment: Text.AlignHCenter
  288.                 verticalAlignment: Text.AlignVCenter
  289.             }
  290.         }
  291.  
  292.  
  293.     }
  294.     Component {
  295.         id: numPadStyle
  296.         ButtonStyle {
  297.             background: Rectangle {
  298.                 gradient: Gradient {
  299.                     GradientStop {
  300.                         position: 0
  301.                         color: "white"
  302.                     }
  303.                     GradientStop {
  304.                         position: 1.7
  305.                         color: "grey"
  306.                     }
  307.                 }
  308.  
  309.                 border.color: "grey"
  310.                 border.width: height * 0.04
  311.                 radius: height / 5
  312.             }
  313.             label: Label {
  314.                 text: control.text
  315.                 color: "black"
  316.                 font.pixelSize: startButton.height * 0.4
  317.                 horizontalAlignment: Text.AlignHCenter
  318.                 verticalAlignment: Text.AlignVCenter
  319.  
  320.             }
  321.  
  322.         }
  323.  
  324.  
  325.     }
  326.  
  327. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement