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("")
28 text: "OnScreen Test App"
36 anchors.top: title.bottom
38 anchors.horizontalCenter: title.horizontalCenter
40 // show received reply information area
45 Layout.alignment: Qt.AlignCenter
46 flickableDirection: Flickable.VerticalFlick
47 boundsBehavior: Flickable.StopAtBounds
49 TextArea.flickable: TextArea {
51 text: "show received reply information area\n...\n...\n...\n...\n"
53 wrapMode: TextArea.Wrap
57 ScrollBar.vertical: ScrollBar { }
60 // select onscreen type area
63 text: qsTr("Please select send OnScreen Message")
71 Layout.alignment: Qt.AlignLeft
76 text: qsTr("One Button")
84 text: qsTr("Two Buttons")
91 text: qsTr("Three Buttons")
98 text: qsTr("No Button")
107 // edit post message area
110 text: qsTr("Post Infomations")
117 Layout.alignment: Qt.AlignLeft
118 Layout.maximumWidth: 800
119 Layout.maximumHeight: 400
127 anchors.left: parent.left
128 anchors.leftMargin: 30
129 text: qsTr("ons_title:")
140 anchors.left: ons_title.right
141 anchors.leftMargin: 20
143 Layout.maximumWidth: 600
144 Layout.maximumHeight: 40
147 elide: Text.ElideRight
148 horizontalAlignment: Label.AlignHCenter
149 verticalAlignment: Label.AlignVCenter
156 anchors.left: parent.left
157 anchors.leftMargin: 30
169 anchors.left: ons_type.right
170 anchors.leftMargin: 20
178 anchors.left: parent.left
179 anchors.leftMargin: 30
180 text: qsTr("contents:")
186 id: ons_contents_data
190 anchors.left: ons_contents.right
191 anchors.leftMargin: 20
193 Layout.maximumWidth: 600
194 Layout.maximumHeight: 200
197 elide: Text.ElideRight
198 horizontalAlignment: Label.AlignLeft
199 verticalAlignment: Label.AlignVCenter
206 anchors.left: parent.left
207 anchors.leftMargin: 30
208 text: qsTr("Button1")
219 anchors.left: btn1.right
220 anchors.leftMargin: 20
228 anchors.left: parent.left
229 anchors.leftMargin: 30
230 text: qsTr("Button2")
240 anchors.left: btn2.right
241 anchors.leftMargin: 20
249 anchors.left: parent.left
250 anchors.leftMargin: 30
251 text: qsTr("Button3")
261 anchors.left: btn3.right
262 anchors.leftMargin: 20
273 Layout.alignment: Qt.AlignCenter
280 function selectOneButton() {
281 console.log("select one button!")
282 onsTitle = qsTr("One Button title")
283 onsType = qsTr("critical")
284 onsContents = qsTr("An operating system is a program that manages a computer’s hardware.")
285 onsButton1 = qsTr("Yes")
286 onsButton2 = qsTr("")
287 onsButton3 = qsTr("")
290 function selectTwoButtons() {
291 console.log("select two buttons!")
292 onsTitle = qsTr("Two Buttons title")
293 onsType = qsTr("exclamation")
294 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.")
295 onsButton1 = qsTr("Yes")
296 onsButton2 = qsTr("No")
297 onsButton3 = qsTr("")
300 function selectThreeButtons() {
301 console.log("select three buttons!")
302 onsTitle = qsTr("Three Buttons title")
303 onsType = qsTr("information")
304 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.")
305 onsButton1 = qsTr("Yes")
306 onsButton2 = qsTr("Abort")
307 onsButton3 = qsTr("No")
310 function selectNoButton() {
311 console.log("select no button!")
312 onsTitle = qsTr("No Button title,very long title beyond screen wide which will show ellipsis at the end")
313 onsType = qsTr("question")
314 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.")
315 onsButton1 = qsTr("")
316 onsButton2 = qsTr("")
317 onsButton3 = qsTr("")
320 function postMessage() {
321 console.log("poster pressed")
323 postmsg = "{\"title\": \"" + onsTitle + "\"," + "\"type\": \"" + onsType + "\"," + "\"contents\": \"" + onsContents + "\"";
324 if (onsButton1 != "") {
325 btndata = "\"" + onsButton1 + "\"";
327 if (onsButton2 != "") {
330 btndata += "\"" + onsButton2 + "\"";
332 if (onsButton3 != "") {
335 btndata += "\"" + onsButton3 + "\"";
339 postmsg += ",\"buttons\":[" + btndata + "]}"
343 // if the application is not already started, start it
345 // if the application is not started, then the first time
346 // we start we also display it using the default policy engine
347 pid = eventHandler.start(onsId, postmsg)
349 // we just need to display it
350 eventHandler.showWindow(onsId, postmsg)
354 function qmlOnReplyShowWindow(text) {
355 console.log("onstestapp received:",text);