-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLibkiBalance.qml
More file actions
78 lines (61 loc) · 1.9 KB
/
Copy pathLibkiBalance.qml
File metadata and controls
78 lines (61 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import QtQuick 2.0
import QtQuick.Layouts 1.12
import "functions.js" as Functions
GridLayout {
id: libkiBalance
rows: 1
columns: 2
anchors.top: parent.top + (parent.top / 4)
property string username
property string password
property string apiKey
property string serverAddress
property string balance
property double currentLibkiBalance: 0
signal load(string u, string p, string a, string s)
onLoad: function (u, p, a, s) {
username = u
password = p
apiKey = a
serverAddress = s
refreshLibkiBalanceTimer.running = true
}
signal unload
onUnload: function () {
username = ""
password = ""
balance = ""
libkiBalanceAmount.text = ""
refreshLibkiBalanceTimer.running = false
}
Timer {
id: refreshLibkiBalanceTimer
interval: 1000
running: false
repeat: true
onTriggered: refreshLibkiBalance()
}
function refreshLibkiBalance() {
const url = Functions.build_user_funds_available_url(serverAddress,
apiKey, username,
password)
Functions.request(url, function (o) {
var data = eval('new Object(' + o.responseText + ')')
let first_check = balance === "";
balance = parseFloat(data.funds)
let evaluate_print_buttons = balance != currentLibkiBalance
currentLibkiBalance = balance
libkiBalanceAmount.text = qsTr("$") + currentLibkiBalance.toFixed(2)
if (first_check || evaluate_print_buttons) {
mainWindow.balanceChanged()
}
}, 'GET')
}
Text {
id: libkiBalanceLabel
text: qsTr("Balance in your Libki account:")
}
Text {
id: libkiBalanceAmount
}
}