2 import QtQuick.Window 2.2
3 import QtQuick.Controls 2.0
4 import QtQuick.Layouts 1.0
5 import AGL.Demo.Controls 1.0
13 property string onsId: qsTr("onscreenapp")
14 property string onsTitle: qsTr("One Button title")
15 property string onsType: "critical"
16 property string onsContents: qsTr("An operating system is a program that manages a computer’s hardware.")
17 property string onsButton1: qsTr("Yes")
18 property string onsButton2: qsTr("")
19 property string onsButton3: qsTr("")
20 property string postmsg: qsTr("")
21 property string btndata: qsTr("")
23 property bool onscreen_role_set: false
25 property string mapp_id: ''
26 property string mapp_data_msg: ''
32 text: "OnScreen Test App"
40 anchors.top: title.bottom
42 anchors.horizontalCenter: title.horizontalCenter
44 // show received reply information area
49 Layout.alignment: Qt.AlignCenter
50 flickableDirection: Flickable.VerticalFlick
51 boundsBehavior: Flickable.StopAtBounds
53 TextArea.flickable: TextArea {
55 text: "show received reply information area\n...\n...\n...\n...\n"
57 wrapMode: TextArea.Wrap
61 ScrollBar.vertical: ScrollBar { }
64 // select onscreen type area
67 text: qsTr("Please select send OnScreen Message")
75 Layout.alignment: Qt.AlignLeft
80 text: qsTr("One Button")
88 text: qsTr("Two Buttons")
95 text: qsTr("Three Buttons")
102 text: qsTr("No Button")
111 // edit post message area
114 text: qsTr("Post Infomations")
121 Layout.alignment: Qt.AlignLeft
122 Layout.maximumWidth: 800
123 Layout.maximumHeight: 400
131 anchors.left: parent.left
132 anchors.leftMargin: 30
133 text: qsTr("ons_title:")
144 anchors.left: ons_title.right
145 anchors.leftMargin: 20
147 Layout.maximumWidth: 600
148 Layout.maximumHeight: 40
151 elide: Text.ElideRight
152 horizontalAlignment: Label.AlignHCenter
153 verticalAlignment: Label.AlignVCenter
160 anchors.left: parent.left
161 anchors.leftMargin: 30
173 anchors.left: ons_type.right
174 anchors.leftMargin: 20
182 anchors.left: parent.left
183 anchors.leftMargin: 30
184 text: qsTr("contents:")
190 id: ons_contents_data
194 anchors.left: ons_contents.right
195 anchors.leftMargin: 20
197 Layout.maximumWidth: 600
198 Layout.maximumHeight: 200
201 elide: Text.ElideRight
202 horizontalAlignment: Label.AlignLeft
203 verticalAlignment: Label.AlignVCenter
210 anchors.left: parent.left
211 anchors.leftMargin: 30
212 text: qsTr("Button1")
223 anchors.left: btn1.right
224 anchors.leftMargin: 20
232 anchors.left: parent.left
233 anchors.leftMargin: 30
234 text: qsTr("Button2")
244 anchors.left: btn2.right
245 anchors.leftMargin: 20
253 anchors.left: parent.left
254 anchors.leftMargin: 30
255 text: qsTr("Button3")
265 anchors.left: btn3.right
266 anchors.leftMargin: 20
277 Layout.alignment: Qt.AlignCenter
284 function selectOneButton() {
285 console.log("select one button!")
286 onsTitle = qsTr("One Button title")
287 onsType = qsTr("critical")
288 onsContents = qsTr("An operating system is a program that manages a computer’s hardware.")
289 onsButton1 = qsTr("Yes")
290 onsButton2 = qsTr("")
291 onsButton3 = qsTr("")
294 function selectTwoButtons() {
295 console.log("select two buttons!")
296 onsTitle = qsTr("Two Buttons title")
297 onsType = qsTr("exclamation")
298 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.")
299 onsButton1 = qsTr("Yes")
300 onsButton2 = qsTr("No")
301 onsButton3 = qsTr("")
304 function selectThreeButtons() {
305 console.log("select three buttons!")
306 onsTitle = qsTr("Three Buttons title")
307 onsType = qsTr("information")
308 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.")
309 onsButton1 = qsTr("Yes")
310 onsButton2 = qsTr("Abort")
311 onsButton3 = qsTr("No")
314 function selectNoButton() {
315 console.log("select no button!")
316 onsTitle = qsTr("No Button title,very long title beyond screen wide which will show ellipsis at the end")
317 onsType = qsTr("question")
318 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.")
319 onsButton1 = qsTr("")
320 onsButton2 = qsTr("")
321 onsButton3 = qsTr("")
330 console.log("calling eventHandler.showWindow for " + mapp_id + " and data msg " + mapp_data_msg)
331 eventHandler.showWindow(mapp_id, mapp_data_msg)
338 function armTimer(app_id, msg) {
341 activate_timer.running = true
344 function postMessage() {
345 console.log("poster pressed")
347 postmsg = "{\"title\": \"" + onsTitle + "\"," + "\"type\": \"" + onsType + "\"," + "\"contents\": \"" + onsContents + "\"";
348 if (onsButton1 != "") {
349 btndata = "\"" + onsButton1 + "\"";
351 if (onsButton2 != "") {
354 btndata += "\"" + onsButton2 + "\"";
356 if (onsButton3 != "") {
359 btndata += "\"" + onsButton3 + "\"";
363 postmsg += ",\"buttons\":[" + btndata + "]}"
367 if (!onscreen_role_set) {
368 console.log("onscreen_role_set is not set")
369 eventHandler.set_window_popup(onsId, 0, 218)
370 console.log("setting for popup for " + onsId)
371 onscreen_role_set = true
374 // if the application is not already started, start it
376 // if the application is not started, then the first time
377 // we start we also display it using the default policy engine
378 pid = eventHandler.start(onsId, postmsg)
379 console.log("calling eventHandler.start for " + onsId + " with pid " + pid)
381 // this is necessary jus the first time as we don't queue the
382 // 'activate_app' event and pass it over once onscreenapp is
383 // started. It is implementation detail in case it is required
384 console.log("calling armTimer for " + onsId)
385 armTimer(onsId, postmsg)
387 // onscreenapp is already start we just need to activate + pass the data
388 eventHandler.showWindow(mapp_id, mapp_data_msg)
393 function qmlOnReplyShowWindow(text) {
394 console.log("onstestapp received:",text);