diff options
author | asanoaozora <fifitaneki@hotmail.com> | 2017-06-22 15:48:08 +0200 |
---|---|---|
committer | asanoaozora <fifitaneki@hotmail.com> | 2017-06-22 15:48:08 +0200 |
commit | 0f6d2db76e35b6ffd97db7a2f2d2d79c895c73d4 (patch) | |
tree | d57fb97350016e654389fefd2e95210e4aae14bb | |
parent | be3e491517363f5ba21b470167e9ff520237ccc7 (diff) | |
download | navigation-0f6d2db76e35b6ffd97db7a2f2d2d79c895c73d4.tar.gz |
introduce a .conf file for the management of the settings
-rw-r--r-- | src/README.md | 4 | ||||
-rw-r--r-- | src/hmi/config/fsa_london.conf | 14 | ||||
-rw-r--r-- | src/hmi/config/fsa_paris.conf | 14 | ||||
-rw-r--r-- | src/hmi/config/fsa_switzerland.conf | 14 | ||||
-rw-r--r-- | src/hmi/config/fsa_tokyo.conf | 14 | ||||
-rw-r--r-- | src/hmi/hmi-launcher/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/hmi/hmi-launcher/main.cpp | 13 | ||||
-rw-r--r-- | src/hmi/hmi-launcher/settings.h | 50 | ||||
-rw-r--r-- | src/hmi/qml/NavigationApp.qml | 14 | ||||
-rw-r--r-- | src/hmi/qml/NavigationAppSettings.qml | 6 | ||||
-rw-r--r-- | src/hmi/qml/NavigationAppTokyo.qml | 80 | ||||
-rwxr-xr-x | src/run | 12 |
12 files changed, 142 insertions, 99 deletions
diff --git a/src/README.md b/src/README.md index 1352303..e4164b6 100644 --- a/src/README.md +++ b/src/README.md @@ -83,5 +83,5 @@ http://maps9.navit-project.org/api/map/?bbox=139.1,35.5,140.4,36.0×tamp=170 Rename the file to tokyo.bin, copy it to ./navigation/src/navigation/map do ./build.sh -c Launch the demo -./run -r -c tokyo -a hmi/qml/NavigationAppTokyo.qml -For sure, there's some hack to do :-) +./run -r -c tokyo +NB: configuration is managed by a fsa.conf located in $HOME/.config/navigation and the run shell replaces it by the right one diff --git a/src/hmi/config/fsa_london.conf b/src/hmi/config/fsa_london.conf new file mode 100644 index 0000000..48c782a --- /dev/null +++ b/src/hmi/config/fsa_london.conf @@ -0,0 +1,14 @@ +[Locale] +language=eng +country=USA +script=Latn +[DefaultPosition] +latitude=51.507576 +longitude=-0.127878 +altitude=20 +[DefaultAddress] +country=United Kingdom +city=London +street=Culworth Street +number=1 + diff --git a/src/hmi/config/fsa_paris.conf b/src/hmi/config/fsa_paris.conf new file mode 100644 index 0000000..674f9ff --- /dev/null +++ b/src/hmi/config/fsa_paris.conf @@ -0,0 +1,14 @@ +[Locale] +language=eng +country=USA +script=Latn +[DefaultPosition] +latitude=48.840051 +longitude=2.338001 +altitude=20 +[DefaultAddress] +country=France +city=Versailles +street=Rue Colbert +number=13 + diff --git a/src/hmi/config/fsa_switzerland.conf b/src/hmi/config/fsa_switzerland.conf new file mode 100644 index 0000000..a07afe7 --- /dev/null +++ b/src/hmi/config/fsa_switzerland.conf @@ -0,0 +1,14 @@ +[Locale] +language=eng +country=USA +script=Latn +[DefaultPosition] +latitude=46.202038 +longitude=6.146845 +altitude=392 +[DefaultAddress] +country=Switzerland +city=Lausanne +street=Rue de Midi +number=8 + diff --git a/src/hmi/config/fsa_tokyo.conf b/src/hmi/config/fsa_tokyo.conf new file mode 100644 index 0000000..9b56b1f --- /dev/null +++ b/src/hmi/config/fsa_tokyo.conf @@ -0,0 +1,14 @@ +[Locale] +language=jpn +country=JPN +script=Hrkt +[DefaultPosition] +latitude=35.758795 +longitude=139.316533 +altitude=19 +[DefaultAddress] +country=Japan +city=東京 +street=井ノ頭通り +number=17 + diff --git a/src/hmi/hmi-launcher/CMakeLists.txt b/src/hmi/hmi-launcher/CMakeLists.txt index 33cca2c..319a001 100644 --- a/src/hmi/hmi-launcher/CMakeLists.txt +++ b/src/hmi/hmi-launcher/CMakeLists.txt @@ -127,6 +127,7 @@ set (SRC_TO_MOC ${CMAKE_CURRENT_SOURCE_DIR}/wheelarea.h ${CMAKE_CURRENT_SOURCE_DIR}/wheelareaplugin.h ${CMAKE_CURRENT_SOURCE_DIR}/preference.h + ${CMAKE_CURRENT_SOURCE_DIR}/settings.h ) execute_process( WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" @@ -153,12 +154,7 @@ add_executable(hmi-launcher main.cpp dbusif.cpp wheelareaplugin.cpp - wheelareaplugin.h preference.cpp - dbusif.h - dbusifsignal.h - wheelarea.h - preference.h ) target_link_libraries(hmi-launcher ${LIBRARIES}) diff --git a/src/hmi/hmi-launcher/main.cpp b/src/hmi/hmi-launcher/main.cpp index 7e6b662..31ae95c 100644 --- a/src/hmi/hmi-launcher/main.cpp +++ b/src/hmi/hmi-launcher/main.cpp @@ -38,6 +38,7 @@ #include "dbusif.h" #include "wheelarea.h" #include "preference.h" +#include "settings.h" int main(int argc, char ** argv) { @@ -48,9 +49,21 @@ int main(int argc, char ** argv) qmlRegisterType<Preference>("lbs.plugin.preference", 1,0, "Preference"); qmlRegisterType<WheelArea>("lbs.plugin.wheelarea", 1, 0, "WheelArea"); + //get settings stored into the conf file (in $HOME/.config/navigation/fsa.conf) + + app.setOrganizationName(QString("navigation")); + app.setApplicationName(QString("fsa")); + + Settings* settings=new Settings; + settings->setIniCodec("UTF-8"); + + QString toto=settings->getValue("DefaultAddress/city").toString(); + int rc = 0; QQmlEngine engine; + engine.rootContext()->setContextProperty("Settings",settings); + QQmlComponent *component = new QQmlComponent(&engine); QPalette pal = app.palette(); diff --git a/src/hmi/hmi-launcher/settings.h b/src/hmi/hmi-launcher/settings.h new file mode 100644 index 0000000..13891cb --- /dev/null +++ b/src/hmi/hmi-launcher/settings.h @@ -0,0 +1,50 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2017, PSA Group +* +* \file settings.h +* +* \brief This file is part of the FSA HMI. +* +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* +* \version 1.0 +* +* 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: +* +* <date>, <name>, <description of change> +* +* @licence end@ +*/ +#ifndef INCLUDE_SETTINGS +#define INCLUDE_SETTINGS + +#include <QSettings> +#include <QCoreApplication> + +class Settings:public QSettings +{ +Q_OBJECT + +public: +explicit Settings(QObject *parent = 0) : QSettings(QSettings::UserScope, + QCoreApplication::instance()->organizationName(), + QCoreApplication::instance()->applicationName(), + parent) {} + +Q_INVOKABLE inline void setValue(const QString &key, const QVariant &value) { QSettings::setValue(key, value); } +Q_INVOKABLE inline QVariant getValue(const QString &key, const QVariant &defaultValue = QVariant()) const { return QSettings::value(key, defaultValue); } + +}; +Q_DECLARE_METATYPE(Settings*) + +#endif diff --git a/src/hmi/qml/NavigationApp.qml b/src/hmi/qml/NavigationApp.qml index 81c991d..56ea5fc 100644 --- a/src/hmi/qml/NavigationApp.qml +++ b/src/hmi/qml/NavigationApp.qml @@ -32,6 +32,7 @@ import "../style-sheets/style-constants.js" as Constants; import "../style-sheets/NavigationAppBrowseMap-css.js" as StyleSheetMap; import "Core/genivi.js" as Genivi; import lbs.plugin.dbusif 1.0 +import lbs.plugin.preference 1.0 ApplicationWindow { id: container @@ -56,11 +57,16 @@ ApplicationWindow { id:dbusIf; } + Preference { + source: 0 + mode: 0 + } + Component.onCompleted: { - //set persistent data - Genivi.setlang("eng","USA","Latn"); //set to english US - Genivi.setDefaultPosition(46.202038,6.146845,392); // (rue Jean Calvin Genève) - Genivi.setDefaultAddress("Switzerland","Lausanne","Rue de Midi","8"); // preferred address + //init persistent data + Genivi.setlang(Settings.getValue("Locale/language"),Settings.getValue("Locale/country"),Settings.getValue("Locale/script")); + Genivi.setDefaultPosition(Settings.getValue("DefaultPosition/latitude"),Settings.getValue("DefaultPosition/longitude"),Settings.getValue("DefaultPosition/altitude")); + Genivi.setDefaultAddress(Settings.getValue("DefaultAddress/country"),Settings.getValue("DefaultAddress/city"),Settings.getValue("DefaultAddress/street"),Settings.getValue("DefaultAddress/number")); //configure the middleware Genivi.navigationcore_configuration_SetLocale(dbusIf,Genivi.g_language,Genivi.g_country,Genivi.g_script); diff --git a/src/hmi/qml/NavigationAppSettings.qml b/src/hmi/qml/NavigationAppSettings.qml index f8dd28d..d46b006 100644 --- a/src/hmi/qml/NavigationAppSettings.qml +++ b/src/hmi/qml/NavigationAppSettings.qml @@ -32,7 +32,6 @@ import "Core/genivi.js" as Genivi; import "../style-sheets/style-constants.js" as Constants; import "../style-sheets/NavigationAppSettings-css.js" as StyleSheet; import lbs.plugin.dbusif 1.0 -import lbs.plugin.preference 1.0 NavigationAppHMIMenu { id: menu @@ -154,11 +153,6 @@ NavigationAppHMIMenu { // (NAVIGATIONCORE_AVOID,NAVIGATIONCORE_TOLL_ROADS) // (NAVIGATIONCORE_AVOID,NAVIGATIONCORE_FERRY) - Preference { - source: 0 - mode: 0 - } - function updatePreferences() { Genivi.routing_SetRoutePreferences(dbusIf,""); //preferences applied to all countries diff --git a/src/hmi/qml/NavigationAppTokyo.qml b/src/hmi/qml/NavigationAppTokyo.qml deleted file mode 100644 index 4779796..0000000 --- a/src/hmi/qml/NavigationAppTokyo.qml +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @licence app begin@ -* SPDX-License-Identifier: MPL-2.0 -* -* \copyright Copyright (C) 2013-2017, PSA GROUPE -* -* \file NavigationApp.qml -* -* \brief This file is part of the navigation hmi. -* -* \author Philippe Colliot <philippe.colliot@mpsa.com> -* -* \version 1.0 -* -* 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: -* <date>, <name>, <description of change> -* -* @licence end@ -*/ -import QtQuick 2.1 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 -import QtQuick.Dialogs 1.0 -import "../style-sheets/style-constants.js" as Constants; -import "../style-sheets/NavigationAppBrowseMap-css.js" as StyleSheetMap; -import "Core/genivi.js" as Genivi; -import lbs.plugin.dbusif 1.0 - -ApplicationWindow { - id: container - flags: Qt.FramelessWindowHint - color: "transparent" - visible: true - width: StyleSheetMap.menu[Constants.WIDTH]; - height: StyleSheetMap.menu[Constants.HEIGHT]; - property Item component; - function load(page) - { - if (component) { - component.destroy(); - } - component = Qt.createQmlObject(page+"{}",container,"dynamic"); - } - - //------------------------------------------// - // Management of the DBus exchanges - //------------------------------------------// - DBusIf { - id:dbusIf; - } - - Component.onCompleted: { - //set persistent data - Genivi.setlang("jpn","JPN","Hrkt"); //set to japanese - Genivi.setDefaultPosition(35.758795,139.316533,19); // (1 Chome-1-5 Gonokami Hamura-shi, Tōkyō-to) - - //configure the middleware - Genivi.setDefaultAddress("Japan","東京","井ノ頭通り","17"); // preferred address - Genivi.navigationcore_configuration_SetLocale(dbusIf,Genivi.g_language,Genivi.g_country,Genivi.g_script); - - //launch the map viewer and init the scale list - Genivi.mapviewer_handle(dbusIf,width,height,Genivi.MAPVIEWER_MAIN_MAP); - Genivi.initScale(dbusIf); - - //launch the HMI - load("NavigationAppMain"); - } - - Component.onDestruction: { - //release the map viewer - Genivi.mapviewer_handle_clear(dbusIf); - } -} @@ -106,7 +106,8 @@ gateway=0 #vehicle gateway disabled lm=0 #layer manager disabled wm="" #to store the current window manager (in case of start with the layer manager) verbose=0 #no debug or log messages displayed -center="4612 N 0608 E" +center="4612 N 0608 E" #geneva +config_file=fsa_switzerland.conf #switzerland settings CUR_DIR=$PWD BIN_DIR=$CUR_DIR/build @@ -116,6 +117,7 @@ SCRIPT_DIR=$SRC_DIR/script HMI_DIR=$SRC_DIR/hmi app=$HMI_DIR/qml/NavigationApp.qml # hmi panel launched by default STYLE_SHEETS_GENERATED_INDICATOR=$HMI_DIR/style-sheets/the-style-sheets-have-been-generated-css.js +CONFIG_DIR=$HMI_DIR/config REPLAYER_LOG_FILE=none export REPLAYER_LOG_FILE @@ -172,13 +174,16 @@ do c) #set the map center case "$OPTARG" in paris) - center="2.34 48.86" + center="2.34 48.84" + config_file=fsa_paris.conf ;; tokyo) center="139.74 35.70" + config_file=fsa_tokyo.conf ;; london) center="-0.13 51.51" + config_file=fsa_london.conf ;; [0-9-]*) center=$OPTARG @@ -258,6 +263,9 @@ export NAVIT_GRAPHICS='sdl' # set the language to en_US for navit export LANGUAGE=en_US +# set the config file for Qt +cp $CONFIG_DIR/$config_file $HOME/.config/navigation/fsa.conf + # start the automotive message broker and wait for dbus service cd $AUTOMOTIVE_MESSAGE_BROKER_BIN_DIR if [ "$verbose" = "1" ] |