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
Item {
id: root
+ property int pid: -1
+ signal languageChanged
Image {
anchors.fill: parent
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
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)
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')
}
}
*/
import QtQuick 2.2
+import QtQuick.Controls 1.0
MouseArea {
id: root
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
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 {
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 {
// }
}
Label {
+ id: labelTime
Layout.fillWidth: true
Layout.fillHeight: true
text: Qt.formatTime(now, 'h:mm ap').toUpperCase()
source: './images/Weather/WeatherIcons_Rain-01.png'
}
Label {
+ id: labelTemperature
text: '64°F'
color: 'white'
font.family: 'Helvetica'
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
<file>HMI_AppLauncher_Radio_Inactive-01.png</file>
<file>HMI_AppLauncher_Settings_Active-01.png</file>
<file>HMI_AppLauncher_Settings_Inactive-01.png</file>
+ <file>B14-90.png</file>
</qresource>
</RCC>
anchors.centerIn: parent
width: 1080
height: 1920
- scale: 1.0
+ scale: 1
source: './images/AGL_HMI_Background_NoCar-01.png'
ColumnLayout {
Home {
id: appLauncherAreaLauncher
+ objectName: "Home"
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight: 1920 - 218 - 215
#include "../src2/applicationlauncher.h"
#include "../src2/statusbarmodel.h"
#include "../src2/applicationmodel.h"
+#include "../src2/usermanagement.h"
void noOutput(QtMsgType, const QMessageLogContext &, const QString &)
{
qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
QQmlApplicationEngine engine;
-
LayoutHandler* layoutHandler = new LayoutHandler();
HomeScreenControlInterface* hsci = new HomeScreenControlInterface();
engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
-
+ QObject *home = engine.rootObjects().first()->findChild<QObject *>("Home");
+ QObject *shortcutArea = engine.rootObjects().first()->findChild<QObject *>("ShortcutArea");
+ QObject *statusArea = engine.rootObjects().first()->findChild<QObject *>("StatusArea");
+ UserManagement userManagement(home, shortcutArea, statusArea);
+ Q_UNUSED(userManagement);
return a.exec();
}
{
return d->name;
}
+void AppInfo::setName(const QString &name)
+{
+ d->name = name;
+}
QString AppInfo::description() const
{
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<Private> d;
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()
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
-
+ void changeLanguage(const QString &lang);
private:
class Private;
Private *d;
--- /dev/null
+#include "usermanagement.h"
+#include <QApplication>
+#include <QDebug>
+UserManagement::UserManagement(QObject *home, QObject *shortcutArea, QObject *statusArea) : QObject()
+{
+ this->home = home;
+ this->appModel = home->findChild<ApplicationModel *>("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é!"));
+ }
+}
--- /dev/null
+#ifndef USERMANAGEMENT_H
+#define USERMANAGEMENT_H
+
+#include <QObject>
+#include "applicationmodel.h"
+#include <QTimer>
+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