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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.ListItems 1.3 as ListItem
import Ubuntu.Components.Popups 1.0
import "../Components"
Dialog {
id: dialogue
title: i18n.tr("Create emulator")
text: i18n.tr("Please select a name for the emulator")
modal: true
TextField {
id: inputName
placeholderText: i18n.tr("Emulator name")
property string lastError
property bool hasError
onTextChanged: validate()
Component.onCompleted: validate()
function validate() {
var result = devicesModel.validateEmulatorName(text);
hasError = !result.valid;
lastError = result.error;
}
}
Label {
horizontalAlignment: Text.AlignHCenter
text: inputName.lastError
color: "red"
visible: inputName.hasError
}
ListItem.ItemSelector {
id: arch
model: [i18n.tr("i386"),
i18n.tr("armhf")]
}
ListItem.ItemSelector {
id: channel
model: ListModel{
id: channelModel
ListElement {
displayName: "stable"
value: "ubuntu-touch/stable/ubuntu"
}
ListElement {
displayName: "rc-proposed"
value: "ubuntu-touch/rc-proposed/ubuntu"
}
ListElement {
displayName: "custom channel"
value: "custom channel"
}
}
delegate: OptionSelectorDelegate{
text: displayName
}
property string selectedChannel: {
return channelModel.get(channel.selectedIndex).value
}
}
TextField {
id: inputChannelName
placeholderText: i18n.tr("Emulator channel")
visible: channel.selectedChannel === "custom channel"
}
ListItem.ItemSelector {
id: custom_pwd
model: ["Use default password (0000)",
"Set custom password"]
}
TextField {
id: inputCustomPassword
echoMode: TextInput.Password
placeholderText: i18n.tr("Password")
visible: custom_pwd.model[custom_pwd.selectedIndex] === "Set custom password"
}
Label {
id: inputChannelNameError
horizontalAlignment: Text.AlignHCenter
text: "Channel name can not be empty"
color: "red"
visible: inputChannelName.visible && inputChannelName.text.length == 0
}
Button {
text: "Cancel"
color: UbuntuColors.warmGrey
onClicked: PopupUtils.close(dialogue)
}
Button {
text: "Create"
color: UbuntuColors.orange
enabled: !inputName.hasError && !inputChannelNameError.visible
onClicked: {
if(inputName.hasError || inputChannelNameError.visible)
return;
devicesModel.createEmulatorImage(inputName.text,
arch.model[arch.selectedIndex],
(inputChannelName.visible ? inputChannelName.text : channel.selectedChannel),
(inputCustomPassword.visible ? inputCustomPassword.text : "0000")
);
PopupUtils.close(dialogue);
}
}
}
|