Compare commits
47 Commits
work/nvrwh
...
work/redst
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e0f0182cb | ||
|
|
3d8f724bb1 | ||
|
|
bc7a663f92 | ||
|
|
90369e927f | ||
|
|
034cad79c7 | ||
|
|
5c8ba7e29e | ||
|
|
bf1dc00338 | ||
|
|
54f7fd08cb | ||
|
|
e7afa07c84 | ||
|
|
e196ef03d6 | ||
|
|
0fa452ca04 | ||
|
|
15b625a3f8 | ||
|
|
e2427c0683 | ||
|
|
a0e8039d92 | ||
|
|
2f87b1f398 | ||
|
|
86fd2e8e1e | ||
|
|
4167f55ad8 | ||
|
|
76919a13b8 | ||
|
|
fe0f159490 | ||
|
|
4527a6399e | ||
|
|
b8ff75c5ce | ||
|
|
049e8af8b2 | ||
|
|
8ce2386cc9 | ||
|
|
5239040d9c | ||
|
|
c5eb7578b7 | ||
|
|
76ce44230d | ||
|
|
4a20371b87 | ||
|
|
9a76c30aaf | ||
|
|
9cba57368e | ||
|
|
d895f8d771 | ||
|
|
de8c9f4878 | ||
|
|
f029cf842a | ||
|
|
6ce9b77b3c | ||
|
|
5a60c6ec67 | ||
|
|
a1ca768711 | ||
|
|
f0d2c19393 | ||
|
|
67db05a0c3 | ||
|
|
05e932b884 | ||
|
|
763713cd32 | ||
|
|
2687448212 | ||
|
|
d059195e92 | ||
|
|
6ef7acc8e5 | ||
|
|
2cb89807ef | ||
|
|
b5fcad3db0 | ||
|
|
d3fd441c88 | ||
|
|
e9568b50fc | ||
|
|
e7040a518a |
@@ -164,6 +164,7 @@ endif()
|
||||
|
||||
if(ANDROID)
|
||||
find_package(Sqlite3)
|
||||
set(BUILD_TESTING FALSE)
|
||||
endif()
|
||||
|
||||
ki18n_install(po)
|
||||
@@ -178,7 +179,7 @@ add_definitions(-DQT_NO_FOREACH)
|
||||
add_subdirectory(src)
|
||||
|
||||
if (BUILD_TESTING)
|
||||
find_package(Qt6 ${QT_MIN_VERSION} NO_MODULE COMPONENTS Test)
|
||||
find_package(Qt6 ${QT_MIN_VERSION} NO_MODULE COMPONENTS Test HttpServer)
|
||||
add_subdirectory(autotests)
|
||||
# add_subdirectory(appiumtests)
|
||||
if (NOT ANDROID)
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_library(neochat_server STATIC server.cpp)
|
||||
|
||||
target_link_libraries(neochat_server PUBLIC Qt::HttpServer QuotientQt6)
|
||||
|
||||
add_definitions(-DDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
|
||||
|
||||
ecm_add_test(
|
||||
@@ -85,6 +89,6 @@ ecm_add_test(
|
||||
|
||||
ecm_add_test(
|
||||
actionstest.cpp
|
||||
LINK_LIBRARIES neochat Qt::Test
|
||||
LINK_LIBRARIES neochat Qt::Test neochat_server
|
||||
TEST_NAME actionstest
|
||||
)
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
#include <QSignalSpy>
|
||||
#include <QVariantList>
|
||||
|
||||
#include "accountmanager.h"
|
||||
#include "chatbarcache.h"
|
||||
#include "models/actionsmodel.h"
|
||||
|
||||
#include "server.h"
|
||||
#include "testutils.h"
|
||||
|
||||
using namespace Quotient;
|
||||
@@ -21,10 +23,12 @@ class ActionsTest : public QObject
|
||||
|
||||
private:
|
||||
Connection *connection = nullptr;
|
||||
TestUtils::TestRoom *room = nullptr;
|
||||
NeoChatRoom *room = nullptr;
|
||||
|
||||
void expectMessage(const QString &actionName, const QString &args, MessageType::Type type, const QString &message);
|
||||
|
||||
Server server;
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testActions();
|
||||
@@ -34,8 +38,23 @@ private Q_SLOTS:
|
||||
|
||||
void ActionsTest::initTestCase()
|
||||
{
|
||||
connection = Connection::makeMockConnection(QStringLiteral("@bob:kde.org"));
|
||||
room = new TestUtils::TestRoom(connection, QStringLiteral("#myroom:kde.org"), QLatin1String("test-min-sync.json"));
|
||||
Connection::setRoomType<NeoChatRoom>();
|
||||
server.start();
|
||||
KLocalizedString::setApplicationDomain(QByteArrayLiteral("neochat"));
|
||||
auto accountManager = new AccountManager(true);
|
||||
QSignalSpy spy(accountManager, &AccountManager::connectionAdded);
|
||||
connection = accountManager->accounts()->front();
|
||||
auto roomId = server.createRoom(u"@user:localhost:1234"_s);
|
||||
server.inviteUser(roomId, u"@invited:example.com"_s);
|
||||
server.banUser(roomId, u"@banned:example.com"_s);
|
||||
server.joinUser(roomId, u"@example:example.com"_s);
|
||||
|
||||
QSignalSpy syncSpy(connection, &Connection::syncDone);
|
||||
// We need to wait for two syncs, as the next one won't have the changes yet
|
||||
QVERIFY(syncSpy.wait());
|
||||
QVERIFY(syncSpy.wait());
|
||||
room = dynamic_cast<NeoChatRoom *>(connection->room(roomId));
|
||||
QVERIFY(room);
|
||||
}
|
||||
|
||||
void ActionsTest::testActions_data()
|
||||
@@ -90,7 +109,7 @@ static ActionsModel::Action findAction(const QString &name)
|
||||
void ActionsTest::expectMessage(const QString &actionName, const QString &args, MessageType::Type type, const QString &message)
|
||||
{
|
||||
auto action = findAction(actionName);
|
||||
QSignalSpy spy(room, &TestUtils::TestRoom::showMessage);
|
||||
QSignalSpy spy(room, &NeoChatRoom::showMessage);
|
||||
auto result = action.handle(args, room, nullptr);
|
||||
auto expected = QVariantList {type, message};
|
||||
auto signal = spy.takeFirst();
|
||||
@@ -106,14 +125,26 @@ void ActionsTest::testInvite()
|
||||
QCOMPARE(room->memberState(u"@banned:example.com"_s), Membership::Ban);
|
||||
expectMessage(u"invite"_s, connection->userId(), MessageType::Positive, u"You are already in this room."_s);
|
||||
QCOMPARE(room->memberState(connection->userId()), Membership::Join);
|
||||
expectMessage(u"invite"_s, u"@example:example.org"_s, MessageType::Information, u"@example:example.org is already in this room."_s);
|
||||
QCOMPARE(room->memberState(u"@example:example.org"_s), Membership::Join);
|
||||
expectMessage(u"invite"_s, u"@example:example.com"_s, MessageType::Information, u"@example:example.com is already in this room."_s);
|
||||
QCOMPARE(room->memberState(u"@example:example.com"_s), Membership::Join);
|
||||
|
||||
QCOMPARE(room->memberState(u"@user:example.com"_s), Membership::Leave);
|
||||
expectMessage(u"invite"_s, u"@user:example.com"_s, MessageType::Positive, u"@user:example.com was invited into this room."_s);
|
||||
|
||||
//TODO mock server, wait for invite state to change
|
||||
//TODO QCOMPARE(room->memberState(u"@user:example.com"_s), Membership::Invite);
|
||||
QSignalSpy spy(room, &NeoChatRoom::changed);
|
||||
QVERIFY(spy.wait());
|
||||
|
||||
auto tries = 0;
|
||||
|
||||
while (room->memberState(u"@user:example.com"_s) != Membership::Invite) {
|
||||
QVERIFY(spy.wait());
|
||||
tries += 1;
|
||||
if (tries > 3) {
|
||||
QVERIFY(false);
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(room->memberState(u"@user:example.com"_s), Membership::Invite);
|
||||
}
|
||||
|
||||
QTEST_MAIN(ActionsTest)
|
||||
|
||||
20
autotests/data/localhost.crt
Normal file
20
autotests/data/localhost.crt
Normal file
@@ -0,0 +1,20 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDNTCCAh2gAwIBAgIUXbyWfTfcvVLrVB1qx36pW/7IkwMwDQYJKoZIhvcNAQEL
|
||||
BQAwQjELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UE
|
||||
CgwTRGVmYXVsdCBDb21wYW55IEx0ZDAgFw0yNDEyMjQxNTAxMDNaGA8yNTcyMDcy
|
||||
NDE1MDEwM1owQjELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEc
|
||||
MBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQAD
|
||||
ggEPADCCAQoCggEBAKlxZ540TQ1uUDAR7ZJ9ue0PzcD2dPmblIIddyekvZS59V7X
|
||||
drhamclXpHE2EelR87Sexst0BaHH/jmrHwxCtwbeXHZ8ueJHkGHJ5DLZCCiwfG+Q
|
||||
gml7wlSXxXz37vie2tdlZh2yJSM8yvLAYceHb2zOskaGvul7ZITIS0JrPc3o6VZk
|
||||
+MYGkYtA2JfUsv3jH4oQbxOf7RXqhWNAXbB+3hlwRBwMIdyoBNK6YS9QSrTeS9jj
|
||||
UqgO5QmaQZOVvpaPf1Y/rHHLd2Qa6+a/cCJ1sr2biagb75AihpQFsK/oy6D1PP70
|
||||
zTe7hPWn/efEpmtCV7CQ8ti4cRu0Kjy0T8grtCsCAwEAAaMhMB8wHQYDVR0OBBYE
|
||||
FIFlylzwADNLfgTDNkhFeFelaEDxMA0GCSqGSIb3DQEBCwUAA4IBAQBQ2rw4GLIU
|
||||
v+GY7Qru9LttkrQPd2bZXKxDMd/jT+wjmMVtqS4MAsCuDYwaYLjU1aWyqy0mN+lY
|
||||
A17kD0VjBNBy45sYqkZveY0ks8mCScBemtrIDmjz2tiueecBIEASwEPBOZgv5/MV
|
||||
cz864FiChF+2r8Zl8bhycGy9DEpRjzYKvIQWSDHQ3zpuh3iBnjfoieLHWX2kKCpk
|
||||
ouS3V6485rHNCWsZT5IcCwfBFQkOuWRJpIazpz4AfwZh1TK9+bgiKA5EyZjSNrKw
|
||||
xGQSpMSTRQMB0/FOCL/AixhN9unVFUViqUcdtSfoHE1VyBHv9kDT/cYms/Xl4B0t
|
||||
/ZSQJ/D/Km1+
|
||||
-----END CERTIFICATE-----
|
||||
28
autotests/data/localhost.key
Normal file
28
autotests/data/localhost.key
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCpcWeeNE0NblAw
|
||||
Ee2SfbntD83A9nT5m5SCHXcnpL2UufVe13a4WpnJV6RxNhHpUfO0nsbLdAWhx/45
|
||||
qx8MQrcG3lx2fLniR5BhyeQy2QgosHxvkIJpe8JUl8V89+74ntrXZWYdsiUjPMry
|
||||
wGHHh29szrJGhr7pe2SEyEtCaz3N6OlWZPjGBpGLQNiX1LL94x+KEG8Tn+0V6oVj
|
||||
QF2wft4ZcEQcDCHcqATSumEvUEq03kvY41KoDuUJmkGTlb6Wj39WP6xxy3dkGuvm
|
||||
v3AidbK9m4moG++QIoaUBbCv6Mug9Tz+9M03u4T1p/3nxKZrQlewkPLYuHEbtCo8
|
||||
tE/IK7QrAgMBAAECggEAH9qmeKrra2F4KLlOGNKS//qPGz4Z+ozhi95/NpA1Zb7Z
|
||||
3pUSCBFcROo5i2D3WA4kiymoRLpQjrv60puVcCggoWVvK4VCKsR6Y6/hOx/q9T9M
|
||||
fWrE4ZC3FVEc+uPfZJT0nja9TkrdyXSV0LITD8Ap1eI7yJ9vR5R/bqj64QcpLMrU
|
||||
QeoQIy1oTMR+qdjj33duyRwBZU3Yf8FRB2iW6OILZ8hzFo1jngec7dph9a1RK4e0
|
||||
mEPdc9ywsKlDM7P0Y7zdmjar5XtQn87GiwNhz23f1fzCC2axLtOW0Xm4e4Qumehb
|
||||
WrIi6Vfq8IWMglU7QrBJ7iR0Ls+XoKA5GxomV2IJZQKBgQDoIkOl5YGPQ3iGR+WK
|
||||
e5/2Ml4G/uURzYiOlzSsyfoPXyO4EI2BJd5HkH+EvfgRx4xKkxUZRJdzR7llYPl8
|
||||
BFYcFitvhO8SbD0mNAB5YW7f+3v1pgEN2umzoKd389Zx5WqTZ7YB1VG5RN/Q1JJL
|
||||
2JM0Xgamq2vNtx3roRPxDBeW7QKBgQC63R/bmACJbgIzfaVBX4Zie3NQG0/Hf+gF
|
||||
LnBwUmQDZOR7MY+kSiIUVMn3NuZRiCSCFBVwApruyK8r535JCibTVm5PWjvhFddY
|
||||
LgaPOCKGlm9TLScjoH1pErYgG3uJ4nXeRfXhg4mco6EkrC7RzQywrd0VDoqpuc1Y
|
||||
EKfEsYk8dwKBgE+mSh3nNOBKX1V73+f3aTiZqaeu2DyWkG+UtE9BclrJ40Cp9VPG
|
||||
AZH+o7KRWEgJdzqzYv7riSfWCWgesRv7hOxYMwktzLY+i3DLUQpVAy05ZhwwnJX7
|
||||
ckrfKfc/pGoqNLplUI8qecMfPciy14vMwR2r0Y5orTHFzi9mcqg35PQ1AoGAW2LX
|
||||
OLq+0HdHhk0Va8I+450CSRQCUUvhed87SANTPEG0Z/dWC3/h6NWKrGdh/k+5oxAV
|
||||
Z+EuSkdFPBCLt0bKtCKZ8h7sF+lplotz08kdQXsC2MfFU2wiySdIgK1QHp/tCxZl
|
||||
6LM+sqdnoJrAjwRcB3AQJkMlV1ox7ba/hbdZqYMCgYBS6+JUXSSASpm5ZHd32a8m
|
||||
xwryEZ7H6Hek6lvMHdxmwoKat5dCavxw64nrtyeeGZpg1W3zLLyamF9x/8kMyr6y
|
||||
KKvtBfJ5sCvAbt80o9Pbs6R3yDB3AKiD3s3PQK7lol1nhE/8IbsF2r8JEQVcYd/k
|
||||
oBzkl7MrMyLhhaCqSxwqQQ==
|
||||
-----END PRIVATE KEY-----
|
||||
235
autotests/server.cpp
Normal file
235
autotests/server.cpp
Normal file
@@ -0,0 +1,235 @@
|
||||
// SPDX-FileCopyrightText: 2025 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
#include "server.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QHttpServer>
|
||||
#include <QHttpServerResponder>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QSslCertificate>
|
||||
#include <QSslKey>
|
||||
#include <QSslServer>
|
||||
#include <QUuid>
|
||||
|
||||
#include <Quotient/networkaccessmanager.h>
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
QString generateEventId()
|
||||
{
|
||||
return u"$"_s + QString::fromLatin1(QCryptographicHash::hash(QUuid::createUuid().toString().toLatin1(), QCryptographicHash::Sha1).toBase64());
|
||||
}
|
||||
|
||||
QString generateRoomId()
|
||||
{
|
||||
return u"!%1:localhost:1234"_s
|
||||
.arg(QString::fromLatin1(QCryptographicHash::hash(QUuid::createUuid().toString().toLatin1(), QCryptographicHash::Sha1).toBase64()))
|
||||
.replace(u'/', QChar());
|
||||
}
|
||||
|
||||
Server::Server()
|
||||
{
|
||||
}
|
||||
|
||||
void Server::start()
|
||||
{
|
||||
QObject::connect(Quotient::NetworkAccessManager::instance(),
|
||||
&QNetworkAccessManager::sslErrors,
|
||||
Quotient::NetworkAccessManager::instance(),
|
||||
[](QNetworkReply *reply) {
|
||||
reply->ignoreSslErrors();
|
||||
});
|
||||
m_server.route(u"/.well-known/matrix/client"_s, QHttpServerRequest::Method::Get, [](QHttpServerResponder &responder) {
|
||||
responder.write(QJsonDocument(QJsonObject{
|
||||
{u"m.homeserver"_s, QJsonObject{{u"base_url"_s, u"https://localhost:1234"_s}}},
|
||||
}),
|
||||
QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
m_server.route(u"/_matrix/client/versions"_s, QHttpServerRequest::Method::Get, [](QHttpServerResponder &responder) {
|
||||
responder.write(QJsonDocument(QJsonObject{
|
||||
{u"versions"_s,
|
||||
QJsonArray{
|
||||
u"v1.0"_s,
|
||||
u"v1.1"_s,
|
||||
u"v1.2"_s,
|
||||
u"v1.3"_s,
|
||||
u"v1.4"_s,
|
||||
u"v1.5"_s,
|
||||
u"v1.6"_s,
|
||||
u"v1.7"_s,
|
||||
u"v1.8"_s,
|
||||
u"v1.9"_s,
|
||||
u"v1.10"_s,
|
||||
u"v1.11"_s,
|
||||
u"v1.12"_s,
|
||||
u"v1.13"_s,
|
||||
}},
|
||||
}),
|
||||
QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
m_server.route(u"/_matrix/client/v3/capabilities"_s, QHttpServerRequest::Method::Get, [](QHttpServerResponder &responder) {
|
||||
responder.write(
|
||||
QJsonDocument(QJsonObject{{u"capabilities"_s,
|
||||
QJsonObject{
|
||||
{u"m.room_versions"_s, QJsonObject{{u"m.available"_s, QJsonObject{{u"1"_s, u"stable"_s}}}, {u"default"_s, u"1"_s}}},
|
||||
}}}),
|
||||
QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
m_server.route(u"/_matrix/client/v3/account/whoami"_s, QHttpServerRequest::Method::Get, [](QHttpServerResponder &responder) {
|
||||
responder.write(QJsonDocument(QJsonObject{
|
||||
{u"device_id"_s, u"device_id_1234"_s},
|
||||
{u"user_id"_s, u"@user:localhost:1234"_s},
|
||||
}),
|
||||
QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
|
||||
m_server.route(u"/_matrix/client/v3/login"_s, QHttpServerRequest::Method::Post, [](QHttpServerResponder &responder) {
|
||||
// TODO
|
||||
// if data["identifier"]["user"] != "user" or data["password"] != "1234":
|
||||
// abort(403)
|
||||
responder.write(QJsonDocument(QJsonObject{
|
||||
{u"access_token"_s, u"token_login"_s},
|
||||
{u"device_id"_s, u"device_1234"_s},
|
||||
{u"user_id"_s, u"@user:localhost:1234"_s},
|
||||
}),
|
||||
QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
|
||||
m_server.route(u"/_matrix/client/v3/login"_s, QHttpServerRequest::Method::Get, [](QHttpServerResponder &responder) {
|
||||
responder.write(QJsonDocument(QJsonObject{
|
||||
{u"flows"_s, QJsonArray{QJsonObject{{u"type"_s, u"m.login.password"_s}}}},
|
||||
}),
|
||||
QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
|
||||
m_server.route(u"/_matrix/client/v3/rooms/<arg>/invite"_s,
|
||||
QHttpServerRequest::Method::Post,
|
||||
[this](const QString &roomId, QHttpServerResponder &responder, const QHttpServerRequest &request) {
|
||||
m_invitedUsers[roomId] += QJsonDocument::fromJson(request.body()).object()[u"user_id"_s].toString();
|
||||
responder.write(QJsonDocument(QJsonObject{}), QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
|
||||
m_server.route(u"/_matrix/client/r0/sync"_s, QHttpServerRequest::Method::Get, [this](QHttpServerResponder &responder) {
|
||||
QMap<QString, QJsonArray> stateEvents;
|
||||
|
||||
for (const auto &[roomId, matrixId] : m_roomsToCreate) {
|
||||
stateEvents[roomId] += QJsonObject{
|
||||
{u"content"_s, QJsonObject{{u"room_version"_s, u"11"_s}}},
|
||||
{u"event_id"_s, generateEventId()},
|
||||
{u"origin_server_ts"_s, QDateTime::currentMSecsSinceEpoch()},
|
||||
{u"room_id"_s, roomId},
|
||||
{u"sender"_s, matrixId},
|
||||
{u"state_key"_s, QString()},
|
||||
{u"type"_s, u"m.room.create"_s},
|
||||
{u"unsigned"_s, QJsonObject{{u"age"_s, 1234}}},
|
||||
};
|
||||
stateEvents[roomId] += QJsonObject{
|
||||
{u"content"_s, QJsonObject{{u"displayname"_s, u"User"_s}, {u"membership"_s, u"join"_s}}},
|
||||
{u"event_id"_s, generateEventId()},
|
||||
{u"origin_server_ts"_s, QDateTime::currentMSecsSinceEpoch()},
|
||||
{u"room_id"_s, roomId},
|
||||
{u"sender"_s, matrixId},
|
||||
{u"state_key"_s, matrixId},
|
||||
{u"type"_s, u"m.room.member"_s},
|
||||
{u"unsigned"_s, QJsonObject{{u"age"_s, 1234}}},
|
||||
};
|
||||
}
|
||||
m_roomsToCreate.clear();
|
||||
for (const auto &roomId : m_invitedUsers.keys()) {
|
||||
const auto &values = m_invitedUsers[roomId];
|
||||
for (const auto &value : values) {
|
||||
stateEvents[roomId] += QJsonObject{
|
||||
{u"content"_s, QJsonObject{{u"displayname"_s, u"User"_s}, {u"membership"_s, u"invite"_s}}},
|
||||
{u"event_id"_s, generateEventId()},
|
||||
{u"origin_server_ts"_s, QDateTime::currentMSecsSinceEpoch()},
|
||||
{u"room_id"_s, roomId},
|
||||
{u"sender"_s, u"@user:localhost:1234"_s},
|
||||
{u"state_key"_s, value},
|
||||
{u"type"_s, u"m.room.member"_s},
|
||||
{u"unsigned"_s, QJsonObject{{u"age"_s, 1234}}},
|
||||
};
|
||||
}
|
||||
}
|
||||
m_invitedUsers.clear();
|
||||
|
||||
for (const auto &roomId : m_bannedUsers.keys()) {
|
||||
const auto &values = m_bannedUsers[roomId];
|
||||
for (const auto &value : values) {
|
||||
stateEvents[roomId] += QJsonObject{
|
||||
{u"content"_s, QJsonObject{{u"displayname"_s, u"User"_s}, {u"membership"_s, u"ban"_s}}},
|
||||
{u"event_id"_s, generateEventId()},
|
||||
{u"origin_server_ts"_s, QDateTime::currentMSecsSinceEpoch()},
|
||||
{u"room_id"_s, roomId},
|
||||
{u"sender"_s, u"@user:localhost:1234"_s},
|
||||
{u"state_key"_s, value},
|
||||
{u"type"_s, u"m.room.member"_s},
|
||||
{u"unsigned"_s, QJsonObject{{u"age"_s, 1234}}},
|
||||
};
|
||||
}
|
||||
}
|
||||
m_bannedUsers.clear();
|
||||
|
||||
for (const auto &roomId : m_joinedUsers.keys()) {
|
||||
const auto &values = m_joinedUsers[roomId];
|
||||
for (const auto &value : values) {
|
||||
stateEvents[roomId] += QJsonObject{
|
||||
{u"content"_s, QJsonObject{{u"displayname"_s, u"User"_s}, {u"membership"_s, u"join"_s}}},
|
||||
{u"event_id"_s, generateEventId()},
|
||||
{u"origin_server_ts"_s, QDateTime::currentMSecsSinceEpoch()},
|
||||
{u"room_id"_s, roomId},
|
||||
{u"sender"_s, u"@user:localhost:1234"_s},
|
||||
{u"state_key"_s, value},
|
||||
{u"type"_s, u"m.room.member"_s},
|
||||
{u"unsigned"_s, QJsonObject{{u"age"_s, 1234}}},
|
||||
};
|
||||
}
|
||||
}
|
||||
m_joinedUsers.clear();
|
||||
|
||||
QJsonObject rooms;
|
||||
for (const auto &roomId : stateEvents.keys()) {
|
||||
rooms[roomId] = QJsonObject{{u"state"_s, QJsonObject{{u"events"_s, stateEvents[roomId]}}}};
|
||||
}
|
||||
|
||||
responder.write(QJsonDocument(QJsonObject{{u"rooms"_s, QJsonObject{{u"join"_s, rooms}}}}), QHttpServerResponder::StatusCode::Ok);
|
||||
});
|
||||
|
||||
QSslConfiguration config;
|
||||
QFile key(QStringLiteral(DATA_DIR) + u"/localhost.key"_s);
|
||||
key.open(QFile::ReadOnly);
|
||||
config.setPrivateKey(QSslKey(&key, QSsl::Rsa));
|
||||
config.setLocalCertificate(QSslCertificate::fromPath(QStringLiteral(DATA_DIR) + u"/localhost.crt"_s).front());
|
||||
m_sslServer.setSslConfiguration(config);
|
||||
if (!m_sslServer.listen(QHostAddress::LocalHost, 1234) || !m_server.bind(&m_sslServer)) {
|
||||
qFatal() << "Server failed to listen on a port.";
|
||||
return;
|
||||
} else {
|
||||
qWarning() << "Server listening";
|
||||
}
|
||||
}
|
||||
|
||||
QString Server::createRoom(const QString &matrixId)
|
||||
{
|
||||
auto roomId = generateRoomId();
|
||||
m_roomsToCreate += {roomId, matrixId};
|
||||
return roomId;
|
||||
}
|
||||
|
||||
void Server::inviteUser(const QString &roomId, const QString &matrixId)
|
||||
{
|
||||
m_invitedUsers[roomId] += matrixId;
|
||||
}
|
||||
|
||||
void Server::banUser(const QString &roomId, const QString &matrixId)
|
||||
{
|
||||
m_bannedUsers[roomId] += matrixId;
|
||||
}
|
||||
|
||||
void Server::joinUser(const QString &roomId, const QString &matrixId)
|
||||
{
|
||||
m_joinedUsers[roomId] += matrixId;
|
||||
}
|
||||
33
autotests/server.h
Normal file
33
autotests/server.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// SPDX-FileCopyrightText: 2025 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
#include <QHttpServer>
|
||||
#include <QSslServer>
|
||||
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server();
|
||||
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Create a room and place the user with id matrixId in it.
|
||||
* Returns the room's id
|
||||
*/
|
||||
QString createRoom(const QString &matrixId);
|
||||
|
||||
void inviteUser(const QString &roomId, const QString &matrixId);
|
||||
void banUser(const QString &roomId, const QString &matrixId);
|
||||
void joinUser(const QString &roomId, const QString &matrixId);
|
||||
|
||||
private:
|
||||
QHttpServer m_server;
|
||||
QSslServer m_sslServer;
|
||||
|
||||
QHash<QString, QList<QString>> m_invitedUsers;
|
||||
QHash<QString, QList<QString>> m_bannedUsers;
|
||||
QHash<QString, QList<QString>> m_joinedUsers;
|
||||
|
||||
QList<std::pair<QString, QString>> m_roomsToCreate;
|
||||
};
|
||||
@@ -264,6 +264,8 @@ void TextHandlerTest::sendCustomTags_data()
|
||||
QTest::newRow("inside code block spoiler") << u"```||apple||```"_s << u"<code>||apple||</code>"_s;
|
||||
QTest::newRow("outside code block spoiler") << u"||apple|| ```||banana||``` ||pear||"_s
|
||||
<< u"<span data-mx-spoiler>apple</span> <code>||banana||</code> <span data-mx-spoiler>pear</span>"_s;
|
||||
QTest::newRow("complex spoiler") << u"Between `formFactor == Horizontal||Vertical` and `location == top||left||bottom||right`"_s
|
||||
<< u"Between <code>formFactor == Horizontal||Vertical</code> and <code>location == top||left||bottom||right</code>"_s;
|
||||
|
||||
// strikethrough
|
||||
QTest::newRow("incomplete strikethrough") << u"~~test"_s << u"~~test"_s;
|
||||
|
||||
1339
po/ar/neochat.po
1339
po/ar/neochat.po
File diff suppressed because it is too large
Load Diff
1261
po/ast/neochat.po
1261
po/ast/neochat.po
File diff suppressed because it is too large
Load Diff
1515
po/az/neochat.po
1515
po/az/neochat.po
File diff suppressed because it is too large
Load Diff
1311
po/ca/neochat.po
1311
po/ca/neochat.po
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1367
po/cs/neochat.po
1367
po/cs/neochat.po
File diff suppressed because it is too large
Load Diff
1437
po/da/neochat.po
1437
po/da/neochat.po
File diff suppressed because it is too large
Load Diff
1437
po/de/neochat.po
1437
po/de/neochat.po
File diff suppressed because it is too large
Load Diff
1462
po/el/neochat.po
1462
po/el/neochat.po
File diff suppressed because it is too large
Load Diff
1428
po/en_GB/neochat.po
1428
po/en_GB/neochat.po
File diff suppressed because it is too large
Load Diff
1416
po/eo/neochat.po
1416
po/eo/neochat.po
File diff suppressed because it is too large
Load Diff
1287
po/es/neochat.po
1287
po/es/neochat.po
File diff suppressed because it is too large
Load Diff
1418
po/eu/neochat.po
1418
po/eu/neochat.po
File diff suppressed because it is too large
Load Diff
1418
po/fi/neochat.po
1418
po/fi/neochat.po
File diff suppressed because it is too large
Load Diff
1349
po/fr/neochat.po
1349
po/fr/neochat.po
File diff suppressed because it is too large
Load Diff
1417
po/gl/neochat.po
1417
po/gl/neochat.po
File diff suppressed because it is too large
Load Diff
1337
po/he/neochat.po
1337
po/he/neochat.po
File diff suppressed because it is too large
Load Diff
1423
po/hi/neochat.po
1423
po/hi/neochat.po
File diff suppressed because it is too large
Load Diff
1431
po/hu/neochat.po
1431
po/hu/neochat.po
File diff suppressed because it is too large
Load Diff
1346
po/ia/neochat.po
1346
po/ia/neochat.po
File diff suppressed because it is too large
Load Diff
1499
po/id/neochat.po
1499
po/id/neochat.po
File diff suppressed because it is too large
Load Diff
1478
po/ie/neochat.po
1478
po/ie/neochat.po
File diff suppressed because it is too large
Load Diff
1362
po/it/neochat.po
1362
po/it/neochat.po
File diff suppressed because it is too large
Load Diff
1259
po/ja/neochat.po
1259
po/ja/neochat.po
File diff suppressed because it is too large
Load Diff
1334
po/ka/neochat.po
1334
po/ka/neochat.po
File diff suppressed because it is too large
Load Diff
1410
po/ko/neochat.po
1410
po/ko/neochat.po
File diff suppressed because it is too large
Load Diff
1265
po/lt/neochat.po
1265
po/lt/neochat.po
File diff suppressed because it is too large
Load Diff
1423
po/lv/neochat.po
1423
po/lv/neochat.po
File diff suppressed because it is too large
Load Diff
1349
po/nl/neochat.po
1349
po/nl/neochat.po
File diff suppressed because it is too large
Load Diff
1366
po/nn/neochat.po
1366
po/nn/neochat.po
File diff suppressed because it is too large
Load Diff
1515
po/pa/neochat.po
1515
po/pa/neochat.po
File diff suppressed because it is too large
Load Diff
1426
po/pl/neochat.po
1426
po/pl/neochat.po
File diff suppressed because it is too large
Load Diff
1495
po/pt/neochat.po
1495
po/pt/neochat.po
File diff suppressed because it is too large
Load Diff
1511
po/pt_BR/neochat.po
1511
po/pt_BR/neochat.po
File diff suppressed because it is too large
Load Diff
1423
po/ru/neochat.po
1423
po/ru/neochat.po
File diff suppressed because it is too large
Load Diff
1419
po/sa/neochat.po
1419
po/sa/neochat.po
File diff suppressed because it is too large
Load Diff
1489
po/sk/neochat.po
1489
po/sk/neochat.po
File diff suppressed because it is too large
Load Diff
1339
po/sl/neochat.po
1339
po/sl/neochat.po
File diff suppressed because it is too large
Load Diff
1416
po/sv/neochat.po
1416
po/sv/neochat.po
File diff suppressed because it is too large
Load Diff
1411
po/ta/neochat.po
1411
po/ta/neochat.po
File diff suppressed because it is too large
Load Diff
1427
po/tok/neochat.po
1427
po/tok/neochat.po
File diff suppressed because it is too large
Load Diff
1360
po/tr/neochat.po
1360
po/tr/neochat.po
File diff suppressed because it is too large
Load Diff
1356
po/uk/neochat.po
1356
po/uk/neochat.po
File diff suppressed because it is too large
Load Diff
1273
po/zh_CN/neochat.po
1273
po/zh_CN/neochat.po
File diff suppressed because it is too large
Load Diff
1349
po/zh_TW/neochat.po
1349
po/zh_TW/neochat.po
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@ endif()
|
||||
add_subdirectory(libneochat)
|
||||
add_subdirectory(login)
|
||||
add_subdirectory(rooms)
|
||||
add_subdirectory(roominfo)
|
||||
add_subdirectory(timeline)
|
||||
add_subdirectory(spaces)
|
||||
add_subdirectory(chatbar)
|
||||
|
||||
@@ -8,8 +8,6 @@ add_library(neochat STATIC
|
||||
controller.h
|
||||
roommanager.cpp
|
||||
roommanager.h
|
||||
models/userfiltermodel.cpp
|
||||
models/userfiltermodel.h
|
||||
models/userdirectorylistmodel.cpp
|
||||
models/userdirectorylistmodel.h
|
||||
notificationsmanager.cpp
|
||||
@@ -49,6 +47,9 @@ if(ANDROID OR WIN32)
|
||||
set_source_files_properties(qml/ShareActionStub.qml PROPERTIES
|
||||
QT_QML_SOURCE_TYPENAME ShareAction
|
||||
)
|
||||
set_source_files_properties(qml/GlobalMenuStub.qml PROPERTIES
|
||||
QT_QML_SOURCE_TYPENAME GlobalMenu
|
||||
)
|
||||
endif()
|
||||
|
||||
ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
@@ -58,10 +59,8 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/AccountMenu.qml
|
||||
qml/CollapsedRoomDelegate.qml
|
||||
qml/RoomPage.qml
|
||||
qml/ExploreRoomsPage.qml
|
||||
qml/ManualRoomDialog.qml
|
||||
qml/ExplorerDelegate.qml
|
||||
qml/InviteUserPage.qml
|
||||
qml/ImageEditorPage.qml
|
||||
qml/NeochatMaximizeComponent.qml
|
||||
qml/TypingPane.qml
|
||||
@@ -69,7 +68,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/AttachmentPane.qml
|
||||
qml/QuickFormatBar.qml
|
||||
qml/UserDetailDialog.qml
|
||||
qml/CreateRoomDialog.qml
|
||||
qml/OpenFileDialog.qml
|
||||
qml/KeyVerificationDialog.qml
|
||||
qml/ConfirmLogoutDialog.qml
|
||||
@@ -79,26 +77,14 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/EmojiSas.qml
|
||||
qml/VerificationCanceled.qml
|
||||
qml/MessageSourceSheet.qml
|
||||
qml/RoomSearchPage.qml
|
||||
qml/RoomPinnedMessagesPage.qml
|
||||
qml/LocationChooser.qml
|
||||
qml/InvitationView.qml
|
||||
qml/AvatarTabButton.qml
|
||||
qml/OsmLocationPlugin.qml
|
||||
qml/FullScreenMap.qml
|
||||
qml/LocationsPage.qml
|
||||
qml/LocationMapItem.qml
|
||||
qml/RoomDrawer.qml
|
||||
qml/RoomDrawerPage.qml
|
||||
qml/DirectChatDrawerHeader.qml
|
||||
qml/GroupChatDrawerHeader.qml
|
||||
qml/RoomInformation.qml
|
||||
qml/RoomMedia.qml
|
||||
qml/ChooseRoomDialog.qml
|
||||
qml/RemoveChildDialog.qml
|
||||
qml/QrCodeMaximizeComponent.qml
|
||||
qml/NotificationsView.qml
|
||||
qml/SearchPage.qml
|
||||
qml/ServerComboBox.qml
|
||||
qml/UserSearchPage.qml
|
||||
qml/ManualUserDialog.qml
|
||||
@@ -118,12 +104,16 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/AvatarNotification.qml
|
||||
qml/ReasonDialog.qml
|
||||
qml/NewPollDialog.qml
|
||||
qml/UserMenu.qml
|
||||
DEPENDENCIES
|
||||
QtCore
|
||||
QtQuick
|
||||
org.kde.prison
|
||||
org.kde.prison.scanner
|
||||
IMPORTS
|
||||
org.kde.neochat.libneochat
|
||||
org.kde.neochat.rooms
|
||||
org.kde.neochat.roominfo
|
||||
org.kde.neochat.timeline
|
||||
org.kde.neochat.spaces
|
||||
org.kde.neochat.settings
|
||||
@@ -139,7 +129,10 @@ if(NOT ANDROID AND NOT WIN32)
|
||||
qml/EditMenu.qml
|
||||
)
|
||||
else()
|
||||
qt_target_qml_sources(neochat QML_FILES qml/ShareActionStub.qml)
|
||||
qt_target_qml_sources(neochat QML_FILES
|
||||
qml/ShareActionStub.qml
|
||||
qml/GlobalMenuStub.qml
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
@@ -189,7 +182,7 @@ else()
|
||||
endif()
|
||||
|
||||
target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
|
||||
target_link_libraries(neochat PRIVATE Loginplugin Roomsplugin Timelineplugin Spacesplugin Chatbarplugin Settingsplugin Devtoolsplugin)
|
||||
target_link_libraries(neochat PRIVATE Loginplugin Roomsplugin RoomInfoplugin Timelineplugin Spacesplugin Chatbarplugin Settingsplugin Devtoolsplugin)
|
||||
target_link_libraries(neochat PUBLIC
|
||||
LibNeoChat
|
||||
Timeline
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "neochatroom.h"
|
||||
#include "notificationsmanager.h"
|
||||
#include "proxycontroller.h"
|
||||
#include "roommanager.h"
|
||||
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
#include "trayicon.h"
|
||||
@@ -98,6 +99,7 @@ Controller::Controller(QObject *parent)
|
||||
MessageModel::setHiddenFilter(hiddenEventFilter);
|
||||
RoomListModel::setHiddenFilter(hiddenEventFilter);
|
||||
RoomTreeModel::setHiddenFilter(hiddenEventFilter);
|
||||
NeoChatRoom::setHiddenFilter(hiddenEventFilter);
|
||||
|
||||
MediaSizeHelper::setMaxSize(NeoChatConfig::mediaMaxWidth(), NeoChatConfig::mediaMaxHeight());
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::MediaMaxWidthChanged, this, []() {
|
||||
@@ -230,6 +232,7 @@ void Controller::initConnection(NeoChatConnection *connection)
|
||||
m_notificationsManager.handleNotifications(connection);
|
||||
});
|
||||
connect(this, &Controller::globalUrlPreviewDefaultChanged, connection, &NeoChatConnection::globalUrlPreviewEnabledChanged);
|
||||
connect(connection, &NeoChatConnection::roomAboutToBeLeft, &RoomManager::instance(), &RoomManager::roomLeft);
|
||||
Q_EMIT connectionAdded(connection);
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ void NotificationsManager::postInviteNotification(NeoChatRoom *rawRoom)
|
||||
if (inAnyOfOurRooms) {
|
||||
doPostInviteNotification(room);
|
||||
} else {
|
||||
room->leaveRoom();
|
||||
room->forget();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -330,14 +330,14 @@ void NotificationsManager::doPostInviteNotification(QPointer<NeoChatRoom> room)
|
||||
if (!room) {
|
||||
return;
|
||||
}
|
||||
RoomManager::instance().leaveRoom(room);
|
||||
room->forget();
|
||||
notification->close();
|
||||
});
|
||||
connect(rejectAndIgnoreAction, &KNotificationAction::activated, this, [room, notification]() {
|
||||
if (!room) {
|
||||
return;
|
||||
}
|
||||
RoomManager::instance().leaveRoom(room);
|
||||
room->forget();
|
||||
room->connection()->addToIgnoredUsers(room->invitingUserId());
|
||||
notification->close();
|
||||
});
|
||||
|
||||
@@ -48,6 +48,7 @@ Delegates.RoundedItemDelegate {
|
||||
|
||||
TapHandler {
|
||||
acceptedDevices: PointerDevice.TouchScreen
|
||||
onTapped: root.selected()
|
||||
onLongPressed: root.contextMenuRequested()
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Kirigami.PromptDialog {
|
||||
text: i18nc("@action:button", "Leave Room")
|
||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
||||
icon.name: "arrow-left-symbolic"
|
||||
onClicked: RoomManager.leaveRoom(root.room)
|
||||
onClicked: root.room.forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import QtPositioning
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.neochat.libneochat
|
||||
|
||||
ApplicationWindow {
|
||||
id: root
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.kde.neochat.settings
|
||||
Labs.MenuBar {
|
||||
id: root
|
||||
|
||||
property NeoChatConnection connection
|
||||
required property NeoChatConnection connection
|
||||
|
||||
Labs.Menu {
|
||||
title: i18nc("menu", "NeoChat")
|
||||
@@ -38,25 +38,31 @@ Labs.MenuBar {
|
||||
title: i18nc("menu", "File")
|
||||
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "Find your friends")
|
||||
icon.name: "list-add-user"
|
||||
text: i18nc("@action:inmenu", "Find your Friends")
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Find your friends") && AccountRegistry.accountCount > 0
|
||||
onTriggered: pushReplaceLayer(Qt.createComponent('org.kde.neochat', 'UserSearchPage'), {
|
||||
onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'UserSearchPage'), {
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@title", "Find your friends")
|
||||
})
|
||||
}
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "New Group…")
|
||||
icon.name: "system-users-symbolic"
|
||||
text: i18nc("@action:inmenu", "Create a Room…")
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Find your friends") && AccountRegistry.accountCount > 0
|
||||
shortcut: StandardKey.New
|
||||
onTriggered: {
|
||||
const dialog = createRoomDialog.createObject(root.overlay);
|
||||
dialog.open();
|
||||
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomDialog'), {
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@title", "Create a Room")
|
||||
});
|
||||
}
|
||||
}
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "Browse Chats…")
|
||||
icon.name: "compass-symbolic"
|
||||
text: i18nc("@action:inmenu", "Explore Rooms")
|
||||
onTriggered: {
|
||||
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), {
|
||||
connection: root.connection
|
||||
@@ -77,7 +83,8 @@ Labs.MenuBar {
|
||||
title: i18nc("menu", "View")
|
||||
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu item that opens a UI element called the 'Quick Switcher', which offers a fast keyboard-based interface for switching in between chats.", "Open Quick Switcher")
|
||||
icon.name: "search-symbolic"
|
||||
text: i18nc("@action:inmenu opens a UI element called the 'Quick Switcher', which offers a fast keyboard-based interface for switching in between chats.", "Search Rooms")
|
||||
onTriggered: quickSwitcher.open()
|
||||
}
|
||||
}
|
||||
@@ -85,6 +92,7 @@ Labs.MenuBar {
|
||||
title: i18nc("menu", "Window")
|
||||
|
||||
Labs.MenuItem {
|
||||
icon.name: "view-fullscreen-symbolic"
|
||||
text: root.visibility === Window.FullScreen ? i18nc("menu", "Exit Full Screen") : i18nc("menu", "Enter Full Screen")
|
||||
onTriggered: root.visibility === Window.FullScreen ? root.showNormal() : root.showFullScreen()
|
||||
}
|
||||
@@ -93,14 +101,12 @@ Labs.MenuBar {
|
||||
title: i18nc("menu", "Help")
|
||||
|
||||
Labs.MenuItem {
|
||||
text: i18nc("menu", "About Matrix")
|
||||
onTriggered: UrlHelper.openUrl("https://matrix.org/docs/chat_basics/matrix-for-im/")
|
||||
}
|
||||
Labs.MenuItem {
|
||||
icon.name: "help-about-symbolic"
|
||||
text: i18nc("menu", "About NeoChat")
|
||||
onTriggered: pageStack.pushDialogLayer(Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutPage"))
|
||||
}
|
||||
Labs.MenuItem {
|
||||
icon.name: "kde-symbolic"
|
||||
text: i18nc("menu", "About KDE")
|
||||
onTriggered: pageStack.pushDialogLayer(Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutKDEPage"))
|
||||
}
|
||||
|
||||
10
src/app/qml/GlobalMenuStub.qml
Normal file
10
src/app/qml/GlobalMenuStub.qml
Normal file
@@ -0,0 +1,10 @@
|
||||
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Item {
|
||||
required property NeoChatConnection connection
|
||||
}
|
||||
@@ -108,7 +108,7 @@ ColumnLayout {
|
||||
icon.name: "dialog-cancel-symbolic"
|
||||
text: i18nc("@action:button Reject this invite", "Reject Invite")
|
||||
|
||||
onClicked: RoomManager.leaveRoom(root.currentRoom)
|
||||
onClicked: root.currentRoom.forget()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ ColumnLayout {
|
||||
text: i18nc("@action:button Block the user", "Block %1", root.invitingMember.displayName)
|
||||
|
||||
onClicked: {
|
||||
RoomManager.leaveRoom(root.currentRoom);
|
||||
root.currentRoom.forget()
|
||||
root.currentRoom.connection.addToIgnoredUsers(root.currentRoom.invitingUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,8 @@ Kirigami.ApplicationWindow {
|
||||
|
||||
Loader {
|
||||
active: Kirigami.Settings.hasPlatformMenuBar && !Kirigami.Settings.isMobile
|
||||
sourceComponent: Qt.createComponent("org.kde.neochat", "GlobalMenu")
|
||||
onActiveChanged: if (active) {
|
||||
item.connection = root.connection;
|
||||
sourceComponent: GlobalMenu {
|
||||
connection: root.connection
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,9 +148,13 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
|
||||
function openRoomDrawer() {
|
||||
pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomDrawerPage'), {
|
||||
connection: root.connection
|
||||
const page = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomDrawerPage'), {
|
||||
connection: root.connection,
|
||||
room: RoomManager.currentRoom,
|
||||
userListModel: RoomManager.userListModel,
|
||||
mediaMessageFilterModel: RoomManager.mediaMessageFilterModel
|
||||
});
|
||||
page.resolveResource.connect((idOrUri, action) => RoomManager.resolveResource(idOrUri, action))
|
||||
}
|
||||
|
||||
contextDrawer: RoomDrawer {
|
||||
@@ -161,7 +164,18 @@ Kirigami.ApplicationWindow {
|
||||
// It is used to ensure that user choice is remembered when changing pages and expanding and contracting the window width
|
||||
property bool drawerUserState: NeoChatConfig.autoRoomInfoDrawer
|
||||
|
||||
room: RoomManager.currentRoom
|
||||
connection: root.connection
|
||||
userListModel: RoomManager.userListModel
|
||||
mediaMessageFilterModel: RoomManager.mediaMessageFilterModel
|
||||
|
||||
onResolveResource: (idOrUri, action) => RoomManager.resolveResource(idOrUri, action)
|
||||
|
||||
roomDrawerWidth: NeoChatConfig.roomDrawerWidth
|
||||
onRoomDrawerWidthChanged: {
|
||||
NeoChatConfig.roomDrawerWidth = actualWidth;
|
||||
NeoChatConfig.save();
|
||||
}
|
||||
|
||||
handleClosedIcon.source: "documentinfo-symbolic"
|
||||
handleClosedToolTip: i18nc("@action:button", "Show Room Information")
|
||||
|
||||
@@ -137,7 +137,9 @@ Kirigami.Page {
|
||||
id: spaceLoader
|
||||
active: root.currentRoom && root.currentRoom.isSpace
|
||||
anchors.fill: parent
|
||||
sourceComponent: SpaceHomePage {}
|
||||
sourceComponent: SpaceHomePage {
|
||||
room: root.currentRoom
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
@@ -264,6 +266,7 @@ Kirigami.Page {
|
||||
plainText: plainText,
|
||||
mimeType: mimeType,
|
||||
progressInfo: progressInfo,
|
||||
messageComponentType: messageComponentType,
|
||||
});
|
||||
contextMenu.popup();
|
||||
}
|
||||
|
||||
74
src/app/qml/UserMenu.qml
Normal file
74
src/app/qml/UserMenu.qml
Normal file
@@ -0,0 +1,74 @@
|
||||
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.components as KirigamiComponents
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.settings
|
||||
import org.kde.neochat.devtools
|
||||
|
||||
KirigamiComponents.ConvergentContextMenu {
|
||||
id: root
|
||||
|
||||
required property Kirigami.ApplicationWindow window
|
||||
required property var author
|
||||
|
||||
headerContentItem: RowLayout {
|
||||
id: detailRow
|
||||
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
KirigamiComponents.Avatar {
|
||||
id: avatar
|
||||
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
|
||||
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
|
||||
|
||||
name: root.author.displayName
|
||||
source: root.author.avatarUrl
|
||||
color: root.author.color
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
spacing: 0
|
||||
|
||||
Kirigami.Heading {
|
||||
level: 1
|
||||
Layout.fillWidth: true
|
||||
font.bold: true
|
||||
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
text: root.author.displayName
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
id: idLabel
|
||||
textFormat: TextEdit.PlainText
|
||||
text: root.author.id
|
||||
elide: Qt.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Action {
|
||||
text: i18nc("@action:button", "Open Profile")
|
||||
icon.name: "im-user-symbolic"
|
||||
onTriggered: RoomManager.resolveResource(root.author.uri)
|
||||
}
|
||||
|
||||
QQC2.Action {
|
||||
text: i18nc("@action:button", "Mention")
|
||||
icon.name: "username-copy-symbolic"
|
||||
onTriggered: {
|
||||
RoomManager.currentRoom.mainCache.mentionAdded(root.author.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,12 @@ void RoomManager::loadInitialRoom()
|
||||
}
|
||||
|
||||
if (m_isMobile) {
|
||||
setCurrentSpace(m_lastSpaceConfig.readEntry(m_connection->userId(), QString()), false);
|
||||
QString lastSpace = m_lastSpaceConfig.readEntry(m_connection->userId(), QString());
|
||||
// We can't have empty keys in KConfig, so we stored it as "Home"
|
||||
if (lastSpace == u"Home"_s) {
|
||||
lastSpace.clear();
|
||||
}
|
||||
setCurrentSpace(lastSpace, false);
|
||||
// We don't want to open a room on startup on mobile
|
||||
return;
|
||||
}
|
||||
@@ -325,14 +330,7 @@ void RoomManager::openRoomForActiveConnection()
|
||||
setCurrentSpace({}, false);
|
||||
return;
|
||||
}
|
||||
setCurrentSpace(m_lastSpaceConfig.readEntry(m_connection->userId(), QString()), false);
|
||||
const auto &lastRoom = m_lastRoomConfig.readEntry(m_connection->userId(), QString());
|
||||
if (lastRoom.isEmpty() || !m_connection->room(lastRoom)) {
|
||||
setCurrentRoom({});
|
||||
} else {
|
||||
m_currentRoom = nullptr;
|
||||
resolveResource(lastRoom);
|
||||
}
|
||||
setCurrentSpace(m_lastSpaceConfig.readEntry(m_connection->userId(), QString()), true);
|
||||
}
|
||||
|
||||
UriResolveResult RoomManager::visitUser(User *user, const QString &action)
|
||||
@@ -448,29 +446,27 @@ void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAlias
|
||||
Qt::SingleShotConnection);
|
||||
}
|
||||
|
||||
void RoomManager::roomLeft(const QString &id)
|
||||
{
|
||||
if (id.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_currentRoom && m_currentRoom->id() == id) {
|
||||
setCurrentRoom({});
|
||||
}
|
||||
|
||||
if (m_currentSpaceId == id) {
|
||||
setCurrentSpace({});
|
||||
}
|
||||
}
|
||||
|
||||
bool RoomManager::visitNonMatrix(const QUrl &url)
|
||||
{
|
||||
UrlHelper().openUrl(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RoomManager::leaveRoom(NeoChatRoom *room)
|
||||
{
|
||||
if (!room) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_currentRoom && m_currentRoom->id() == room->id()) {
|
||||
setCurrentRoom({});
|
||||
}
|
||||
|
||||
if (m_currentSpaceId == room->id()) {
|
||||
setCurrentSpace({});
|
||||
}
|
||||
|
||||
room->forget();
|
||||
}
|
||||
|
||||
ChatDocumentHandler *RoomManager::chatDocumentHandler() const
|
||||
{
|
||||
return m_chatDocumentHandler;
|
||||
@@ -523,18 +519,32 @@ void RoomManager::setCurrentSpace(const QString &spaceId, bool setRoom)
|
||||
|
||||
Q_EMIT currentSpaceChanged();
|
||||
if (m_connection) {
|
||||
m_lastSpaceConfig.writeEntry(m_connection->userId(), spaceId);
|
||||
if (spaceId.isEmpty()) {
|
||||
m_lastSpaceConfig.writeEntry(m_connection->userId(), u"Home"_s);
|
||||
} else {
|
||||
m_lastSpaceConfig.writeEntry(m_connection->userId(), spaceId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!setRoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We intentionally don't want to open the last room on mobile
|
||||
if (!m_isMobile) {
|
||||
if (spaceId.length() > 3) {
|
||||
resolveResource(spaceId, "no_join"_L1);
|
||||
QString configSpaceId = spaceId;
|
||||
// We can't have empty keys in KConfig, so it's stored as "Home"
|
||||
if (spaceId.isEmpty()) {
|
||||
configSpaceId = u"Home"_s;
|
||||
}
|
||||
|
||||
const auto &lastRoom = m_lastRoomConfig.readEntry(configSpaceId, QString());
|
||||
if (lastRoom.isEmpty()) {
|
||||
if (spaceId != u"DM"_s && spaceId != u"Home"_s) {
|
||||
resolveResource(spaceId, "no_join"_L1);
|
||||
}
|
||||
} else {
|
||||
visitRoom({}, {});
|
||||
resolveResource(lastRoom, "no_join"_L1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -557,7 +567,16 @@ void RoomManager::setCurrentRoom(const QString &roomId)
|
||||
|
||||
Q_EMIT currentRoomChanged();
|
||||
if (m_connection) {
|
||||
m_lastRoomConfig.writeEntry(m_connection->userId(), roomId);
|
||||
if (roomId.isEmpty()) {
|
||||
m_lastRoomConfig.deleteEntry(m_currentSpaceId);
|
||||
} else {
|
||||
// We can't have empty keys in KConfig, so name it "Home"
|
||||
if (m_currentSpaceId.isEmpty()) {
|
||||
m_lastRoomConfig.writeEntry(u"Home"_s, roomId);
|
||||
} else {
|
||||
m_lastRoomConfig.writeEntry(m_currentSpaceId, roomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (roomId.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -195,11 +195,6 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void loadInitialRoom();
|
||||
|
||||
/**
|
||||
* @brief Leave the room and close it if it is open.
|
||||
*/
|
||||
Q_INVOKABLE void leaveRoom(NeoChatRoom *room);
|
||||
|
||||
/**
|
||||
* @brief Knock a room.
|
||||
*
|
||||
@@ -208,6 +203,13 @@ public:
|
||||
*/
|
||||
void knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers);
|
||||
|
||||
/**
|
||||
* @brief Cleanup after the given room is left.
|
||||
*
|
||||
* This ensures that the current room and space are not set to the left room.
|
||||
*/
|
||||
void roomLeft(const QString &id);
|
||||
|
||||
/**
|
||||
* @brief Show a media item maximized.
|
||||
*
|
||||
|
||||
@@ -55,6 +55,19 @@ QQC2.Control {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: currentRoom.mainCache
|
||||
|
||||
function onMentionAdded(mention: string): void {
|
||||
// add mention text
|
||||
textField.append(mention + " ");
|
||||
// move cursor to the end
|
||||
textField.cursorPosition = textField.text.length;
|
||||
// move the focus back to the chat bar
|
||||
textField.forceActiveFocus(Qt.OtherFocusReason);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The list of actions in the ChatBar.
|
||||
*
|
||||
@@ -342,11 +355,13 @@ QQC2.Control {
|
||||
icon.name: modelData.isBusy ? "" : (modelData.icon.name.length > 0 ? modelData.icon.name : modelData.icon.source)
|
||||
onClicked: modelData.trigger()
|
||||
|
||||
padding: Kirigami.Units.smallSpacing
|
||||
|
||||
QQC2.ToolTip.visible: hovered
|
||||
QQC2.ToolTip.text: modelData.tooltip
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
|
||||
PieProgressBar {
|
||||
contentItem: PieProgressBar {
|
||||
visible: modelData.isBusy
|
||||
progress: root.currentRoom.fileUploadingProgress
|
||||
}
|
||||
|
||||
@@ -41,12 +41,26 @@ target_sources(LibNeoChat PRIVATE
|
||||
models/locationsmodel.cpp
|
||||
models/roomlistmodel.cpp
|
||||
models/stickermodel.cpp
|
||||
models/userfiltermodel.cpp
|
||||
models/userlistmodel.cpp
|
||||
)
|
||||
|
||||
ecm_add_qml_module(LibNeoChat GENERATE_PLUGIN_SOURCE
|
||||
URI org.kde.neochat.libneochat
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/libneochat
|
||||
DEPENDENCIES
|
||||
QtCore
|
||||
QtQuick
|
||||
org.kde.prison
|
||||
org.kde.prison.scanner
|
||||
QML_FILES
|
||||
qml/GroupChatDrawerHeader.qml
|
||||
qml/LocationMapItem.qml
|
||||
qml/InviteUserPage.qml
|
||||
qml/ExploreRoomsPage.qml
|
||||
qml/SearchPage.qml
|
||||
qml/CreateRoomDialog.qml
|
||||
qml/CreateSpaceDialog.qml
|
||||
)
|
||||
|
||||
ecm_qt_declare_logging_category(LibNeoChat
|
||||
|
||||
@@ -23,12 +23,10 @@ AccountManager::AccountManager(bool testMode, QObject *parent)
|
||||
loadAccountsFromCache();
|
||||
});
|
||||
} else {
|
||||
auto c = new NeoChatConnection(this);
|
||||
auto c = new NeoChatConnection(QUrl(u"https://localhost:1234"_s), this);
|
||||
c->assumeIdentity(u"@user:localhost:1234"_s, u"device_1234"_s, u"token_1234"_s);
|
||||
connect(c, &NeoChatConnection::connected, this, [c, this]() {
|
||||
m_accountRegistry->add(c);
|
||||
c->syncLoop();
|
||||
});
|
||||
m_accountRegistry->add(c);
|
||||
c->syncLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ Q_SIGNALS:
|
||||
void relationIdChanged(const QString &oldEventId, const QString &newEventId);
|
||||
void threadIdChanged(const QString &oldThreadId, const QString &newThreadId);
|
||||
void attachmentPathChanged();
|
||||
void mentionAdded(const QString &mention);
|
||||
|
||||
private:
|
||||
QString m_text = QString();
|
||||
|
||||
@@ -29,7 +29,7 @@ QStringList rainbowColors{"#ff2b00"_L1, "#ff5500"_L1, "#ff8000"_L1, "#ffaa00"_L1
|
||||
auto leaveRoomLambda = [](const QString &text, NeoChatRoom *room, ChatBarCache *) {
|
||||
if (text.isEmpty()) {
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18n("Leaving this room."));
|
||||
room->connection()->leaveRoom(room);
|
||||
room->forget();
|
||||
} else {
|
||||
QRegularExpression roomRegex(uR"(^[#!][^:]+:\w(?:\w|\.|-)*\.\w+(?::\d{1,5})?)"_s);
|
||||
auto regexMatch = roomRegex.match(text);
|
||||
@@ -38,13 +38,13 @@ auto leaveRoomLambda = [](const QString &text, NeoChatRoom *room, ChatBarCache *
|
||||
i18nc("'<text>' does not look like a room id or alias.", "'%1' does not look like a room id or alias.", text));
|
||||
return QString();
|
||||
}
|
||||
auto leaving = room->connection()->room(text);
|
||||
auto leaving = dynamic_cast<NeoChatRoom *>(room->connection()->room(text));
|
||||
if (!leaving) {
|
||||
leaving = room->connection()->roomByAlias(text);
|
||||
leaving = dynamic_cast<NeoChatRoom *>(room->connection()->roomByAlias(text));
|
||||
}
|
||||
if (leaving) {
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18nc("Leaving room <roomname>.", "Leaving room %1.", text));
|
||||
room->connection()->leaveRoom(leaving);
|
||||
leaving->forget();
|
||||
} else {
|
||||
Q_EMIT room->showMessage(MessageType::Information, i18nc("Room <roomname> not found", "Room %1 not found.", text));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "neochatroom.h"
|
||||
#include "spacehierarchycache.h"
|
||||
|
||||
#include <Quotient/connection.h>
|
||||
#include <Quotient/jobs/basejob.h>
|
||||
#include <Quotient/quotient_common.h>
|
||||
#include <qt6keychain/keychain.h>
|
||||
@@ -386,6 +387,13 @@ void NeoChatConnection::createSpace(const QString &name, const QString &topic, c
|
||||
});
|
||||
}
|
||||
|
||||
Quotient::ForgetRoomJob *NeoChatConnection::forgetRoom(const QString &id)
|
||||
{
|
||||
Q_EMIT roomAboutToBeLeft(id);
|
||||
|
||||
return Connection::forgetRoom(id);
|
||||
}
|
||||
|
||||
bool NeoChatConnection::directChatExists(Quotient::User *user)
|
||||
{
|
||||
return directChats().contains(user);
|
||||
|
||||
@@ -150,6 +150,14 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void createSpace(const QString &name, const QString &topic, const QString &parent = {}, bool setChildParent = false);
|
||||
|
||||
/**
|
||||
* @brief Send /forget to the server and delete room locally.
|
||||
*
|
||||
* @note This wraps around the Quotient::Connection::forgetRoom() to allow
|
||||
* roomAboutToBeLeft() to be emitted.
|
||||
*/
|
||||
Quotient::ForgetRoomJob *forgetRoom(const QString &id);
|
||||
|
||||
/**
|
||||
* @brief Whether a direct chat with the user exists.
|
||||
*/
|
||||
@@ -224,6 +232,11 @@ Q_SIGNALS:
|
||||
*/
|
||||
void errorOccured(const QString &error);
|
||||
|
||||
/**
|
||||
* @brief The given room ID is about to be forgotten.
|
||||
*/
|
||||
void roomAboutToBeLeft(const QString &id);
|
||||
|
||||
private:
|
||||
static bool m_globalUrlPreviewDefault;
|
||||
static PushRuleAction::Action m_defaultAction;
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
std::function<bool(const Quotient::RoomEvent *)> NeoChatRoom::m_hiddenFilter = [](const Quotient::RoomEvent *) -> bool {
|
||||
return false;
|
||||
};
|
||||
|
||||
NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinState)
|
||||
: Room(connection, std::move(roomId), joinState)
|
||||
{
|
||||
@@ -305,8 +309,9 @@ void NeoChatRoom::forget()
|
||||
roomIds += predecessor->id();
|
||||
}
|
||||
|
||||
const auto neochatConnection = dynamic_cast<NeoChatConnection *>(connection());
|
||||
for (const auto &id : roomIds) {
|
||||
connection()->forgetRoom(id);
|
||||
neochatConnection->forgetRoom(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +373,7 @@ const RoomEvent *NeoChatRoom::lastEvent(std::function<bool(const RoomEvent *)> f
|
||||
|
||||
void NeoChatRoom::cacheLastEvent()
|
||||
{
|
||||
auto event = lastEvent();
|
||||
auto event = lastEvent(m_hiddenFilter);
|
||||
if (event != nullptr) {
|
||||
auto &roomLastMessageProvider = RoomLastMessageProvider::self();
|
||||
|
||||
@@ -480,30 +485,6 @@ void NeoChatRoom::changeAvatar(const QUrl &localFile)
|
||||
}
|
||||
}
|
||||
|
||||
QString msgTypeToString(MessageEventType msgType)
|
||||
{
|
||||
switch (msgType) {
|
||||
case MessageEventType::Text:
|
||||
return "m.text"_L1;
|
||||
case MessageEventType::File:
|
||||
return "m.file"_L1;
|
||||
case MessageEventType::Audio:
|
||||
return "m.audio"_L1;
|
||||
case MessageEventType::Emote:
|
||||
return "m.emote"_L1;
|
||||
case MessageEventType::Image:
|
||||
return "m.image"_L1;
|
||||
case MessageEventType::Video:
|
||||
return "m.video"_L1;
|
||||
case MessageEventType::Notice:
|
||||
return "m.notice"_L1;
|
||||
case MessageEventType::Location:
|
||||
return "m.location"_L1;
|
||||
default:
|
||||
return "m.text"_L1;
|
||||
}
|
||||
}
|
||||
|
||||
void NeoChatRoom::toggleReaction(const QString &eventId, const QString &reaction)
|
||||
{
|
||||
if (eventId.isEmpty() || reaction.isEmpty()) {
|
||||
@@ -1741,4 +1722,9 @@ QString NeoChatRoom::rootIdForThread(const QString &eventId) const
|
||||
return rootId;
|
||||
}
|
||||
|
||||
void NeoChatRoom::setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter)
|
||||
{
|
||||
NeoChatRoom::m_hiddenFilter = hiddenFilter;
|
||||
}
|
||||
|
||||
#include "moc_neochatroom.cpp"
|
||||
|
||||
@@ -587,6 +587,8 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE QString rootIdForThread(const QString &eventId) const;
|
||||
|
||||
static void setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter);
|
||||
|
||||
private:
|
||||
bool m_visible = false;
|
||||
|
||||
@@ -618,6 +620,7 @@ private:
|
||||
void cleanupExtraEvent(const QString &eventId);
|
||||
|
||||
std::unordered_map<QString, std::unique_ptr<NeochatRoomMember>> m_memberObjects;
|
||||
static std::function<bool(const Quotient::RoomEvent *)> m_hiddenFilter;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updatePushNotificationState(QString type);
|
||||
|
||||
73
src/libneochat/qml/CreateRoomDialog.qml
Normal file
73
src/libneochat/qml/CreateRoomDialog.qml
Normal file
@@ -0,0 +1,73 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-or-later OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigamiaddons.labs.components as Components
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
property string parentId
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
signal newChild(string childName)
|
||||
|
||||
title: i18nc("@title", "Create Room")
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
standardButtons: Kirigami.Dialog.Cancel
|
||||
|
||||
customFooterActions: [
|
||||
Kirigami.Action {
|
||||
icon.name: "list-add-symbolic"
|
||||
text: i18nc("@action:button Create new room", "Create")
|
||||
enabled: roomNameField.text.length > 0
|
||||
onTriggered: {
|
||||
root.connection.createRoom(roomNameField.text, "", root.parentId, false);
|
||||
root.newChild(roomNameField.text);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Component.onCompleted: roomNameField.forceActiveFocus()
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
FormCard.FormRadioDelegate {
|
||||
id: privateTypeDelegate
|
||||
text: i18nc("@info:label", "Private")
|
||||
description: i18nc("@info:description", "This room can only be joined with an invite.")
|
||||
checked: true
|
||||
}
|
||||
|
||||
FormCard.FormRadioDelegate {
|
||||
id: publicTypeDelegate
|
||||
text: i18nc("@info:label", "Public")
|
||||
description: i18nc("@info:description", "This room can be found and joined by anyone.")
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {}
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: roomNameField
|
||||
label: i18nc("@info:label Name of the room", "Name:")
|
||||
placeholderText: i18nc("@info:placeholder Placeholder for room name", "New Room")
|
||||
}
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: roomAddressField
|
||||
label: i18nc("@info:label Address or alias to refer to the room by", "Address:")
|
||||
placeholderText: i18nc("@info:placeholder Placeholder address for the room", "new-room")
|
||||
visible: publicTypeDelegate.checked
|
||||
}
|
||||
}
|
||||
}
|
||||
64
src/libneochat/qml/CreateSpaceDialog.qml
Normal file
64
src/libneochat/qml/CreateSpaceDialog.qml
Normal file
@@ -0,0 +1,64 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-or-later OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigamiaddons.labs.components as Components
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
property string parentId
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
signal newChild(string childName)
|
||||
|
||||
title: i18nc("@title", "Create a Space")
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
standardButtons: Kirigami.Dialog.Cancel
|
||||
|
||||
Component.onCompleted: roomNameField.forceActiveFocus()
|
||||
|
||||
customFooterActions: [
|
||||
Kirigami.Action {
|
||||
icon.name: "list-add-symbolic"
|
||||
text: i18nc("@action:button Create new space", "Create")
|
||||
enabled: roomNameField.text.length > 0
|
||||
onTriggered: {
|
||||
root.connection.createSpace(roomNameField.text, "", root.parentId, newOfficialCheck.checked);
|
||||
root.newChild(roomNameField.text);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: roomNameField
|
||||
label: i18nc("@info:label Name of the space", "Name:")
|
||||
placeholderText: i18nc("@info:placeholder", "New Space")
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: roomNameField
|
||||
below: newOfficialCheck
|
||||
visible: newOfficialCheck.visible
|
||||
}
|
||||
|
||||
FormCard.FormCheckDelegate {
|
||||
id: newOfficialCheck
|
||||
visible: root.parentId.length > 0
|
||||
text: i18nc("@option:check As in make the space from which this dialog was created an official parent.", "Make this parent official")
|
||||
checked: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,11 @@ ColumnLayout {
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
/**
|
||||
* @brief The canonical alias of the room, if it exists. Otherwise falls back to the first available alias.
|
||||
*/
|
||||
readonly property var roomAlias: room.aliases[0]
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
RowLayout {
|
||||
@@ -73,8 +78,8 @@ ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
font: Kirigami.Theme.smallFont
|
||||
textFormat: TextEdit.PlainText
|
||||
visible: root.room && root.room.canonicalAlias
|
||||
text: root.room && root.room.canonicalAlias ? root.room.canonicalAlias : ""
|
||||
visible: root.room && root.roomAlias
|
||||
text: root.room && root.roomAlias ? root.roomAlias : ""
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
}
|
||||
@@ -718,10 +718,15 @@ QString TextHandler::customMarkdownToHtml(const QString &stringIn)
|
||||
break;
|
||||
}
|
||||
|
||||
// If we're inside a code block, ignore and move the search past the code block
|
||||
// If we're inside a code block, ignore and move the search past this code block
|
||||
const bool validCodeBlock = beginCodeBlockTag != -1 && endCodeBlockTag != -1;
|
||||
if (validCodeBlock && pos > beginCodeBlockTag && pos < endCodeBlockTag) {
|
||||
lastPos = endCodeBlockTag + 5;
|
||||
lastPos = endCodeBlockTag + 7;
|
||||
|
||||
// since we moved past this code block, make sure to update the indices for the next one
|
||||
beginCodeBlockTag = buffer.indexOf(u"<code>"_s, lastPos + 1);
|
||||
endCodeBlockTag = buffer.indexOf(u"</code>"_s, beginCodeBlockTag + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -731,20 +736,24 @@ QString TextHandler::customMarkdownToHtml(const QString &stringIn)
|
||||
}
|
||||
|
||||
// Replace the beginning syntax
|
||||
buffer.replace(pos, 2, beginTag);
|
||||
buffer.replace(pos, syntax.length(), beginTag);
|
||||
|
||||
// Update positions and re-search since the underlying text buffer changed
|
||||
nextPos = buffer.indexOf(syntax, pos + 1);
|
||||
beginCodeBlockTag = buffer.indexOf(u"<code>"_s, pos + 1);
|
||||
endCodeBlockTag = buffer.indexOf(u"</code>"_s, beginCodeBlockTag + 1);
|
||||
|
||||
// Now replace the end syntax
|
||||
buffer.replace(nextPos, 2, endTag);
|
||||
buffer.replace(nextPos, syntax.length(), endTag);
|
||||
|
||||
// If we have begun checking spoilers past our current code block, make sure we're in the next one (if it exists)
|
||||
if (nextPos > endCodeBlockTag) {
|
||||
beginCodeBlockTag = buffer.indexOf(u"<code>"_s, nextPos + 1);
|
||||
endCodeBlockTag = buffer.indexOf(u"</code>"_s, beginCodeBlockTag + 1);
|
||||
}
|
||||
|
||||
// Move the search pointer past this point.
|
||||
// Not technically needed in most cases since we replaced the original tag, but needed for code blocks
|
||||
// which still have the characters.
|
||||
lastPos = nextPos + 2;
|
||||
lastPos = nextPos + syntax.length();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
17
src/roominfo/CMakeLists.txt
Normal file
17
src/roominfo/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
# SPDX-FileCopyrightText: 2025 James Graham <james.h.graham@protonmail.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
qt_add_library(RoomInfo STATIC)
|
||||
ecm_add_qml_module(RoomInfo GENERATE_PLUGIN_SOURCE
|
||||
URI org.kde.neochat.roominfo
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/roominfo
|
||||
QML_FILES
|
||||
RoomDrawer.qml
|
||||
RoomDrawerPage.qml
|
||||
RoomInformation.qml
|
||||
RoomMedia.qml
|
||||
DirectChatDrawerHeader.qml
|
||||
LocationsPage.qml
|
||||
RoomPinnedMessagesPage.qml
|
||||
RoomSearchPage.qml
|
||||
)
|
||||
@@ -8,7 +8,7 @@ import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.libneochat
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
@@ -18,6 +18,8 @@ ColumnLayout {
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
signal resolveResource(string idOrUri, string action)
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
spacing: 0
|
||||
@@ -33,7 +35,7 @@ ColumnLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
onClicked: {
|
||||
RoomManager.resolveResource(root.room.directChatRemoteMember.uri)
|
||||
root.resolveResource(root.room.directChatRemoteMember.uri, "")
|
||||
}
|
||||
|
||||
contentItem: KirigamiComponents.Avatar {
|
||||
@@ -6,12 +6,13 @@ import QtLocation
|
||||
import QtPositioning
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.neochat
|
||||
|
||||
import org.kde.neochat.libneochat
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
|
||||
required property var room
|
||||
required property NeoChatRoom room
|
||||
|
||||
title: i18nc("Locations on a map", "Locations")
|
||||
|
||||
@@ -9,14 +9,19 @@ import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kitemmodels
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.settings
|
||||
import org.kde.neochat.libneochat
|
||||
import org.kde.neochat.timeline as Timeline
|
||||
import org.kde.neochat.settings as Settings
|
||||
|
||||
Kirigami.OverlayDrawer {
|
||||
id: root
|
||||
|
||||
readonly property NeoChatRoom room: RoomManager.currentRoom
|
||||
required property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
required property UserListModel userListModel
|
||||
required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
|
||||
|
||||
signal resolveResource(string idOrUri, string action)
|
||||
|
||||
width: actualWidth
|
||||
interactive: modal
|
||||
@@ -24,11 +29,12 @@ Kirigami.OverlayDrawer {
|
||||
readonly property int minWidth: Kirigami.Units.gridUnit * 15
|
||||
readonly property int maxWidth: Kirigami.Units.gridUnit * 25
|
||||
readonly property int defaultWidth: Kirigami.Units.gridUnit * 20
|
||||
property int roomDrawerWidth
|
||||
property int actualWidth: {
|
||||
if (NeoChatConfig.roomDrawerWidth === -1) {
|
||||
if (root.roomDrawerWidth === -1) {
|
||||
return Kirigami.Units.gridUnit * 20;
|
||||
} else {
|
||||
return NeoChatConfig.roomDrawerWidth;
|
||||
return root.roomDrawerWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +52,7 @@ Kirigami.OverlayDrawer {
|
||||
visible: true
|
||||
onPressed: _lastX = mapToGlobal(mouseX, mouseY).x
|
||||
onReleased: {
|
||||
NeoChatConfig.roomDrawerWidth = root.actualWidth;
|
||||
NeoChatConfig.save();
|
||||
root.roomDrawerWidth = root.actualWidth;
|
||||
}
|
||||
property real _lastX: -1
|
||||
|
||||
@@ -56,9 +61,9 @@ Kirigami.OverlayDrawer {
|
||||
return;
|
||||
}
|
||||
if (Qt.application.layoutDirection === Qt.RightToLeft) {
|
||||
root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, NeoChatConfig.roomDrawerWidth - _lastX + mapToGlobal(mouseX, mouseY).x));
|
||||
root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, root.roomDrawerWidth - _lastX + mapToGlobal(mouseX, mouseY).x));
|
||||
} else {
|
||||
root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, NeoChatConfig.roomDrawerWidth + _lastX - mapToGlobal(mouseX, mouseY).x));
|
||||
root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, root.roomDrawerWidth + _lastX - mapToGlobal(mouseX, mouseY).x));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +126,7 @@ Kirigami.OverlayDrawer {
|
||||
QQC2.ToolTip.visible: hovered
|
||||
|
||||
onClicked: {
|
||||
RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Room);
|
||||
Settings.RoomSettingsView.openRoomSettings(root.room, Settings.RoomSettingsView.Room);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,15 +143,17 @@ Kirigami.OverlayDrawer {
|
||||
id: roomInformation
|
||||
RoomInformation {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
userListModel: root.userListModel
|
||||
|
||||
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: roomMedia
|
||||
RoomMedia {
|
||||
currentRoom: root.room
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
mediaMessageFilterModel: root.mediaMessageFilterModel
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kitemmodels
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.libneochat
|
||||
import org.kde.neochat.timeline as Timeline
|
||||
|
||||
/**
|
||||
* @brief Page for holding a room drawer component.
|
||||
@@ -24,8 +25,12 @@ Kirigami.Page {
|
||||
/**
|
||||
* @brief The current room that user is viewing.
|
||||
*/
|
||||
readonly property NeoChatRoom room: RoomManager.currentRoom
|
||||
required property NeoChatRoom room
|
||||
required property NeoChatConnection connection
|
||||
required property UserListModel userListModel
|
||||
required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
|
||||
|
||||
signal resolveResource(string idOrUri, string action)
|
||||
|
||||
title: drawerItemLoader.item ? drawerItemLoader.item.title : ""
|
||||
|
||||
@@ -61,15 +66,17 @@ Kirigami.Page {
|
||||
id: roomInformation
|
||||
RoomInformation {
|
||||
room: root.room
|
||||
connection: root.connection
|
||||
userListModel: root.userListModel
|
||||
|
||||
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: roomMedia
|
||||
RoomMedia {
|
||||
currentRoom: root.room
|
||||
connection: root.connection
|
||||
room: root.room
|
||||
mediaMessageFilterModel: root.mediaMessageFilterModel
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.kde.kirigamiaddons.delegates as Delegates
|
||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||
import org.kde.kitemmodels
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.libneochat
|
||||
|
||||
/**
|
||||
* @brief Component for visualising the room information.
|
||||
@@ -34,13 +34,15 @@ QQC2.ScrollView {
|
||||
*/
|
||||
required property NeoChatRoom room
|
||||
|
||||
required property NeoChatConnection connection
|
||||
required property UserListModel userListModel
|
||||
|
||||
/**
|
||||
* @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")
|
||||
|
||||
signal resolveResource(string idOrUri, string action)
|
||||
|
||||
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
|
||||
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
||||
|
||||
@@ -216,7 +218,7 @@ QQC2.ScrollView {
|
||||
|
||||
UserFilterModel {
|
||||
id: userFilterModel
|
||||
sourceModel: RoomManager.userListModel
|
||||
sourceModel: root.userListModel
|
||||
allowEmpty: true
|
||||
}
|
||||
|
||||
@@ -249,7 +251,7 @@ QQC2.ScrollView {
|
||||
KeyNavigation.backtab: index === 0 ? userList.headerItem.userListSearchField : null
|
||||
|
||||
onClicked: {
|
||||
RoomManager.resolveResource(userDelegate.userId, "mention");
|
||||
root.resolveResource(userDelegate.userId, "mention");
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
@@ -286,6 +288,8 @@ QQC2.ScrollView {
|
||||
id: directChatDrawerHeader
|
||||
DirectChatDrawerHeader {
|
||||
room: root.room
|
||||
|
||||
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
import Qt.labs.qmlmodels
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.timeline
|
||||
import org.kde.neochat.libneochat
|
||||
import org.kde.neochat.timeline as Timeline
|
||||
|
||||
/**
|
||||
* @brief Component for visualising the loaded media items in the room.
|
||||
@@ -31,9 +31,9 @@ QQC2.ScrollView {
|
||||
/**
|
||||
* @brief The current room that user is viewing.
|
||||
*/
|
||||
required property NeoChatRoom currentRoom
|
||||
required property NeoChatRoom room
|
||||
|
||||
required property NeoChatConnection connection
|
||||
required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
|
||||
|
||||
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
|
||||
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
||||
@@ -42,26 +42,26 @@ QQC2.ScrollView {
|
||||
clip: true
|
||||
verticalLayoutDirection: ListView.BottomToTop
|
||||
|
||||
model: RoomManager.mediaMessageFilterModel
|
||||
model: root.mediaMessageFilterModel
|
||||
|
||||
delegate: DelegateChooser {
|
||||
role: "type"
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MediaMessageFilterModel.Image
|
||||
delegate: MessageDelegate {
|
||||
roleValue: Timeline.MediaMessageFilterModel.Image
|
||||
delegate: Timeline.MessageDelegate {
|
||||
alwaysFillWidth: true
|
||||
cardBackground: false
|
||||
room: root.currentRoom
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MediaMessageFilterModel.Video
|
||||
delegate: MessageDelegate {
|
||||
roleValue: Timeline.MediaMessageFilterModel.Video
|
||||
delegate: Timeline.MessageDelegate {
|
||||
alwaysFillWidth: true
|
||||
cardBackground: false
|
||||
room: root.currentRoom
|
||||
room: root.room
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.libneochat
|
||||
import org.kde.neochat.timeline
|
||||
|
||||
/**
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.libneochat
|
||||
import org.kde.neochat.timeline
|
||||
|
||||
/**
|
||||
@@ -90,29 +90,13 @@ RowLayout {
|
||||
action: QQC2.Action {
|
||||
shortcut: StandardKey.New
|
||||
onTriggered: {
|
||||
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomDialog'), {
|
||||
Qt.createComponent('org.kde.neochat', 'CreateRoomDialog').createObject(root, {
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@title", "Create a Room")
|
||||
});
|
||||
}).open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Create a Space")
|
||||
icon.name: "list-add"
|
||||
onTriggered: {
|
||||
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomDialog'), {
|
||||
connection: root.connection,
|
||||
isSpace: true,
|
||||
title: i18nc("@title", "Create a Space")
|
||||
}, {
|
||||
title: i18nc("@title", "Create a Space")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.MenuItem {
|
||||
text: i18n("Scan a QR Code")
|
||||
icon.name: "view-barcode-qr"
|
||||
|
||||
@@ -159,13 +159,9 @@ Kirigami.NavigationTabBar {
|
||||
text: i18n("Create a Space")
|
||||
icon.name: "list-add"
|
||||
onTriggered: {
|
||||
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomDialog'), {
|
||||
connection: root.connection,
|
||||
isSpace: true,
|
||||
title: i18nc("@title", "Create a Space")
|
||||
}, {
|
||||
title: i18nc("@title", "Create a Space")
|
||||
});
|
||||
Qt.createComponent('org.kde.neochat', 'CreateSpaceDialog').createObject(root, {
|
||||
connection: root.connection
|
||||
}).open();
|
||||
explorePopup.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +125,17 @@ KirigamiComponents.ConvergentContextMenu {
|
||||
QQC2.Action {
|
||||
text: room.isDirectChat() ? i18nc("@action:inmenu", "Copy user's Matrix ID") : i18nc("@action:inmenu", "Copy Room Address")
|
||||
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);
|
||||
onTriggered: {
|
||||
// The canonical alias (if it exists) otherwise the first available alias
|
||||
const firstAlias = room.aliases[0];
|
||||
|
||||
if (room.isDirectChat()) {
|
||||
Clipboard.saveText(room.directChatRemoteMember.id);
|
||||
} else if (!firstAlias) {
|
||||
Clipboard.saveText(room.id);
|
||||
} else {
|
||||
Clipboard.saveText(firstAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,13 +268,11 @@ QQC2.Control {
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
onSelected: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomDialog'), {
|
||||
connection: root.connection,
|
||||
isSpace: true,
|
||||
title: i18nc("@title", "Create a Space")
|
||||
}, {
|
||||
title: i18nc("@title", "Create a Space")
|
||||
})
|
||||
onSelected: {
|
||||
Qt.createComponent('org.kde.neochat', 'CreateSpaceDialog').createObject(root, {
|
||||
connection: root.connection
|
||||
}).open();
|
||||
}
|
||||
}
|
||||
|
||||
AvatarTabButton {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user