brmbar v3: Add support for numpad touch entry, use in charge and withdrawal screens

This commit is contained in:
Petr Baudis 2012-09-26 01:18:38 +02:00
parent 586b2411cf
commit 27f9b35b52
5 changed files with 81 additions and 45 deletions

View file

@ -0,0 +1,39 @@
import Qt 4.7
Grid {
property string keys: ""
property int gridRows: 0
property int gridColumns: 0
property int buttonWidth: 70
property int buttonHeight: 70
property bool shift: false
signal letterBackspace()
signal letterEntered(string letter)
rows: gridRows
columns: gridColumns
spacing: 1
Repeater {
model: keys.length
BarButton {
width: buttonWidth; height: buttonHeight
property string key: keys.charAt(index)
property bool special: key == "^" || key == "<"
text: key == "^" ? "shift" : key == "<" ? "bksp" : shift ? key.toUpperCase() : key
fontSize: special ? 20 : 44
onButtonClick: {
if (key == "^")
shift = !shift
else if (key == "<")
letterBackspace()
else
letterEntered(key)
}
}
}
}

View file

@ -0,0 +1,9 @@
import Qt 4.7
BarKeyboard {
keys: "7894561230.<"
gridRows: 4
gridColumns: 3
buttonWidth: 80
buttonHeight: 70
}

View file

@ -12,13 +12,14 @@ Item {
Text {
id: item_name
x: 65
x: 422
y: 156
width: 537
height: 160
height: 80
color: "#ffffff"
text: parent.username ? parent.username : "Credit charge"
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 44
}
@ -26,7 +27,7 @@ Item {
Text {
id: text3
x: 611
y: 156
y: 256
height: 160
width: 348
color: "#ffff7c"
@ -39,8 +40,17 @@ Item {
BarTextHint {
x: 65
y: 430
hint_goal: parent.amount ? (parent.username ? "Charge now?" : "Charge user:") : "Charge credit:"
hint_action: !(parent.amount && parent.userdbid) ? "Scan barcode now" : ""
hint_goal: (parent.username ? "" : parent.amount ? "Charge user:" : "Charge credit:")
hint_action: (parent.username ? (parent.amount ? "" : "(or scan barcode now)") : "Scan barcode now")
}
BarNumPad {
id: credit_pad
x: 65
y: 195
visible: parent.username != ""
onLetterEntered: { amount = amount.toString() + letter; }
onLetterBackspace: { amount = amount.toString().replace(/.$/, ''); }
}
BarcodeInput {
@ -89,22 +99,6 @@ Item {
}
}
Text {
id: text1
x: 112
y: 333
width: 800
height: 80
color: "#ffffff"
text: "Put "+amount+" Kč in the money box now."
visible: amount ? true : false
anchors.horizontalCenterOffset: 0
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 36
anchors.horizontalCenter: parent.horizontalCenter
}
function chargeCredit() {
var balance = shop.chargeCredit(amount, userdbid)
status_text.setStatus("Charged! "+username+"'s credit is "+balance+".", "#ffff7c")

View file

@ -12,13 +12,14 @@ Item {
Text {
id: item_name
x: 65
x: 422
y: 156
width: 537
height: 160
height: 80
color: "#ffffff"
text: parent.username ? parent.username : "Credit withdrawal"
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 44
}
@ -26,7 +27,7 @@ Item {
Text {
id: text3
x: 611
y: 156
y: 256
height: 160
width: 348
color: "#ffff7c"
@ -39,8 +40,17 @@ Item {
BarTextHint {
x: 65
y: 430
hint_goal: parent.amount ? (parent.username ? "Withdraw amount?" : "Withdraw:") : "Withdraw:"
hint_action: !(parent.amount && parent.userdbid) ? "Scan barcode now" : ""
hint_goal: (parent.username ? "" : parent.amount ? "Withdraw:" : "Withdraw amount?")
hint_action: (parent.username ? (parent.amount ? "" : "(or scan barcode now)") : "Scan barcode now")
}
BarNumPad {
id: withdraw_pad
x: 65
y: 195
visible: parent.username != ""
onLetterEntered: { amount = amount.toString() + letter; }
onLetterBackspace: { amount = amount.toString().replace(/.$/, ''); }
}
BarcodeInput {
@ -89,22 +99,6 @@ Item {
}
}
Text {
id: text1
x: 112
y: 333
width: 800
height: 80
color: "#ffffff"
text: "Take "+amount+" Kč from the money box now."
visible: amount ? true : false
anchors.horizontalCenterOffset: 0
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 36
anchors.horizontalCenter: parent.horizontalCenter
}
function withdrawCredit() {
var balance = shop.withdrawCredit(amount, userdbid)
status_text.setStatus("Withdrawn! "+username+"'s credit is "+balance+".", "#ffff7c")