Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Icon Credit:
- ----------Power.png -------------------
- Author: http://www.freepik.com
- License: Creative Commons BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
- Source (from): https://www.flaticon.com/free-icon/power_840513
- ----------Power-off.png----------------
- Author: http://www.freepik.com
- License: Creative Commons BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
- Source (from): https://www.flaticon.com/free-icon/power_840513
- ---------------------------------------
- */
- import QtQuick 2.6
- import QtQuick.Window 2.2
- import QtQuick.Controls 1.4
- import QtQuick.Controls.Styles 1.2
- Window {
- id: mainWindow
- visible: true
- width: 1024
- height: 600
- color: "black"
- Column {
- id: mainColumn
- spacing: 20
- anchors.centerIn: parent
- TextField {
- width: 265
- height: 50
- x: x+125
- id: inputBox
- font.pixelSize: 26;font.bold: true
- text: ""
- font.weight: Font.Bold
- //transformOrigin: Item.Center
- focus: true
- }
- Row {
- id: mainRow
- spacing: 25
- Column {
- id: column1
- Grid {
- id: grid
- columns: 3
- columnSpacing: 30
- rowSpacing: 32
- Button {
- id: numPadGod
- width: 185
- height: 85
- style: numPadStyle
- text: "7";onClicked: {
- checkInputBox("7")
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- text: "8";onClicked: {
- checkInputBox("8")
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- text: "9"; transformOrigin: Item.Center; clip: false; opacity: 1;onClicked: {
- checkInputBox("9")
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- text: "4";onClicked: {
- checkInputBox("4")
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- text: "5";onClicked: {
- checkInputBox("5")
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- text: "6";onClicked: {
- checkInputBox("6")
- }
- }
- Button {
- text: "1"
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- onClicked: {
- checkInputBox("1")
- }
- }
- Button {
- text: "2"
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- onClicked: {
- checkInputBox("2")
- }
- }
- Button {
- text: "3"
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- onClicked: {
- checkInputBox("3")
- }
- }
- Button {
- text: "0"
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- onClicked: {
- checkInputBox("0")
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- style: numPadStyle
- iconSource: "/images/backspace-arrow.png";onClicked: {
- onDelete()
- }
- }
- Button {
- width: numPadGod.width; height: numPadGod.height
- text: "Enter";
- style: numPadStyle
- onClicked: {
- inputCatch();
- NiesDriver.sendMessage(inputBox.text);
- }
- }
- }
- }
- Column {
- spacing: 60
- y: y-70
- Text {
- id: dataText
- anchors.horizontalCenter: parent.horizontalCenter
- font.pixelSize: 40
- color: "white"
- text: "Enter Amount"
- }
- Button {
- id: startButton
- width: 376; height: 160;
- text: "Start"
- style: startStyle
- MouseArea {
- anchors.fill:parent
- onPressed: {
- parent.opacity = .7
- }
- onReleased: {
- parent.opacity = 1
- }
- }
- }
- Button {
- id: stopButton
- width: startButton.width; height: startButton.height
- text: "Stop"
- style: stopStyle
- MouseArea {
- anchors.fill:parent
- onPressed: {
- parent.opacity = .7
- }
- onReleased: {
- parent.opacity = 1
- }
- }
- }
- }
- }
- }
- function checkInputBox(mystring) {
- if (!inputBox.text.localeCompare("Scan or Select Amount"))
- inputBox.text = mystring;
- else
- inputBox.text = inputBox.text + mystring;
- }
- function onDelete() {
- // Something to be careful about if the scanner ends up having more tghan just digets could be probelmatic
- if (inputCatch())
- inputBox.text = inputBox.text.substring(0, inputBox.text.length - 1);
- else {
- inputBox.text = "";
- }
- }
- function inputCatch() {
- var reg = /^\d+$/;
- if (!reg.test(inputBox.text)) {
- inputBox.text = "Error Enter Again";
- return false
- }
- return true;
- }
- Connections {
- target: NiesDriver
- onCardUpdate: {
- dataText.text = count
- }
- }
- Component {
- id: startStyle
- ButtonStyle {
- background: Rectangle {
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "green"
- }
- GradientStop {
- position: 1.4
- color: "white"
- }
- }
- border.color: "grey"
- border.width: height * 0.04
- radius: height / 5
- }
- label: Label {
- text: "Start"
- color: "black"
- font.pixelSize: startButton.height * 0.5
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
- Component {
- id: stopStyle
- ButtonStyle {
- background: Rectangle {
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "red"
- }
- GradientStop {
- position: 1.8
- color: "white"
- }
- }
- border.color: "grey"
- border.width: height * 0.04
- radius: height / 5
- }
- label: Label {
- text: "Stop"
- color: "black"
- font.pixelSize: startButton.height * 0.5
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
- Component {
- id: numPadStyle
- ButtonStyle {
- background: Rectangle {
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "white"
- }
- GradientStop {
- position: 1.7
- color: "grey"
- }
- }
- border.color: "grey"
- border.width: height * 0.04
- radius: height / 5
- }
- label: Label {
- text: control.text
- color: "black"
- font.pixelSize: startButton.height * 0.4
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement