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: ''
28 // position of the pop-up
36 text: "OnScreen Test App"
44 anchors.top: title.bottom
46 anchors.horizontalCenter: title.horizontalCenter
48 // show received reply information area
53 // Layout.alignment: Qt.AlignCenter
54 // flickableDirection: Flickable.VerticalFlick
55 // boundsBehavior: Flickable.StopAtBounds
57 // TextArea.flickable: TextArea {
59 // text: "show received reply information area\n...\n...\n...\n...\n"
61 // wrapMode: TextArea.Wrap
65 // ScrollBar.vertical: ScrollBar { }
68 // select onscreen type area
71 text: qsTr("Please select send OnScreen Message")
79 Layout.alignment: Qt.AlignLeft
84 text: qsTr("One Button")
92 text: qsTr("Two Buttons")
99 text: qsTr("Three Buttons")
102 selectThreeButtons();
106 text: qsTr("No Button")
115 // edit post message area
118 text: qsTr("Post Infomations")
125 Layout.alignment: Qt.AlignLeft
126 Layout.maximumWidth: 800
127 Layout.maximumHeight: 400
135 anchors.left: parent.left
136 anchors.leftMargin: 30
137 text: qsTr("ons_title:")
148 anchors.left: ons_title.right
149 anchors.leftMargin: 20
151 Layout.maximumWidth: 600
152 Layout.maximumHeight: 40
155 elide: Text.ElideRight
156 horizontalAlignment: Label.AlignHCenter
157 verticalAlignment: Label.AlignVCenter
164 anchors.left: parent.left
165 anchors.leftMargin: 30
177 anchors.left: ons_type.right
178 anchors.leftMargin: 20
186 anchors.left: parent.left
187 anchors.leftMargin: 30
188 text: qsTr("contents:")
194 id: ons_contents_data
198 anchors.left: ons_contents.right
199 anchors.leftMargin: 20
201 Layout.maximumWidth: 600
202 Layout.maximumHeight: 200
205 elide: Text.ElideRight
206 horizontalAlignment: Label.AlignLeft
207 verticalAlignment: Label.AlignVCenter
214 anchors.left: parent.left
215 anchors.leftMargin: 30
216 text: qsTr("Button1")
227 anchors.left: btn1.right
228 anchors.leftMargin: 20
236 anchors.left: parent.left
237 anchors.leftMargin: 30
238 text: qsTr("Button2")
248 anchors.left: btn2.right
249 anchors.leftMargin: 20
257 anchors.left: parent.left
258 anchors.leftMargin: 30
259 text: qsTr("Button3")
269 anchors.left: btn3.right
270 anchors.leftMargin: 20
281 Layout.alignment: Qt.AlignCenter
288 function selectOneButton() {
289 console.log("select one button!")
290 onsTitle = qsTr("One Button title")
291 onsType = qsTr("critical")
292 onsContents = qsTr("An operating system is a program that manages a computer’s hardware.")
293 onsButton1 = qsTr("Yes")
294 onsButton2 = qsTr("")
295 onsButton3 = qsTr("")
298 function selectTwoButtons() {
299 console.log("select two buttons!")
300 onsTitle = qsTr("Two Buttons title")
301 onsType = qsTr("exclamation")
302 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.")
303 onsButton1 = qsTr("Yes")
304 onsButton2 = qsTr("No")
305 onsButton3 = qsTr("")
308 function selectThreeButtons() {
309 console.log("select three buttons!")
310 onsTitle = qsTr("Three Buttons title")
311 onsType = qsTr("information")
312 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.")
313 onsButton1 = qsTr("Yes")
314 onsButton2 = qsTr("Abort")
315 onsButton3 = qsTr("No")
318 function selectNoButton() {
319 console.log("select no button!")
320 onsTitle = qsTr("No Button title,very long title beyond screen wide which will show ellipsis at the end")
321 onsType = qsTr("question")
322 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.")
323 onsButton1 = qsTr("")
324 onsButton2 = qsTr("")
325 onsButton3 = qsTr("")
334 console.log("calling eventHandler.showWindow for " + mapp_id + " and data msg " + mapp_data_msg)
335 eventHandler.showWindow(mapp_id, mapp_data_msg)
342 function armTimer(app_id, msg) {
345 activate_timer.running = true
348 function postMessage() {
349 console.log("poster pressed")
351 postmsg = "{\"title\": \"" + onsTitle + "\"," + "\"type\": \"" + onsType + "\"," + "\"contents\": \"" + onsContents + "\"";
352 if (onsButton1 != "") {
353 btndata = "\"" + onsButton1 + "\"";
355 if (onsButton2 != "") {
358 btndata += "\"" + onsButton2 + "\"";
360 if (onsButton3 != "") {
363 btndata += "\"" + onsButton3 + "\"";
367 postmsg += ",\"buttons\":[" + btndata + "]}"
371 if (!onscreen_role_set) {
372 console.log("onscreen_role_set is not set")
373 eventHandler.set_window_popup(onsId, x, y)
374 console.log("setting for popup for " + onsId)
375 onscreen_role_set = true
378 // if the application is not already started, start it
380 // if the application is not started, then the first time
381 // we start we also display it using the default policy engine
382 pid = eventHandler.start(onsId, postmsg)
383 console.log("calling eventHandler.start for " + onsId + " with pid " + pid)
385 // this is necessary jus the first time as we don't queue the
386 // 'activate_app' event and pass it over once onscreenapp is
387 // started. It is implementation detail in case it is required
388 console.log("calling armTimer for " + onsId)
389 armTimer(onsId, postmsg)
391 // onscreenapp is already start we just need to activate + pass the data
392 if (!eventHandler.is_running(onsId) && pid > 0) {
393 // this is mostly for testing, in case onscreenapp died
395 eventHandler.set_window_popup(onsId, x, y)
396 pid = eventHandler.start(onsId, postmsg)
397 armTimer(onsId, postmsg)
399 eventHandler.showWindow(onsId, postmsg)
405 function qmlOnReplyShowWindow(text) {
406 console.log("onstestapp received:",text);
407 //output.text = text;