From babe614555b09f5a62557b0ac7ec104710c7be1f Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 15 Oct 2018 06:49:30 +0800 Subject: [PATCH] More error indication. Also fixes #80. --- src/controller.cpp | 12 ++++++++++++ src/spectralroom.cpp | 2 ++ src/spectralroom.h | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/controller.cpp b/src/controller.cpp index dbb1934..d276fd1 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -74,6 +74,10 @@ void Controller::loginWithCredentials(QString serverAddr, QString user, account.sync(); addConnection(m_connection); }); + connect(m_connection, &Connection::networkError, + [=](QString error, QByteArray detail) { + emit errorOccured("Network", error); + }); connect(m_connection, &Connection::loginError, [=](QString error, QByteArray detail) { emit errorOccured("Login Failed", error); @@ -141,6 +145,14 @@ void Controller::invokeLogin() { c->loadState(); addConnection(c); }); + connect(c, &Connection::loginError, + [=](QString error, QByteArray detail) { + emit errorOccured("Login Failed", error); + }); + connect(c, &Connection::networkError, + [=](QString error, QByteArray detail) { + emit errorOccured("Network", error); + }); c->connectWithToken(account.userId(), accessToken, account.deviceId()); } } diff --git a/src/spectralroom.cpp b/src/spectralroom.cpp index 57966bf..ea6821d 100644 --- a/src/spectralroom.cpp +++ b/src/spectralroom.cpp @@ -14,6 +14,8 @@ SpectralRoom::SpectralRoom(Connection* connection, QString roomId, JoinState joinState) : Room(connection, std::move(roomId), joinState) { + connect(this, &Room::avatarChanged, this, + &SpectralRoom::inheritedAvatarChanged); connect(this, &SpectralRoom::notificationCountChanged, this, &SpectralRoom::countChanged); connect(this, &SpectralRoom::highlightCountChanged, this, diff --git a/src/spectralroom.h b/src/spectralroom.h index 75441a1..13bd7b1 100644 --- a/src/spectralroom.h +++ b/src/spectralroom.h @@ -10,7 +10,7 @@ using namespace QMatrixClient; class SpectralRoom : public Room { Q_OBJECT - Q_PROPERTY(QImage avatar READ getAvatar NOTIFY avatarChanged) + Q_PROPERTY(QImage avatar READ getAvatar NOTIFY inheritedAvatarChanged) Q_PROPERTY(bool hasUsersTyping READ hasUsersTyping NOTIFY typingChanged) Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged) Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY @@ -74,6 +74,7 @@ class SpectralRoom : public Room { signals: void cachedInputChanged(); void busyChanged(); + void inheritedAvatarChanged(); // https://bugreports.qt.io/browse/QTBUG-7684 public slots: void chooseAndUploadFile();