summaryrefslogtreecommitdiffstats
path: root/sample/app/main.qml
blob: b9f415b0708edf81cb76607794aef7b63e9050cb (plain)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
import QtQuick 2.7
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import AGL.Demo.Controls 1.0

ApplicationWindow {
    id: root
    visible: true
    width: 1080
    height: 1487

    property string onsId: qsTr("onscreenapp")
    property string onsTitle: qsTr("One Button title")
    property string onsType: "critical"
    property string onsContents: qsTr("An operating system is a program that manages a computer’s hardware.")
    property string onsButton1: qsTr("Yes")
    property string onsButton2: qsTr("")
    property string onsButton3: qsTr("")
    property string postmsg: qsTr("")
    property string btndata: qsTr("")

    Label {
        id: title
        width: parent.width
        height: 40
        text: "OnScreen Test App"
        font.pixelSize: 40
        font.bold: true
        color: "white"
    }

    ColumnLayout {
        spacing: 20
        anchors.top: title.bottom
        anchors.topMargin: 40
        anchors.horizontalCenter: title.horizontalCenter

        // show received reply information area
        Flickable {
             id: flickable
             width: 800
             height: 320
             Layout.alignment: Qt.AlignCenter
             flickableDirection: Flickable.VerticalFlick
             boundsBehavior: Flickable.StopAtBounds

             TextArea.flickable: TextArea {
                 id: output
                 text: "show received reply information area\n...\n...\n...\n...\n"
                 font.pixelSize: 24
                 wrapMode: TextArea.Wrap
                 color: '#00ADDC'
             }

             ScrollBar.vertical: ScrollBar { }
         }

        // select onscreen type area
        GroupBox {
            label: Label {
                text: qsTr("Please select send OnScreen Message")
                font.pixelSize: 32
                font.bold: true
                color: "white"
            }

            width: 800
            height: 100
            Layout.alignment: Qt.AlignLeft

            RowLayout {
                anchors.fill: parent
                RadioButton {
                    text: qsTr("One Button")
                    font.pixelSize: 20
                    checked: true
                    onClicked: {
                        selectOneButton();
                    }
                }
                RadioButton {
                    text: qsTr("Two Buttons")
                    font.pixelSize: 20
                    onClicked: {
                        selectTwoButtons();
                    }
                }
                RadioButton {
                    text: qsTr("Three Buttons")
                    font.pixelSize: 20
                    onClicked: {
                        selectThreeButtons();
                    }
                }
                RadioButton {
                    text: qsTr("No Button")
                    font.pixelSize: 20
                    onClicked: {
                        selectNoButton();
                    }
                }
            }
        }

        // edit post message area
        GroupBox {
            label: Label {
                text: qsTr("Post Infomations")
                font.pixelSize: 32
                font.bold: true
                color: "white"
            }
            width: 800
            height: 400
            Layout.alignment: Qt.AlignLeft
            Layout.maximumWidth: 800
            Layout.maximumHeight: 400

            ColumnLayout {
                spacing:  20
                RowLayout {
                    spacing: 20
                    Label {
                        id: ons_title
                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        text: qsTr("ons_title:")
                        font.pixelSize: 20
                        font.italic: true
                        color: '#00ADDC'
                    }

                    Label {
                        id: ons_title_data
                        text: onsTitle
                        font.pixelSize: 20
                        font.italic: true
                        anchors.left: ons_title.right
                        anchors.leftMargin: 20
                        color: '#00ADDC'
                        Layout.maximumWidth: 600
                        Layout.maximumHeight: 40
                        maximumLineCount: 1
                        wrapMode: Text.Wrap
                        elide: Text.ElideRight
                        horizontalAlignment: Label.AlignHCenter
                        verticalAlignment: Label.AlignVCenter
                    }
                }
                RowLayout {
                    spacing: 20
                    Label {
                        id: ons_type
                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        text: qsTr("type:")
                        font.pixelSize: 20
                        font.italic: true
                        color: '#00ADDC'
                    }

                    Label {
                        id: ons_type_data
                        text: onsType
                        font.pixelSize: 20
                        font.italic: true
                        anchors.left: ons_type.right
                        anchors.leftMargin: 20
                        color: '#00ADDC'
                    }
                }
                RowLayout {
                    spacing: 20
                    Label {
                        id: ons_contents
                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        text: qsTr("contents:")
                        font.pixelSize: 20
                        font.italic: true
                        color: '#00ADDC'
                    }
                    Label {
                        id: ons_contents_data
                        text: onsContents
                        font.pixelSize: 20
                        font.italic: true
                        anchors.left: ons_contents.right
                        anchors.leftMargin: 20
                        color: '#00ADDC'
                        Layout.maximumWidth: 600
                        Layout.maximumHeight: 200
                        maximumLineCount: 4
                        wrapMode: Text.Wrap
                        elide: Text.ElideRight
                        horizontalAlignment: Label.AlignLeft
                        verticalAlignment: Label.AlignVCenter
                    }
                }
                RowLayout {
                    spacing: 20
                    Label {
                        id: btn1
                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        text: qsTr("Button1")
                        font.pixelSize: 20
                        font.italic: true
                        color: '#00ADDC'
                    }

                    Label {
                        id: btn1_data
                        text: onsButton1
                        font.pixelSize: 20
                        font.italic: true
                        anchors.left: btn1.right
                        anchors.leftMargin: 20
                        color: '#00ADDC'
                    }
                }
                RowLayout {
                    spacing: 20
                    Label {
                        id: btn2
                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        text: qsTr("Button2")
                        font.pixelSize: 20
                        font.italic: true
                        color: '#00ADDC'
                    }
                    Label {
                        id: btn2_data
                        text: onsButton2
                        font.pixelSize: 20
                        font.italic: true
                        anchors.left: btn2.right
                        anchors.leftMargin: 20
                        color: '#00ADDC'
                    }
                }
                RowLayout {
                    spacing: 20
                    Label {
                        id: btn3
                        anchors.left: parent.left
                        anchors.leftMargin: 30
                        text: qsTr("Button3")
                        font.pixelSize: 20
                        font.italic: true
                        color: '#00ADDC'
                    }
                    Label {
                        id: btn3_data
                        text: onsButton3
                        font.pixelSize: 20
                        font.italic: true
                        anchors.left: btn3.right
                        anchors.leftMargin: 20
                        color: '#00ADDC'
                    }
                }
            }
        }

        // post button
        Button {
            id: poster
            text: "Post"
            Layout.alignment: Qt.AlignCenter
            onClicked: {
                postMessage();
            }
        }
    }

    function selectOneButton() {
        console.log("select one button!")
        onsTitle = qsTr("One Button title")
        onsType = qsTr("critical")
        onsContents = qsTr("An operating system is a program that manages a computer’s hardware.")
        onsButton1 = qsTr("Yes")
        onsButton2 = qsTr("")
        onsButton3 = qsTr("")
    }

    function selectTwoButtons() {
        console.log("select two buttons!")
        onsTitle = qsTr("Two Buttons title")
        onsType = qsTr("exclamation")
        onsContents = qsTr("Beforewe can explore the details of computer system operation, we need to know something about system structure. We thus discuss the basic functions of system startup, I/O, and storage early in this chapter. We also describe the basic computer architecture that makes it possible to write a functional operating system.")
        onsButton1 = qsTr("Yes")
        onsButton2 = qsTr("No")
        onsButton3 = qsTr("")
    }

    function selectThreeButtons() {
        console.log("select three buttons!")
        onsTitle = qsTr("Three Buttons title")
        onsType = qsTr("information")
        onsContents = qsTr("We can also view a computer system as consisting of hardware, software,and data. The operating system provides the means for proper use of these resources in the operation of the computer system.")
        onsButton1 = qsTr("Yes")
        onsButton2 = qsTr("Abort")
        onsButton3 = qsTr("No")
    }

    function selectNoButton() {
        console.log("select no button!")
        onsTitle = qsTr("No Button title,very long title beyond screen wide which will show ellipsis at the end")
        onsType = qsTr("question")
        onsContents = qsTr("Recently, many varieties of mobile computers, such as smartphones and tablets, have come into fashion. Most mobile computers are standalone units for individual users. Quite often, they are connected to networks through cellular or other wireless technologies. Increasingly, these mobile devices are replacing desktop and laptop computers for people who are primarily interested in using computers for e-mail and web browsing. The user interface for mobile computers generally features a touch screen, where the user interacts with the system by pressing and swiping fingers across the screen rather than using a physical keyboard and mouse.")
        onsButton1 = qsTr("")
        onsButton2 = qsTr("")
        onsButton3 = qsTr("")
    }

    function postMessage() {
        console.log("poster pressed")
        btndata = ""
        postmsg = "{\"title\": \"" + onsTitle + "\"," + "\"type\": \"" + onsType + "\"," + "\"contents\": \"" + onsContents + "\"";
        if (onsButton1 != "") {
            btndata = "\"" + onsButton1 + "\"";
        }
        if (onsButton2 != "") {
            if (btndata != "")
                btndata += ",";
            btndata += "\"" + onsButton2 + "\"";
        }
        if (onsButton3 != "") {
            if (btndata != "")
                btndata += ",";
            btndata += "\"" + onsButton3 + "\"";
        }

        if(btndata != "")
            postmsg += ",\"buttons\":[" + btndata + "]}"
        else
            postmsg += "}"

        eventHandler.showWindow(onsId, postmsg);
    }

    function qmlOnReplyShowWindow(text) {
        console.log("onstestapp received:",text);
        output.text = text;
    }
}