summaryrefslogtreecommitdiff
path: root/SDL_Core/src/components/qt_hmi/qml_model_qt5/MainWindow.qml
blob: 1e952330ab6c9489db1811e9d0753facbdf6d9cf (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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
/**
 * @file MainWindow.qml
 * @brief Implementation of main window.
 * Copyright (c) 2013, Ford Motor Company
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the
 * distribution.
 *
 * Neither the name of the Ford Motor Company nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

import QtQuick 2.0
import QtMultimedia 5.0
import com.ford.sdl.hmi.dbus_adapter 1.0
import com.ford.sdl.hmi.log4cxx 1.0
import com.ford.sdl.hmi.named_pipe_notifier 1.0
import "./controls"
import "./views"
import "./hmi_api" as HmiApi
import "./models"
import "./popups"
import "hmi_api/Common.js" as Common
import "./models/Constants.js" as Constants
import "models/Internal.js" as Internal

Rectangle {
    width: 1280
    height: 768
    property string startQml: "./views/ApplicationListView.qml"
    property int minWidth: Constants.mainScreenMinWidth
    property int minHeight: Constants.mainScreenMiHeight
    color: Constants.secondaryColor

    DataStorage {
        id: dataContainer

        onSystemContextChanged: {
            sdlUI.onSystemContext(systemContext)
        }

        // Please note that applicationContext is changed only after setting currentApplication
        onApplicationContextChanged: {
            if (applicationContext) {
                sdlBasicCommunication.onAppActivated(currentApplication.appId)
            } else {
                sdlBasicCommunication.onAppDeactivated(currentApplication.appId, contentLoader.item.category)
            }
        }
    }

    Audio {
        id: beep
        source: "res/initial.wav"
    }

    Audio {
        id: stream

        property real bufferProgress: 0.0
    }

    SettingsStorage {
        id: settingsContainer
    }

    Item {
        id: mainScreen
        anchors.top: parent. top
        anchors.left: parent.left
        width: (parent.width - simulationScreen.width < minWidth) ?
                   minWidth : parent.width - simulationScreen.width
        height: (parent.height - hardwareScreen.height < minHeight) ?
                    minHeight : parent.height - hardwareScreen.height
        clip: true
        visible: false

        Item {
            anchors.top: parent.top
            anchors.horizontalCenter: parent.horizontalCenter
            height: parent.height * 0.10
            width: parent.width
            HeaderMenu {}
        }

        Item {
            height: parent.height * 0.90
            width: parent.width
            anchors.bottom: parent.bottom
            anchors.horizontalCenter: parent.horizontalCenter

            Video {
                id: player
                anchors.fill: parent
                visible: {
                    var naviString = new RegExp("SDLNavi\.qml")
                    return naviString.test(contentLoader.source);
                }

                NamedPipeNotifier {
                    id: notifier
                    onReadyRead: {
                        player.source = name
                        player.play()
                    }
                }

                Component.onCompleted: {
                    notifier.start()
                }
                onStopped: {
                    notifier.start()

                }
                function startStream(url) {
                    notifier.name = url
                    notifier.start()
                }
            }

            Loader {
                id: contentLoader
                height: parent.height - Constants.margin
                width: parent.width - 2 * Constants.margin
                asynchronous: true
                anchors.bottom: parent.bottom
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.leftMargin: Constants.margin
                anchors.rightMargin: Constants.margin
                anchors.bottomMargin: Constants.margin


                source:startQml
                property var viewTransitionStack : []

                function reset() {
                    viewTransitionStack = []
                }

                property string currentLocation
                function go(path, appId) {
                    console.debug("enter:", path, ", appId:", appId)
                    if (path) {
                        if (currentLocation !== path) {
                            viewTransitionStack.push({ uri: source.toString(), applicationContext: false })
                            if (appId) {
                                dataContainer.setCurrentApplication(appId)
                            }
                            item.leaveScreen()
                            currentLocation = path                            
                            source = path
                        }
                    }
                    console.debug("exit")
                }

                function back() {
                    if (viewTransitionStack.length) {
                        item.leaveScreen()
                        source = viewTransitionStack.pop().uri
                    }
                    currentLocation = ""
                }

                onStatusChanged: {
                    if (status == Component.Ready) {
                        if (!dataContainer.activeAlert) {
                            dataContainer.applicationContext = item.applicationContext
                        }
                        else {
                            dataContainer.applicationSavedContext = item.applicationContext
                        }
                        if (viewTransitionStack && viewTransitionStack.length) {
                            viewTransitionStack[viewTransitionStack.length - 1].applicationContext = item.applicationContext
                        }
                        dataContainer.setSystemContext()
                    }
                }
            }
        }

        WarningInfo { id: warningInfo }

        VRHelpPopup {
            id: vrHelpPopup
            popUpName: "UI.VrHelp"
            anchors.centerIn: parent
            visible: false
        }

        InteractionPopup {
            id: interactionPopup
            popUpName: "UI.PerformInteraction"
            anchors.centerIn: parent
            visible: false
        }

        SliderPopup {
            id: sliderPopup
            popUpName: "UI.Slider"
            anchors.centerIn: parent
            visible: false
        }

        PerformAudioPassThruPopup {
            id: performAudioPassThruPopup
            popUpName: "UI.PerformAudioPassThru"
            anchors.centerIn: parent
            visible: false
        }

        AlertWindow {
            id: alertWindow
            popUpName: "UI.Alert"
            objectName: "AlertWindow"
            anchors.fill: parent
            visible: false
        }
    }

    Item {
        id: simulationScreen
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.left: mainScreen.right
        width: simulationPanel.width
        clip: true
        SimulationView {
            id: simulationPanel

            VRPopUp {
                id: vrPopUp
                visible: false
                anchors.fill: parent
            }

            TTSPopUp {
                id: ttsPopUp
                anchors.top: parent.top
                anchors.right: parent.right
                visible: false
            }
        }
    }

    Item {
        id: hardwareScreen
        anchors.top: mainScreen.bottom
        anchors.left: parent.left
        anchors.right: simulationScreen.left
        height: hardwarePanel.height
        clip: true
        HardwareButtonsView { id: hardwarePanel }
    }

    HMIProxy {
        HmiApi.ButtonsProxy {
            id: sdlButtons
            objectName: "Buttons"
        }
        HmiApi.BasicCommunicationProxy {
            id: sdlBasicCommunication
            objectName: "BasicCommunication"
        }
        HmiApi.VRProxy {
            id: sdlVR
            objectName: "VR"
        }
        HmiApi.TTSProxy {
            id: sdlTTS
            objectName: "TTS"
        }
        HmiApi.NavigationProxy {
            id: sdlNavigation
            objectName: "Navigation"
        }
        HmiApi.VehicleInfoProxy {
            id: sdlVehicleInfo
            objectName: "VehicleInfo"
        }
        HmiApi.UIProxy {
            id: sdlUI
            objectName: "UI"
        }
    }

    SDLProxy {
        id: sdlProxy

        onAppRegistered: {
            var appTypeToAdd = 0
            if (application.appType !== undefined) {
                for (var index in application.appType) {
                    if (application.appType[index] > 31) {
                        return { __retCode: Common.Result.GENERIC_ERROR, __message: "Apptype value > 31" }
                    }
                    appTypeToAdd |= 1 << application.appType[index]
                }
            }

            dataContainer.addApplication(
            {
                appName: application.appName,
                ngnMediaScreenAppName: application.ngnMediaScreenAppName,
                icon: application.icon,
                deviceName: application.deviceName,
                appId: application.appId,
                hmiDisplayLanguageDesired: application.hmiDisplayLanguageDesired,
                isMediaApplication: application.isMediaApplication,
                appType: appTypeToAdd,
                hmiUIText: { },
                mediaClock: {
                    "updateMode": Internal.MediaClockUpdateMode.MCU_COUNTUP,
                    "runningMode": Internal.MediaClockRunningMode.MCR_STOPPED,
                    "startTime": -1,
                    "endTime": -1,
                    "startTimeForProgress": -1
                }
             });
        }

        onAppUnregistered: {
            console.debug("enter")
            console.debug("Resume unregister:", resume)
            if (resume) {
                dataContainer.stashApplication(appId);
            }
            dataContainer.removeApplication(appId);
            if ((dataContainer.currentApplication.appId === appId)) {
                if (dataContainer.applicationContext) {
                    contentLoader.go("views/ApplicationListView.qml");
                }
                if (contentLoader.viewTransitionStack.filter(function(x) { return x.applicationContext })) {
                    contentLoader.reset();
                }
                dataContainer.currentApplication.reset()
            }
            console.debug("exit")
        }

        onPlayTone: {
            beep.play()
        }

    }

    Component.onCompleted: {
        dataContainer.hmiVRAvailable = true
        dataContainer.hmiTTSAvailable = true
        dataContainer.hmiNavigationAvailable = true
        dataContainer.hmiVehicleInfoAvailable = true
        dataContainer.hmiUIAvailable = true

        sdlBasicCommunication.onReady()
    }

    /*
      * Test Support Section
      *
      */
    function getSlider(){
        return sliderPopup
    }

    function getDataStorage(){
        return dataContainer
    }

    function getUIProxy(){
        return sdlUI
    }

    function getMainScreen(){
        return mainScreen
    }

    function getContentLoader(){
        return contentLoader
    }

    function getWarningInfo(){
        return warningInfo
    }
    /*
      * Test Support Section End
      */
}