summaryrefslogtreecommitdiff
path: root/src/hmi/qml/NavigationAppSettingsPreferences.qml
blob: 949d7dc109b6970b0e2ddefdc44b5c8032747a0f (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
/**
* @licence app begin@
* SPDX-License-Identifier: MPL-2.0
*
* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen
*
* \file NavigationSettingsPreferences.qml
*
* \brief This file is part of the navigation hmi.
*
* \author Martin Schaller <martin.schaller@it-schaller.de>
* \author Philippe Colliot <philippe.colliot@mpsa.com>
*
* \version 1.1
*
* 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:
* 2014-03-05, Philippe Colliot, migration to the new HMI design
* <date>, <name>, <description of change>
*
* @licence end@
*/
import QtQuick 2.1 
import "Core"
import "Core/genivi.js" as Genivi;
import "Core/style-sheets/style-constants.js" as Constants;
import "Core/style-sheets/NavigationAppSettingsPreference-css.js" as StyleSheet;
import lbs.plugin.dbusif 1.0
import lbs.plugin.preference 1.0

HMIMenu {
	id: menu
    property string pagefile:"NavigationAppSettingsPreferences"

    DBusIf {
        id: dbusIf
    }

// please note that the preferences are hard coded, limited to three couples:
//    (NAVIGATIONCORE_AVOID,NAVIGATIONCORE_HIGHWAYS_MOTORWAYS)
//    (NAVIGATIONCORE_AVOID,NAVIGATIONCORE_TOLL_ROADS)
//    (NAVIGATIONCORE_AVOID,NAVIGATIONCORE_FERRY)

    Preference {
        source: 0
        mode: 0
    }

	function update()
    {
        Genivi.routing_SetRoutePreferences(dbusIf,""); //preferences applied to all countries
        var active=Genivi.routing_GetRoutePreferences(dbusIf,"");

        var roadPreferenceList;
        var conditionPreferenceList;
        roadPreferenceList=active[1];
        conditionPreferenceList=active[3];
        var roadPreferenceMode,roadPreferenceSource;
        var conditionPreferenceMode,conditionPreferenceSource;

        for(var i=0; i<roadPreferenceList.length; i+=2)
        {
            roadPreferenceMode=roadPreferenceList[i+1][1];
            roadPreferenceSource=roadPreferenceList[i+1][3];
            Genivi.roadPreferenceList[roadPreferenceSource]=roadPreferenceMode;

            if(roadPreferenceSource == Genivi.NAVIGATIONCORE_FERRY)
            {
                if(roadPreferenceMode == Genivi.NAVIGATIONCORE_AVOID)
                {
                    ferries_yes.disabled=false;
                    ferries_no.disabled=true;
                }
                else
                {
                    ferries_yes.disabled=true;
                    ferries_no.disabled=false;
                }
            }
            else
            {
                if(roadPreferenceSource == Genivi.NAVIGATIONCORE_TOLL_ROADS)
                {
                    if(roadPreferenceMode == Genivi.NAVIGATIONCORE_AVOID)
                    {
                        toll_roads_yes.disabled=false;
                        toll_roads_no.disabled=true;
                    }
                    else
                    {
                        toll_roads_yes.disabled=true;
                        toll_roads_no.disabled=false;
                    }
                }
                else
                {
                    if(roadPreferenceSource == Genivi.NAVIGATIONCORE_HIGHWAYS_MOTORWAYS)
                    {
                        if(roadPreferenceMode == Genivi.NAVIGATIONCORE_AVOID)
                        {
                            motorways_yes.disabled=false;
                            motorways_no.disabled=true;
                        }
                        else
                        {
                            motorways_yes.disabled=true;
                            motorways_no.disabled=false;
                        }
                    }
                }
            }
        }
	}

    function use(preferenceSource)
	{
        Genivi.roadPreferenceList[preferenceSource]=Genivi.NAVIGATIONCORE_USE;
		update();
	}

    function avoid(preferenceSource)
	{
        Genivi.roadPreferenceList[preferenceSource]=Genivi.NAVIGATIONCORE_AVOID;
		update();
	}

	HMIBgImage {
		id: content
        image:StyleSheet.navigation_app_settings_preference_background[Constants.SOURCE];
        anchors { fill: parent; topMargin: parent.headlineHeight}
		Text {
            x:StyleSheet.costModelTitle[Constants.X]; y:StyleSheet.costModelTitle[Constants.Y]; width:StyleSheet.costModelTitle[Constants.WIDTH]; height:StyleSheet.costModelTitle[Constants.HEIGHT];color:StyleSheet.costModelTitle[Constants.TEXTCOLOR];styleColor:StyleSheet.costModelTitle[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.costModelTitle[Constants.PIXELSIZE];
            id:costModelTitle;
            style: Text.Sunken;
            smooth: true
            text: Genivi.gettext("CostModel")
        }

		Text {
            x:StyleSheet.routingPreferencesTitle[Constants.X]; y:StyleSheet.routingPreferencesTitle[Constants.Y]; width:StyleSheet.routingPreferencesTitle[Constants.WIDTH]; height:StyleSheet.routingPreferencesTitle[Constants.HEIGHT];color:StyleSheet.routingPreferencesTitle[Constants.TEXTCOLOR];styleColor:StyleSheet.routingPreferencesTitle[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.routingPreferencesTitle[Constants.PIXELSIZE];
            id:routingPreferencesTitle;
            style: Text.Sunken;
            smooth: true
            text: Genivi.gettext("RoutingPreferences")
        }

		Text {
            x:StyleSheet.ferriesText[Constants.X]; y:StyleSheet.ferriesText[Constants.Y]; width:StyleSheet.ferriesText[Constants.WIDTH]; height:StyleSheet.ferriesText[Constants.HEIGHT];color:StyleSheet.ferriesText[Constants.TEXTCOLOR];styleColor:StyleSheet.ferriesText[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.ferriesText[Constants.PIXELSIZE];
            id: ferriesText;
            style: Text.Sunken;
            smooth: true
            text: Genivi.gettext("Ferries")
        }
        StdButton { source:StyleSheet.allow_ferries[Constants.SOURCE]; x:StyleSheet.allow_ferries[Constants.X]; y:StyleSheet.allow_ferries[Constants.Y]; width:StyleSheet.allow_ferries[Constants.WIDTH]; height:StyleSheet.allow_ferries[Constants.HEIGHT];
            id:ferries_yes; next:back; prev:back; explode:false; onClicked:{use(Genivi.NAVIGATIONCORE_FERRY)}}
        StdButton { source:StyleSheet.avoid_ferries[Constants.SOURCE]; x:StyleSheet.avoid_ferries[Constants.X]; y:StyleSheet.avoid_ferries[Constants.Y]; width:StyleSheet.avoid_ferries[Constants.WIDTH]; height:StyleSheet.avoid_ferries[Constants.HEIGHT];
            id:ferries_no; next:back; prev:back; explode:false; onClicked:{avoid(Genivi.NAVIGATIONCORE_FERRY)}}

		Text {
            x:StyleSheet.tollRoadsText[Constants.X]; y:StyleSheet.tollRoadsText[Constants.Y]; width:StyleSheet.tollRoadsText[Constants.WIDTH]; height:StyleSheet.tollRoadsText[Constants.HEIGHT];color:StyleSheet.tollRoadsText[Constants.TEXTCOLOR];styleColor:StyleSheet.tollRoadsText[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.tollRoadsText[Constants.PIXELSIZE];
            id: tollRoadsText;
            style: Text.Sunken;
            smooth: true
            text: Genivi.gettext("TollRoads")
        }
        StdButton { source:StyleSheet.allow_tollRoads[Constants.SOURCE]; x:StyleSheet.allow_tollRoads[Constants.X]; y:StyleSheet.allow_tollRoads[Constants.Y]; width:StyleSheet.allow_tollRoads[Constants.WIDTH]; height:StyleSheet.allow_tollRoads[Constants.HEIGHT];
            id:toll_roads_yes; next:back; prev:back; explode:false; onClicked:{use(Genivi.NAVIGATIONCORE_TOLL_ROADS)}}
        StdButton { source:StyleSheet.avoid_tollRoads[Constants.SOURCE]; x:StyleSheet.avoid_tollRoads[Constants.X]; y:StyleSheet.avoid_tollRoads[Constants.Y]; width:StyleSheet.avoid_tollRoads[Constants.WIDTH]; height:StyleSheet.avoid_tollRoads[Constants.HEIGHT];
            id:toll_roads_no;  next:back; prev:back; explode:false; onClicked:{avoid(Genivi.NAVIGATIONCORE_TOLL_ROADS)}}

		Text {
            x:StyleSheet.motorWaysText[Constants.X]; y:StyleSheet.motorWaysText[Constants.Y]; width:StyleSheet.motorWaysText[Constants.WIDTH]; height:StyleSheet.motorWaysText[Constants.HEIGHT];color:StyleSheet.motorWaysText[Constants.TEXTCOLOR];styleColor:StyleSheet.motorWaysText[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.motorWaysText[Constants.PIXELSIZE];
            id:motorWaysText;
            style: Text.Sunken;
            smooth: true
            text: Genivi.gettext("MotorWays")
        }
        StdButton { source:StyleSheet.allow_motorways[Constants.SOURCE]; x:StyleSheet.allow_motorways[Constants.X]; y:StyleSheet.allow_motorways[Constants.Y]; width:StyleSheet.allow_motorways[Constants.WIDTH]; height:StyleSheet.allow_motorways[Constants.HEIGHT];
            id:motorways_yes; next:back; prev:back; explode:false; onClicked:{use(Genivi.NAVIGATIONCORE_HIGHWAYS_MOTORWAYS)}}
        StdButton { source:StyleSheet.avoid_motorways[Constants.SOURCE]; x:StyleSheet.avoid_motorways[Constants.X]; y:StyleSheet.avoid_motorways[Constants.Y]; width:StyleSheet.avoid_motorways[Constants.WIDTH]; height:StyleSheet.avoid_motorways[Constants.HEIGHT];
            id:motorways_no;  next:back; prev:back; explode:false; onClicked:{avoid(Genivi.NAVIGATIONCORE_HIGHWAYS_MOTORWAYS)}}

        StdButton { source:StyleSheet.back[Constants.SOURCE]; x:StyleSheet.back[Constants.X]; y:StyleSheet.back[Constants.Y]; width:StyleSheet.back[Constants.WIDTH]; height:StyleSheet.back[Constants.HEIGHT];textColor:StyleSheet.backText[Constants.TEXTCOLOR]; pixelSize:StyleSheet.backText[Constants.PIXELSIZE];
            id:back; text: Genivi.gettext("Back"); disabled:false; next:back; prev:back; onClicked:{leaveMenu();}}

	}

    Component.onCompleted: {
        var res=Genivi.routing_GetCostModel(dbusIf);
        var costmodel=res[1];
        var costModelsList=Genivi.routing_GetSupportedCostModels(dbusIf);
        for (var i = 0 ; i < costModelsList[1].length ; i+=2) {
            var button=Qt.createQmlObject('import QtQuick 2.1 ; import "Core"; StdButton { }',content,'dynamic');
            button.source=StyleSheet.cost_model[Constants.SOURCE];
            button.x=StyleSheet.cost_model[Constants.X];
            button.y=StyleSheet.cost_model[Constants.Y] + i*50; //to be improved
            button.width=StyleSheet.cost_model[Constants.WIDTH];
            button.height=StyleSheet.cost_model[Constants.HEIGHT];
            button.textColor=StyleSheet.costModelValue[Constants.TEXTCOLOR];
            button.pixelSize=StyleSheet.costModelValue[Constants.PIXELSIZE];
            button.userdata=costModelsList[1][i+1];
            button.text=Genivi.CostModels[button.userdata];
            button.disabled=button.userdata == costmodel;
            button.clicked.connect(
                function(what) {
                    Genivi.routing_SetCostModel(dbusIf,what.userdata);
                    pageOpen(menu.pagefile); //reload the page
                }
            );
        }

        update();
    }
}