|
|
@ -141,21 +141,21 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
typingRefresher_ = new QTimer(this); |
|
|
|
typingRefresher_ = new QTimer(this); |
|
|
|
typingRefresher_->setInterval(TYPING_REFRESH_TIMEOUT); |
|
|
|
typingRefresher_->setInterval(TYPING_REFRESH_TIMEOUT); |
|
|
|
|
|
|
|
|
|
|
|
connect(user_info_widget_, &UserInfoWidget::logout, this, [=]() { |
|
|
|
connect(user_info_widget_, &UserInfoWidget::logout, this, [this]() { |
|
|
|
client_->logout(); |
|
|
|
client_->logout(); |
|
|
|
emit showOverlayProgressBar(); |
|
|
|
emit showOverlayProgressBar(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), &MatrixClient::loggedOut, this, &ChatPage::logout); |
|
|
|
connect(client_.data(), &MatrixClient::loggedOut, this, &ChatPage::logout); |
|
|
|
|
|
|
|
|
|
|
|
connect(top_bar_, &TopRoomBar::inviteUsers, this, [=](QStringList users) { |
|
|
|
connect(top_bar_, &TopRoomBar::inviteUsers, this, [this](QStringList users) { |
|
|
|
for (int ii = 0; ii < users.size(); ++ii) { |
|
|
|
for (int ii = 0; ii < users.size(); ++ii) { |
|
|
|
QTimer::singleShot(ii * 1000, this, [=]() { |
|
|
|
QTimer::singleShot(ii * 1000, this, [this, &ii, &users]() { |
|
|
|
client_->inviteUser(current_room_, users.at(ii)); |
|
|
|
client_->inviteUser(current_room_, users.at(ii)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect(room_list_, &RoomList::roomChanged, this, [=](const QString &roomid) { |
|
|
|
connect(room_list_, &RoomList::roomChanged, this, [this](const QString &roomid) { |
|
|
|
QStringList users; |
|
|
|
QStringList users; |
|
|
|
|
|
|
|
|
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) { |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) { |
|
|
@ -178,7 +178,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
connect(room_list_, &RoomList::acceptInvite, client_.data(), &MatrixClient::joinRoom); |
|
|
|
connect(room_list_, &RoomList::acceptInvite, client_.data(), &MatrixClient::joinRoom); |
|
|
|
connect(room_list_, &RoomList::declineInvite, client_.data(), &MatrixClient::leaveRoom); |
|
|
|
connect(room_list_, &RoomList::declineInvite, client_.data(), &MatrixClient::leaveRoom); |
|
|
|
|
|
|
|
|
|
|
|
connect(text_input_, &TextInputWidget::startedTyping, this, [=]() { |
|
|
|
connect(text_input_, &TextInputWidget::startedTyping, this, [this]() { |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -186,7 +186,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
client_->sendTypingNotification(current_room_); |
|
|
|
client_->sendTypingNotification(current_room_); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect(text_input_, &TextInputWidget::stoppedTyping, this, [=]() { |
|
|
|
connect(text_input_, &TextInputWidget::stoppedTyping, this, [this]() { |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -194,7 +194,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
client_->removeTypingNotification(current_room_); |
|
|
|
client_->removeTypingNotification(current_room_); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect(typingRefresher_, &QTimer::timeout, this, [=]() { |
|
|
|
connect(typingRefresher_, &QTimer::timeout, this, [this]() { |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) |
|
|
|
if (!userSettings_->isTypingNotificationsEnabled()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -229,62 +229,66 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
connect(text_input_, |
|
|
|
connect(text_input_, |
|
|
|
&TextInputWidget::uploadImage, |
|
|
|
&TextInputWidget::uploadImage, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
[this](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
client_->uploadImage(current_room_, fn, data); |
|
|
|
client_->uploadImage(current_room_, fn, data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect(text_input_, |
|
|
|
connect(text_input_, |
|
|
|
&TextInputWidget::uploadFile, |
|
|
|
&TextInputWidget::uploadFile, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
[this](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
client_->uploadFile(current_room_, fn, data); |
|
|
|
client_->uploadFile(current_room_, fn, data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect(text_input_, |
|
|
|
connect(text_input_, |
|
|
|
&TextInputWidget::uploadAudio, |
|
|
|
&TextInputWidget::uploadAudio, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
[this](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
client_->uploadAudio(current_room_, fn, data); |
|
|
|
client_->uploadAudio(current_room_, fn, data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(text_input_, |
|
|
|
connect(text_input_, |
|
|
|
&TextInputWidget::uploadVideo, |
|
|
|
&TextInputWidget::uploadVideo, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
[this](QSharedPointer<QIODevice> data, const QString &fn) { |
|
|
|
client_->uploadVideo(current_room_, fn, data); |
|
|
|
client_->uploadVideo(current_room_, fn, data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect( |
|
|
|
connect( |
|
|
|
client_.data(), &MatrixClient::roomCreationFailed, this, &ChatPage::showNotification); |
|
|
|
client_.data(), &MatrixClient::roomCreationFailed, this, &ChatPage::showNotification); |
|
|
|
connect(client_.data(), &MatrixClient::joinFailed, this, &ChatPage::showNotification); |
|
|
|
connect(client_.data(), &MatrixClient::joinFailed, this, &ChatPage::showNotification); |
|
|
|
connect(client_.data(), &MatrixClient::uploadFailed, this, [=](int, const QString &msg) { |
|
|
|
connect(client_.data(), &MatrixClient::uploadFailed, this, [this](int, const QString &msg) { |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
emit showNotification(msg); |
|
|
|
emit showNotification(msg); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), |
|
|
|
connect( |
|
|
|
|
|
|
|
client_.data(), |
|
|
|
&MatrixClient::imageUploaded, |
|
|
|
&MatrixClient::imageUploaded, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
[this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
view_manager_->queueImageMessage(roomid, filename, url, mime, dsize); |
|
|
|
view_manager_->queueImageMessage(roomid, filename, url, mime, dsize); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), |
|
|
|
connect( |
|
|
|
|
|
|
|
client_.data(), |
|
|
|
&MatrixClient::fileUploaded, |
|
|
|
&MatrixClient::fileUploaded, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
[this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
view_manager_->queueFileMessage(roomid, filename, url, mime, dsize); |
|
|
|
view_manager_->queueFileMessage(roomid, filename, url, mime, dsize); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), |
|
|
|
connect( |
|
|
|
|
|
|
|
client_.data(), |
|
|
|
&MatrixClient::audioUploaded, |
|
|
|
&MatrixClient::audioUploaded, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
[this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
view_manager_->queueAudioMessage(roomid, filename, url, mime, dsize); |
|
|
|
view_manager_->queueAudioMessage(roomid, filename, url, mime, dsize); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), |
|
|
|
connect( |
|
|
|
|
|
|
|
client_.data(), |
|
|
|
&MatrixClient::videoUploaded, |
|
|
|
&MatrixClient::videoUploaded, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
[this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
text_input_->hideUploadSpinner(); |
|
|
|
view_manager_->queueVideoMessage(roomid, filename, url, mime, dsize); |
|
|
|
view_manager_->queueVideoMessage(roomid, filename, url, mime, dsize); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -309,13 +313,13 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
connect(client_.data(), |
|
|
|
connect(client_.data(), |
|
|
|
&MatrixClient::communityProfileRetrieved, |
|
|
|
&MatrixClient::communityProfileRetrieved, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QString communityId, QJsonObject profile) { |
|
|
|
[this](QString communityId, QJsonObject profile) { |
|
|
|
communities_[communityId]->parseProfile(profile); |
|
|
|
communities_[communityId]->parseProfile(profile); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), |
|
|
|
connect(client_.data(), |
|
|
|
&MatrixClient::communityRoomsRetrieved, |
|
|
|
&MatrixClient::communityRoomsRetrieved, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](QString communityId, QJsonObject rooms) { |
|
|
|
[this](QString communityId, QJsonObject rooms) { |
|
|
|
communities_[communityId]->parseRooms(rooms); |
|
|
|
communities_[communityId]->parseRooms(rooms); |
|
|
|
|
|
|
|
|
|
|
|
if (communityId == current_community_) { |
|
|
|
if (communityId == current_community_) { |
|
|
@ -328,27 +332,27 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
connect(client_.data(), &MatrixClient::joinedRoom, this, [=](const QString &room_id) { |
|
|
|
connect(client_.data(), &MatrixClient::joinedRoom, this, [this](const QString &room_id) { |
|
|
|
emit showNotification("You joined the room."); |
|
|
|
emit showNotification("You joined the room."); |
|
|
|
removeInvite(room_id); |
|
|
|
removeInvite(room_id); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), &MatrixClient::invitedUser, this, [=](QString, QString user) { |
|
|
|
connect(client_.data(), &MatrixClient::invitedUser, this, [this](QString, QString user) { |
|
|
|
emit showNotification(QString("Invited user %1").arg(user)); |
|
|
|
emit showNotification(QString("Invited user %1").arg(user)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), &MatrixClient::roomCreated, this, [=](QString room_id) { |
|
|
|
connect(client_.data(), &MatrixClient::roomCreated, this, [this](QString room_id) { |
|
|
|
emit showNotification(QString("Room %1 created").arg(room_id)); |
|
|
|
emit showNotification(QString("Room %1 created").arg(room_id)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(client_.data(), &MatrixClient::leftRoom, this, &ChatPage::removeRoom); |
|
|
|
connect(client_.data(), &MatrixClient::leftRoom, this, &ChatPage::removeRoom); |
|
|
|
|
|
|
|
|
|
|
|
showContentTimer_ = new QTimer(this); |
|
|
|
showContentTimer_ = new QTimer(this); |
|
|
|
showContentTimer_->setSingleShot(true); |
|
|
|
showContentTimer_->setSingleShot(true); |
|
|
|
connect(showContentTimer_, &QTimer::timeout, this, [=]() { |
|
|
|
connect(showContentTimer_, &QTimer::timeout, this, [this]() { |
|
|
|
consensusTimer_->stop(); |
|
|
|
consensusTimer_->stop(); |
|
|
|
emit contentLoaded(); |
|
|
|
emit contentLoaded(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
consensusTimer_ = new QTimer(this); |
|
|
|
consensusTimer_ = new QTimer(this); |
|
|
|
connect(consensusTimer_, &QTimer::timeout, this, [=]() { |
|
|
|
connect(consensusTimer_, &QTimer::timeout, this, [this]() { |
|
|
|
if (view_manager_->hasLoaded()) { |
|
|
|
if (view_manager_->hasLoaded()) { |
|
|
|
// Remove the spinner overlay.
|
|
|
|
// Remove the spinner overlay.
|
|
|
|
emit contentLoaded(); |
|
|
|
emit contentLoaded(); |
|
|
@ -361,7 +365,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
connect(initialSyncTimer_, &QTimer::timeout, this, &ChatPage::retryInitialSync); |
|
|
|
connect(initialSyncTimer_, &QTimer::timeout, this, &ChatPage::retryInitialSync); |
|
|
|
|
|
|
|
|
|
|
|
syncTimeoutTimer_ = new QTimer(this); |
|
|
|
syncTimeoutTimer_ = new QTimer(this); |
|
|
|
connect(syncTimeoutTimer_, &QTimer::timeout, this, [=]() { |
|
|
|
connect(syncTimeoutTimer_, &QTimer::timeout, this, [this]() { |
|
|
|
if (client_->getHomeServer().isEmpty()) { |
|
|
|
if (client_->getHomeServer().isEmpty()) { |
|
|
|
syncTimeoutTimer_->stop(); |
|
|
|
syncTimeoutTimer_->stop(); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -374,7 +378,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, |
|
|
|
connect(communitiesList_, |
|
|
|
connect(communitiesList_, |
|
|
|
&CommunitiesList::communityChanged, |
|
|
|
&CommunitiesList::communityChanged, |
|
|
|
this, |
|
|
|
this, |
|
|
|
[=](const QString &communityId) { |
|
|
|
[this](const QString &communityId) { |
|
|
|
current_community_ = communityId; |
|
|
|
current_community_ = communityId; |
|
|
|
|
|
|
|
|
|
|
|
if (communityId == "world") |
|
|
|
if (communityId == "world") |
|
|
@ -577,8 +581,8 @@ ChatPage::updateOwnProfileInfo(const QUrl &avatar_url, const QString &display_na |
|
|
|
if (avatar_url.isValid()) |
|
|
|
if (avatar_url.isValid()) |
|
|
|
client_->fetchUserAvatar( |
|
|
|
client_->fetchUserAvatar( |
|
|
|
avatar_url, |
|
|
|
avatar_url, |
|
|
|
[=](QImage img) { user_info_widget_->setAvatar(img); }, |
|
|
|
[this](QImage img) { user_info_widget_->setAvatar(img); }, |
|
|
|
[=](QString error) { qWarning() << error << ": failed to fetch own avatar"; }); |
|
|
|
[](QString error) { qWarning() << error << ": failed to fetch own avatar"; }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
@ -691,24 +695,24 @@ ChatPage::showQuickSwitcher() |
|
|
|
if (quickSwitcher_.isNull()) { |
|
|
|
if (quickSwitcher_.isNull()) { |
|
|
|
quickSwitcher_ = QSharedPointer<QuickSwitcher>( |
|
|
|
quickSwitcher_ = QSharedPointer<QuickSwitcher>( |
|
|
|
new QuickSwitcher(this), |
|
|
|
new QuickSwitcher(this), |
|
|
|
[=](QuickSwitcher *switcher) { switcher->deleteLater(); }); |
|
|
|
[](QuickSwitcher *switcher) { switcher->deleteLater(); }); |
|
|
|
|
|
|
|
|
|
|
|
connect(quickSwitcher_.data(), |
|
|
|
connect(quickSwitcher_.data(), |
|
|
|
&QuickSwitcher::roomSelected, |
|
|
|
&QuickSwitcher::roomSelected, |
|
|
|
room_list_, |
|
|
|
room_list_, |
|
|
|
&RoomList::highlightSelectedRoom); |
|
|
|
&RoomList::highlightSelectedRoom); |
|
|
|
|
|
|
|
|
|
|
|
connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() { |
|
|
|
connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [this]() { |
|
|
|
if (!this->quickSwitcherModal_.isNull()) |
|
|
|
if (!quickSwitcherModal_.isNull()) |
|
|
|
this->quickSwitcherModal_->hide(); |
|
|
|
quickSwitcherModal_->hide(); |
|
|
|
this->text_input_->setFocus(Qt::FocusReason::PopupFocusReason); |
|
|
|
text_input_->setFocus(Qt::FocusReason::PopupFocusReason); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (quickSwitcherModal_.isNull()) { |
|
|
|
if (quickSwitcherModal_.isNull()) { |
|
|
|
quickSwitcherModal_ = QSharedPointer<OverlayModal>( |
|
|
|
quickSwitcherModal_ = QSharedPointer<OverlayModal>( |
|
|
|
new OverlayModal(MainWindow::instance(), quickSwitcher_.data()), |
|
|
|
new OverlayModal(MainWindow::instance(), quickSwitcher_.data()), |
|
|
|
[=](OverlayModal *modal) { modal->deleteLater(); }); |
|
|
|
[](OverlayModal *modal) { modal->deleteLater(); }); |
|
|
|
quickSwitcherModal_->setColor(QColor(30, 30, 30, 170)); |
|
|
|
quickSwitcherModal_->setColor(QColor(30, 30, 30, 170)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -934,13 +938,13 @@ ChatPage::showReadReceipts(const QString &event_id) |
|
|
|
if (receiptsDialog_.isNull()) { |
|
|
|
if (receiptsDialog_.isNull()) { |
|
|
|
receiptsDialog_ = QSharedPointer<dialogs::ReadReceipts>( |
|
|
|
receiptsDialog_ = QSharedPointer<dialogs::ReadReceipts>( |
|
|
|
new dialogs::ReadReceipts(this), |
|
|
|
new dialogs::ReadReceipts(this), |
|
|
|
[=](dialogs::ReadReceipts *dialog) { dialog->deleteLater(); }); |
|
|
|
[](dialogs::ReadReceipts *dialog) { dialog->deleteLater(); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (receiptsModal_.isNull()) { |
|
|
|
if (receiptsModal_.isNull()) { |
|
|
|
receiptsModal_ = QSharedPointer<OverlayModal>( |
|
|
|
receiptsModal_ = QSharedPointer<OverlayModal>( |
|
|
|
new OverlayModal(MainWindow::instance(), receiptsDialog_.data()), |
|
|
|
new OverlayModal(MainWindow::instance(), receiptsDialog_.data()), |
|
|
|
[=](OverlayModal *modal) { modal->deleteLater(); }); |
|
|
|
[](OverlayModal *modal) { modal->deleteLater(); }); |
|
|
|
receiptsModal_->setColor(QColor(30, 30, 30, 170)); |
|
|
|
receiptsModal_->setColor(QColor(30, 30, 30, 170)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|