Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F140510
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
17 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/contents/ui/EventView.qml b/src/contents/ui/EventView.qml
index 4e55497..ec95c24 100644
--- a/src/contents/ui/EventView.qml
+++ b/src/contents/ui/EventView.qml
@@ -1,159 +1,173 @@
/*
* Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import Qt.labs.qmlmodels 1.0
import org.kde.kirigami 2.13 as Kirigami
import 'event-types' as Types
Item {
id: eventView
property var event
property var sender
property var messageType: getMessageType(event)
property var iconSize: Kirigami.Units.iconSizes.large
property var senderNameSize: Kirigami.Units.gridUnit * 1.2
height: loader.item.implicitHeight
//padding: Kirigami.Units.largeSpacing
Component {
id: textEV
Types.Text {
event: eventView.event
sender: eventView.sender
}
}
Component {
id: emoteEV
Types.Emote {
event: eventView.event
sender: eventView.sender
}
}
Component {
id: noticeEV
Types.Notice {
event: eventView.event
sender: eventView.sender
}
}
+ Component {
+ id: stateEV
+ Types.State {
+ event: eventView.event
+ sender: eventView.sender
+ }
+ }
+
Component {
id: unknownEV
Label {
text: 'unknown event'
}
}
Loader {
sourceComponent: getSource(messageType)
id: loader
}
function getSource(t) {
switch (t) {
case 'text':
return textEV;
case 'emote':
return emoteEV;
case 'notice':
return noticeEV;
+ case 'state':
+ return stateEV;
+
default:
return unknownEV;
}
}
/* DelegateChooser { */
/* id: inner */
/* role: 'messageType' */
/* DelegateChoice { */
/* roleValue: 'text' */
/* Types.Simple { */
/* event: eventView.event */
/* sender: eventView.sender */
/* } */
/* } */
/* DelegateChoice { */
/* roleValue: 'unknown' */
/* Label { */
/* text: 'unknown event' */
/* } */
/* } */
/* DelegateChoice { */
/* roleValue: '' */
/* Label { */
/* text: '???' */
/* } */
/* } */
/* } */
function getMessageType(e) {
+ if (e.isState) {
+ return 'state';
+ }
switch (e.type) {
case 'm.room.message':
switch (e.content.msgtype) {
case 'm.text':
console.log('msg type=text');
return 'text';
case 'm.emote':
return 'emote';
case 'm.notice':
return 'notice';
case 'm.image':
return 'image';
case 'm.file':
return 'file';
case 'm.audio':
return 'audio';
case 'm.video':
return 'video';
case 'm.location':
return 'location';
default:
console.log('msg type=unknown');
return 'unknown';
}
default:
console.log('msg type=unknown');
return 'unknown';
}
}
}
diff --git a/src/contents/ui/event-types/State.qml b/src/contents/ui/event-types/State.qml
new file mode 100644
index 0000000..ddb0fee
--- /dev/null
+++ b/src/contents/ui/event-types/State.qml
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
+ *
+ * This file is part of kazv.
+ *
+ * kazv is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * kazv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with kazv. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.2
+import QtQuick.Layouts 1.15
+import QtQuick.Controls 2.15
+
+import org.kde.kirigami 2.13 as Kirigami
+
+import '.' as Types
+
+Types.TextTemplate {
+ id: upper
+ text: getText()
+
+ Label {
+ text: '->'
+ }
+
+ function getText() {
+ switch (event.type) {
+ case 'm.room.member':
+ return getMemberChange();
+
+ default:
+ return event.content.body;
+ }
+ }
+
+ function getMemberChange() {
+ const newState = event.content.membership;
+ // If there were no previous content, we consider that the room
+ // never knew this member.
+ const prevContent = event.unsignedData.prev_content || {};
+ const oldState = prevContent.membership || 'leave';
+ // Someone changing their own member state
+ const isSelfSent = event.stateKey === event.sender;
+
+ const gender = 'neutral';
+
+ if (newState === 'join') {
+ if (oldState !== 'join') {
+ return l10n.get('member-state-joined-room');
+ } else {
+ const nameChanged = event.content.displayname !== prevContent.displayname;
+ const avatarChanged = event.content.avatar_url !== prevContent.avatar_url;
+ if (nameChanged && avatarChanged) {
+ return l10n.get('member-state-changed-name-and-avatar', { gender });
+ } else if (nameChanged) {
+ return l10n.get('member-state-changed-name', { gender });
+ } else if (avatarChanged) {
+ return l10n.get('member-state-changed-avatar', { gender });
+ } else {
+ return ''; // stayed in the room without name/avatar change. should not happen
+ }
+ }
+ }
+ }
+}
diff --git a/src/l10n/cmn-Hans/100-ui.ftl b/src/l10n/cmn-Hans/100-ui.ftl
index 38f770f..0d0b9c4 100644
--- a/src/l10n/cmn-Hans/100-ui.ftl
+++ b/src/l10n/cmn-Hans/100-ui.ftl
@@ -1,46 +1,51 @@
### Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
###
### This file is part of kazv.
###
### kazv is free software: you can redistribute it and/or modify
### it under the terms of the GNU Affero General Public License as
### published by the Free Software Foundation, either version 3 of the
### License, or (at your option) any later version.
###
### kazv is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
### GNU Affero General Public License for more details.
###
### You should have received a copy of the GNU Affero General Public License
### along with kazv. If not, see <https://www.gnu.org/licenses/>.
app-title = { -kt-app-name }
global-drawer-title = { -kt-app-name }
global-drawer-action-switch-account = 切换账号
global-drawer-action-hard-logout = 登出
empty-room-page-title = 没有选中房间
empty-room-page-description = 当前没有选中的房间。
login-page-title = 登录
login-page-userid-prompt = 用户 id:
login-page-userid-input-placeholder = 例如: @foo:example.org
login-page-password-prompt = 密码:
login-page-login-button = 登录
login-page-close-button = 关闭
login-page-existing-sessions-prompt = 从已有会话中选一个:
login-page-alternative-password-login-prompt = 或者用用户 id 和密码启动新会话:
login-page-restore-session-button = 恢复会话
main-page-title = { -kt-app-name } - { $userId }
main-page-recent-tab-title = 最近
main-page-people-tab-title = 人们
main-page-rooms-tab-title = 房间
room-list-view-room-item-title = { $name } ({ $roomId })
room-list-view-room-item-fav-action = 设为最爱
room-list-view-room-item-fav-action-notification = 把 { $name } 设为了最爱
send-message-box-input-placeholder = 在此输入您的讯息...
+
+member-state-joined-room = 加入了房间。
+member-state-changed-name-and-avatar = 修改了名字和头像。
+member-state-changed-name = 修改了名字。
+member-state-changed-avatar = 修改了头像。
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
index 6e5d1c7..cf9b4d9 100644
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -1,46 +1,63 @@
### Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
###
### This file is part of kazv.
###
### kazv is free software: you can redistribute it and/or modify
### it under the terms of the GNU Affero General Public License as
### published by the Free Software Foundation, either version 3 of the
### License, or (at your option) any later version.
###
### kazv is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
### GNU Affero General Public License for more details.
###
### You should have received a copy of the GNU Affero General Public License
### along with kazv. If not, see <https://www.gnu.org/licenses/>.
app-title = { -kt-app-name }
global-drawer-title = { -kt-app-name }
global-drawer-action-switch-account = Switch account
global-drawer-action-hard-logout = Logout
empty-room-page-title = No rooms selected
empty-room-page-description = There is no room selected now.
login-page-title = Log in
login-page-userid-prompt = User id:
login-page-userid-input-placeholder = E.g.: @foo:example.org
login-page-password-prompt = Password:
login-page-login-button = Log in
login-page-close-button = Close
login-page-existing-sessions-prompt = Choose from one of the existing sessions:
login-page-alternative-password-login-prompt = Or start a new session with user id and password:
login-page-restore-session-button = Restore session
main-page-title = { -kt-app-name } - { $userId }
main-page-recent-tab-title = Recent
main-page-people-tab-title = People
main-page-rooms-tab-title = Rooms
room-list-view-room-item-title = { $name } ({ $roomId })
room-list-view-room-item-fav-action = Set as favourite
room-list-view-room-item-fav-action-notification = Set { $name } as favourite
send-message-box-input-placeholder = Type your message here...
+
+member-state-joined-room = joined the room.
+member-state-changed-name-and-avatar = changed { $gender ->
+ [male] his
+ [female] her
+ *[neutral] their
+ } name and avatar.
+member-state-changed-name = changed { $gender ->
+ [male] his
+ [female] her
+ *[neutral] their
+ } name.
+member-state-changed-avatar = changed { $gender ->
+ [male] his
+ [female] her
+ *[neutral] their
+ } avatar.
diff --git a/src/matrix-event.cpp b/src/matrix-event.cpp
index 599e44d..d803aa3 100644
--- a/src/matrix-event.cpp
+++ b/src/matrix-event.cpp
@@ -1,41 +1,50 @@
/*
- * Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
+ * Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#include <libkazv-config.hpp>
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include "matrix-event.hpp"
#include "helper.hpp"
using namespace Kazv;
MatrixEvent::MatrixEvent(lager::reader<Event> event, QObject *parent)
: QObject(parent)
, m_event(event)
, LAGER_QT(eventId)(m_event.xform(zug::map([](Event e) { return e.id(); }) | strToQt))
, LAGER_QT(sender)(m_event.xform(zug::map([](Event e) { return e.sender(); }) | strToQt))
, LAGER_QT(type)(m_event.xform(zug::map([](Event e) { return e.type(); }) | strToQt))
, LAGER_QT(stateKey)(m_event.xform(zug::map([](Event e) { return e.stateKey(); }) | strToQt))
, LAGER_QT(content)(m_event.xform(zug::map([](Event e) { return e.content().get().get<QJsonObject>(); })))
, LAGER_QT(encrypted)(m_event.xform(zug::map([](Event e) { return e.encrypted(); })))
+ , LAGER_QT(isState)(m_event.map([](Event e) { return e.isState(); }))
+ , LAGER_QT(unsignedData)(m_event.map([](Event e) {
+ auto j = e.raw();
+ if (j.get().contains("unsigned")) {
+ return j.get()["unsigned"].template get<QJsonObject>();
+ } else {
+ return QJsonObject();
+ }
+ }))
{
}
MatrixEvent::~MatrixEvent() = default;
diff --git a/src/matrix-event.hpp b/src/matrix-event.hpp
index bf14bf1..8cb5c52 100644
--- a/src/matrix-event.hpp
+++ b/src/matrix-event.hpp
@@ -1,52 +1,54 @@
/*
- * Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
+ * Copyright (C) 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <libkazv-config.hpp>
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <QObject>
#include <QQmlEngine>
#include <lager/extra/qt.hpp>
#include <client/room/room.hpp>
#include "qt-json.hpp"
class MatrixEvent : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
lager::reader<Kazv::Event> m_event;
public:
explicit MatrixEvent(lager::reader<Kazv::Event> event, QObject *parent = 0);
~MatrixEvent() override;
LAGER_QT_READER(QString, eventId);
LAGER_QT_READER(QString, sender);
LAGER_QT_READER(QString, type);
LAGER_QT_READER(QString, stateKey);
LAGER_QT_READER(QJsonObject, content);
LAGER_QT_READER(bool, encrypted);
+ LAGER_QT_READER(bool, isState);
+ LAGER_QT_READER(QJsonObject, unsignedData);
};
diff --git a/src/resources.qrc b/src/resources.qrc
index 5116bb7..1b8eaa8 100644
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -1,26 +1,27 @@
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
<file alias="LoginPage.qml">contents/ui/LoginPage.qml</file>
<file alias="MainPage.qml">contents/ui/MainPage.qml</file>
<file alias="TabView.qml">contents/ui/TabView.qml</file>
<file alias="Tab.qml">contents/ui/Tab.qml</file>
<file alias="RoomListView.qml">contents/ui/RoomListView.qml</file>
<file alias="RoomPage.qml">contents/ui/RoomPage.qml</file>
<file alias="RoomTimelineView.qml">contents/ui/RoomTimelineView.qml</file>
<file alias="SendMessageBox.qml">contents/ui/SendMessageBox.qml</file>
<file alias="EventView.qml">contents/ui/EventView.qml</file>
<file alias="event-types/Simple.qml">contents/ui/event-types/Simple.qml</file>
<file alias="event-types/Text.qml">contents/ui/event-types/Text.qml</file>
<file alias="event-types/Emote.qml">contents/ui/event-types/Emote.qml</file>
<file alias="event-types/Notice.qml">contents/ui/event-types/Notice.qml</file>
+ <file alias="event-types/State.qml">contents/ui/event-types/State.qml</file>
<file alias="event-types/TextTemplate.qml">contents/ui/event-types/TextTemplate.qml</file>
<file alias="l10n.js">js/l10n.js</file>
<file alias="fluent-bundle.js">js/transformed-libs/fluent-bundle.js</file>
<file alias="fluent-sequence.js">js/transformed-libs/fluent-sequence.js</file>
<file alias="fluent-langneg.js">js/transformed-libs/fluent-langneg.js</file>
<file alias="bundled-deps.js">js/transformed-libs/bundled-deps.js</file>
<file alias="global-this.js">js/global-this.js</file>
</qresource>
</RCC>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 11:30 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55506
Default Alt Text
(17 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment