forked from IgorYbema/tscSettings
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNumericKeyboardScreen.qml
More file actions
72 lines (60 loc) · 2.64 KB
/
NumericKeyboardScreen.qml
File metadata and controls
72 lines (60 loc) · 2.64 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
import QtQuick 2.1
import qb.base 1.0
import qb.components 1.0
import "NumericKeyboard.js" as NumericKeyboardJs
Screen {
id: numericKeyboardScreen
property alias keyboardState: numericKeyboard.state
property string alphaState: "alpha_normal"
property string alphaCapsState: "alpha_caps"
property string alphaCapsFixedState: "alpha_caps_fixed"
property string nummericState: "num_shift_down"
property string nummericShiftUpState: "num_shift_up"
property bool dimWasReachable
function open(title, defaultNumber, leftText, rightText, cbSavedFunction, cbValidateFunction ) {
numericKeyboard.state = alphaState;
setTitle(title);
NumericKeyboardJs.numberSavedCallback = cbSavedFunction;
NumericKeyboardJs.numberChangedCallback = cbValidateFunction;
numericKeyboard.inputText = defaultNumber;
show();
numericKeyboard.inputFocus = true;
}
function showKeyboardErrorPopup(dialogContentText) {
if (dialogContentText) {
qdialog.showDialog(qdialog.SizeLarge,
dialogContentText.title ? dialogContentText.title : qsTr("Keyboard error"),
dialogContentText.content);
}
}
hasCancelButton: true
hasSaveButton: false
onShown: {
dimWasReachable = screenStateController.screenColorDimmedIsReachable;
screenStateController.screenColorDimmedIsReachable = false;
addCustomTopRightButton(qsTr("Save"));
}
onHidden: {
screenStateController.screenColorDimmedIsReachable = dimWasReachable;
}
onCustomButtonClicked: {
var dialogText = null;
if (NumericKeyboardJs.numberChangedCallback) {
dialogText = NumericKeyboardJs.numberChangedCallback(numericKeyboard.inputText, true);
}
if (dialogText == null) {
if (NumericKeyboardJs.numberSavedCallback) {
NumericKeyboardJs.numberSavedCallback(numericKeyboard.inputText);
}
hide();
} else {
showKeyboardErrorPopup(dialogText);
}
}
EditTextLabel {
id: numericKeyboard
anchors.horizontalCenter: parent.horizontalCenter
inputHints: Qt.ImhDigitsOnly
y: 10
}
}