Compare commits
158 Commits
v24.12.0
...
work/carl/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fab2a81aee | ||
|
|
4daff26747 | ||
|
|
fe09dc23a6 | ||
|
|
9cd4a7416e | ||
|
|
f6e3210b0d | ||
|
|
16d33eb02c | ||
|
|
326512697c | ||
|
|
f25de891bf | ||
|
|
e785533858 | ||
|
|
0699bc4147 | ||
|
|
d07a8258e9 | ||
|
|
d490e65315 | ||
|
|
7a632c9561 | ||
|
|
ec4b35fa5f | ||
|
|
b263755629 | ||
|
|
828585a260 | ||
|
|
3b33121dbc | ||
|
|
21484c8184 | ||
|
|
020385c850 | ||
|
|
c585f3d8ae | ||
|
|
3356e6c6cf | ||
|
|
2fa6ad22a3 | ||
|
|
b887519f26 | ||
|
|
b1e54a834c | ||
|
|
171e62a272 | ||
|
|
053770c117 | ||
|
|
911f3e1f54 | ||
|
|
1494ba95b3 | ||
|
|
c0b00ce146 | ||
|
|
47a08b829e | ||
|
|
953bb60aac | ||
|
|
fc4cb31277 | ||
|
|
9876636dbc | ||
|
|
8314ab03bd | ||
|
|
9d887ba3e7 | ||
|
|
1612a8a960 | ||
|
|
99af210e62 | ||
|
|
8fd108cde1 | ||
|
|
ca81d35936 | ||
|
|
d65aacac6f | ||
|
|
43f052a363 | ||
|
|
0e0a38ffa2 | ||
|
|
819586fc4e | ||
|
|
6b8a331428 | ||
|
|
57e7004e05 | ||
|
|
25c95cafe3 | ||
|
|
54be1a8918 | ||
|
|
d4a0573051 | ||
|
|
4a96eac67b | ||
|
|
2f4134a6d2 | ||
|
|
4f87dcc0c0 | ||
|
|
47eba6b720 | ||
|
|
cba537d561 | ||
|
|
c9d03cb042 | ||
|
|
e42c002fbd | ||
|
|
7c7b073a47 | ||
|
|
20090d21eb | ||
|
|
b0e69ff4b8 | ||
|
|
552bb0a98b | ||
|
|
19510858af | ||
|
|
44b2f6ee63 | ||
|
|
c5d3002f31 | ||
|
|
2e3659d4ee | ||
|
|
f8a5509a91 | ||
|
|
421f436871 | ||
|
|
a37c9d6cea | ||
|
|
d14d576d99 | ||
|
|
9391e44e4b | ||
|
|
a7aebe3a61 | ||
|
|
1fca9021a4 | ||
|
|
a39194b2ad | ||
|
|
bff93d9352 | ||
|
|
d76c9cd16d | ||
|
|
14774fe235 | ||
|
|
39046632aa | ||
|
|
fbb2afdb49 | ||
|
|
aff0402f71 | ||
|
|
cee9058c77 | ||
|
|
3f922b4c90 | ||
|
|
02d2d31cf3 | ||
|
|
240cf6a0ed | ||
|
|
dcd9ee93de | ||
|
|
2a8cd74ab1 | ||
|
|
63bc7055c2 | ||
|
|
1cca9733d6 | ||
|
|
1104da5e2c | ||
|
|
3a9718c09d | ||
|
|
55362c5573 | ||
|
|
0bba2299b3 | ||
|
|
45685af9e9 | ||
|
|
6c416a9338 | ||
|
|
1b0027e1d2 | ||
|
|
2409adf516 | ||
|
|
554801dfe4 | ||
|
|
20c23917e9 | ||
|
|
ef953b7574 | ||
|
|
6b79795229 | ||
|
|
9cb7ec2348 | ||
|
|
437c981d30 | ||
|
|
0334cae4c8 | ||
|
|
24c405d747 | ||
|
|
a3f5962809 | ||
|
|
0deb7495f0 | ||
|
|
d34f89fc4b | ||
|
|
a909ed498f | ||
|
|
16f4e17e8f | ||
|
|
0e9592a96c | ||
|
|
704ee6a53a | ||
|
|
5b9afbce9a | ||
|
|
396cc8e8ef | ||
|
|
bf776b5c06 | ||
|
|
be319f88d3 | ||
|
|
af40d555d4 | ||
|
|
f802dbe686 | ||
|
|
2379e3d83b | ||
|
|
9e90ac0412 | ||
|
|
c27948ca3c | ||
|
|
c3b9d664df | ||
|
|
31ef0a5223 | ||
|
|
14c58acea1 | ||
|
|
5dae20603e | ||
|
|
3f6fa94289 | ||
|
|
117615a8b0 | ||
|
|
4a52773c7d | ||
|
|
edfee495c6 | ||
|
|
7d112df7c6 | ||
|
|
9acaaade45 | ||
|
|
aaca28dbf6 | ||
|
|
d4ef5f9d4d | ||
|
|
2095dea801 | ||
|
|
a36f7ef10d | ||
|
|
9874962ee3 | ||
|
|
4b08022075 | ||
|
|
dc3db3aec4 | ||
|
|
0568c2a93d | ||
|
|
7ab0a6fc9e | ||
|
|
d6b780762e | ||
|
|
5ef66b5cf6 | ||
|
|
19e8cd5e48 | ||
|
|
df5117892f | ||
|
|
aaa4216f55 | ||
|
|
85ee5084b6 | ||
|
|
bb9ce117de | ||
|
|
00c5aa26bb | ||
|
|
bae4de227c | ||
|
|
253f891c5a | ||
|
|
6966159062 | ||
|
|
07d3b80c3e | ||
|
|
a41d0f3214 | ||
|
|
1ee15de78b | ||
|
|
b044358970 | ||
|
|
d2e11bb3bb | ||
|
|
a55bac899c | ||
|
|
c2380fb8df | ||
|
|
f31c644b13 | ||
|
|
26cd621d0e | ||
|
|
4c58512c54 | ||
|
|
04c1b47660 |
55
.reuse/dep5
55
.reuse/dep5
@@ -1,55 +0,0 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: NeoChat
|
||||
Upstream-Contact: Carl Schwan <carlschwan@kde.org>
|
||||
|
||||
Files: 128-logo.png icons/* logo.png org.kde.neochat.svg org.kde.neochat.tray.svg android/res/drawable/neochat.png
|
||||
Copyright: 2020 Carson Black <uhhadd@gmail.com>
|
||||
License: LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
|
||||
Files: android/res/drawable/splash.xml
|
||||
Copyright: 2020 Tobias Fella <tobias.fella@kde.org>
|
||||
License: BSD-2-Clause
|
||||
|
||||
Files: .gitignore
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
Files: .gitlab/issue_templates/bug.md
|
||||
Copyright: 2021 Carl Schwan <carlschwan@kde.org>
|
||||
License: CC0-1.0
|
||||
|
||||
Files: src/res.qrc src/res_android.qrc src/res_desktop.qrc
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
Files: cmake/Flatpak/99-noto-mono-color-emoji.conf
|
||||
Copyright: 2021 Carl Schwan <carlschwan@kde.org>
|
||||
License: BSD-2-Clause
|
||||
|
||||
Files: src/neochatconfig.kcfg
|
||||
Copyright: 2020-2021 Carl Schwan <carlschwan@kde.org>, Tobias Fella <tobias.fella@kde.org>
|
||||
License: BSD-2-Clause
|
||||
|
||||
Files: src/neochat.notifyrc
|
||||
Copyright: 2020 Tobias Fella <tobias.fella@kde.org>
|
||||
License: BSD-2-Clause
|
||||
|
||||
Files: src/qml/confetti.png src/qml/glowdot.png
|
||||
Copyright: 2021 Alexey Andreyev <aa13q@ya.ru>
|
||||
License: CC0-1.0
|
||||
|
||||
Files: .flatpak-manifest.json
|
||||
Copyright: 2020-2022 Tobias Fella <tobias.fella@kde.org>
|
||||
License: BSD-2-Clause
|
||||
|
||||
Files: autotests/data/*
|
||||
Copyright: none
|
||||
License: CC0-1.0
|
||||
|
||||
Files: appiumtests/data/*
|
||||
Copyright: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
License: CC0-1.0
|
||||
|
||||
Files: src/purpose/purposeplugin.json
|
||||
Copyright: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
License: BSD-2-Clause
|
||||
@@ -7,9 +7,9 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# KDE Applications version, managed by release script.
|
||||
set(RELEASE_SERVICE_VERSION_MAJOR "24")
|
||||
set(RELEASE_SERVICE_VERSION_MINOR "12")
|
||||
set(RELEASE_SERVICE_VERSION_MICRO "0")
|
||||
set(RELEASE_SERVICE_VERSION_MAJOR "25")
|
||||
set(RELEASE_SERVICE_VERSION_MINOR "03")
|
||||
set(RELEASE_SERVICE_VERSION_MICRO "70")
|
||||
set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
|
||||
|
||||
project(NeoChat VERSION ${RELEASE_SERVICE_VERSION})
|
||||
|
||||
84
REUSE.toml
Normal file
84
REUSE.toml
Normal file
@@ -0,0 +1,84 @@
|
||||
# SPDX-FileCopyrightText: none
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
version = 1
|
||||
SPDX-PackageName = "NeoChat"
|
||||
SPDX-PackageSupplier = "Carl Schwan <carlschwan@kde.org>"
|
||||
|
||||
[[annotations]]
|
||||
path = ["128-logo.png", "icons/**", "logo.png", "org.kde.neochat.svg", "org.kde.neochat.tray.svg", "android/res/drawable/neochat.png", "android/neochat-playstore.png"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2020 Carson Black <uhhadd@gmail.com>"
|
||||
SPDX-License-Identifier = "LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL"
|
||||
|
||||
[[annotations]]
|
||||
path = "android/res/drawable/splash.xml"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2020 Tobias Fella <tobias.fella@kde.org>"
|
||||
SPDX-License-Identifier = "BSD-2-Clause"
|
||||
|
||||
[[annotations]]
|
||||
path = ".gitignore"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "None"
|
||||
SPDX-License-Identifier = "CC0-1.0"
|
||||
|
||||
[[annotations]]
|
||||
path = ".gitlab/issue_templates/bug.md"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2021 Carl Schwan <carlschwan@kde.org>"
|
||||
SPDX-License-Identifier = "CC0-1.0"
|
||||
|
||||
[[annotations]]
|
||||
path = ["src/res.qrc", "src/res_android.qrc", "src/res_desktop.qrc"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "None"
|
||||
SPDX-License-Identifier = "CC0-1.0"
|
||||
|
||||
[[annotations]]
|
||||
path = "cmake/Flatpak/99-noto-mono-color-emoji.conf"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2021 Carl Schwan <carlschwan@kde.org>"
|
||||
SPDX-License-Identifier = "BSD-2-Clause"
|
||||
|
||||
[[annotations]]
|
||||
path = "src/neochatconfig.kcfg"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2020-2021 Carl Schwan <carlschwan@kde.org>, Tobias Fella <tobias.fella@kde.org>"
|
||||
SPDX-License-Identifier = "BSD-2-Clause"
|
||||
|
||||
[[annotations]]
|
||||
path = "src/neochat.notifyrc"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2020 Tobias Fella <tobias.fella@kde.org>"
|
||||
SPDX-License-Identifier = "BSD-2-Clause"
|
||||
|
||||
[[annotations]]
|
||||
path = ["src/qml/confetti.png", "src/qml/glowdot.png"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2021 Alexey Andreyev <aa13q@ya.ru>"
|
||||
SPDX-License-Identifier = "CC0-1.0"
|
||||
|
||||
[[annotations]]
|
||||
path = ".flatpak-manifest.json"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2020-2022 Tobias Fella <tobias.fella@kde.org>"
|
||||
SPDX-License-Identifier = "BSD-2-Clause"
|
||||
|
||||
[[annotations]]
|
||||
path = "autotests/data/**"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "none"
|
||||
SPDX-License-Identifier = "CC0-1.0"
|
||||
|
||||
[[annotations]]
|
||||
path = "appiumtests/data/**"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2023 Tobias Fella <tobias.fella@kde.org>"
|
||||
SPDX-License-Identifier = "CC0-1.0"
|
||||
|
||||
[[annotations]]
|
||||
path = "src/purpose/purposeplugin.json"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2023 Tobias Fella <tobias.fella@kde.org>"
|
||||
SPDX-License-Identifier = "BSD-2-Clause"
|
||||
BIN
android/neochat-playstore.png
Normal file
BIN
android/neochat-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@@ -83,6 +83,15 @@ def create_room():
|
||||
next_sync_payload = "sync_response_new_room"
|
||||
return response
|
||||
|
||||
@app.route("/_matrix/client/v3/publicRooms", methods=["POST"])
|
||||
def public_rooms():
|
||||
if request.get_json()["filter"]["generic_search_term"] == "forbidden":
|
||||
data = dict()
|
||||
data["errcode"] = "M_FORBIDDEN"
|
||||
data["error"] = "You are not allowed to search for this. Go to https://wikipedia.org for more information"
|
||||
return data, 403
|
||||
return dict()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -32,8 +32,6 @@ private:
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
|
||||
void eventId();
|
||||
void nullEventId();
|
||||
void authorDisplayName();
|
||||
void nullAuthorDisplayName();
|
||||
void singleLineSidplayName();
|
||||
@@ -56,14 +54,8 @@ private Q_SLOTS:
|
||||
void nullSubtitle();
|
||||
void mediaInfo();
|
||||
void nullMediaInfo();
|
||||
void hasReply();
|
||||
void nullHasReply();
|
||||
void replyId();
|
||||
void nullReplyId();
|
||||
void replyAuthor();
|
||||
void nullReplyAuthor();
|
||||
void thread();
|
||||
void nullThread();
|
||||
void location();
|
||||
void nullLocation();
|
||||
};
|
||||
@@ -74,17 +66,6 @@ void EventHandlerTest::initTestCase()
|
||||
room = new TestUtils::TestRoom(connection, QStringLiteral("#myroom:kde.org"), QLatin1String("test-eventhandler-sync.json"));
|
||||
}
|
||||
|
||||
void EventHandlerTest::eventId()
|
||||
{
|
||||
QCOMPARE(EventHandler::id(room->messageEvents().at(0).get()), QStringLiteral("$153456789:example.org"));
|
||||
}
|
||||
|
||||
void EventHandlerTest::nullEventId()
|
||||
{
|
||||
QTest::ignoreMessage(QtWarningMsg, "id called with event set to nullptr.");
|
||||
QCOMPARE(EventHandler::id(nullptr), QString());
|
||||
}
|
||||
|
||||
void EventHandlerTest::authorDisplayName()
|
||||
{
|
||||
QCOMPARE(EventHandler::authorDisplayName(room, room->messageEvents().at(1).get()), QStringLiteral("before"));
|
||||
@@ -118,8 +99,9 @@ void EventHandlerTest::time()
|
||||
{
|
||||
const auto event = room->messageEvents().at(0).get();
|
||||
|
||||
QCOMPARE(EventHandler::time(event), QDateTime::fromMSecsSinceEpoch(1432735824654, Qt::UTC));
|
||||
QCOMPARE(EventHandler::time(event, true, QDateTime::fromMSecsSinceEpoch(1234, Qt::UTC)), QDateTime::fromMSecsSinceEpoch(1234, Qt::UTC));
|
||||
QCOMPARE(EventHandler::time(event), QDateTime::fromMSecsSinceEpoch(1432735824654, QTimeZone(QTimeZone::UTC)));
|
||||
QCOMPARE(EventHandler::time(event, true, QDateTime::fromMSecsSinceEpoch(1234, QTimeZone(QTimeZone::UTC))),
|
||||
QDateTime::fromMSecsSinceEpoch(1234, QTimeZone(QTimeZone::UTC)));
|
||||
}
|
||||
|
||||
void EventHandlerTest::nullTime()
|
||||
@@ -138,19 +120,19 @@ void EventHandlerTest::timeString()
|
||||
KFormat format;
|
||||
|
||||
QCOMPARE(EventHandler::timeString(event, false),
|
||||
QLocale().toString(QDateTime::fromMSecsSinceEpoch(1432735824654, Qt::UTC).toLocalTime().time(), QLocale::ShortFormat));
|
||||
QLocale().toString(QDateTime::fromMSecsSinceEpoch(1432735824654, QTimeZone(QTimeZone::UTC)).toLocalTime().time(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, true),
|
||||
format.formatRelativeDate(QDateTime::fromMSecsSinceEpoch(1432735824654, Qt::UTC).toLocalTime().date(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, false, QLocale::ShortFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC)),
|
||||
QLocale().toString(QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC).toLocalTime().time(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, true, QLocale::ShortFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC)),
|
||||
format.formatRelativeDate(QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC).toLocalTime().date(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, false, QLocale::LongFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC)),
|
||||
QLocale().toString(QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC).toLocalTime().time(), QLocale::LongFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, true, QLocale::LongFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC)),
|
||||
format.formatRelativeDate(QDateTime::fromMSecsSinceEpoch(1690699214545, Qt::UTC).toLocalTime().date(), QLocale::LongFormat));
|
||||
format.formatRelativeDate(QDateTime::fromMSecsSinceEpoch(1432735824654, QTimeZone(QTimeZone::UTC)).toLocalTime().date(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, false, QLocale::ShortFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC))),
|
||||
QLocale().toString(QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC)).toLocalTime().time(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, true, QLocale::ShortFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC))),
|
||||
format.formatRelativeDate(QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC)).toLocalTime().date(), QLocale::ShortFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, false, QLocale::LongFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC))),
|
||||
QLocale().toString(QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC)).toLocalTime().time(), QLocale::LongFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, true, QLocale::LongFormat, true, QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC))),
|
||||
format.formatRelativeDate(QDateTime::fromMSecsSinceEpoch(1690699214545, QTimeZone(QTimeZone::UTC)).toLocalTime().date(), QLocale::LongFormat));
|
||||
QCOMPARE(EventHandler::timeString(event, QStringLiteral("hh:mm")),
|
||||
QDateTime::fromMSecsSinceEpoch(1432735824654, Qt::UTC).toString(QStringLiteral("hh:mm")));
|
||||
QDateTime::fromMSecsSinceEpoch(1432735824654, QTimeZone(QTimeZone::UTC)).toString(QStringLiteral("hh:mm")));
|
||||
}
|
||||
|
||||
void EventHandlerTest::highlighted()
|
||||
@@ -295,30 +277,6 @@ void EventHandlerTest::nullMediaInfo()
|
||||
QCOMPARE(EventHandler::mediaInfo(room, nullptr), QVariantMap());
|
||||
}
|
||||
|
||||
void EventHandlerTest::hasReply()
|
||||
{
|
||||
QCOMPARE(EventHandler::hasReply(room->messageEvents().at(5).get()), true);
|
||||
QCOMPARE(EventHandler::hasReply(room->messageEvents().at(0).get()), false);
|
||||
}
|
||||
|
||||
void EventHandlerTest::nullHasReply()
|
||||
{
|
||||
QTest::ignoreMessage(QtWarningMsg, "hasReply called with event set to nullptr.");
|
||||
QCOMPARE(EventHandler::hasReply(nullptr), false);
|
||||
}
|
||||
|
||||
void EventHandlerTest::replyId()
|
||||
{
|
||||
QCOMPARE(EventHandler::replyId(room->messageEvents().at(5).get()), QStringLiteral("$153456789:example.org"));
|
||||
QCOMPARE(EventHandler::replyId(room->messageEvents().at(0).get()), QStringLiteral(""));
|
||||
}
|
||||
|
||||
void EventHandlerTest::nullReplyId()
|
||||
{
|
||||
QTest::ignoreMessage(QtWarningMsg, "replyId called with event set to nullptr.");
|
||||
QCOMPARE(EventHandler::replyId(nullptr), QString());
|
||||
}
|
||||
|
||||
void EventHandlerTest::replyAuthor()
|
||||
{
|
||||
auto replyEvent = room->messageEvents().at(0).get();
|
||||
@@ -344,29 +302,6 @@ void EventHandlerTest::nullReplyAuthor()
|
||||
QCOMPARE(EventHandler::replyAuthor(room, nullptr), RoomMember());
|
||||
}
|
||||
|
||||
void EventHandlerTest::thread()
|
||||
{
|
||||
QCOMPARE(EventHandler::isThreaded(room->messageEvents().at(0).get()), false);
|
||||
QCOMPARE(EventHandler::threadRoot(room->messageEvents().at(0).get()), QString());
|
||||
|
||||
QCOMPARE(EventHandler::isThreaded(room->messageEvents().at(9).get()), true);
|
||||
QCOMPARE(EventHandler::threadRoot(room->messageEvents().at(9).get()), QStringLiteral("$threadroot:example.org"));
|
||||
QCOMPARE(EventHandler::replyId(room->messageEvents().at(9).get()), QStringLiteral("$threadroot:example.org"));
|
||||
|
||||
QCOMPARE(EventHandler::isThreaded(room->messageEvents().at(10).get()), true);
|
||||
QCOMPARE(EventHandler::threadRoot(room->messageEvents().at(10).get()), QStringLiteral("$threadroot:example.org"));
|
||||
QCOMPARE(EventHandler::replyId(room->messageEvents().at(10).get()), QStringLiteral("$threadmessage1:example.org"));
|
||||
}
|
||||
|
||||
void EventHandlerTest::nullThread()
|
||||
{
|
||||
QTest::ignoreMessage(QtWarningMsg, "isThreaded called with event set to nullptr.");
|
||||
QCOMPARE(EventHandler::isThreaded(nullptr), false);
|
||||
|
||||
QTest::ignoreMessage(QtWarningMsg, "threadRoot called with event set to nullptr.");
|
||||
QCOMPARE(EventHandler::threadRoot(nullptr), QString());
|
||||
}
|
||||
|
||||
void EventHandlerTest::location()
|
||||
{
|
||||
QCOMPARE(EventHandler::latitude(room->messageEvents().at(7).get()), QStringLiteral("51.7035").toFloat());
|
||||
|
||||
@@ -61,10 +61,12 @@
|
||||
<summary xml:lang="fi">Keskustelu Matrixissä</summary>
|
||||
<summary xml:lang="fr">Discuter sur Matrix</summary>
|
||||
<summary xml:lang="gl">Charlar en Matrix</summary>
|
||||
<summary xml:lang="he">התכתבות דרך Matrix</summary>
|
||||
<summary xml:lang="hu">Csevegés Matrixon</summary>
|
||||
<summary xml:lang="ia">Conversation en ditecto sur Matrix</summary>
|
||||
<summary xml:lang="it">Chat su Matrix</summary>
|
||||
<summary xml:lang="ka">ისაუბრეთ Matrix-ზე</summary>
|
||||
<summary xml:lang="lv">Tērzējiet „Matrix“ tīklā</summary>
|
||||
<summary xml:lang="nl">Chat op Matrix</summary>
|
||||
<summary xml:lang="nn">Prat med via Matrix</summary>
|
||||
<summary xml:lang="pl">Rozmawiaj na Matriksie</summary>
|
||||
@@ -291,6 +293,7 @@
|
||||
<value key="KDE::windows_store::StoreLogoSquare">https://invent.kde.org/network/neochat/-/raw/master/icons/windows/storelogo-1080x1080.png</value>
|
||||
<value key="KDE::windows_store::Icon">https://invent.kde.org/network/neochat/-/raw/master/icons/300-apps-neochat.png</value>
|
||||
<value key="KDE::windows_store::PromotionalArt16x9">https://invent.kde.org/network/neochat/-/raw/master/icons/windows/promoimage-1920x1080.png</value>
|
||||
<value key="KDE::supporters">Tanguy Fardet;[dabe](https://freeradical.zone/@dabe);[lengau](https://mastodon.world/@lengau);Joshua Strobl;Stuart Turton</value>
|
||||
</custom>
|
||||
<launchable type="desktop-id">org.kde.neochat.desktop</launchable>
|
||||
<screenshots>
|
||||
|
||||
@@ -95,18 +95,23 @@ Comment[de]=Über Matrix unterhalten
|
||||
Comment[en_GB]=Chat on Matrix
|
||||
Comment[es]=Chat en Matrix
|
||||
Comment[eu]=Berriketa Matrix-en
|
||||
Comment[fi]=Keskustele Matrixissä
|
||||
Comment[fr]=Clavarder sur Matrix
|
||||
Comment[gl]=Charle en Matrix
|
||||
Comment[he]=התכתבות דרך Matrix
|
||||
Comment[hu]=Csevegés Matrixon
|
||||
Comment[ia]=Conversation en ditecto sur Matrix
|
||||
Comment[it]= su Matrix
|
||||
Comment[ka]=საუბარი Matrix-ზე
|
||||
Comment[ka]=ჩატი Matrix-ზე
|
||||
Comment[lv]=Tērzējiet „Matrix“ tīklā
|
||||
Comment[nl]=Chat op Matrix
|
||||
Comment[pl]=Rozmawiaj na Matriksie
|
||||
Comment[sl]=Klepet na Matrixu
|
||||
Comment[sv]=Chatta på Matrix
|
||||
Comment[ta]=மேட்ரிக்ஸில் உரையாட உதவும்
|
||||
Comment[tr]=Matrix Üzerinde Sohbet Et
|
||||
Comment[uk]=Спілкування у Matrix
|
||||
Comment[x-test]=xxChat on Matrixxx
|
||||
Comment[zh_TW]=在 Matrix 上聊天
|
||||
MimeType=x-scheme-handler/matrix;
|
||||
Exec=neochat %u
|
||||
|
||||
1017
po/ar/neochat.po
1017
po/ar/neochat.po
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1082
po/az/neochat.po
1082
po/az/neochat.po
File diff suppressed because it is too large
Load Diff
1292
po/ca/neochat.po
1292
po/ca/neochat.po
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1154
po/cs/neochat.po
1154
po/cs/neochat.po
File diff suppressed because it is too large
Load Diff
1066
po/da/neochat.po
1066
po/da/neochat.po
File diff suppressed because it is too large
Load Diff
1128
po/de/neochat.po
1128
po/de/neochat.po
File diff suppressed because it is too large
Load Diff
1103
po/el/neochat.po
1103
po/el/neochat.po
File diff suppressed because it is too large
Load Diff
1148
po/en_GB/neochat.po
1148
po/en_GB/neochat.po
File diff suppressed because it is too large
Load Diff
1164
po/eo/neochat.po
1164
po/eo/neochat.po
File diff suppressed because it is too large
Load Diff
996
po/es/neochat.po
996
po/es/neochat.po
File diff suppressed because it is too large
Load Diff
1040
po/eu/neochat.po
1040
po/eu/neochat.po
File diff suppressed because it is too large
Load Diff
1152
po/fi/neochat.po
1152
po/fi/neochat.po
File diff suppressed because it is too large
Load Diff
1014
po/fr/neochat.po
1014
po/fr/neochat.po
File diff suppressed because it is too large
Load Diff
1010
po/gl/neochat.po
1010
po/gl/neochat.po
File diff suppressed because it is too large
Load Diff
1166
po/hu/neochat.po
1166
po/hu/neochat.po
File diff suppressed because it is too large
Load Diff
1144
po/ia/neochat.po
1144
po/ia/neochat.po
File diff suppressed because it is too large
Load Diff
1117
po/id/neochat.po
1117
po/id/neochat.po
File diff suppressed because it is too large
Load Diff
1067
po/ie/neochat.po
1067
po/ie/neochat.po
File diff suppressed because it is too large
Load Diff
1144
po/it/neochat.po
1144
po/it/neochat.po
File diff suppressed because it is too large
Load Diff
929
po/ja/neochat.po
929
po/ja/neochat.po
File diff suppressed because it is too large
Load Diff
995
po/ka/neochat.po
995
po/ka/neochat.po
File diff suppressed because it is too large
Load Diff
1141
po/ko/neochat.po
1141
po/ko/neochat.po
File diff suppressed because it is too large
Load Diff
929
po/lt/neochat.po
929
po/lt/neochat.po
File diff suppressed because it is too large
Load Diff
1169
po/lv/neochat.po
1169
po/lv/neochat.po
File diff suppressed because it is too large
Load Diff
1005
po/nl/neochat.po
1005
po/nl/neochat.po
File diff suppressed because it is too large
Load Diff
1147
po/nn/neochat.po
1147
po/nn/neochat.po
File diff suppressed because it is too large
Load Diff
1059
po/pa/neochat.po
1059
po/pa/neochat.po
File diff suppressed because it is too large
Load Diff
1166
po/pl/neochat.po
1166
po/pl/neochat.po
File diff suppressed because it is too large
Load Diff
1117
po/pt/neochat.po
1117
po/pt/neochat.po
File diff suppressed because it is too large
Load Diff
1085
po/pt_BR/neochat.po
1085
po/pt_BR/neochat.po
File diff suppressed because it is too large
Load Diff
1132
po/ru/neochat.po
1132
po/ru/neochat.po
File diff suppressed because it is too large
Load Diff
1639
po/sk/neochat.po
1639
po/sk/neochat.po
File diff suppressed because it is too large
Load Diff
996
po/sl/neochat.po
996
po/sl/neochat.po
File diff suppressed because it is too large
Load Diff
1013
po/sv/neochat.po
1013
po/sv/neochat.po
File diff suppressed because it is too large
Load Diff
994
po/ta/neochat.po
994
po/ta/neochat.po
File diff suppressed because it is too large
Load Diff
1037
po/tok/neochat.po
1037
po/tok/neochat.po
File diff suppressed because it is too large
Load Diff
1002
po/tr/neochat.po
1002
po/tr/neochat.po
File diff suppressed because it is too large
Load Diff
998
po/uk/neochat.po
998
po/uk/neochat.po
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1140
po/zh_TW/neochat.po
1140
po/zh_TW/neochat.po
File diff suppressed because it is too large
Load Diff
@@ -194,6 +194,8 @@ add_library(neochat STATIC
|
||||
models/threadmodel.h
|
||||
enums/messagetype.h
|
||||
messagecomponent.h
|
||||
enums/roomsortparameter.cpp
|
||||
enums/roomsortparameter.h
|
||||
)
|
||||
|
||||
set_source_files_properties(qml/OsmLocationPlugin.qml PROPERTIES
|
||||
@@ -533,6 +535,7 @@ if(ANDROID)
|
||||
"kde"
|
||||
"list-remove-symbolic"
|
||||
"edit-delete"
|
||||
"user-home-symbolic"
|
||||
)
|
||||
ecm_add_android_apk(neochat-app ANDROID_DIR ${CMAKE_SOURCE_DIR}/android)
|
||||
else()
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "neochatroom.h"
|
||||
#include "texthandler.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
ChatBarCache::ChatBarCache(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
@@ -319,7 +321,25 @@ void ChatBarCache::postMessage()
|
||||
return;
|
||||
}
|
||||
|
||||
room->postMessage(text(), sendText, *std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result), replyId(), editId(), threadId());
|
||||
bool isReply = !replyId().isEmpty();
|
||||
const auto replyIt = room->findInTimeline(replyId());
|
||||
if (replyIt == room->historyEdge()) {
|
||||
isReply = false;
|
||||
}
|
||||
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(sendText, u"text/html"_s);
|
||||
std::optional<Quotient::EventRelation> relatesTo = std::nullopt;
|
||||
|
||||
if (!threadId().isEmpty()) {
|
||||
relatesTo = Quotient::EventRelation::replyInThread(threadId(), !isReply, isReply ? replyId() : threadId());
|
||||
} else if (!editId().isEmpty()) {
|
||||
relatesTo = Quotient::EventRelation::replace(editId());
|
||||
} else if (isReply) {
|
||||
relatesTo = Quotient::EventRelation::replyTo(replyId());
|
||||
}
|
||||
|
||||
const auto type = std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result);
|
||||
room->post<Quotient::RoomMessageEvent>(text(), type ? *type : Quotient::RoomMessageEvent::MsgType::Text, std::move(content), relatesTo);
|
||||
clearCache();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
ColorSchemer::ColorSchemer(QObject *parent)
|
||||
: QObject(parent)
|
||||
, c(new KColorSchemeManager(this))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,17 +17,17 @@ ColorSchemer::~ColorSchemer()
|
||||
|
||||
QAbstractItemModel *ColorSchemer::model() const
|
||||
{
|
||||
return c->model();
|
||||
return KColorSchemeManager::instance()->model();
|
||||
}
|
||||
|
||||
void ColorSchemer::apply(int idx)
|
||||
{
|
||||
c->activateScheme(c->model()->index(idx, 0));
|
||||
KColorSchemeManager::instance()->activateScheme(KColorSchemeManager::instance()->model()->index(idx, 0));
|
||||
}
|
||||
|
||||
int ColorSchemer::indexForCurrentScheme()
|
||||
{
|
||||
return c->indexForSchemeId(c->activeSchemeId()).row();
|
||||
return KColorSchemeManager::instance()->indexForSchemeId(KColorSchemeManager::instance()->activeSchemeId()).row();
|
||||
}
|
||||
|
||||
#include "moc_colorschemer.cpp"
|
||||
|
||||
@@ -49,7 +49,4 @@ public:
|
||||
* @sa KColorScheme
|
||||
*/
|
||||
Q_INVOKABLE int indexForCurrentScheme();
|
||||
|
||||
private:
|
||||
KColorSchemeManager *c;
|
||||
};
|
||||
|
||||
@@ -33,4 +33,28 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
FormCard.FormCard {
|
||||
FormCard.FormSwitchDelegate {
|
||||
id: showAccessTokenCheckbox
|
||||
text: i18nc("@info", "Show Access Token")
|
||||
description: i18n("This should not be shared with anyone, even other users. This token gives full access to your account.")
|
||||
}
|
||||
FormCard.FormTextDelegate {
|
||||
text: i18nc("@info", "Access Token")
|
||||
description: root.connection.accessToken
|
||||
visible: showAccessTokenCheckbox.checked
|
||||
|
||||
contentItem.children: QQC2.Button {
|
||||
text: i18nc("@action:button", "Copy access token to clipboard")
|
||||
icon.name: "edit-copy"
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
|
||||
onClicked: Clipboard.saveText(root.connection.accessToken)
|
||||
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
QQC2.ToolTip.visible: hovered
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,19 +21,22 @@ ColumnLayout {
|
||||
title: i18nc("@title", "Choose Room")
|
||||
}
|
||||
FormCard.FormCard {
|
||||
FormCard.FormComboBoxDelegate {
|
||||
id: roomComboBox
|
||||
text: i18n("Room")
|
||||
textRole: "escapedDisplayName"
|
||||
valueRole: "roomId"
|
||||
displayText: RoomManager.roomListModel.data(RoomManager.roomListModel.index(currentIndex, 0), RoomListModel.EscapedDisplayNameRole)
|
||||
model: RoomManager.roomListModel
|
||||
currentIndex: 0
|
||||
displayMode: FormCard.FormComboBoxDelegate.Page
|
||||
Component.onCompleted: currentIndex = RoomManager.roomListModel.rowForRoom(root.room)
|
||||
onCurrentValueChanged: root.room = RoomManager.roomListModel.roomByAliasOrId(roomComboBox.currentValue)
|
||||
FormCard.FormButtonDelegate {
|
||||
text: root.room?.displayNameForHtml ?? i18nc("@info", "No room selected")
|
||||
description: i18nc("@info", "Click to choose a room");
|
||||
|
||||
onClicked: {
|
||||
let dialog = root.Window.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ChooseRoomDialog'), {
|
||||
connection: root.connection,
|
||||
}, {
|
||||
title: i18nc("@title:dialog", "Choose Room"),
|
||||
width: Kirigami.Units.gridUnit * 24
|
||||
});
|
||||
dialog.chosen.connect(id => root.room = root.connection.room(id))
|
||||
}
|
||||
}
|
||||
FormCard.FormTextDelegate {
|
||||
visible: root.room
|
||||
text: i18n("Room Id: %1", root.room.id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ FormCard.FormCardPage {
|
||||
}
|
||||
|
||||
function openEventSource(stateKey: string): void {
|
||||
applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'MessageSourceSheet'), {
|
||||
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'MessageSourceSheet'), {
|
||||
model: stateKeysModel,
|
||||
allowEdit: true,
|
||||
room: root.room,
|
||||
|
||||
85
src/enums/roomsortparameter.cpp
Normal file
85
src/enums/roomsortparameter.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
#include "roomsortparameter.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename T>
|
||||
int typeCompare(T left, T right)
|
||||
{
|
||||
return left == right ? 0 : left > right ? 1 : -1;
|
||||
}
|
||||
|
||||
template<>
|
||||
int typeCompare<QString>(QString left, QString right)
|
||||
{
|
||||
return left.localeAwareCompare(right);
|
||||
}
|
||||
}
|
||||
|
||||
int RoomSortParameter::compareParameter(Parameter parameter, NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
switch (parameter) {
|
||||
case AlphabeticalAscending:
|
||||
return compareParameter<AlphabeticalAscending>(leftRoom, rightRoom);
|
||||
case AlphabeticalDescending:
|
||||
return compareParameter<AlphabeticalDescending>(leftRoom, rightRoom);
|
||||
case HasUnread:
|
||||
return compareParameter<HasUnread>(leftRoom, rightRoom);
|
||||
case MostUnread:
|
||||
return compareParameter<MostUnread>(leftRoom, rightRoom);
|
||||
case HasHighlight:
|
||||
return compareParameter<HasHighlight>(leftRoom, rightRoom);
|
||||
case MostHighlights:
|
||||
return compareParameter<MostHighlights>(leftRoom, rightRoom);
|
||||
case LastActive:
|
||||
return compareParameter<LastActive>(leftRoom, rightRoom);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::AlphabeticalAscending>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
return -typeCompare(leftRoom->displayName(), rightRoom->displayName());
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::AlphabeticalDescending>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
return typeCompare(leftRoom->displayName(), rightRoom->displayName());
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::HasUnread>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
return typeCompare(leftRoom->contextAwareNotificationCount() > 0, rightRoom->contextAwareNotificationCount() > 0);
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::MostUnread>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
return typeCompare(leftRoom->contextAwareNotificationCount(), rightRoom->contextAwareNotificationCount());
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::HasHighlight>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
const auto leftHighlight = leftRoom->highlightCount() > 0 && leftRoom->contextAwareNotificationCount() > 0;
|
||||
const auto rightHighlight = rightRoom->highlightCount() > 0 && rightRoom->contextAwareNotificationCount() > 0;
|
||||
return typeCompare(leftHighlight, rightHighlight);
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::MostHighlights>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
return typeCompare(int(leftRoom->highlightCount()), int(rightRoom->highlightCount()));
|
||||
}
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::LastActive>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
return typeCompare(leftRoom->lastActiveTime(), rightRoom->lastActiveTime());
|
||||
}
|
||||
122
src/enums/roomsortparameter.h
Normal file
122
src/enums/roomsortparameter.h
Normal file
@@ -0,0 +1,122 @@
|
||||
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "neochatroom.h"
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
/**
|
||||
* @class RoomSortParameter
|
||||
*
|
||||
* A class with the Parameter enum for room sort parameters.
|
||||
*/
|
||||
class RoomSortParameter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_UNCREATABLE("")
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Defines the available sort parameters.
|
||||
*/
|
||||
enum Parameter {
|
||||
AlphabeticalAscending,
|
||||
AlphabeticalDescending,
|
||||
HasUnread,
|
||||
MostUnread,
|
||||
HasHighlight,
|
||||
MostHighlights,
|
||||
LastActive,
|
||||
};
|
||||
Q_ENUM(Parameter)
|
||||
|
||||
/**
|
||||
* @brief Translate the Parameter enum value to a human readable name string.
|
||||
*
|
||||
* @sa Parameter
|
||||
*/
|
||||
static QString parameterName(Parameter parameter)
|
||||
{
|
||||
switch (parameter) {
|
||||
case Parameter::AlphabeticalAscending:
|
||||
return i18nc("As in sorting alphabetically with A first and Z last", "Alphabetical Ascending");
|
||||
case Parameter::AlphabeticalDescending:
|
||||
return i18nc("As in sorting alphabetically with Z first and A last", "Alphabetical Descending");
|
||||
case Parameter::HasUnread:
|
||||
return i18nc("As in sorting rooms with unread message above those without", "Has Unread Messages");
|
||||
case Parameter::MostUnread:
|
||||
return i18nc("As in sorting rooms with the most unread messages higher", "Most Unread Messages");
|
||||
case Parameter::HasHighlight:
|
||||
return i18nc("As in sorting rooms with highlighted message above those without", "Has Highlighted Messages");
|
||||
case Parameter::MostHighlights:
|
||||
return i18nc("As in sorting rooms with the most highlighted messages higher", "Most Highlighted Messages");
|
||||
case Parameter::LastActive:
|
||||
return i18nc("As in sorting the chat room with the newest meassage first", "Last Active");
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Translate the Parameter enum value to a human readable description string.
|
||||
*
|
||||
* @sa Parameter
|
||||
*/
|
||||
static QString parameterDescription(Parameter parameter)
|
||||
{
|
||||
switch (parameter) {
|
||||
case Parameter::AlphabeticalAscending:
|
||||
return i18nc("@info", "Room names closer to A alphabetically are higher");
|
||||
case Parameter::AlphabeticalDescending:
|
||||
return i18nc("@info", "Room names closer to Z alphabetically are higher");
|
||||
case Parameter::HasUnread:
|
||||
return i18nc("@info", "Rooms with unread messages are higher");
|
||||
case Parameter::MostUnread:
|
||||
return i18nc("@info", "Rooms with the most unread message are higher");
|
||||
case Parameter::HasHighlight:
|
||||
return i18nc("@info", "Rooms with highlighted messages are higher");
|
||||
case Parameter::MostHighlights:
|
||||
return i18nc("@info", "Rooms with the most highlighted messages are higher");
|
||||
case Parameter::LastActive:
|
||||
return i18nc("@info", "Rooms with the newer messages are higher");
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Compare the given parameter of the two given rooms.
|
||||
*
|
||||
* @return 0 if they are equal, 1 if the left is greater and -1 if the right is greater.
|
||||
*
|
||||
* @sa Parameter
|
||||
*/
|
||||
static int compareParameter(Parameter parameter, NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
|
||||
private:
|
||||
template<Parameter parameter>
|
||||
static int compareParameter(NeoChatRoom *, NeoChatRoom *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::AlphabeticalAscending>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::AlphabeticalDescending>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::HasUnread>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::MostUnread>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::HasHighlight>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::MostHighlights>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
template<>
|
||||
int RoomSortParameter::compareParameter<RoomSortParameter::LastActive>(NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
@@ -49,16 +49,6 @@ Q_DECLARE_FLAGS(MemberChanges, MemberChange)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(MemberChanges)
|
||||
};
|
||||
|
||||
QString EventHandler::id(const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
qCWarning(EventHandling) << "id called with event set to nullptr.";
|
||||
return {};
|
||||
}
|
||||
|
||||
return !event->id().isEmpty() ? event->id() : event->transactionId();
|
||||
}
|
||||
|
||||
QString EventHandler::authorDisplayName(const NeoChatRoom *room, const Quotient::RoomEvent *event, bool isPending)
|
||||
{
|
||||
if (room == nullptr) {
|
||||
@@ -70,7 +60,7 @@ QString EventHandler::authorDisplayName(const NeoChatRoom *room, const Quotient:
|
||||
return {};
|
||||
}
|
||||
|
||||
if (is<RoomMemberEvent>(*event) && !event->unsignedJson()[QStringLiteral("prev_content")][QStringLiteral("displayname")].isNull()
|
||||
if (is<RoomMemberEvent>(*event) && event->unsignedJson()[QStringLiteral("prev_content")].toObject().contains("displayname"_L1)
|
||||
&& event->stateKey() == event->senderId()) {
|
||||
auto previousDisplayName = event->unsignedJson()[QStringLiteral("prev_content")][QStringLiteral("displayname")].toString().toHtmlEscaped();
|
||||
if (previousDisplayName.isEmpty()) {
|
||||
@@ -291,7 +281,7 @@ QString EventHandler::markdownBody(const Quotient::RoomEvent *event)
|
||||
|
||||
QString EventHandler::getBody(const NeoChatRoom *room, const Quotient::RoomEvent *event, Qt::TextFormat format, bool stripNewlines)
|
||||
{
|
||||
if (event->isRedacted()) {
|
||||
if (event->isRedacted() && !event->isStateEvent()) {
|
||||
auto reason = event->redactedBecause()->reason();
|
||||
return (reason.isEmpty()) ? i18n("<i>[This message was deleted]</i>") : i18n("<i>[This message was deleted: %1]</i>", reason.toHtmlEscaped());
|
||||
}
|
||||
@@ -508,7 +498,7 @@ QString EventHandler::genericBody(const NeoChatRoom *room, const Quotient::RoomE
|
||||
qCWarning(EventHandling) << "genericBody called with event set to nullptr.";
|
||||
return {};
|
||||
}
|
||||
if (event->isRedacted()) {
|
||||
if (event->isRedacted() && !event->isStateEvent()) {
|
||||
return i18n("<i>[This message was deleted]</i>");
|
||||
}
|
||||
|
||||
@@ -834,31 +824,6 @@ QVariantMap EventHandler::getMediaInfoFromTumbnail(const NeoChatRoom *room, cons
|
||||
return thumbnailInfo;
|
||||
}
|
||||
|
||||
bool EventHandler::hasReply(const Quotient::RoomEvent *event, bool showFallbacks)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
qCWarning(EventHandling) << "hasReply called with event set to nullptr.";
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto relations = event->contentPart<QJsonObject>("m.relates_to"_ls);
|
||||
if (!relations.isEmpty()) {
|
||||
const bool hasReplyRelation = relations.contains("m.in_reply_to"_ls);
|
||||
bool isFallingBack = relations["is_falling_back"_ls].toBool();
|
||||
return hasReplyRelation && (showFallbacks ? true : !isFallingBack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString EventHandler::replyId(const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
qCWarning(EventHandling) << "replyId called with event set to nullptr.";
|
||||
return {};
|
||||
}
|
||||
return event->contentJson()["m.relates_to"_ls].toObject()["m.in_reply_to"_ls].toObject()["event_id"_ls].toString();
|
||||
}
|
||||
|
||||
Quotient::RoomMember EventHandler::replyAuthor(const NeoChatRoom *room, const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (room == nullptr) {
|
||||
@@ -877,38 +842,6 @@ Quotient::RoomMember EventHandler::replyAuthor(const NeoChatRoom *room, const Qu
|
||||
}
|
||||
}
|
||||
|
||||
bool EventHandler::isThreaded(const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
qCWarning(EventHandling) << "isThreaded called with event set to nullptr.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return (event->contentPart<QJsonObject>("m.relates_to"_ls).contains("rel_type"_ls)
|
||||
&& event->contentPart<QJsonObject>("m.relates_to"_ls)["rel_type"_ls].toString() == "m.thread"_ls)
|
||||
|| (!event->unsignedPart<QJsonObject>("m.relations"_ls).isEmpty() && event->unsignedPart<QJsonObject>("m.relations"_ls).contains("m.thread"_ls));
|
||||
}
|
||||
|
||||
QString EventHandler::threadRoot(const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
qCWarning(EventHandling) << "threadRoot called with event set to nullptr.";
|
||||
return {};
|
||||
}
|
||||
|
||||
// Get the thread root ID from m.relates_to if it exists.
|
||||
if (event->contentPart<QJsonObject>("m.relates_to"_ls).contains("rel_type"_ls)
|
||||
&& event->contentPart<QJsonObject>("m.relates_to"_ls)["rel_type"_ls].toString() == "m.thread"_ls) {
|
||||
return event->contentPart<QJsonObject>("m.relates_to"_ls)["event_id"_ls].toString();
|
||||
}
|
||||
// For thread root events they have an m.relations in the unsigned part with a m.thread object.
|
||||
// If so return the event ID as it is the root.
|
||||
if (!event->unsignedPart<QJsonObject>("m.relations"_ls).isEmpty() && event->unsignedPart<QJsonObject>("m.relations"_ls).contains("m.thread"_ls)) {
|
||||
return id(event);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
float EventHandler::latitude(const Quotient::RoomEvent *event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
|
||||
@@ -37,14 +37,6 @@ class NeoChatRoom;
|
||||
class EventHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Return the ID of the event.
|
||||
*
|
||||
* Returns the transaction ID if the Matrix ID is empty, which may be the case
|
||||
* for a pending event.
|
||||
*/
|
||||
static QString id(const Quotient::RoomEvent *event);
|
||||
|
||||
/**
|
||||
* @brief Get the display name of the event author.
|
||||
*
|
||||
@@ -220,20 +212,6 @@ public:
|
||||
*/
|
||||
static QVariantMap mediaInfo(const NeoChatRoom *room, const Quotient::RoomEvent *event);
|
||||
|
||||
/**
|
||||
* @brief Whether the event is a reply to another in the timeline.
|
||||
*
|
||||
* @param showFallbacks whether message that have is_falling_back set true should
|
||||
* show the fallback reply. Leave true for non-threaded
|
||||
* timelines.
|
||||
*/
|
||||
static bool hasReply(const Quotient::RoomEvent *event, bool showFallbacks = true);
|
||||
|
||||
/**
|
||||
* @brief Return the Matrix ID of the event replied to.
|
||||
*/
|
||||
static QString replyId(const Quotient::RoomEvent *event);
|
||||
|
||||
/**
|
||||
* @brief Get the author of the event replied to in context of the room.
|
||||
*
|
||||
@@ -249,20 +227,6 @@ public:
|
||||
*/
|
||||
static Quotient::RoomMember replyAuthor(const NeoChatRoom *room, const Quotient::RoomEvent *event);
|
||||
|
||||
/**
|
||||
* @brief Whether the message is part of a thread.
|
||||
*
|
||||
* i.e. There is a rel_type of m.thread.
|
||||
*/
|
||||
static bool isThreaded(const Quotient::RoomEvent *event);
|
||||
|
||||
/**
|
||||
* @brief Return the Matrix ID of the thread's root message.
|
||||
*
|
||||
* Empty if this not part of a thread.
|
||||
*/
|
||||
static QString threadRoot(const Quotient::RoomEvent *event);
|
||||
|
||||
/**
|
||||
* @brief Return the latitude for the event.
|
||||
*
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
#include "linkpreviewer.h"
|
||||
|
||||
#include <Quotient/connection.h>
|
||||
#include <Quotient/csapi/authed-content-repo.h>
|
||||
#include <Quotient/csapi/content-repo.h>
|
||||
|
||||
#include <Quotient/events/roommessageevent.h>
|
||||
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace Quotient;
|
||||
@@ -61,7 +62,13 @@ void LinkPreviewer::loadUrlPreview()
|
||||
if (conn == nullptr) {
|
||||
return;
|
||||
}
|
||||
GetUrlPreviewJob *job = conn->callApi<GetUrlPreviewJob>(m_url);
|
||||
|
||||
BaseJob *job = nullptr;
|
||||
if (conn->supportedMatrixSpecVersions().contains("v1.11"_L1)) {
|
||||
job = conn->callApi<GetUrlPreviewAuthedJob>(m_url);
|
||||
} else {
|
||||
QT_IGNORE_DEPRECATIONS(job = conn->callApi<GetUrlPreviewJob>(m_url);)
|
||||
}
|
||||
|
||||
connect(job, &BaseJob::success, this, [this, job, conn]() {
|
||||
const auto json = job->jsonData();
|
||||
|
||||
@@ -271,7 +271,6 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QCoreApplication::quit);
|
||||
engine.setNetworkAccessManagerFactory(new NetworkAccessManagerFactory());
|
||||
|
||||
if (parser.isSet("ignore-ssl-errors"_ls)) {
|
||||
|
||||
@@ -109,11 +109,10 @@ QList<ActionsModel::Action> actions{
|
||||
rainbowText += QStringLiteral("<font color='%2'>%3</font>").arg(rainbowColors[i % rainbowColors.length()], text.at(i));
|
||||
}
|
||||
// Ideally, we would just return rainbowText and let that do the rest, but the colors don't survive markdownToHTML.
|
||||
room->postMessage(QStringLiteral("/rainbow %1").arg(text),
|
||||
rainbowText,
|
||||
RoomMessageEvent::MsgType::Text,
|
||||
chatBarCache->replyId(),
|
||||
chatBarCache->editId());
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(rainbowText, u"text/html"_s);
|
||||
EventRelation relatesTo =
|
||||
chatBarCache->isReplying() ? EventRelation::replyTo(chatBarCache->replyId()) : EventRelation::replace(chatBarCache->editId());
|
||||
room->post<Quotient::RoomMessageEvent>("/rainbow %1"_L1.arg(text), MessageEventType::Text, std::move(content), relatesTo);
|
||||
return QString();
|
||||
},
|
||||
false,
|
||||
@@ -129,11 +128,10 @@ QList<ActionsModel::Action> actions{
|
||||
rainbowText += QStringLiteral("<font color='%2'>%3</font>").arg(rainbowColors[i % rainbowColors.length()], text.at(i));
|
||||
}
|
||||
// Ideally, we would just return rainbowText and let that do the rest, but the colors don't survive markdownToHTML.
|
||||
room->postMessage(QStringLiteral("/rainbow %1").arg(text),
|
||||
rainbowText,
|
||||
RoomMessageEvent::MsgType::Emote,
|
||||
chatBarCache->replyId(),
|
||||
chatBarCache->editId());
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(rainbowText, u"text/html"_s);
|
||||
EventRelation relatesTo =
|
||||
chatBarCache->isReplying() ? EventRelation::replyTo(chatBarCache->replyId()) : EventRelation::replace(chatBarCache->editId());
|
||||
room->post<Quotient::RoomMessageEvent>(u"/rainbow %1"_s.arg(text), MessageEventType::Text, std::move(content), relatesTo);
|
||||
return QString();
|
||||
},
|
||||
false,
|
||||
@@ -144,7 +142,7 @@ QList<ActionsModel::Action> actions{
|
||||
Action{
|
||||
QStringLiteral("plain"),
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
room->postMessage(text, text.toHtmlEscaped(), RoomMessageEvent::MsgType::Text, {}, {});
|
||||
room->postPlainText(text.toHtmlEscaped());
|
||||
return QString();
|
||||
},
|
||||
false,
|
||||
@@ -156,11 +154,10 @@ QList<ActionsModel::Action> actions{
|
||||
QStringLiteral("spoiler"),
|
||||
[](const QString &text, NeoChatRoom *room, ChatBarCache *chatBarCache) {
|
||||
// Ideally, we would just return rainbowText and let that do the rest, but the colors don't survive markdownToHTML.
|
||||
room->postMessage(QStringLiteral("/spoiler %1").arg(text),
|
||||
QStringLiteral("<span data-mx-spoiler>%1</span>").arg(text),
|
||||
RoomMessageEvent::MsgType::Text,
|
||||
chatBarCache->replyId(),
|
||||
chatBarCache->editId());
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(u"<span data-mx-spoiler>%1</span>"_s.arg(text), u"text/html"_s);
|
||||
EventRelation relatesTo =
|
||||
chatBarCache->isReplying() ? EventRelation::replyTo(chatBarCache->replyId()) : EventRelation::replace(chatBarCache->editId());
|
||||
room->post<Quotient::RoomMessageEvent>(u"/spoiler %1"_s.arg(text), MessageEventType::Text, std::move(content), relatesTo);
|
||||
return QString();
|
||||
},
|
||||
false,
|
||||
@@ -605,15 +602,15 @@ bool ActionsModel::handleQuickEditAction(NeoChatRoom *room, const QString &messa
|
||||
if (eventRelation && eventRelation->type == "m.replace"_L1) {
|
||||
replaceId = eventRelation->eventId;
|
||||
}
|
||||
|
||||
std::unique_ptr<EventContent::TextContent> content = nullptr;
|
||||
if (flags == "/g"_L1) {
|
||||
room->postHtmlMessage(messageText, originalString.replace(regex, replacement), event->msgtype(), {}, replaceId);
|
||||
content = std::make_unique<Quotient::EventContent::TextContent>(originalString.replace(regex, replacement), u"text/html"_s);
|
||||
} else {
|
||||
room->postHtmlMessage(messageText,
|
||||
originalString.replace(originalString.indexOf(regex), regex.size(), replacement),
|
||||
event->msgtype(),
|
||||
{},
|
||||
replaceId);
|
||||
content = std::make_unique<Quotient::EventContent::TextContent>(originalString.replace(regex, replacement), u"text/html"_s);
|
||||
}
|
||||
Quotient::EventRelation relatesTo = Quotient::EventRelation::replace(replaceId);
|
||||
room->post<Quotient::RoomMessageEvent>(messageText, event->msgtype(), std::move(content), relatesTo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ MessageContentModel::MessageContentModel(NeoChatRoom *room, const QString &event
|
||||
: QAbstractListModel(parent)
|
||||
, m_room(room)
|
||||
, m_eventId(eventId)
|
||||
, m_isPending(isPending)
|
||||
, m_currentState(isPending ? Pending : Unknown)
|
||||
, m_isReply(isReply)
|
||||
{
|
||||
initializeModel();
|
||||
@@ -45,19 +45,27 @@ void MessageContentModel::initializeModel()
|
||||
Q_ASSERT(m_room != nullptr);
|
||||
Q_ASSERT(!m_eventId.isEmpty());
|
||||
|
||||
connect(this, &MessageContentModel::eventUnavailable, this, &MessageContentModel::getEvent);
|
||||
|
||||
connect(m_room, &NeoChatRoom::pendingEventAdded, this, [this]() {
|
||||
if (m_room != nullptr && m_currentState == Unknown) {
|
||||
initializeEvent();
|
||||
updateReplyModel();
|
||||
resetModel();
|
||||
}
|
||||
});
|
||||
connect(m_room, &NeoChatRoom::pendingEventAboutToMerge, this, [this](Quotient::RoomEvent *serverEvent) {
|
||||
if (m_room != nullptr) {
|
||||
if (m_eventId == serverEvent->id() || m_eventId == serverEvent->transactionId()) {
|
||||
beginResetModel();
|
||||
m_isPending = false;
|
||||
m_eventId = serverEvent->id();
|
||||
initializeEvent();
|
||||
endResetModel();
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(m_room, &NeoChatRoom::pendingEventMerged, this, [this]() {
|
||||
if (m_room != nullptr && m_currentState == Pending) {
|
||||
initializeEvent();
|
||||
updateReplyModel();
|
||||
resetModel();
|
||||
}
|
||||
});
|
||||
connect(m_room, &NeoChatRoom::addedMessages, this, [this](int fromIndex, int toIndex) {
|
||||
if (m_room != nullptr) {
|
||||
for (int i = fromIndex; i <= toIndex; i++) {
|
||||
@@ -143,20 +151,33 @@ void MessageContentModel::initializeModel()
|
||||
});
|
||||
|
||||
initializeEvent();
|
||||
updateReplyModel();
|
||||
if (m_currentState == Available || m_currentState == Pending) {
|
||||
updateReplyModel();
|
||||
}
|
||||
resetModel();
|
||||
}
|
||||
|
||||
void MessageContentModel::initializeEvent()
|
||||
{
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (event == nullptr) {
|
||||
Q_EMIT eventUnavailable();
|
||||
if (m_currentState == UnAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto eventResult = m_room->getEvent(m_eventId);
|
||||
if (eventResult.first == nullptr) {
|
||||
if (m_currentState != Pending) {
|
||||
getEvent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (eventResult.second) {
|
||||
m_currentState = Pending;
|
||||
} else {
|
||||
m_currentState = Available;
|
||||
}
|
||||
|
||||
if (m_eventSenderObject == nullptr) {
|
||||
auto senderId = event->senderId();
|
||||
auto senderId = eventResult.first->senderId();
|
||||
// A pending event might not have a sender ID set yet but in that case it must
|
||||
// be the local member.
|
||||
if (senderId.isEmpty()) {
|
||||
@@ -172,7 +193,6 @@ void MessageContentModel::getEvent()
|
||||
Quotient::connectUntil(m_room.get(), &NeoChatRoom::extraEventLoaded, this, [this](const QString &eventId) {
|
||||
if (m_room != nullptr) {
|
||||
if (eventId == m_eventId) {
|
||||
m_notFound = false;
|
||||
initializeEvent();
|
||||
updateReplyModel();
|
||||
resetModel();
|
||||
@@ -184,7 +204,7 @@ void MessageContentModel::getEvent()
|
||||
Quotient::connectUntil(m_room.get(), &NeoChatRoom::extraEventNotFound, this, [this](const QString &eventId) {
|
||||
if (m_room != nullptr) {
|
||||
if (eventId == m_eventId) {
|
||||
m_notFound = true;
|
||||
m_currentState = UnAvailable;
|
||||
resetModel();
|
||||
return true;
|
||||
}
|
||||
@@ -237,7 +257,7 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
const auto component = m_components[index.row()];
|
||||
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (event == nullptr) {
|
||||
if (event.first == nullptr) {
|
||||
if (role == DisplayRole) {
|
||||
if (m_isReply) {
|
||||
return i18n("Loading reply");
|
||||
@@ -252,7 +272,7 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
if (role == DisplayRole) {
|
||||
if (m_notFound || m_room->connection()->isIgnored(m_eventSenderId)) {
|
||||
if (m_currentState == UnAvailable || m_room->connection()->isIgnored(m_eventSenderId)) {
|
||||
Kirigami::Platform::PlatformTheme *theme =
|
||||
static_cast<Kirigami::Platform::PlatformTheme *>(qmlAttachedPropertiesObject<Kirigami::Platform::PlatformTheme>(this, true));
|
||||
|
||||
@@ -276,7 +296,7 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
if (!component.content.isEmpty()) {
|
||||
return component.content;
|
||||
}
|
||||
return EventHandler::richBody(m_room, event);
|
||||
return EventHandler::richBody(m_room, event.first);
|
||||
}
|
||||
if (role == ComponentTypeRole) {
|
||||
return component.type;
|
||||
@@ -285,53 +305,55 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||
return component.attributes;
|
||||
}
|
||||
if (role == EventIdRole) {
|
||||
return EventHandler::id(event);
|
||||
return event.first->displayId();
|
||||
}
|
||||
if (role == TimeRole) {
|
||||
const auto pendingIt = std::find_if(m_room->pendingEvents().cbegin(), m_room->pendingEvents().cend(), [event](const PendingEventItem &pendingEvent) {
|
||||
return event->transactionId() == pendingEvent->transactionId();
|
||||
return event.first->transactionId() == pendingEvent->transactionId();
|
||||
});
|
||||
|
||||
auto lastUpdated = pendingIt == m_room->pendingEvents().cend() ? QDateTime() : pendingIt->lastUpdated();
|
||||
return EventHandler::time(event, m_isPending, lastUpdated);
|
||||
return EventHandler::time(event.first, m_currentState == Pending, lastUpdated);
|
||||
}
|
||||
if (role == TimeStringRole) {
|
||||
const auto pendingIt = std::find_if(m_room->pendingEvents().cbegin(), m_room->pendingEvents().cend(), [event](const PendingEventItem &pendingEvent) {
|
||||
return event->transactionId() == pendingEvent->transactionId();
|
||||
return event.first->transactionId() == pendingEvent->transactionId();
|
||||
});
|
||||
|
||||
auto lastUpdated = pendingIt == m_room->pendingEvents().cend() ? QDateTime() : pendingIt->lastUpdated();
|
||||
return EventHandler::timeString(event, QStringLiteral("hh:mm"), m_isPending, lastUpdated);
|
||||
return EventHandler::timeString(event.first, QStringLiteral("hh:mm"), m_currentState == Pending, lastUpdated);
|
||||
}
|
||||
if (role == AuthorRole) {
|
||||
return QVariant::fromValue<NeochatRoomMember *>(m_eventSenderObject.get());
|
||||
}
|
||||
if (role == MediaInfoRole) {
|
||||
return EventHandler::mediaInfo(m_room, event);
|
||||
return EventHandler::mediaInfo(m_room, event.first);
|
||||
}
|
||||
if (role == FileTransferInfoRole) {
|
||||
return QVariant::fromValue(m_room->cachedFileTransferInfo(event));
|
||||
return QVariant::fromValue(m_room->cachedFileTransferInfo(event.first));
|
||||
}
|
||||
if (role == ItineraryModelRole) {
|
||||
return QVariant::fromValue<ItineraryModel *>(m_itineraryModel);
|
||||
}
|
||||
if (role == LatitudeRole) {
|
||||
return EventHandler::latitude(event);
|
||||
return EventHandler::latitude(event.first);
|
||||
}
|
||||
if (role == LongitudeRole) {
|
||||
return EventHandler::longitude(event);
|
||||
return EventHandler::longitude(event.first);
|
||||
}
|
||||
if (role == AssetRole) {
|
||||
return EventHandler::locationAssetType(event);
|
||||
return EventHandler::locationAssetType(event.first);
|
||||
}
|
||||
if (role == PollHandlerRole) {
|
||||
return QVariant::fromValue<PollHandler *>(m_room->poll(m_eventId));
|
||||
}
|
||||
if (role == ReplyEventIdRole) {
|
||||
return EventHandler::replyId(event);
|
||||
if (const auto roomMessageEvent = eventCast<const RoomMessageEvent>(event.first)) {
|
||||
return roomMessageEvent->replyEventId();
|
||||
}
|
||||
}
|
||||
if (role == ReplyAuthorRole) {
|
||||
return QVariant::fromValue(EventHandler::replyAuthor(m_room, event));
|
||||
return QVariant::fromValue(EventHandler::replyAuthor(m_room, event.first));
|
||||
}
|
||||
if (role == ReplyContentModelRole) {
|
||||
return QVariant::fromValue<MessageContentModel *>(m_replyModel);
|
||||
@@ -387,18 +409,17 @@ QHash<int, QByteArray> MessageContentModel::roleNames() const
|
||||
|
||||
void MessageContentModel::resetModel()
|
||||
{
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
|
||||
beginResetModel();
|
||||
m_components.clear();
|
||||
|
||||
if (m_room->connection()->isIgnored(m_eventSenderId) || m_notFound) {
|
||||
if (m_room->connection()->isIgnored(m_eventSenderId) || m_currentState == UnAvailable) {
|
||||
m_components += MessageComponent{MessageComponentType::Text, QString(), {}};
|
||||
endResetModel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event == nullptr) {
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (event.first == nullptr) {
|
||||
m_components += MessageComponent{MessageComponentType::Loading, QString(), {}};
|
||||
endResetModel();
|
||||
return;
|
||||
@@ -431,19 +452,19 @@ void MessageContentModel::resetContent(bool isEditing, bool isThreading)
|
||||
QList<MessageComponent> MessageContentModel::messageContentComponents(bool isEditing, bool isThreading)
|
||||
{
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (event == nullptr) {
|
||||
if (event.first == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<MessageComponent> newComponents;
|
||||
|
||||
if (eventCast<const Quotient::RoomMessageEvent>(event)
|
||||
&& eventCast<const Quotient::RoomMessageEvent>(event)->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||
if (roomMessageEvent && roomMessageEvent->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
|
||||
newComponents += MessageComponent{MessageComponentType::Verification, QString(), {}};
|
||||
return newComponents;
|
||||
}
|
||||
|
||||
if (event->isRedacted()) {
|
||||
if (event.first->isRedacted()) {
|
||||
newComponents += MessageComponent{MessageComponentType::Text, QString(), {}};
|
||||
return newComponents;
|
||||
}
|
||||
@@ -455,7 +476,7 @@ QList<MessageComponent> MessageContentModel::messageContentComponents(bool isEdi
|
||||
if (isEditing) {
|
||||
newComponents += MessageComponent{MessageComponentType::ChatBar, QString(), {}};
|
||||
} else {
|
||||
newComponents.append(componentsForType(MessageComponentType::typeForEvent(*event)));
|
||||
newComponents.append(componentsForType(MessageComponentType::typeForEvent(*event.first)));
|
||||
}
|
||||
|
||||
if (m_room->urlPreviewEnabled()) {
|
||||
@@ -463,7 +484,7 @@ QList<MessageComponent> MessageContentModel::messageContentComponents(bool isEdi
|
||||
}
|
||||
|
||||
// If the event is already threaded the ThreadModel will handle displaying a chat bar.
|
||||
if (isThreading && !EventHandler::isThreaded(event)) {
|
||||
if (isThreading && roomMessageEvent && roomMessageEvent->isThreaded()) {
|
||||
newComponents += MessageComponent{MessageComponentType::ChatBar, QString(), {}};
|
||||
}
|
||||
|
||||
@@ -473,11 +494,15 @@ QList<MessageComponent> MessageContentModel::messageContentComponents(bool isEdi
|
||||
void MessageContentModel::updateReplyModel()
|
||||
{
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (event == nullptr || m_isReply) {
|
||||
if (event.first == nullptr || m_isReply) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EventHandler::hasReply(event) || (EventHandler::isThreaded(event) && NeoChatConfig::self()->threads())) {
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||
if (roomMessageEvent == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!roomMessageEvent->isReply() || (roomMessageEvent->isThreaded() && NeoChatConfig::self()->threads())) {
|
||||
if (m_replyModel) {
|
||||
delete m_replyModel;
|
||||
}
|
||||
@@ -488,7 +513,7 @@ void MessageContentModel::updateReplyModel()
|
||||
return;
|
||||
}
|
||||
|
||||
m_replyModel = new MessageContentModel(m_room, EventHandler::replyId(event), true, false, this);
|
||||
m_replyModel = new MessageContentModel(m_room, roomMessageEvent->replyEventId(), true, false, this);
|
||||
|
||||
connect(m_replyModel, &MessageContentModel::eventUpdated, this, [this]() {
|
||||
Q_EMIT dataChanged(index(0), index(0), {ReplyAuthorRole});
|
||||
@@ -498,13 +523,13 @@ void MessageContentModel::updateReplyModel()
|
||||
QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentType::Type type)
|
||||
{
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (event == nullptr) {
|
||||
if (event.first == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case MessageComponentType::Text: {
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event);
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||
auto body = EventHandler::rawMessageBody(*roomMessageEvent);
|
||||
return TextHandler().textComponents(body,
|
||||
EventHandler::messageBodyInputFormat(*roomMessageEvent),
|
||||
@@ -515,11 +540,11 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
|
||||
case MessageComponentType::File: {
|
||||
QList<MessageComponent> components;
|
||||
components += MessageComponent{MessageComponentType::File, QString(), {}};
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event);
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||
|
||||
if (m_emptyItinerary) {
|
||||
if (!m_isReply) {
|
||||
auto fileTransferInfo = m_room->cachedFileTransferInfo(event);
|
||||
auto fileTransferInfo = m_room->cachedFileTransferInfo(event.first);
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->has<EventContent::FileContent>());
|
||||
@@ -567,8 +592,8 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
|
||||
case MessageComponentType::Image:
|
||||
case MessageComponentType::Audio:
|
||||
case MessageComponentType::Video: {
|
||||
if (!event->is<StickerEvent>()) {
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event);
|
||||
if (!event.first->is<StickerEvent>()) {
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
|
||||
const auto fileContent = roomMessageEvent->get<EventContent::FileContentBase>();
|
||||
if (fileContent != nullptr) {
|
||||
const auto fileInfo = fileContent->commonInfo();
|
||||
@@ -587,6 +612,7 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
|
||||
}
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
default:
|
||||
return {MessageComponent{type, QString(), {}}};
|
||||
}
|
||||
@@ -660,13 +686,13 @@ void MessageContentModel::closeLinkPreview(int row)
|
||||
void MessageContentModel::updateItineraryModel()
|
||||
{
|
||||
const auto event = m_room->getEvent(m_eventId);
|
||||
if (m_room == nullptr || event == nullptr) {
|
||||
if (m_room == nullptr || event.first == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||
if (auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first)) {
|
||||
if (roomMessageEvent->has<EventContent::FileContent>()) {
|
||||
auto filePath = m_room->cachedFileTransferInfo(event).localPath;
|
||||
auto filePath = m_room->cachedFileTransferInfo(event.first).localPath;
|
||||
if (filePath.isEmpty() && m_itineraryModel != nullptr) {
|
||||
delete m_itineraryModel;
|
||||
m_itineraryModel = nullptr;
|
||||
|
||||
@@ -31,6 +31,14 @@ class MessageContentModel : public QAbstractListModel
|
||||
Q_PROPERTY(bool showAuthor READ showAuthor WRITE setShowAuthor NOTIFY showAuthorChanged)
|
||||
|
||||
public:
|
||||
enum MessageState {
|
||||
Unknown, /**< The message state is unknown. */
|
||||
Pending, /**< The message is a new pending message which the server has not yet acknowledged. */
|
||||
Available, /**< The message is available and acknowledged by the server. */
|
||||
UnAvailable, /**< The message can't be retrieved either because it doesn't exist or is blocked. */
|
||||
};
|
||||
Q_ENUM(MessageState)
|
||||
|
||||
/**
|
||||
* @brief Defines the model roles.
|
||||
*/
|
||||
@@ -98,7 +106,6 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void showAuthorChanged();
|
||||
void eventUnavailable();
|
||||
void eventUpdated();
|
||||
|
||||
private:
|
||||
@@ -107,10 +114,9 @@ private:
|
||||
QString m_eventSenderId;
|
||||
std::unique_ptr<NeochatRoomMember> m_eventSenderObject = nullptr;
|
||||
|
||||
bool m_isPending;
|
||||
MessageState m_currentState = Unknown;
|
||||
bool m_showAuthor = true;
|
||||
bool m_isReply;
|
||||
bool m_notFound = false;
|
||||
|
||||
void initializeModel();
|
||||
void initializeEvent();
|
||||
|
||||
@@ -160,12 +160,21 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
refreshLastUserEvents(i);
|
||||
}
|
||||
});
|
||||
#if Quotient_VERSION_MINOR > 9 || (Quotient_VERSION_MINOR == 9 && Quotient_VERSION_PATCH > 0)
|
||||
connect(m_currentRoom, &Room::pendingEventAdded, this, [this](const Quotient::RoomEvent *event) {
|
||||
m_initialized = true;
|
||||
createEventObjects(event, true);
|
||||
beginInsertRows({}, 0, 0);
|
||||
endInsertRows();
|
||||
});
|
||||
#else
|
||||
connect(m_currentRoom, &Room::pendingEventAboutToAdd, this, [this](Quotient::RoomEvent *event) {
|
||||
m_initialized = true;
|
||||
createEventObjects(event);
|
||||
createEventObjects(event, true);
|
||||
beginInsertRows({}, 0, 0);
|
||||
});
|
||||
connect(m_currentRoom, &Room::pendingEventAdded, this, &MessageEventModel::endInsertRows);
|
||||
#endif
|
||||
connect(m_currentRoom, &Room::pendingEventAboutToMerge, this, [this](RoomEvent *, int i) {
|
||||
Q_EMIT dataChanged(index(i, 0), index(i, 0), {IsPendingRole});
|
||||
if (i == 0) {
|
||||
@@ -492,7 +501,8 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
return EventStatus::Hidden;
|
||||
}
|
||||
|
||||
if (EventHandler::isThreaded(&evt) && EventHandler::threadRoot(&evt) != EventHandler::id(&evt) && NeoChatConfig::threads()) {
|
||||
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&evt);
|
||||
if (roomMessageEvent && roomMessageEvent->isThreaded() && roomMessageEvent->threadRootEventId() != evt.id() && NeoChatConfig::threads()) {
|
||||
return EventStatus::Hidden;
|
||||
}
|
||||
|
||||
@@ -500,7 +510,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
}
|
||||
|
||||
if (role == EventIdRole) {
|
||||
return EventHandler::id(&evt);
|
||||
return evt.displayId();
|
||||
}
|
||||
|
||||
if (role == ProgressInfoRole) {
|
||||
@@ -525,11 +535,18 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
}
|
||||
|
||||
if (role == IsThreadedRole) {
|
||||
return EventHandler::isThreaded(&evt);
|
||||
if (auto roomMessageEvent = eventCast<const RoomMessageEvent>(&evt)) {
|
||||
return roomMessageEvent->isThreaded();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
if (role == ThreadRootRole) {
|
||||
return EventHandler::threadRoot(&evt);
|
||||
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&evt);
|
||||
if (roomMessageEvent && roomMessageEvent->isThreaded()) {
|
||||
return roomMessageEvent->threadRootEventId();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
if (role == ShowSectionRole) {
|
||||
@@ -618,7 +635,7 @@ int MessageEventModel::eventIdToRow(const QString &eventID) const
|
||||
return it - m_currentRoom->messageEvents().rbegin() + timelineBaseIndex();
|
||||
}
|
||||
|
||||
void MessageEventModel::createEventObjects(const Quotient::RoomEvent *event)
|
||||
void MessageEventModel::createEventObjects(const Quotient::RoomEvent *event, bool isPending)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
return;
|
||||
@@ -641,12 +658,14 @@ void MessageEventModel::createEventObjects(const Quotient::RoomEvent *event)
|
||||
|
||||
if (!m_contentModels.contains(eventId) && !m_contentModels.contains(event->transactionId())) {
|
||||
if (!event->isStateEvent() || event->matrixType() == QStringLiteral("org.matrix.msc3672.beacon_info")) {
|
||||
m_contentModels[eventId] = std::unique_ptr<MessageContentModel>(new MessageContentModel(m_currentRoom, eventId));
|
||||
m_contentModels[eventId] = std::unique_ptr<MessageContentModel>(new MessageContentModel(m_currentRoom, eventId, false, isPending));
|
||||
}
|
||||
}
|
||||
|
||||
if (EventHandler::isThreaded(event) && !m_threadModels.contains(EventHandler::threadRoot(event))) {
|
||||
m_threadModels[EventHandler::threadRoot(event)] = QSharedPointer<ThreadModel>(new ThreadModel(EventHandler::threadRoot(event), m_currentRoom));
|
||||
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event);
|
||||
if (roomMessageEvent && roomMessageEvent->isThreaded() && !m_threadModels.contains(roomMessageEvent->threadRootEventId())) {
|
||||
m_threadModels[roomMessageEvent->threadRootEventId()] =
|
||||
QSharedPointer<ThreadModel>(new ThreadModel(roomMessageEvent->threadRootEventId(), m_currentRoom));
|
||||
}
|
||||
|
||||
// ReadMarkerModel handles updates to add and remove markers, we only need to
|
||||
|
||||
@@ -136,7 +136,7 @@ private:
|
||||
int refreshEventRoles(const QString &eventId, const QList<int> &roles = {});
|
||||
void moveReadMarker(const QString &toEventId);
|
||||
|
||||
void createEventObjects(const Quotient::RoomEvent *event);
|
||||
void createEventObjects(const Quotient::RoomEvent *event, bool isPending = false);
|
||||
// Hack to ensure that we don't call endInsertRows when we haven't called beginInsertRows
|
||||
bool m_initialized = false;
|
||||
|
||||
|
||||
@@ -8,6 +8,23 @@
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
class NeoChatQueryPublicRoomsJob : public QueryPublicRoomsJob
|
||||
{
|
||||
public:
|
||||
explicit NeoChatQueryPublicRoomsJob(const QString &server = {},
|
||||
std::optional<int> limit = std::nullopt,
|
||||
const QString &since = {},
|
||||
const std::optional<Filter> &filter = std::nullopt,
|
||||
std::optional<bool> includeAllNetworks = std::nullopt,
|
||||
const QString &thirdPartyInstanceId = {})
|
||||
: QueryPublicRoomsJob(server, limit, since, filter, includeAllNetworks, thirdPartyInstanceId)
|
||||
{
|
||||
// TODO Remove once we can use libQuotient's job directly
|
||||
// This is to make libQuotient happy about results not having the "chunk" field
|
||||
setExpectedKeys({});
|
||||
}
|
||||
};
|
||||
|
||||
PublicRoomListModel::PublicRoomListModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
@@ -153,6 +170,8 @@ void PublicRoomListModel::next(int limit)
|
||||
if (m_connection == nullptr || limit < 1) {
|
||||
return;
|
||||
}
|
||||
m_redirectedText.clear();
|
||||
Q_EMIT redirectedChanged();
|
||||
|
||||
if (job) {
|
||||
qCDebug(PublicRoomList) << "Other job running, ignore";
|
||||
@@ -163,7 +182,7 @@ void PublicRoomListModel::next(int limit)
|
||||
if (m_showOnlySpaces) {
|
||||
roomTypes += QLatin1String("m.space");
|
||||
}
|
||||
job = m_connection->callApi<QueryPublicRoomsJob>(m_server, limit, nextBatch, QueryPublicRoomsJob::Filter{m_searchText, roomTypes});
|
||||
job = m_connection->callApi<NeoChatQueryPublicRoomsJob>(m_server, limit, nextBatch, QueryPublicRoomsJob::Filter{m_searchText, roomTypes});
|
||||
Q_EMIT searchingChanged();
|
||||
|
||||
connect(job, &BaseJob::finished, this, [this] {
|
||||
@@ -181,6 +200,9 @@ void PublicRoomListModel::next(int limit)
|
||||
this->beginInsertRows({}, rooms.count(), rooms.count() + job->chunk().count() - 1);
|
||||
rooms.append(job->chunk());
|
||||
this->endInsertRows();
|
||||
} else if (job->error() == BaseJob::ContentAccessError) {
|
||||
m_redirectedText = job->jsonData()[u"error"_s].toString();
|
||||
Q_EMIT redirectedChanged();
|
||||
}
|
||||
|
||||
this->job = nullptr;
|
||||
@@ -302,4 +324,9 @@ bool PublicRoomListModel::searching() const
|
||||
return job != nullptr;
|
||||
}
|
||||
|
||||
QString PublicRoomListModel::redirectedText() const
|
||||
{
|
||||
return m_redirectedText;
|
||||
}
|
||||
|
||||
#include "moc_publicroomlistmodel.cpp"
|
||||
|
||||
@@ -52,6 +52,11 @@ class PublicRoomListModel : public QAbstractListModel
|
||||
*/
|
||||
Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged)
|
||||
|
||||
/**
|
||||
* @brief The text returned by the server after redirection
|
||||
*/
|
||||
Q_PROPERTY(QString redirectedText READ redirectedText NOTIFY redirectedChanged)
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Defines the model roles.
|
||||
@@ -113,6 +118,8 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void search(int limit = 50);
|
||||
|
||||
QString redirectedText() const;
|
||||
|
||||
private:
|
||||
QPointer<NeoChatConnection> m_connection = nullptr;
|
||||
QString m_server;
|
||||
@@ -135,6 +142,7 @@ private:
|
||||
QList<Quotient::PublicRoomsChunk> rooms;
|
||||
|
||||
Quotient::QueryPublicRoomsJob *job = nullptr;
|
||||
QString m_redirectedText;
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectionChanged();
|
||||
@@ -142,4 +150,5 @@ Q_SIGNALS:
|
||||
void searchTextChanged();
|
||||
void showOnlySpacesChanged();
|
||||
void searchingChanged();
|
||||
void redirectedChanged();
|
||||
};
|
||||
|
||||
@@ -129,7 +129,7 @@ void RoomListModel::connectRoomSignals(NeoChatRoom *room)
|
||||
refresh(room);
|
||||
});
|
||||
connect(room, &Room::addedMessages, this, [this, room] {
|
||||
refresh(room, {SubtitleTextRole, LastActiveTimeRole});
|
||||
refresh(room, {SubtitleTextRole});
|
||||
});
|
||||
connect(room, &Room::pendingEventMerged, this, [this, room] {
|
||||
refresh(room, {SubtitleTextRole});
|
||||
@@ -229,9 +229,6 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
||||
if (role == HasHighlightNotificationsRole) {
|
||||
return room->highlightCount() > 0 && room->contextAwareNotificationCount() > 0;
|
||||
}
|
||||
if (role == LastActiveTimeRole) {
|
||||
return room->lastActiveTime();
|
||||
}
|
||||
if (role == JoinStateRole) {
|
||||
if (!room->successorId().isEmpty()) {
|
||||
return QStringLiteral("upgraded");
|
||||
@@ -291,7 +288,6 @@ QHash<int, QByteArray> RoomListModel::roleNames() const
|
||||
roles[CategoryRole] = "category";
|
||||
roles[ContextNotificationCountRole] = "contextNotificationCount";
|
||||
roles[HasHighlightNotificationsRole] = "hasHighlightNotifications";
|
||||
roles[LastActiveTimeRole] = "lastActiveTime";
|
||||
roles[JoinStateRole] = "joinState";
|
||||
roles[CurrentRoomRole] = "currentRoom";
|
||||
roles[SubtitleTextRole] = "subtitleText";
|
||||
|
||||
@@ -43,7 +43,6 @@ public:
|
||||
CategoryRole, /**< The room category, e.g favourite. */
|
||||
ContextNotificationCountRole, /**< The context aware notification count for the room. */
|
||||
HasHighlightNotificationsRole, /**< Whether there are any highlight notifications. */
|
||||
LastActiveTimeRole, /**< The timestamp of the last event sent in the room. */
|
||||
JoinStateRole, /**< The local user's join state in the room. */
|
||||
CurrentRoomRole, /**< The room object for the room. */
|
||||
SubtitleTextRole, /**< The text to show as the room subtitle. */
|
||||
|
||||
@@ -176,7 +176,7 @@ void RoomTreeModel::connectRoomSignals(NeoChatRoom *room)
|
||||
refreshRoomRoles(room);
|
||||
});
|
||||
connect(room, &Room::addedMessages, this, [this, room] {
|
||||
refreshRoomRoles(room, {SubtitleTextRole, LastActiveTimeRole});
|
||||
refreshRoomRoles(room, {SubtitleTextRole});
|
||||
});
|
||||
connect(room, &Room::pendingEventMerged, this, [this, room] {
|
||||
refreshRoomRoles(room, {SubtitleTextRole});
|
||||
@@ -274,7 +274,6 @@ QHash<int, QByteArray> RoomTreeModel::roleNames() const
|
||||
roles[CategoryRole] = "category";
|
||||
roles[ContextNotificationCountRole] = "contextNotificationCount";
|
||||
roles[HasHighlightNotificationsRole] = "hasHighlightNotifications";
|
||||
roles[LastActiveTimeRole] = "lastActiveTime";
|
||||
roles[JoinStateRole] = "joinState";
|
||||
roles[CurrentRoomRole] = "currentRoom";
|
||||
roles[SubtitleTextRole] = "subtitleText";
|
||||
@@ -284,8 +283,6 @@ QHash<int, QByteArray> RoomTreeModel::roleNames() const
|
||||
roles[IsDirectChat] = "isDirectChat";
|
||||
roles[DelegateTypeRole] = "delegateType";
|
||||
roles[IconRole] = "icon";
|
||||
roles[AttentionRole] = "attention";
|
||||
roles[FavouriteRole] = "favourite";
|
||||
roles[RoomTypeRole] = "roomType";
|
||||
return roles;
|
||||
}
|
||||
@@ -341,9 +338,6 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
||||
if (role == HasHighlightNotificationsRole) {
|
||||
return room->highlightCount() > 0 && room->contextAwareNotificationCount() > 0;
|
||||
}
|
||||
if (role == LastActiveTimeRole) {
|
||||
return room->lastActiveTime();
|
||||
}
|
||||
if (role == JoinStateRole) {
|
||||
if (!room->successorId().isEmpty()) {
|
||||
return QStringLiteral("upgraded");
|
||||
@@ -380,12 +374,6 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
||||
if (role == DelegateTypeRole) {
|
||||
return QStringLiteral("normal");
|
||||
}
|
||||
if (role == AttentionRole) {
|
||||
return room->notificationCount() + room->highlightCount() > 0;
|
||||
}
|
||||
if (role == FavouriteRole) {
|
||||
return room->isFavourite();
|
||||
}
|
||||
if (role == RoomTypeRole) {
|
||||
if (room->creation()) {
|
||||
return room->creation()->contentPart<QString>("type"_L1);
|
||||
|
||||
@@ -36,7 +36,6 @@ public:
|
||||
CategoryRole, /**< The room category, e.g favourite. */
|
||||
ContextNotificationCountRole, /**< The context aware notification count for the room. */
|
||||
HasHighlightNotificationsRole, /**< Whether there are any highlight notifications. */
|
||||
LastActiveTimeRole, /**< The timestamp of the last event sent in the room. */
|
||||
JoinStateRole, /**< The local user's join state in the room. */
|
||||
CurrentRoomRole, /**< The room object for the room. */
|
||||
SubtitleTextRole, /**< The text to show as the room subtitle. */
|
||||
@@ -48,8 +47,6 @@ public:
|
||||
IsDirectChat, /**< Whether this room is a direct chat. */
|
||||
DelegateTypeRole,
|
||||
IconRole,
|
||||
AttentionRole, /**< Whether there are any notifications. */
|
||||
FavouriteRole, /**< Whether the room is favourited. */
|
||||
RoomTypeRole, /**< The room's type. */
|
||||
};
|
||||
Q_ENUM(EventRoles)
|
||||
|
||||
@@ -108,11 +108,17 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
||||
case HighlightRole:
|
||||
return EventHandler::isHighlighted(m_room, &event);
|
||||
case EventIdRole:
|
||||
return EventHandler::id(&event);
|
||||
return event.displayId();
|
||||
case IsThreadedRole:
|
||||
return EventHandler::isThreaded(&event);
|
||||
if (auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event)) {
|
||||
return roomMessageEvent->isThreaded();
|
||||
}
|
||||
return {};
|
||||
case ThreadRootRole:
|
||||
return EventHandler::threadRoot(&event);
|
||||
if (auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event); roomMessageEvent->isThreaded()) {
|
||||
return roomMessageEvent->threadRootEventId();
|
||||
}
|
||||
return {};
|
||||
case ContentModelRole: {
|
||||
if (!event.isStateEvent()) {
|
||||
return QVariant::fromValue<MessageContentModel *>(new MessageContentModel(m_room, event.id()));
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "neochatroom.h"
|
||||
#include "neochatroomtype.h"
|
||||
#include "roommanager.h"
|
||||
#include "roomtreemodel.h"
|
||||
@@ -44,58 +45,49 @@ SortFilterRoomTreeModel::SortFilterRoomTreeModel(RoomTreeModel *sourceModel, QOb
|
||||
void SortFilterRoomTreeModel::setRoomSortOrder(SortFilterRoomTreeModel::RoomSortOrder sortOrder)
|
||||
{
|
||||
m_sortOrder = sortOrder;
|
||||
if (sortOrder == SortFilterRoomTreeModel::Alphabetical) {
|
||||
setSortRole(RoomTreeModel::DisplayNameRole);
|
||||
} else if (sortOrder == SortFilterRoomTreeModel::Activity) {
|
||||
setSortRole(RoomTreeModel::LastActiveTimeRole);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
static const QVector<RoomTreeModel::EventRoles> alphabeticalSortPriorities{
|
||||
static const QVector<RoomSortParameter::Parameter> alphabeticalSortPriorities{
|
||||
// Does exactly what it says on the tin.
|
||||
RoomTreeModel::DisplayNameRole,
|
||||
RoomSortParameter::AlphabeticalAscending,
|
||||
};
|
||||
|
||||
static const QVector<RoomTreeModel::EventRoles> activitySortPriorities{
|
||||
// Anything useful at the top, quiet rooms at the bottom
|
||||
RoomTreeModel::AttentionRole,
|
||||
// Organize by highlights, notifications, unread favorites, all other unread, in that order
|
||||
RoomTreeModel::HasHighlightNotificationsRole,
|
||||
RoomTreeModel::ContextNotificationCountRole,
|
||||
RoomTreeModel::FavouriteRole,
|
||||
// Finally sort by last activity time
|
||||
RoomTreeModel::LastActiveTimeRole,
|
||||
static const QVector<RoomSortParameter::Parameter> activitySortPriorities{
|
||||
RoomSortParameter::HasHighlight,
|
||||
RoomSortParameter::MostHighlights,
|
||||
RoomSortParameter::HasUnread,
|
||||
RoomSortParameter::MostUnread,
|
||||
RoomSortParameter::LastActive,
|
||||
};
|
||||
|
||||
bool SortFilterRoomTreeModel::roleCmp(const QVariant &sortLeft, const QVariant &sortRight) const
|
||||
{
|
||||
switch (sortLeft.typeId()) {
|
||||
case QMetaType::Bool:
|
||||
return (sortLeft == sortRight) ? false : sortLeft.toBool();
|
||||
case QMetaType::QString:
|
||||
return sortLeft.toString() < sortRight.toString();
|
||||
case QMetaType::Int:
|
||||
return sortLeft.toInt() > sortRight.toInt();
|
||||
case QMetaType::QDateTime:
|
||||
return sortLeft.toDateTime() > sortRight.toDateTime();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static const QVector<RoomSortParameter::Parameter> lastMessageSortPriorities{
|
||||
RoomSortParameter::LastActive,
|
||||
};
|
||||
|
||||
bool SortFilterRoomTreeModel::prioritiesCmp(const QVector<RoomTreeModel::EventRoles> &priorities,
|
||||
bool SortFilterRoomTreeModel::prioritiesCmp(const QVector<RoomSortParameter::Parameter> &priorities,
|
||||
const QModelIndex &source_left,
|
||||
const QModelIndex &source_right) const
|
||||
{
|
||||
for (RoomTreeModel::EventRoles sortRole : priorities) {
|
||||
const auto sortLeft = sourceModel()->data(source_left, sortRole);
|
||||
const auto sortRight = sourceModel()->data(source_right, sortRole);
|
||||
if (sortLeft != sortRight) {
|
||||
return roleCmp(sortLeft, sortRight);
|
||||
const auto treeModel = dynamic_cast<RoomTreeModel *>(sourceModel());
|
||||
if (treeModel == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto leftRoom = dynamic_cast<NeoChatRoom *>(treeModel->connection()->room(source_left.data(RoomTreeModel::RoomIdRole).toString()));
|
||||
const auto rightRoom = dynamic_cast<NeoChatRoom *>(treeModel->connection()->room(source_right.data(RoomTreeModel::RoomIdRole).toString()));
|
||||
if (leftRoom == nullptr || rightRoom == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto sortRole : priorities) {
|
||||
auto result = RoomSortParameter::compareParameter(sortRole, leftRoom, rightRoom);
|
||||
|
||||
if (result != 0) {
|
||||
return result > 0;
|
||||
}
|
||||
}
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SortFilterRoomTreeModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
@@ -110,8 +102,9 @@ bool SortFilterRoomTreeModel::lessThan(const QModelIndex &source_left, const QMo
|
||||
return prioritiesCmp(alphabeticalSortPriorities, source_left, source_right);
|
||||
case SortFilterRoomTreeModel::Activity:
|
||||
return prioritiesCmp(activitySortPriorities, source_left, source_right);
|
||||
case SortFilterRoomTreeModel::LastMessage:
|
||||
return prioritiesCmp(lastMessageSortPriorities, source_left, source_right);
|
||||
}
|
||||
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QQmlEngine>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "enums/roomsortparameter.h"
|
||||
#include "models/roomtreemodel.h"
|
||||
|
||||
/**
|
||||
@@ -53,6 +54,7 @@ public:
|
||||
enum RoomSortOrder {
|
||||
Alphabetical,
|
||||
Activity,
|
||||
LastMessage,
|
||||
};
|
||||
Q_ENUM(RoomSortOrder)
|
||||
|
||||
@@ -104,6 +106,5 @@ private:
|
||||
QString m_filterText;
|
||||
QString m_activeSpaceId;
|
||||
|
||||
bool roleCmp(const QVariant &left, const QVariant &right) const;
|
||||
bool prioritiesCmp(const QVector<RoomTreeModel::EventRoles> &priorities, const QModelIndex &left, const QModelIndex &right) const;
|
||||
bool prioritiesCmp(const QVector<RoomSortParameter::Parameter> &priorities, const QModelIndex &left, const QModelIndex &right) const;
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ ThreadModel::ThreadModel(const QString &threadRootId, NeoChatRoom *room)
|
||||
|
||||
connect(room, &Quotient::Room::pendingEventAboutToAdd, this, [this](Quotient::RoomEvent *event) {
|
||||
if (auto roomEvent = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||
if (EventHandler::isThreaded(roomEvent) && EventHandler::threadRoot(roomEvent) == m_threadRootId) {
|
||||
if (roomEvent->isThreaded() && roomEvent->threadRootEventId() == m_threadRootId) {
|
||||
addNewEvent(event);
|
||||
addModels();
|
||||
}
|
||||
@@ -34,7 +34,7 @@ ThreadModel::ThreadModel(const QString &threadRootId, NeoChatRoom *room)
|
||||
connect(room, &Quotient::Room::aboutToAddNewMessages, this, [this](Quotient::RoomEventsRange events) {
|
||||
for (const auto &event : events) {
|
||||
if (auto roomEvent = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||
if (EventHandler::isThreaded(roomEvent) && EventHandler::threadRoot(roomEvent) == m_threadRootId) {
|
||||
if (roomEvent->isThreaded() && roomEvent->threadRootEventId() == m_threadRootId) {
|
||||
addNewEvent(roomEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include <Quotient/events/eventcontent.h>
|
||||
#include <Quotient/events/eventrelation.h>
|
||||
#include <Quotient/events/roommessageevent.h>
|
||||
#include <Quotient/jobs/basejob.h>
|
||||
#include <Quotient/quotient_common.h>
|
||||
#include <qcoro/qcorosignal.h>
|
||||
@@ -482,119 +484,6 @@ QString msgTypeToString(MessageEventType msgType)
|
||||
}
|
||||
}
|
||||
|
||||
void NeoChatRoom::postMessage(const QString &rawText,
|
||||
const QString &text,
|
||||
MessageEventType type,
|
||||
const QString &replyEventId,
|
||||
const QString &relateToEventId,
|
||||
const QString &threadRootId,
|
||||
const QString &fallbackId)
|
||||
{
|
||||
postHtmlMessage(rawText, text, type, replyEventId, relateToEventId, threadRootId, fallbackId);
|
||||
}
|
||||
|
||||
void NeoChatRoom::postHtmlMessage(const QString &text,
|
||||
const QString &html,
|
||||
MessageEventType type,
|
||||
const QString &replyEventId,
|
||||
const QString &relateToEventId,
|
||||
const QString &threadRootId,
|
||||
const QString &fallbackId)
|
||||
{
|
||||
bool isReply = !replyEventId.isEmpty();
|
||||
bool isEdit = !relateToEventId.isEmpty();
|
||||
bool isThread = !threadRootId.isEmpty();
|
||||
const auto replyIt = findInTimeline(replyEventId);
|
||||
if (replyIt == historyEdge()) {
|
||||
isReply = false;
|
||||
}
|
||||
|
||||
if (isThread) {
|
||||
bool isFallingBack = !fallbackId.isEmpty();
|
||||
QString replyEventId = isFallingBack ? fallbackId : QString();
|
||||
if (isReply) {
|
||||
isFallingBack = false;
|
||||
replyEventId = EventHandler::id(replyIt->get());
|
||||
}
|
||||
|
||||
// If we are not replying and there is no fallback ID it means a new thread
|
||||
// is being created.
|
||||
if (!isFallingBack && !isReply) {
|
||||
isFallingBack = true;
|
||||
replyEventId = threadRootId;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
QJsonObject json{
|
||||
{"msgtype"_ls, msgTypeToString(type)},
|
||||
{"body"_ls, text},
|
||||
{"format"_ls, "org.matrix.custom.html"_ls},
|
||||
{"m.relates_to"_ls,
|
||||
QJsonObject {
|
||||
{"rel_type"_ls, "m.thread"_ls},
|
||||
{"event_id"_ls, threadRootId},
|
||||
{"is_falling_back"_ls, isFallingBack},
|
||||
{"m.in_reply_to"_ls,
|
||||
QJsonObject {
|
||||
{"event_id"_ls, replyEventId}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{"formatted_body"_ls, html}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
postJson("m.room.message"_ls, json);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEdit) {
|
||||
QJsonObject json{
|
||||
{"type"_ls, "m.room.message"_ls},
|
||||
{"msgtype"_ls, msgTypeToString(type)},
|
||||
{"body"_ls, "* %1"_ls.arg(text)},
|
||||
{"format"_ls, "org.matrix.custom.html"_ls},
|
||||
{"formatted_body"_ls, html},
|
||||
{"m.new_content"_ls,
|
||||
QJsonObject{{"body"_ls, text}, {"msgtype"_ls, msgTypeToString(type)}, {"format"_ls, "org.matrix.custom.html"_ls}, {"formatted_body"_ls, html}}},
|
||||
{"m.relates_to"_ls, QJsonObject{{"rel_type"_ls, "m.replace"_ls}, {"event_id"_ls, relateToEventId}}}};
|
||||
|
||||
postJson("m.room.message"_ls, json);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isReply) {
|
||||
const auto &replyEvt = **replyIt;
|
||||
|
||||
// clang-format off
|
||||
QJsonObject json{
|
||||
{"msgtype"_ls, msgTypeToString(type)},
|
||||
{"body"_ls, "> <%1> %2\n\n%3"_ls.arg(replyEvt.senderId(), EventHandler::plainBody(this, &replyEvt), text)},
|
||||
{"format"_ls, "org.matrix.custom.html"_ls},
|
||||
{"m.relates_to"_ls,
|
||||
QJsonObject {
|
||||
{"m.in_reply_to"_ls,
|
||||
QJsonObject {
|
||||
{"event_id"_ls, replyEventId}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{"formatted_body"_ls,
|
||||
"<mx-reply><blockquote><a href=\"https://matrix.to/#/%1/%2\">In reply to</a> <a href=\"https://matrix.to/#/%3\">%4</a><br>%5</blockquote></mx-reply>%6"_ls.arg(id(), replyEventId, replyEvt.senderId(), replyEvt.senderId(), EventHandler::richBody(this, &replyEvt), html)
|
||||
}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
postJson("m.room.message"_ls, json);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Room::postHtmlMessage(text, html, type);
|
||||
}
|
||||
|
||||
void NeoChatRoom::toggleReaction(const QString &eventId, const QString &reaction)
|
||||
{
|
||||
if (eventId.isEmpty() || reaction.isEmpty()) {
|
||||
@@ -1749,25 +1638,31 @@ void NeoChatRoom::downloadEventFromServer(const QString &eventId)
|
||||
});
|
||||
}
|
||||
|
||||
const RoomEvent *NeoChatRoom::getEvent(const QString &eventId) const
|
||||
std::pair<const Quotient::RoomEvent *, bool> NeoChatRoom::getEvent(const QString &eventId) const
|
||||
{
|
||||
if (eventId.isEmpty()) {
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
const auto timelineIt = findInTimeline(eventId);
|
||||
if (timelineIt != historyEdge()) {
|
||||
return timelineIt->get();
|
||||
return std::make_pair(timelineIt->get(), false);
|
||||
}
|
||||
|
||||
const auto pendingIt = findPendingEvent(eventId);
|
||||
auto pendingIt = findPendingEvent(eventId);
|
||||
if (pendingIt != pendingEvents().end()) {
|
||||
return pendingIt->event();
|
||||
return std::make_pair(pendingIt->event(), true);
|
||||
}
|
||||
// findPendingEvent() searches by transaction ID, we also need to check event ID.
|
||||
for (const auto &event : pendingEvents()) {
|
||||
if (event->id() == eventId || event->transactionId() == eventId) {
|
||||
return std::make_pair(event.event(), true);
|
||||
}
|
||||
}
|
||||
|
||||
auto extraIt = std::find_if(m_extraEvents.begin(), m_extraEvents.end(), [eventId](const Quotient::event_ptr_tt<Quotient::RoomEvent> &event) {
|
||||
return event->id() == eventId;
|
||||
});
|
||||
return extraIt != m_extraEvents.end() ? extraIt->get() : nullptr;
|
||||
return std::make_pair(extraIt != m_extraEvents.end() ? extraIt->get() : nullptr, false);
|
||||
}
|
||||
|
||||
const RoomEvent *NeoChatRoom::getReplyForEvent(const RoomEvent &event) const
|
||||
|
||||
@@ -570,7 +570,7 @@ public:
|
||||
*
|
||||
* The result will be nullptr if not found so needs to be managed.
|
||||
*/
|
||||
const Quotient::RoomEvent *getEvent(const QString &eventId) const;
|
||||
std::pair<const Quotient::RoomEvent *, bool> getEvent(const QString &eventId) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the event that is being replied to. This includes events that were manually loaded using NeoChatRoom::loadReply.
|
||||
@@ -691,40 +691,6 @@ public Q_SLOTS:
|
||||
*/
|
||||
void sendTypingNotification(bool isTyping);
|
||||
|
||||
/**
|
||||
* @brief Send a message to the room.
|
||||
*
|
||||
* @param rawText the text as it was typed.
|
||||
* @param cleanedText the text marked up as html.
|
||||
* @param type the type of message being sent.
|
||||
* @param replyEventId the id of the message being replied to if a reply.
|
||||
* @param relateToEventId the id of the message being edited if an edit.
|
||||
*/
|
||||
void postMessage(const QString &rawText,
|
||||
const QString &cleanedText,
|
||||
Quotient::MessageEventType type = Quotient::MessageEventType::Text,
|
||||
const QString &replyEventId = QString(),
|
||||
const QString &relateToEventId = QString(),
|
||||
const QString &threadRootId = QString(),
|
||||
const QString &fallbackId = QString());
|
||||
|
||||
/**
|
||||
* @brief Send an html message to the room.
|
||||
*
|
||||
* @param text the text as it was typed.
|
||||
* @param html the text marked up as html.
|
||||
* @param type the type of message being sent.
|
||||
* @param replyEventId the id of the message being replied to if a reply.
|
||||
* @param relateToEventId the id of the message being edited if an edit.
|
||||
*/
|
||||
void postHtmlMessage(const QString &text,
|
||||
const QString &html,
|
||||
Quotient::MessageEventType type = Quotient::MessageEventType::Text,
|
||||
const QString &replyEventId = QString(),
|
||||
const QString &relateToEventId = QString(),
|
||||
const QString &threadRootId = QString(),
|
||||
const QString &fallbackId = QString());
|
||||
|
||||
/**
|
||||
* @brief Set the room avatar.
|
||||
*/
|
||||
|
||||
@@ -161,3 +161,5 @@ QUrl NeochatRoomMember::avatarUrl() const
|
||||
|
||||
return m_room->member(m_memberId).avatarUrl();
|
||||
}
|
||||
|
||||
#include "moc_neochatroommember.cpp"
|
||||
|
||||
@@ -248,7 +248,9 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
|
||||
connect(replyAction.get(), &KNotificationReplyAction::replied, this, [room, replyEventId](const QString &text) {
|
||||
TextHandler textHandler;
|
||||
textHandler.setData(text);
|
||||
room->postMessage(text, textHandler.handleSendText(), RoomMessageEvent::MsgType::Text, replyEventId, QString());
|
||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(textHandler.handleSendText(), u"text/html"_s);
|
||||
EventRelation relatesTo = EventRelation::replyTo(replyEventId);
|
||||
room->post<Quotient::RoomMessageEvent>(text, MessageEventType::Text, std::move(content), relatesTo);
|
||||
});
|
||||
notification->setReplyAction(std::move(replyAction));
|
||||
}
|
||||
|
||||
@@ -168,9 +168,8 @@ void PollHandler::sendPollAnswer(const QString &eventId, const QString &answerId
|
||||
ownAnswers.insert(0, answerId);
|
||||
}
|
||||
|
||||
auto response = new PollResponseEvent(eventId, ownAnswers);
|
||||
const auto &response = room->post<PollResponseEvent>(eventId, ownAnswers);
|
||||
handleAnswer(response->contentJson(), room->localMember().id(), QDateTime::currentDateTime());
|
||||
room->postEvent(response);
|
||||
}
|
||||
|
||||
bool PollHandler::hasEnded() const
|
||||
|
||||
@@ -20,7 +20,7 @@ QQC2.Menu {
|
||||
margins: Kirigami.Units.smallSpacing
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: i18nc("@action:button", "Show QR code")
|
||||
text: i18nc("@action:button", "Show QR Code")
|
||||
icon.name: "view-barcode-qr-symbolic"
|
||||
onTriggered: {
|
||||
let qrMax = Qt.createComponent('org.kde.neochat', 'QrCodeMaximizeComponent').createObject(QQC2.Overlay.overlay, {
|
||||
@@ -37,7 +37,7 @@ QQC2.Menu {
|
||||
}
|
||||
}
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Edit this account")
|
||||
text: i18n("Edit This Account")
|
||||
icon.name: "document-edit"
|
||||
onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), {
|
||||
connection: root.connection
|
||||
@@ -46,7 +46,7 @@ QQC2.Menu {
|
||||
})
|
||||
}
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Notification settings")
|
||||
text: i18n("Notification Settings")
|
||||
icon.name: "notifications"
|
||||
onTriggered: {
|
||||
NeoChatSettingsView.open('notifications');
|
||||
@@ -60,7 +60,7 @@ QQC2.Menu {
|
||||
}
|
||||
}
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Open developer tools")
|
||||
text: i18n("Open Developer Tools")
|
||||
icon.name: "tools"
|
||||
visible: NeoChatConfig.developerTools
|
||||
onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.devtools', 'DevtoolsPage'), {
|
||||
@@ -80,7 +80,7 @@ QQC2.Menu {
|
||||
})
|
||||
}
|
||||
QQC2.MenuItem {
|
||||
text: i18nc("@action:inmenu", "Verify this Device")
|
||||
text: i18nc("@action:inmenu", "Verify This Device")
|
||||
icon.name: "security-low"
|
||||
onTriggered: root.connection.startSelfVerification()
|
||||
enabled: Controller.csSupported
|
||||
|
||||
@@ -23,7 +23,11 @@ SearchPage {
|
||||
|
||||
model: RoomManager.sortFilterRoomListModel
|
||||
modelDelegate: RoomDelegate {
|
||||
onClicked: root.chosen(currentRoom.id)
|
||||
onClicked: {
|
||||
root.chosen(currentRoom.id);
|
||||
root.closeDialog();
|
||||
}
|
||||
connection: root.connection
|
||||
openOnClick: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,38 +27,17 @@ Loader {
|
||||
Component {
|
||||
id: regularMenu
|
||||
QQC2.Menu {
|
||||
QQC2.MenuItem {
|
||||
text: room.isFavourite ? i18n("Remove from Favorites") : i18n("Add to Favorites")
|
||||
icon.name: room.isFavourite ? "bookmark-remove" : "bookmark-new"
|
||||
onTriggered: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: room.isLowPriority ? i18n("Reprioritize") : i18n("Deprioritize")
|
||||
icon.name: room.isLowPriority ? "arrow-up-symbolic" : "arrow-down-symbolic"
|
||||
onTriggered: room.isLowPriority ? room.removeTag("m.lowpriority") : room.addTag("m.lowpriority", 1.0)
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Mark as Read")
|
||||
icon.name: "checkmark"
|
||||
enabled: room.notificationCount > 0
|
||||
onTriggered: room.markAllMessagesAsRead()
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: room.isDirectChat() ? i18nc("@action:inmenu", "Copy user's Matrix ID to Clipboard") : i18nc("@action:inmenu", "Copy Address to Clipboard")
|
||||
icon.name: "edit-copy"
|
||||
onTriggered: if (room.isDirectChat()) {
|
||||
Clipboard.saveText(room.directChatRemoteMember.id);
|
||||
} else if (room.canonicalAlias.length === 0) {
|
||||
Clipboard.saveText(room.id);
|
||||
} else {
|
||||
Clipboard.saveText(room.canonicalAlias);
|
||||
}
|
||||
}
|
||||
QQC2.MenuSeparator {}
|
||||
|
||||
QQC2.Menu {
|
||||
title: i18n("Notification State")
|
||||
title: i18nc("@action:inmenu", "Notifications")
|
||||
icon.name: "notifications"
|
||||
|
||||
QQC2.MenuItem {
|
||||
@@ -107,6 +86,32 @@ Loader {
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: room.isFavourite ? i18n("Remove from Favorites") : i18n("Add to Favorites")
|
||||
icon.name: room.isFavourite ? "rating" : "rating-unrated"
|
||||
onTriggered: room.isFavourite ? room.removeTag("m.favourite") : room.addTag("m.favourite", 1.0)
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: room.isLowPriority ? i18n("Reprioritize") : i18n("Deprioritize")
|
||||
icon.name: room.isLowPriority ? "arrow-up-symbolic" : "arrow-down-symbolic"
|
||||
onTriggered: room.isLowPriority ? room.removeTag("m.lowpriority") : room.addTag("m.lowpriority", 1.0)
|
||||
}
|
||||
|
||||
QQC2.MenuSeparator {}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: room.isDirectChat() ? i18nc("@action:inmenu", "Copy user's Matrix ID to Clipboard") : i18nc("@action:inmenu", "Copy Address to Clipboard")
|
||||
icon.name: "edit-copy"
|
||||
onTriggered: if (room.isDirectChat()) {
|
||||
Clipboard.saveText(room.directChatRemoteMember.id);
|
||||
} else if (room.canonicalAlias.length === 0) {
|
||||
Clipboard.saveText(room.id);
|
||||
} else {
|
||||
Clipboard.saveText(room.canonicalAlias);
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: i18nc("@action:inmenu", "Room Settings")
|
||||
icon.name: 'settings-configure-symbolic'
|
||||
|
||||
@@ -57,6 +57,11 @@ Loader {
|
||||
*/
|
||||
property string selectedText: ""
|
||||
|
||||
/**
|
||||
* @brief The link the user has currently hovered.
|
||||
*/
|
||||
property string hoveredLink: ""
|
||||
|
||||
/**
|
||||
* @brief The list of menu item actions that have sub-actions.
|
||||
*
|
||||
|
||||
@@ -50,6 +50,8 @@ SearchPage {
|
||||
signal roomSelected(string roomId, string displayName, url avatarUrl, string alias, string topic, int memberCount, bool isJoined)
|
||||
|
||||
title: i18nc("@action:title", "Explore Rooms")
|
||||
customPlaceholderText: publicRoomListModel.redirectedText
|
||||
customPlaceholderIcon: "data-warning"
|
||||
|
||||
Component.onCompleted: focusSearch()
|
||||
|
||||
@@ -93,6 +95,7 @@ SearchPage {
|
||||
|
||||
activeFocusOnTab: false // We handle moving to this item via up/down arrows, otherwise the tab order is wacky
|
||||
text: i18n("Enter a Room Manually")
|
||||
visible: publicRoomListModel.redirectedText.length === 0
|
||||
icon.name: "compass"
|
||||
icon.width: Kirigami.Units.gridUnit * 2
|
||||
icon.height: Kirigami.Units.gridUnit * 2
|
||||
|
||||
@@ -42,15 +42,19 @@ DelegateContextMenu {
|
||||
* Each action will be instantiated as a single line in the menu.
|
||||
*/
|
||||
property list<Kirigami.Action> actions: [
|
||||
DelegateContextMenu.ReplyMessageAction {},
|
||||
Kirigami.Action {
|
||||
text: i18n("Open Externally")
|
||||
separator: true
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18nc("@action:inmenu", "Open Image")
|
||||
icon.name: "document-open"
|
||||
onTriggered: {
|
||||
currentRoom.openEventMediaExternally(root.eventId);
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Save As")
|
||||
text: i18nc("@action:inmenu", "Save Image…")
|
||||
icon.name: "document-save"
|
||||
onTriggered: {
|
||||
var dialog = saveAsDialog.createObject(QQC2.Overlay.overlay);
|
||||
@@ -58,14 +62,16 @@ DelegateContextMenu {
|
||||
dialog.open();
|
||||
}
|
||||
},
|
||||
DelegateContextMenu.ReplyMessageAction {},
|
||||
Kirigami.Action {
|
||||
text: i18n("Copy")
|
||||
text: i18nc("@action:inmenu", "Copy Image")
|
||||
icon.name: "edit-copy"
|
||||
onTriggered: {
|
||||
currentRoom.copyEventMedia(root.eventId);
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
separator: true
|
||||
},
|
||||
Kirigami.Action {
|
||||
visible: author.id === currentRoom.localMember.id || currentRoom.canSendState("redact")
|
||||
text: i18n("Remove")
|
||||
@@ -88,7 +94,13 @@ DelegateContextMenu {
|
||||
},
|
||||
DelegateContextMenu.ReportMessageAction {},
|
||||
DelegateContextMenu.ShowUserAction {},
|
||||
DelegateContextMenu.ViewSourceAction {}
|
||||
Kirigami.Action {
|
||||
separator: true
|
||||
visible: viewSourceAction.visible
|
||||
},
|
||||
DelegateContextMenu.ViewSourceAction {
|
||||
id: viewSourceAction
|
||||
}
|
||||
]
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,8 +20,15 @@ Kirigami.ApplicationWindow {
|
||||
|
||||
property bool initialized: false
|
||||
|
||||
|
||||
title: NeoChatConfig.windowTitleFocus ? activeFocusItem + " " + (activeFocusItem ? activeFocusItem.Accessible.name : "") : "NeoChat"
|
||||
title: {
|
||||
if (NeoChatConfig.windowTitleFocus) {
|
||||
return activeFocusItem + " " + (activeFocusItem ? activeFocusItem.Accessible.name : "");
|
||||
} else if (RoomManager.currentRoom) {
|
||||
return RoomManager.currentRoom.displayName;
|
||||
} else {
|
||||
return Application.displayName;
|
||||
}
|
||||
}
|
||||
|
||||
minimumWidth: Kirigami.Units.gridUnit * 20
|
||||
minimumHeight: Kirigami.Units.gridUnit * 15
|
||||
@@ -85,7 +92,7 @@ Kirigami.ApplicationWindow {
|
||||
target: RoomManager
|
||||
|
||||
function onCurrentRoomChanged() {
|
||||
if (RoomManager.currentRoom && pageStack.depth <= 1 && initialized && Kirigami.Settings.isMobile) {
|
||||
if (RoomManager.currentRoom && pageStack.depth <= 1 && root.initialized && Kirigami.Settings.isMobile) {
|
||||
let roomPage = pageStack.layers.push(Qt.createComponent('org.kde.neochat', 'RoomPage'), {
|
||||
connection: root.connection
|
||||
});
|
||||
@@ -300,7 +307,7 @@ Kirigami.ApplicationWindow {
|
||||
target: ShareHandler
|
||||
function onTextChanged(): void {
|
||||
if (root.connection && ShareHandler.text.length > 0) {
|
||||
handleShare();
|
||||
root.handleShare();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ DelegateContextMenu {
|
||||
},
|
||||
DelegateContextMenu.ReplyMessageAction {},
|
||||
Kirigami.Action {
|
||||
text: i18nc("@action:inmenu As in 'Forward this message'", "Forward")
|
||||
text: i18nc("@action:inmenu As in 'Forward this message'", "Forward…")
|
||||
icon.name: "mail-forward-symbolic"
|
||||
onTriggered: {
|
||||
let page = applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ChooseRoomDialog'), {
|
||||
@@ -59,21 +59,39 @@ DelegateContextMenu {
|
||||
});
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
separator: true
|
||||
},
|
||||
DelegateContextMenu.RemoveMessageAction {},
|
||||
Kirigami.Action {
|
||||
text: i18n("Copy")
|
||||
text: i18nc("@action:inmenu", "Copy Link Address")
|
||||
icon.name: "edit-copy"
|
||||
visible: root.hoveredLink.length > 0
|
||||
onTriggered: Clipboard.saveText(root.hoveredLink)
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18nc("@action:inmenu", "Copy Text")
|
||||
icon.name: "edit-copy"
|
||||
onTriggered: Clipboard.saveText(root.selectedText.length > 0 ? root.selectedText : root.plainText)
|
||||
},
|
||||
DelegateContextMenu.ReportMessageAction {},
|
||||
DelegateContextMenu.ShowUserAction {},
|
||||
DelegateContextMenu.ViewSourceAction {},
|
||||
Kirigami.Action {
|
||||
text: i18n("Copy Link")
|
||||
text: i18nc("@action:inmenu", "Copy Message Link")
|
||||
icon.name: "edit-copy"
|
||||
onTriggered: {
|
||||
Clipboard.saveText("https://matrix.to/#/" + currentRoom.id + "/" + root.eventId);
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
separator: true
|
||||
},
|
||||
DelegateContextMenu.ReportMessageAction {},
|
||||
DelegateContextMenu.ShowUserAction {},
|
||||
Kirigami.Action {
|
||||
separator: true
|
||||
visible: viewSourceAction.visible
|
||||
},
|
||||
DelegateContextMenu.ViewSourceAction {
|
||||
id: viewSourceAction
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ Delegates.RoundedItemDelegate {
|
||||
required property string subtitleText
|
||||
required property string displayName
|
||||
|
||||
property bool openOnClick: true
|
||||
property bool showConfigure: true
|
||||
|
||||
property bool collapsed: false
|
||||
@@ -35,8 +36,10 @@ Delegates.RoundedItemDelegate {
|
||||
Accessible.onPressAction: clicked()
|
||||
|
||||
onClicked: {
|
||||
RoomManager.resolveResource(currentRoom.id);
|
||||
pageStack.currentIndex = 1;
|
||||
if (root.openOnClick) {
|
||||
RoomManager.resolveResource(currentRoom.id);
|
||||
pageStack.currentIndex = 1;
|
||||
}
|
||||
}
|
||||
|
||||
onPressAndHold: createRoomListContextMenu()
|
||||
|
||||
@@ -19,6 +19,7 @@ Kirigami.OverlayDrawer {
|
||||
required property NeoChatConnection connection
|
||||
|
||||
width: actualWidth
|
||||
interactive: modal
|
||||
|
||||
readonly property int minWidth: Kirigami.Units.gridUnit * 15
|
||||
readonly property int maxWidth: Kirigami.Units.gridUnit * 25
|
||||
|
||||
@@ -39,7 +39,7 @@ QQC2.ScrollView {
|
||||
/**
|
||||
* @brief The title that should be displayed for this component if available.
|
||||
*/
|
||||
readonly property string title: root.room.isSpace ? i18nc("@action:title", "Space Members") : i18nc("@action:title", "Room information")
|
||||
readonly property string title: root.room.isSpace ? i18nc("@action:title", "Space Members") : i18nc("@action:title", "Room Information")
|
||||
|
||||
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
|
||||
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
||||
@@ -133,7 +133,7 @@ QQC2.ScrollView {
|
||||
Delegates.RoundedItemDelegate {
|
||||
id: leaveButton
|
||||
icon.name: "arrow-left-symbolic"
|
||||
text: i18nc("@action:button", "Leave this room")
|
||||
text: root.room.isSpace ? i18nc("@action:button", "Leave this space") : i18nc("@action:button", "Leave this room")
|
||||
activeFocusOnTab: true
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
@@ -325,7 +325,7 @@ Kirigami.Page {
|
||||
QtObject {
|
||||
id: _private
|
||||
property int currentWidth: NeoChatConfig.collapsed ? collapsedSize : defaultWidth
|
||||
readonly property int defaultWidth: Kirigami.Units.gridUnit * 17
|
||||
readonly property int defaultWidth: Kirigami.Units.gridUnit * 15
|
||||
readonly property int collapseWidth: Kirigami.Units.gridUnit * 10
|
||||
readonly property int collapsedSize: Kirigami.Units.gridUnit + (NeoChatConfig.compactRoomList ? 0 : Kirigami.Units.largeSpacing * 2) + Kirigami.Units.largeSpacing * 2 + (scrollView.QQC2.ScrollBar.vertical.visible ? scrollView.QQC2.ScrollBar.vertical.width : 0)
|
||||
}
|
||||
|
||||
@@ -163,6 +163,23 @@ Kirigami.Page {
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
Kirigami.Theme.inherit: false
|
||||
color: NeoChatConfig.compactLayout ? Kirigami.Theme.backgroundColor : "transparent"
|
||||
|
||||
Image {
|
||||
visible: !NeoChatConfig.compactLayout && !NeoChatConfig.blur
|
||||
source: "qrc:/qt/qml/org/kde/neochat/timeline/images/chat-page-background.svg"
|
||||
anchors.fill: parent
|
||||
fillMode: Image.Tile
|
||||
horizontalAlignment: Image.AlignLeft
|
||||
verticalAlignment: Image.AlignTop
|
||||
|
||||
function isDarkColor(background: color): bool {
|
||||
const temp = Qt.darker(background, 1);
|
||||
const darkness = 1 - (0.299 * temp.r + 0.587 * temp.g + 0.114 * temp.b);
|
||||
return temp.a > 0 && darkness >= 0.4;
|
||||
}
|
||||
|
||||
opacity: isDarkColor(Kirigami.Theme.backgroundColor) ? 0.2 : 1
|
||||
}
|
||||
}
|
||||
|
||||
footer: Loader {
|
||||
@@ -245,9 +262,10 @@ Kirigami.Page {
|
||||
});
|
||||
}
|
||||
|
||||
function onShowMessageMenu(eventId, author, messageComponentType, plainText, htmlText, selectedText, isThread) {
|
||||
function onShowMessageMenu(eventId, author, messageComponentType, plainText, htmlText, selectedText, hoveredLink, isThread) {
|
||||
const contextMenu = messageDelegateContextMenu.createObject(root, {
|
||||
selectedText: selectedText,
|
||||
hoveredLink: hoveredLink,
|
||||
author: author,
|
||||
eventId: eventId,
|
||||
messageComponentType: messageComponentType,
|
||||
|
||||
@@ -80,6 +80,17 @@ Kirigami.ScrollablePage {
|
||||
*/
|
||||
property bool showSearchButton: true
|
||||
|
||||
/**
|
||||
* @brief Message to be shown in a custom placeholder.
|
||||
* The custom placeholder will be shown if the text is not empty
|
||||
*/
|
||||
property alias customPlaceholderText: customPlaceholder.text
|
||||
|
||||
/**
|
||||
* @brief icon for the custom placeholder
|
||||
*/
|
||||
property string customPlaceholderIcon: ""
|
||||
|
||||
/**
|
||||
* @brief Force the search field to be focussed.
|
||||
*/
|
||||
@@ -167,18 +178,25 @@ Kirigami.ScrollablePage {
|
||||
Kirigami.PlaceholderMessage {
|
||||
id: noSearchMessage
|
||||
anchors.centerIn: parent
|
||||
visible: searchField.text.length === 0 && listView.count === 0
|
||||
visible: searchField.text.length === 0 && listView.count === 0 && customPlaceholder.text.length === 0
|
||||
}
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
id: noResultMessage
|
||||
anchors.centerIn: parent
|
||||
visible: searchField.text.length > 0 && listView.count === 0 && !root.model.searching
|
||||
visible: searchField.text.length > 0 && listView.count === 0 && !root.model.searching && customPlaceholder.text.length === 0
|
||||
}
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
id: customPlaceholder
|
||||
anchors.centerIn: parent
|
||||
visible: searchField.text.length > 0 && listView.count === 0 && !root.model.searching && text.length > 0
|
||||
icon.name: root.customPlaceholderIcon
|
||||
}
|
||||
|
||||
Kirigami.LoadingPlaceholder {
|
||||
anchors.centerIn: parent
|
||||
visible: searchField.text.length > 0 && listView.count === 0 && root.model.searching
|
||||
visible: searchField.text.length > 0 && listView.count === 0 && root.model.searching && customPlaceholder.text.length === 0
|
||||
}
|
||||
|
||||
Keys.onUpPressed: {
|
||||
|
||||
@@ -131,7 +131,7 @@ QQC2.Control {
|
||||
|
||||
text: i18nc("@button View all one-on-one chats with your friends.", "Friends")
|
||||
contentItem: Kirigami.Icon {
|
||||
source: "system-users"
|
||||
source: "system-users-symbolic"
|
||||
|
||||
QQC2.Label {
|
||||
id: directChatNotificationCountLabel
|
||||
@@ -200,7 +200,6 @@ QQC2.Control {
|
||||
activeFocusOnTab: true
|
||||
|
||||
onSelected: {
|
||||
RoomManager.resolveResource(spaceDelegate.roomId);
|
||||
RoomManager.currentSpace = spaceDelegate.roomId;
|
||||
}
|
||||
checked: RoomManager.currentSpace === roomId
|
||||
|
||||
@@ -62,7 +62,7 @@ ColumnLayout {
|
||||
onClicked: _private.createRoom(root.currentRoom.id)
|
||||
}
|
||||
QQC2.Button {
|
||||
text: i18nc("@button", "Leave the space")
|
||||
text: i18nc("@action:button", "Leave this space")
|
||||
icon.name: "go-previous"
|
||||
onClicked: RoomManager.leaveRoom(root.currentRoom)
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void RoomManager::viewEventSource(const QString &eventId)
|
||||
Q_EMIT showEventSource(eventId);
|
||||
}
|
||||
|
||||
void RoomManager::viewEventMenu(const QString &eventId, NeoChatRoom *room, NeochatRoomMember *sender, const QString &selectedText)
|
||||
void RoomManager::viewEventMenu(const QString &eventId, NeoChatRoom *room, NeochatRoomMember *sender, const QString &selectedText, const QString &hoveredLink)
|
||||
{
|
||||
const auto &event = **room->findInTimeline(eventId);
|
||||
|
||||
@@ -214,7 +214,8 @@ void RoomManager::viewEventMenu(const QString &eventId, NeoChatRoom *room, Neoch
|
||||
MessageComponentType::typeForEvent(event),
|
||||
EventHandler::plainBody(room, &event),
|
||||
EventHandler::richBody(room, &event),
|
||||
selectedText);
|
||||
selectedText,
|
||||
hoveredLink);
|
||||
}
|
||||
|
||||
bool RoomManager::hasOpenRoom() const
|
||||
@@ -455,10 +456,12 @@ void RoomManager::setCurrentSpace(const QString &spaceId, bool setRoom)
|
||||
return;
|
||||
}
|
||||
|
||||
if (spaceId.length() > 3) {
|
||||
resolveResource(spaceId, "no_join"_ls);
|
||||
} else if (!m_isMobile) {
|
||||
visitRoom({}, {});
|
||||
if (!m_isMobile) {
|
||||
if (spaceId.length() > 3) {
|
||||
resolveResource(spaceId, "no_join"_ls);
|
||||
} else {
|
||||
visitRoom({}, {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user