forked from IgorYbema/tscSettings
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAlphaNumericKeyboardScreen.qml
More file actions
71 lines (59 loc) · 2.66 KB
/
AlphaNumericKeyboardScreen.qml
File metadata and controls
71 lines (59 loc) · 2.66 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
import QtQuick 2.1
import qb.base 1.0
import qb.components 1.0
import "AlphaNumericKeyboard.js" as AlphaNumericKeyboardJs
Screen {
id: alphaNumericKeyboardScreen
property alias keyboardState: alphaNumericKeyboard.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, defaultText, cbSavedFunction, cbValidateFunction, maximumLength ) {
alphaNumericKeyboard.state = alphaState;
setTitle(title);
AlphaNumericKeyboardJs.textSavedCallback = cbSavedFunction;
AlphaNumericKeyboardJs.textChangedCallback = cbValidateFunction;
alphaNumericKeyboard.inputText = defaultText;
show();
alphaNumericKeyboard.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 (AlphaNumericKeyboardJs.textChangedCallback) {
dialogText = AlphaNumericKeyboardJs.textChangedCallback(alphaNumericKeyboard.inputText, true);
}
if (dialogText == null) {
if (AlphaNumericKeyboardJs.textSavedCallback) {
AlphaNumericKeyboardJs.textSavedCallback(alphaNumericKeyboard.inputText);
}
hide();
} else {
showKeyboardErrorPopup(dialogText);
}
}
EditTextLabel {
id: alphaNumericKeyboard
anchors.horizontalCenter: parent.horizontalCenter
y: 10
}
}