Init desktop notifications.

This commit is contained in:
Black Hat 2018-07-19 16:04:09 +08:00
parent 43f02c4fa1
commit 7dd9132176
6 changed files with 31 additions and 18 deletions

View File

@ -1,4 +1,4 @@
QT += quick QT += quick widgets
CONFIG += c++14 CONFIG += c++14
CONFIG += object_parallel_to_source CONFIG += object_parallel_to_source

View File

@ -15,7 +15,7 @@ Page {
connection: matriqueController.isLogin ? page.connection : undefined connection: matriqueController.isLogin ? page.connection : undefined
onNewMessage: console.log("New message in room " + room.displayName) onNewMessage: trayIcon.showMessage("New message", "New message for room " + room.displayName)
} }
RowLayout { RowLayout {

View File

@ -98,6 +98,7 @@ Item {
delegate: MessageDelegate {} delegate: MessageDelegate {}
onAtYBeginningChanged: atYBeginning && currentRoom ? currentRoom.getPreviousContent(50) : {} onAtYBeginningChanged: atYBeginning && currentRoom ? currentRoom.getPreviousContent(50) : {}
onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {}
ScrollBar.vertical: ScrollBar {} ScrollBar.vertical: ScrollBar {}

View File

@ -28,18 +28,18 @@ ApplicationWindow {
property alias token: matriqueController.token property alias token: matriqueController.token
} }
// Platform.SystemTrayIcon { Platform.SystemTrayIcon {
// id: trayIcon id: trayIcon
// visible: true visible: true
// iconSource: "qrc:/asset/img/icon.png" iconSource: "qrc:/asset/img/icon.png"
// onActivated: { onActivated: {
// window.show() window.show()
// window.raise() window.raise()
// window.requestActivate() window.requestActivate()
// } }
// } }
Controller { Controller {
id: matriqueController id: matriqueController
@ -163,7 +163,6 @@ ApplicationWindow {
Component.onCompleted: { Component.onCompleted: {
imageProvider.connection = matriqueController.connection imageProvider.connection = matriqueController.connection
console.log(matriqueController.homeserver, matriqueController.userID, matriqueController.token)
if (matriqueController.userID && matriqueController.token) { if (matriqueController.userID && matriqueController.token) {
console.log("Perform auto-login."); console.log("Perform auto-login.");
matriqueController.login(); matriqueController.login();

View File

@ -1,4 +1,4 @@
#include <QGuiApplication> #include <QApplication>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif #endif
QGuiApplication app(argc, argv); QApplication app(argc, argv);
// Enable this if you need proxy. // Enable this if you need proxy.
// QNetworkProxy proxy; // QNetworkProxy proxy;

View File

@ -1,5 +1,7 @@
#include "roomlistmodel.h" #include "roomlistmodel.h"
#include "events/roomevent.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QBrush> #include <QtGui/QBrush>
#include <QtGui/QColor> #include <QtGui/QColor>
@ -62,9 +64,20 @@ void RoomListModel::connectRoomSignals(QMatrixClient::Room* room) {
connect(room, &QMatrixClient::Room::avatarChanged, this, connect(room, &QMatrixClient::Room::avatarChanged, this,
[=] { refresh(room, {AvatarRole}); }); [=] { refresh(room, {AvatarRole}); });
connect( connect(room, &QMatrixClient::Room::unreadMessagesChanged, this,
room, &QMatrixClient::Room::aboutToAddNewMessages, this, [=](QMatrixClient::Room* r) {
[=](QMatrixClient::RoomEventsRange events) { emit newMessage(room); }); if (r->hasUnreadMessages()) emit newMessage(r);
});
// connect(
// room, &QMatrixClient::Room::aboutToAddNewMessages, this,
// [=](QMatrixClient::RoomEventsRange eventsRange) {
// for (QMatrixClient::RoomEvents events : eventsRange.const_iterator) {
// for (QMatrixClient::RoomEvent event : events) {
// qDebug() << event.fullJson();
// }
// }
// emit newMessage(room);
// });
} }
void RoomListModel::updateRoom(QMatrixClient::Room* room, void RoomListModel::updateRoom(QMatrixClient::Room* room,