diff options
author | 2016-12-14 16:56:14 +0100 | |
---|---|---|
committer | 2016-12-16 10:05:20 +0100 | |
commit | 66f924e8baca29a2dd6bab8c6f17115b16ec4a2f (patch) | |
tree | b0a63ff9332c3cd5fec4308b67941fb85c7b8ba2 | |
parent | dd7bb40b885efbde6ca7121194403857ef263208 (diff) |
add visa card, start websocket inplementation
-rw-r--r-- | HomeScreen/HomeScreen.pro | 2 | ||||
-rw-r--r-- | HomeScreen/qml/Home.qml | 14 | ||||
-rw-r--r-- | HomeScreen/qml/images/Home/home.qrc | 1 | ||||
-rwxr-xr-x | HomeScreen/qml/images/Home/visa.png | bin | 0 -> 61687 bytes | |||
-rw-r--r-- | HomeScreen/src2/usermanagement.cpp | 28 | ||||
-rw-r--r-- | HomeScreen/src2/usermanagement.h | 6 |
6 files changed, 50 insertions, 1 deletions
diff --git a/HomeScreen/HomeScreen.pro b/HomeScreen/HomeScreen.pro index ac4f2d2..2f08a0f 100644 --- a/HomeScreen/HomeScreen.pro +++ b/HomeScreen/HomeScreen.pro @@ -14,7 +14,7 @@ TEMPLATE = app TARGET = HomeScreen -QT = qml quick dbus +QT = qml quick widgets dbus websockets CONFIG += c++11 include(../interfaces/interfaces.pri) diff --git a/HomeScreen/qml/Home.qml b/HomeScreen/qml/Home.qml index c4951fe..aadf6df 100644 --- a/HomeScreen/qml/Home.qml +++ b/HomeScreen/qml/Home.qml @@ -41,6 +41,17 @@ Item { source: './images/B14-90.png' visible: false } + Image { + id: visa + width: 200 + height: 124 + anchors.right: parent.right + anchors.rightMargin: 20 + anchors.top: parent.top + anchors.topMargin: 20 + source: './images/visa.png' + visible: false + } Item { id: hello anchors.horizontalCenter: parent.horizontalCenter @@ -84,6 +95,9 @@ Item { sign90.visible = show } + function showVisa(show) { + visa.visible = show + } GridView { anchors.centerIn: parent width: cellHeight * 3 diff --git a/HomeScreen/qml/images/Home/home.qrc b/HomeScreen/qml/images/Home/home.qrc index 4a112ce..14e2828 100644 --- a/HomeScreen/qml/images/Home/home.qrc +++ b/HomeScreen/qml/images/Home/home.qrc @@ -20,5 +20,6 @@ <file>HMI_AppLauncher_Settings_Active-01.png</file> <file>HMI_AppLauncher_Settings_Inactive-01.png</file> <file>B14-90.png</file> + <file>visa.png</file> </qresource> </RCC> diff --git a/HomeScreen/qml/images/Home/visa.png b/HomeScreen/qml/images/Home/visa.png Binary files differnew file mode 100755 index 0000000..1c854bc --- /dev/null +++ b/HomeScreen/qml/images/Home/visa.png diff --git a/HomeScreen/src2/usermanagement.cpp b/HomeScreen/src2/usermanagement.cpp index bbbbac1..f973001 100644 --- a/HomeScreen/src2/usermanagement.cpp +++ b/HomeScreen/src2/usermanagement.cpp @@ -11,6 +11,7 @@ UserManagement::UserManagement(QObject *home, QObject *shortcutArea, QObject *st connect(&timerTest, SIGNAL(timeout()), this, SLOT(slot_timerTest())); timerTest.setSingleShot(false); timerTest.start(5000); + connectWebsockets(QStringLiteral("wss://echo.websocket.org")); } void UserManagement::slot_timerTest() { @@ -25,10 +26,37 @@ void UserManagement::slot_timerTest() if(currentLanguage == "fr") { QLocale::setDefault(QLocale("fr_FR")); QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, true)); + QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false)); 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, "showVisa", Q_ARG(QVariant, true)); QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Hello José!")); } } +void UserManagement::connectWebsockets(const QUrl &url) +{ + QSslConfiguration config = QSslConfiguration::defaultConfiguration(); + config.setProtocol(QSsl::SecureProtocols); + webSocket.setSslConfiguration(config); + connect(&webSocket, &QWebSocket::connected, this, &UserManagement::onConnected); + connect(&webSocket, &QWebSocket::disconnected, this, &UserManagement::onClosed); + webSocket.open(QUrl(url)); +} +void UserManagement::onConnected() +{ + connect(&webSocket, &QWebSocket::textMessageReceived, + this, &UserManagement::onTextMessageReceived); + webSocket.sendTextMessage(QStringLiteral("Hello, world!")); + +} +void UserManagement::onTextMessageReceived(QString message) +{ + qWarning()<<"message received:"<<message; +} + +void UserManagement::onClosed() +{ + qWarning()<<"webSocket closed"; +} diff --git a/HomeScreen/src2/usermanagement.h b/HomeScreen/src2/usermanagement.h index 804df22..099c991 100644 --- a/HomeScreen/src2/usermanagement.h +++ b/HomeScreen/src2/usermanagement.h @@ -4,6 +4,7 @@ #include <QObject> #include "applicationmodel.h" #include <QTimer> +#include <QtWebSockets/QWebSocket> class UserManagement : public QObject { Q_OBJECT @@ -14,6 +15,9 @@ signals: public slots: void slot_timerTest(); + void onConnected(); + void onClosed(); + void onTextMessageReceived(QString message); private: QObject *home; QObject *shortcutArea; @@ -21,6 +25,8 @@ private: ApplicationModel *appModel; QTimer timerTest; QString currentLanguage; + QWebSocket webSocket; + void connectWebsockets(const QUrl &url); }; #endif // USERMANAGEMENT_H |