summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authortrilene <trilene@runbox.com>2020-07-10 19:39:44 -0400
committertrilene <trilene@runbox.com>2020-07-10 19:39:44 -0400
commitc73cfe181006fe3be8a3f141acda5c8a1318e47a (patch)
tree5232569c34b91653e2fe0e4220e42bd8d3196303 /src
parentSupport voice calls (diff)
parentFix autolinking breaking on single quotes in href attribute (diff)
downloadnheko-c73cfe181006fe3be8a3f141acda5c8a1318e47a.tar.xz
Merge remote-tracking branch 'upstream/master' into voip
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp22
-rw-r--r--src/Config.h6
-rw-r--r--src/EventAccessors.cpp6
-rw-r--r--src/timeline/TimelineModel.cpp130
-rw-r--r--src/timeline/TimelineViewManager.cpp10
-rw-r--r--src/timeline/TimelineViewManager.h2
-rw-r--r--src/ui/SnackBar.cpp2
7 files changed, 112 insertions, 66 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp

index 1bea8564..c83ce350 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -589,8 +589,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) emit notificationsRetrieved(std::move(res)); }); }); - connect(this, &ChatPage::syncRoomlist, room_list_, &RoomList::sync); - connect(this, &ChatPage::syncTags, communitiesList_, &CommunitiesList::syncTags); + connect(this, &ChatPage::syncRoomlist, room_list_, &RoomList::sync, Qt::QueuedConnection); + connect(this, + &ChatPage::syncTags, + communitiesList_, + &CommunitiesList::syncTags, + Qt::QueuedConnection); connect( this, &ChatPage::syncTopBar, this, [this](const std::map<QString, RoomInfo> &updates) { if (updates.find(currentRoom()) != updates.end()) @@ -605,11 +609,15 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) user_info_widget_->setDisplayName(name); }); - connect(this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync); - connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync); - connect(this, &ChatPage::tryDelayedSyncCb, this, [this]() { - QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); - }); + connect( + this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync, Qt::QueuedConnection); + connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync, Qt::QueuedConnection); + connect( + this, + &ChatPage::tryDelayedSyncCb, + this, + [this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); }, + Qt::QueuedConnection); connect(this, &ChatPage::dropToLoginPageCb, this, &ChatPage::dropToLoginPage); diff --git a/src/Config.h b/src/Config.h
index f99cf36b..c0624709 100644 --- a/src/Config.h +++ b/src/Config.h
@@ -53,9 +53,9 @@ namespace strings { const QString url_html = "<a href=\"\\1\">\\1</a>"; const QRegularExpression url_regex( // match an URL, that is not quoted, i.e. - // vvvvvv match quote via negative lookahead/lookbehind vv - // vvvv atomic match url -> fail if there is a " before or after vvv - R"((?<!")(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,\.\s<>'"\]\)\:]))(?!"))"); + // vvvvvv match quote via negative lookahead/lookbehind vv + // vvvv atomic match url -> fail if there is a " before or after vvv + R"((?<!["'])(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,\.\s<>'"\]\)\:]))(?!["']))"); } // Window geometry. diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp
index a2d8adbb..7071819b 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp
@@ -85,8 +85,10 @@ struct EventFormattedBody template<class T> std::string operator()(const mtx::events::RoomEvent<T> &e) { - if constexpr (is_detected<formatted_body_t, T>::value) - return e.content.formatted_body; + if constexpr (is_detected<formatted_body_t, T>::value) { + if (e.content.format == "org.matrix.custom.html") + return e.content.formatted_body; + } return ""; } }; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index cdbd36c5..aaaf7d4a 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -159,72 +159,96 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj , room_id_(room_id) , manager_(manager) { + connect(this, + &TimelineModel::oldMessagesRetrieved, + this, + &TimelineModel::addBackwardsEvents, + Qt::QueuedConnection); connect( - this, &TimelineModel::oldMessagesRetrieved, this, &TimelineModel::addBackwardsEvents); - connect(this, &TimelineModel::messageFailed, this, [this](QString txn_id) { - nhlog::ui()->error("Failed to send {}, retrying", txn_id.toStdString()); - - QTimer::singleShot(5000, this, [this]() { emit nextPendingMessage(); }); - }); - connect(this, &TimelineModel::messageSent, this, [this](QString txn_id, QString event_id) { - pending.removeOne(txn_id); + this, + &TimelineModel::messageFailed, + this, + [this](QString txn_id) { + nhlog::ui()->error("Failed to send {}, retrying", txn_id.toStdString()); - auto ev = events.value(txn_id); + QTimer::singleShot(5000, this, [this]() { emit nextPendingMessage(); }); + }, + Qt::QueuedConnection); + connect( + this, + &TimelineModel::messageSent, + this, + [this](QString txn_id, QString event_id) { + pending.removeOne(txn_id); - if (auto reaction = - std::get_if<mtx::events::RoomEvent<mtx::events::msg::Reaction>>(&ev)) { - QString reactedTo = - QString::fromStdString(reaction->content.relates_to.event_id); - auto &rModel = reactions[reactedTo]; - rModel.removeReaction(*reaction); - auto rCopy = *reaction; - rCopy.event_id = event_id.toStdString(); - rModel.addReaction(room_id_.toStdString(), rCopy); - } + auto ev = events.value(txn_id); - int idx = idToIndex(txn_id); - if (idx < 0) { - // transaction already received via sync - return; - } - eventOrder[idx] = event_id; - ev = std::visit( - [event_id](const auto &e) -> mtx::events::collections::TimelineEvents { - auto eventCopy = e; - eventCopy.event_id = event_id.toStdString(); - return eventCopy; - }, - ev); + if (auto reaction = + std::get_if<mtx::events::RoomEvent<mtx::events::msg::Reaction>>(&ev)) { + QString reactedTo = + QString::fromStdString(reaction->content.relates_to.event_id); + auto &rModel = reactions[reactedTo]; + rModel.removeReaction(*reaction); + auto rCopy = *reaction; + rCopy.event_id = event_id.toStdString(); + rModel.addReaction(room_id_.toStdString(), rCopy); + } - events.remove(txn_id); - events.insert(event_id, ev); + int idx = idToIndex(txn_id); + if (idx < 0) { + // transaction already received via sync + return; + } + eventOrder[idx] = event_id; + ev = std::visit( + [event_id](const auto &e) -> mtx::events::collections::TimelineEvents { + auto eventCopy = e; + eventCopy.event_id = event_id.toStdString(); + return eventCopy; + }, + ev); - // mark our messages as read - readEvent(event_id.toStdString()); + events.remove(txn_id); + events.insert(event_id, ev); - emit dataChanged(index(idx, 0), index(idx, 0)); + // mark our messages as read + readEvent(event_id.toStdString()); - if (pending.size() > 0) - emit nextPendingMessage(); - }); - connect(this, &TimelineModel::redactionFailed, this, [](const QString &msg) { - emit ChatPage::instance()->showNotification(msg); - }); + emit dataChanged(index(idx, 0), index(idx, 0)); + if (pending.size() > 0) + emit nextPendingMessage(); + }, + Qt::QueuedConnection); connect( - this, &TimelineModel::nextPendingMessage, this, &TimelineModel::processOnePendingMessage); - connect(this, &TimelineModel::newMessageToSend, this, &TimelineModel::addPendingMessage); + this, + &TimelineModel::redactionFailed, + this, + [](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, + Qt::QueuedConnection); connect(this, - &TimelineModel::eventFetched, + &TimelineModel::nextPendingMessage, this, - [this](QString requestingEvent, mtx::events::collections::TimelineEvents event) { - events.insert(QString::fromStdString(mtx::accessors::event_id(event)), - event); - auto idx = idToIndex(requestingEvent); - if (idx >= 0) - emit dataChanged(index(idx, 0), index(idx, 0)); - }); + &TimelineModel::processOnePendingMessage, + Qt::QueuedConnection); + connect(this, + &TimelineModel::newMessageToSend, + this, + &TimelineModel::addPendingMessage, + Qt::QueuedConnection); + + connect( + this, + &TimelineModel::eventFetched, + this, + [this](QString requestingEvent, mtx::events::collections::TimelineEvents event) { + events.insert(QString::fromStdString(mtx::accessors::event_id(event)), event); + auto idx = idToIndex(requestingEvent); + if (idx >= 0) + emit dataChanged(index(idx, 0), index(idx, 0)); + }, + Qt::QueuedConnection); } QHash<int, QByteArray> diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index b652b78e..84be895f 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -1,5 +1,6 @@ #include "TimelineViewManager.h" +#include <QDesktopServices> #include <QMetaType> #include <QPalette> #include <QQmlContext> @@ -112,7 +113,10 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin container = view; view->setResizeMode(QQuickWidget::SizeRootObjectToView); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) view->quickWindow()->setTextRenderType(QQuickWindow::NativeTextRendering); +#endif connect(view, &QQuickWidget::statusChanged, this, [](QQuickWidget::Status status) { nhlog::ui()->debug("Status changed to {}", status); @@ -232,6 +236,12 @@ TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId) const } void +TimelineViewManager::openLink(QString link) const +{ + QDesktopServices::openUrl(link); +} + +void TimelineViewManager::updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids) { diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 5224cd56..902dc047 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h
@@ -50,6 +50,8 @@ public: Q_INVOKABLE QString userPresence(QString id) const; Q_INVOKABLE QString userStatus(QString id) const; + Q_INVOKABLE void openLink(QString link) const; + signals: void clearRoomMessageCount(QString roomid); void updateRoomsLastMessage(QString roomid, const DescInfo &info); diff --git a/src/ui/SnackBar.cpp b/src/ui/SnackBar.cpp
index 5daa697e..51a0ff38 100644 --- a/src/ui/SnackBar.cpp +++ b/src/ui/SnackBar.cpp
@@ -63,7 +63,7 @@ SnackBar::hideMessage() // Moving on to the next message. messages_.pop_front(); - // Reseting the starting position of the widget. + // Resetting the starting position of the widget. offset_ = STARTING_OFFSET; if (!messages_.empty())