From: Philippe Lelong Date: Wed, 14 Dec 2016 10:58:20 +0000 (+0100) Subject: Home screen translation changes X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=staging%2FHomeScreen.git;a=commitdiff_plain;h=15e7b5003a6590f780cb115fb2bdb526ce68defc Home screen translation changes Signed-off-by: Philippe Lelong --- diff --git a/HomeScreen/HomeScreen.pro b/HomeScreen/HomeScreen.pro index b2afdd3..ac4f2d2 100644 --- a/HomeScreen/HomeScreen.pro +++ b/HomeScreen/HomeScreen.pro @@ -23,11 +23,13 @@ include(../ivi_layermanagement_api.pri) SOURCES += \ src/main.cpp \ src/homescreencontrolinterface.cpp \ - src/layouthandler.cpp + src/layouthandler.cpp \ + src2/usermanagement.cpp HEADERS += \ src/homescreencontrolinterface.h \ - src/layouthandler.h + src/layouthandler.h \ + src2/usermanagement.h OTHER_FILES += \ README.md diff --git a/HomeScreen/qml/Home.qml b/HomeScreen/qml/Home.qml index 142e7f5..a3603be 100644 --- a/HomeScreen/qml/Home.qml +++ b/HomeScreen/qml/Home.qml @@ -22,6 +22,8 @@ import Home 1.0 Item { id: root + property int pid: -1 + signal languageChanged Image { anchors.fill: parent @@ -29,8 +31,58 @@ Item { anchors.bottomMargin: -215 source: './images/AGL_HMI_Background_Car-01.png' } + Image { + id: sign90 + width: 200 + height: 200 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 20 + source: './images/B14-90.png' + visible: false + } + Item { + id: hello + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 40 + visible: false + Text { + id: helloText + anchors.centerIn: parent + color: "white" + text: "Hello José!" + font.pixelSize: 40 + font.family: "Roboto" + SequentialAnimation on font.letterSpacing { + id: animation1 + loops: 1; + NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 } + onRunningChanged: { + if(running) + hello.visible = true + else + hello.visible = false + } + } - property int pid: -1 + SequentialAnimation on opacity { + id: animation2 + loops: 1; + NumberAnimation { from: 1; to: 0; duration: 2600 } + PauseAnimation { duration: 400 } + } + } + } + function showHello(helloString) { + helloText.text = helloString + animation1.running = true; + animation2.running = true; + } + + function showSign90(show) { + sign90.visible = show + } GridView { anchors.centerIn: parent @@ -47,6 +99,22 @@ Item { Image { anchors.fill: parent source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive') + Label { + id: labelName + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + y: 257 + font.pixelSize: 32 + font.family: "Roboto" + color: "white" + text: '%1'.arg(model.name) + function myChangeLanguage() { + text = '%1'.arg(model.name) + } + Component.onCompleted: { + root.languageChanged.connect(myChangeLanguage) + } + } } onClicked: { console.log("app is ", model.id) diff --git a/HomeScreen/qml/ShortcutArea.qml b/HomeScreen/qml/ShortcutArea.qml index 1d7dd92..092b034 100644 --- a/HomeScreen/qml/ShortcutArea.qml +++ b/HomeScreen/qml/ShortcutArea.qml @@ -28,19 +28,36 @@ Item { id: applicationModel ListElement { name: 'Home' - application: '' + application: 'home@0.1' + label: 'HOME' } ListElement { name: 'Multimedia' application: 'mediaplayer@0.1' + label: 'MULTIMEDIA' } ListElement { name: 'HVAC' application: 'hvac@0.1' + label: 'HVAC' } ListElement { name: 'Navigation' application: 'navigation@0.1' + label: 'NAVIGATION' + } + } + function languageChanged(lang) { + if(lang === "fr") { + applicationModel.setProperty(0, "label", 'ACCEUIL') + applicationModel.setProperty(1, "label", 'MULTIMÉDIA') + applicationModel.setProperty(2, "label", 'CLIMATISATION') + applicationModel.setProperty(3, "label", 'NAVIGATION') + } else { + applicationModel.setProperty(0, "label", 'HOME') + applicationModel.setProperty(1, "label", 'MULTIMEDIA') + applicationModel.setProperty(2, "label", 'HVAC') + applicationModel.setProperty(3, "label", 'NAVIGATION') } } diff --git a/HomeScreen/qml/ShortcutIcon.qml b/HomeScreen/qml/ShortcutIcon.qml index 299f6a8..34ade01 100644 --- a/HomeScreen/qml/ShortcutIcon.qml +++ b/HomeScreen/qml/ShortcutIcon.qml @@ -16,6 +16,7 @@ */ import QtQuick 2.2 +import QtQuick.Controls 1.0 MouseArea { id: root @@ -33,6 +34,16 @@ MouseArea { source: './images/Shortcut/HMI_Shortcut_%1_Active-01.png'.arg(root.name) opacity: 1.0 - icon.opacity } + Label { + id: labelName + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + y: 155 + font.pixelSize: 20 + font.family: "Roboto" + color: "white" + text: '%1'.arg(model.label) + } states: [ State { when: root.active diff --git a/HomeScreen/qml/StatusArea.qml b/HomeScreen/qml/StatusArea.qml index ca9a3ef..12d0d46 100644 --- a/HomeScreen/qml/StatusArea.qml +++ b/HomeScreen/qml/StatusArea.qml @@ -24,6 +24,62 @@ Item { id: root width: 295 height: 218 + function languageChanged(lang) { + if(lang === "fr") { + labelTime.text = Qt.formatTime(now, 'HH:mm').toUpperCase() + labelTemperature.text = '18°C' + switch(now.getDay()) { + case 1: + labelDay.text = 'LUNDI' + break + case 2: + labelDay.text = 'MARDI' + break + case 3: + labelDay.text = 'MERCREDI' + break + case 4: + labelDay.text = 'JEUDI' + break + case 5: + labelDay.text = 'VENDREDI' + break + case 6: + labelDay.text = 'SAMEDI' + break + case 7: + labelDay.text = 'DIMANCHE' + break + } + + } else { + labelTime.text = Qt.formatTime(now, 'h:mm ap').toUpperCase() + labelTemperature.text = '64°F' + switch(now.getDay()) { + case 1: + labelDay.text = 'MONDAY' + break + case 2: + labelDay.text = 'TUESDAY' + break + case 3: + labelDay.text = 'WEDNESDAY' + break + case 4: + labelDay.text = 'THURSDAY' + break + case 5: + labelDay.text = 'FRIDAY' + break + case 6: + labelDay.text = 'SATURDAY' + break + case 7: + labelDay.text = 'SUNDAY' + break + } + } + } property date now: new Date Timer { @@ -43,11 +99,13 @@ Item { anchors.margins: 40 spacing: 0 Label { + id: labelDay Layout.fillWidth: true Layout.fillHeight: true text: Qt.formatDate(now, 'dddd').toUpperCase() font.family: 'Roboto' - font.pixelSize: 13 +// font.pixelSize: 13 + font.pixelSize: 18 color: 'white' verticalAlignment: Text.AlignVCenter // Rectangle { @@ -60,6 +118,7 @@ Item { // } } Label { + id: labelTime Layout.fillWidth: true Layout.fillHeight: true text: Qt.formatTime(now, 'h:mm ap').toUpperCase() @@ -77,6 +136,7 @@ Item { source: './images/Weather/WeatherIcons_Rain-01.png' } Label { + id: labelTemperature text: '64°F' color: 'white' font.family: 'Helvetica' diff --git a/HomeScreen/qml/TopArea.qml b/HomeScreen/qml/TopArea.qml index fdf5a13..76430e2 100644 --- a/HomeScreen/qml/TopArea.qml +++ b/HomeScreen/qml/TopArea.qml @@ -29,12 +29,14 @@ Image { spacing: 0 ShortcutArea { id: shortcutArea + objectName: "ShortcutArea" Layout.fillWidth: true Layout.fillHeight: true Layout.preferredWidth: 785 } StatusArea { id: statusArea + objectName: "StatusArea" Layout.fillWidth: true Layout.fillHeight: true Layout.preferredWidth: 295 diff --git a/HomeScreen/qml/images/Home/B14-90.png b/HomeScreen/qml/images/Home/B14-90.png new file mode 100755 index 0000000..702f8c6 Binary files /dev/null and b/HomeScreen/qml/images/Home/B14-90.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png index 888d0bd..b37a2d9 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png index ab83b0e..c4b12a9 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Connectivity_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png index 11d39e5..d1fba09 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png index 6c0b914..138ebf7 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Dashboard_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png index efc11e9..deeb402 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png index b528376..92cd8a8 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_HVAC_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png index 1c99ac4..c1af827 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png index 0bed61d..9a9c96a 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Multimedia_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png index e7ad085..e5bae8b 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png index dd40750..cc9cb1a 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Navigation_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png index 2df01d3..c52d5bb 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png index ec62b87..d55e5fb 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_POI_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png index 2150581..7a079e2 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png index 61dcedc..0de908b 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Phone_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png index 1aa5a01..8503ae2 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png index 616983e..f8693c9 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Radio_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png index 1d13fd6..ff030ef 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Active-01.png differ diff --git a/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png index 027f1fe..15bdeb8 100644 Binary files a/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png and b/HomeScreen/qml/images/Home/HMI_AppLauncher_Settings_Inactive-01.png differ diff --git a/HomeScreen/qml/images/Home/home.qrc b/HomeScreen/qml/images/Home/home.qrc index 7dde212..4a112ce 100644 --- a/HomeScreen/qml/images/Home/home.qrc +++ b/HomeScreen/qml/images/Home/home.qrc @@ -19,5 +19,6 @@ HMI_AppLauncher_Radio_Inactive-01.png HMI_AppLauncher_Settings_Active-01.png HMI_AppLauncher_Settings_Inactive-01.png + B14-90.png diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC-01.png index f5188f5..221fe60 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC_Active-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC_Active-01.png index abe92d2..cbd625a 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC_Active-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_HVAC_Active-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home-01.png index 9aca151..3685d4a 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home_Active-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home_Active-01.png index 696168f..4c64670 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home_Active-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Home_Active-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia-01.png index 229860c..797d893 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia_Active-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia_Active-01.png index b0a023c..3d831bf 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia_Active-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Multimedia_Active-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation-01.png index 34b0671..a58534c 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation-01.png differ diff --git a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation_Active-01.png b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation_Active-01.png index 98e6146..99fbc23 100644 Binary files a/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation_Active-01.png and b/HomeScreen/qml/images/Shortcut/HMI_Shortcut_Navigation_Active-01.png differ diff --git a/HomeScreen/qml/main.qml b/HomeScreen/qml/main.qml index 6a515fc..c97702d 100644 --- a/HomeScreen/qml/main.qml +++ b/HomeScreen/qml/main.qml @@ -36,7 +36,7 @@ Window { anchors.centerIn: parent width: 1080 height: 1920 - scale: 1.0 + scale: 1 source: './images/AGL_HMI_Background_NoCar-01.png' ColumnLayout { @@ -59,6 +59,7 @@ Window { Home { id: appLauncherAreaLauncher + objectName: "Home" Layout.fillWidth: true Layout.fillHeight: true Layout.preferredHeight: 1920 - 218 - 215 diff --git a/HomeScreen/src/main.cpp b/HomeScreen/src/main.cpp index ef7a015..4e928c6 100644 --- a/HomeScreen/src/main.cpp +++ b/HomeScreen/src/main.cpp @@ -26,6 +26,7 @@ #include "../src2/applicationlauncher.h" #include "../src2/statusbarmodel.h" #include "../src2/applicationmodel.h" +#include "../src2/usermanagement.h" void noOutput(QtMsgType, const QMessageLogContext &, const QString &) { @@ -62,7 +63,6 @@ int main(int argc, char *argv[]) qmlRegisterType("HomeScreen", 1, 0, "StatusBarModel"); QQmlApplicationEngine engine; - LayoutHandler* layoutHandler = new LayoutHandler(); HomeScreenControlInterface* hsci = new HomeScreenControlInterface(); @@ -75,6 +75,10 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("layoutHandler", layoutHandler); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - + QObject *home = engine.rootObjects().first()->findChild("Home"); + QObject *shortcutArea = engine.rootObjects().first()->findChild("ShortcutArea"); + QObject *statusArea = engine.rootObjects().first()->findChild("StatusArea"); + UserManagement userManagement(home, shortcutArea, statusArea); + Q_UNUSED(userManagement); return a.exec(); } diff --git a/HomeScreen/src2/appinfo.cpp b/HomeScreen/src2/appinfo.cpp index 6b61632..4792b52 100644 --- a/HomeScreen/src2/appinfo.cpp +++ b/HomeScreen/src2/appinfo.cpp @@ -108,6 +108,10 @@ QString AppInfo::name() const { return d->name; } +void AppInfo::setName(const QString &name) +{ + d->name = name; +} QString AppInfo::description() const { diff --git a/HomeScreen/src2/appinfo.h b/HomeScreen/src2/appinfo.h index a800a80..a108d85 100644 --- a/HomeScreen/src2/appinfo.h +++ b/HomeScreen/src2/appinfo.h @@ -56,6 +56,7 @@ public: friend QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &appInfo); friend const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &appInfo); + void setName(const QString &name); private: class Private; QSharedDataPointer d; diff --git a/HomeScreen/src2/applicationmodel.cpp b/HomeScreen/src2/applicationmodel.cpp index 2a16ace..136161a 100644 --- a/HomeScreen/src2/applicationmodel.cpp +++ b/HomeScreen/src2/applicationmodel.cpp @@ -52,11 +52,36 @@ ApplicationModel::Private::Private(ApplicationModel *parent) data.append(AppInfo(QStringLiteral("POI"), QStringLiteral("POINT OF\nINTEREST"), QStringLiteral("poi@0.1"))); } } +void ApplicationModel::changeLanguage(const QString &lang) +{ //todo: use QT translator instead of hardcoded strings. + if(lang == "fr") { + d->data[0].setName("CLIMATISATION"); + d->data[1].setName("NAVIGATION"); + d->data[2].setName("TÉLÉPHONE"); + d->data[3].setName("RADIO"); + d->data[4].setName("MULTIMÉDIA"); + d->data[5].setName("CONNEXIONS"); + d->data[6].setName("TABLEAU DE\nBORD"); + d->data[7].setName("PARAMÈTRES"); + d->data[8].setName("POINT D'INTÉRÊT"); + } else { + d->data[0].setName("HVAC"); + d->data[1].setName("NAVIGATION"); + d->data[2].setName("PHONE"); + d->data[3].setName("RADIO"); + d->data[4].setName("MULTIMEDIA"); + d->data[5].setName("CONNECTIVITY"); + d->data[6].setName("DASHBOARD"); + d->data[7].setName("SETTINGS"); + d->data[8].setName("POINT OF\nINTEREST"); + } +} ApplicationModel::ApplicationModel(QObject *parent) : QAbstractListModel(parent) , d(new Private(this)) { + setObjectName("ApplicationModel"); } ApplicationModel::~ApplicationModel() diff --git a/HomeScreen/src2/applicationmodel.h b/HomeScreen/src2/applicationmodel.h index bffc4c9..40741bd 100644 --- a/HomeScreen/src2/applicationmodel.h +++ b/HomeScreen/src2/applicationmodel.h @@ -30,7 +30,7 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; - + void changeLanguage(const QString &lang); private: class Private; Private *d; diff --git a/HomeScreen/src2/usermanagement.cpp b/HomeScreen/src2/usermanagement.cpp new file mode 100644 index 0000000..bbbbac1 --- /dev/null +++ b/HomeScreen/src2/usermanagement.cpp @@ -0,0 +1,34 @@ +#include "usermanagement.h" +#include +#include +UserManagement::UserManagement(QObject *home, QObject *shortcutArea, QObject *statusArea) : QObject() +{ + this->home = home; + this->appModel = home->findChild("ApplicationModel"); + this->shortcutArea = shortcutArea; + this->statusArea = statusArea; + this->currentLanguage = "en"; + connect(&timerTest, SIGNAL(timeout()), this, SLOT(slot_timerTest())); + timerTest.setSingleShot(false); + timerTest.start(5000); +} +void UserManagement::slot_timerTest() +{ + if(currentLanguage == "fr") + currentLanguage = "en"; + else + currentLanguage = "fr"; + appModel->changeLanguage(currentLanguage); + QMetaObject::invokeMethod(home, "languageChanged"); + QMetaObject::invokeMethod(shortcutArea, "languageChanged", Q_ARG(QVariant, currentLanguage)); + QMetaObject::invokeMethod(statusArea, "languageChanged", Q_ARG(QVariant, currentLanguage)); + if(currentLanguage == "fr") { + QLocale::setDefault(QLocale("fr_FR")); + QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, true)); + QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Bonjour José!")); + } else { + QLocale::setDefault(QLocale("en_US")); + QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, false)); + QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Hello José!")); + } +} diff --git a/HomeScreen/src2/usermanagement.h b/HomeScreen/src2/usermanagement.h new file mode 100644 index 0000000..804df22 --- /dev/null +++ b/HomeScreen/src2/usermanagement.h @@ -0,0 +1,26 @@ +#ifndef USERMANAGEMENT_H +#define USERMANAGEMENT_H + +#include +#include "applicationmodel.h" +#include +class UserManagement : public QObject +{ + Q_OBJECT +public: + explicit UserManagement(QObject *home, QObject *shortcutArea, QObject *statusArea); + +signals: + +public slots: + void slot_timerTest(); +private: + QObject *home; + QObject *shortcutArea; + QObject *statusArea; + ApplicationModel *appModel; + QTimer timerTest; + QString currentLanguage; +}; + +#endif // USERMANAGEMENT_H