summaryrefslogtreecommitdiff
path: root/app/gdp-hmi-launcher/main.qml
blob: a954259b64b883fc7ae63a6c4825b1844905f74c (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
/**
 * SPDX license identifier: MPL-2.0
 *
 * Copyright (C) 2015 GENIVI Alliance
 *
 * This file is part of GENIVI Development Platform HMI.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * For further information see http://www.genivi.org/.
 *
 * List of changes:
 * 06.Feb.2015, Holger Behrens, written based on template created by QtCreator
 */

import QtQuick 2.3
import QtQuick.Controls 1.2

Rectangle {
    id: gdp_launcher
    visible: true
    width: 1024
    height: 768
    color: "steelblue"
    opacity: 1.0

    signal appSelectSignal(string unit)
    signal requestOffSignal()

    Rectangle {
        id: grid_rectangle
        visible: true
        anchors.bottom: panel.top
        anchors.bottomMargin: 0
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: parent.top
        anchors.topMargin: 0

        // handle clicks on empty area
        MouseArea {
            anchors.fill: parent
            onClicked: grid.currentIndex = -1
        }

        // grid with a list (model) of runable applications
        GridView {
            id: grid
            width: 600
            height: 450
            flickableDirection: Flickable.AutoFlickDirection
            keyNavigationWraps: true
            cellHeight: 225
            cellWidth: 200

            anchors.horizontalCenterOffset: 0
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 30

            Component {
                id: applicationDelegate
                Item {
                    width: grid.cellWidth; height: grid.cellHeight
                    Column {
                        anchors.fill: parent
                        Image {
                            source: icon;
                            anchors.horizontalCenter: parent.horizontalCenter;
                            width: 200;
                            height: 200;
                        }
                        Text {
                            text: name;
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
                    } // Column
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            grid.currentIndex = index
                            //console.log("grid clicked", index, " ", model.unit)
                            gdp_launcher.appSelectSignal(model.unit)
                        }
                    }
                } // Item
            } // Component

            model: ApplicationsModel {}
            delegate: applicationDelegate
            highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
            focus: true

            // unselect any item
            Component.onCompleted: currentIndex = -1
        } // GridView - grid
    } // Rectangle - grid_rectangle

    // panel with power-off button
    Image {
        id: panel
        x: 0
        y: 686
        height: 68
        opacity: 1.0
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 0
        source: "file://usr/share/gdp/GDP_Panel.png"

        ToolButton {
            id: powerButton
            width: 60
            height: 60
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 4
            onClicked: {
                console.log("powerButton clicked")
                gdp_launcher.requestOffSignal()
            }
            Image {
                anchors.rightMargin: 5
                anchors.leftMargin: 5
                anchors.bottomMargin: 5
                anchors.topMargin: 5
                anchors.fill: parent
                source: "file://usr/share/gdp/power-icon_red.png"
            }
        }
        Text {
            id: notice
            color: "#ffffff"
            style: Text.Normal
            font.pixelSize: 12
            text: qsTr("Copyright © 2016, GENIVI Alliance")
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 8
            anchors.right: parent.right
            anchors.rightMargin: 8
        }
    } // Image - panel
} // Rectangle - gdp_launcher