Page MenuHomePhorge

No OneTemporary

Size
15 KB
Referenced Files
None
Subscribers
None
diff --git a/src/contents/ui/EventView.qml b/src/contents/ui/EventView.qml
index ec95c24..249d373 100644
--- a/src/contents/ui/EventView.qml
+++ b/src/contents/ui/EventView.qml
@@ -1,173 +1,175 @@
/*
* 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 stateKeyUser
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
+ stateKeyUser: eventView.stateKeyUser
}
}
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/RoomTimelineView.qml b/src/contents/ui/RoomTimelineView.qml
index 4a503bc..2a68c03 100644
--- a/src/contents/ui/RoomTimelineView.qml
+++ b/src/contents/ui/RoomTimelineView.qml
@@ -1,73 +1,74 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* 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
ListView {
id: roomTimelineView
property var timeline
property var eventIds: timeline.eventIds
property string selectedEventId
spacing: Kirigami.Units.largeSpacing
width: parent.width
Layout.fillHeight: true
model: timeline.count
Layout.minimumHeight: childrenRect.height
currentIndex: -1
//currentIndex: eventIds.indexOf(selectedEventId)
//onModelChanged: currentIndex = Qt.binding(function() { return eventIds.indexOf(selectedEventId) })
delegate: EventView {
event: timeline.at(index)
sender: room.member(event.sender)
+ stateKeyUser: event.stateKey ? room.member(event.stateKey) : {}
}
/* Kirigami.BasicListItem { */
/* property var item: timeline.at(index) */
/* //onClicked: roomTimelineView.selectedEventId = item.eventId */
/* onClicked: {} */
/* checkable: false */
/* checked: false */
/* //onClicked: print("clicked room %1".arg(index)) */
/* //checkable: true */
/* //checked: roomTimelineView.selectedEventId == item.eventId */
/* //autoExclusive: true */
/* Label { */
/* text: i18n("Message from %1 of type %2: %3", item.sender, item.type, item.content) */
/* } */
/* /\* actions: [ */
/* Kirigami.Action { */
/* text: i18n("Set as favourite") */
/* iconName: "non-starred-symbolic" */
/* onTriggered: showPassiveNotification(i18n("Set %1 as favourite", item.name)) */
/* } */
/* ]*\/ */
/* } */
}
diff --git a/src/contents/ui/event-types/State.qml b/src/contents/ui/event-types/State.qml
index ddb0fee..92d1442 100644
--- a/src/contents/ui/event-types/State.qml
+++ b/src/contents/ui/event-types/State.qml
@@ -1,75 +1,104 @@
/*
* 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()
+ property var stateKeyUser
+
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';
+ const stateKeyUserGender = 'neutral';
if (newState === 'join') {
if (oldState !== 'join') {
- return l10n.get('member-state-joined-room');
+ return l10n.get('member-state-joined-room', { gender });
} 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
}
}
+ } else if (newState === 'invite') {
+ return l10n.get('member-state-invited', { gender,
+ stateKeyUser: stateKeyUser.displayname,
+ stateKeyUserGender
+ });
+ } else if (newState === 'left') {
+ if (oldState === 'ban') {
+ return l10n.get('member-state-unbanned', { gender,
+ stateKeyUser: stateKeyUser.displayname,
+ stateKeyUserGender
+ });
+ } else if (isSelfSent) {
+ return l10n.get('member-state-left', { gender });
+ } else {
+ return l10n.get('member-state-kicked', { gender,
+ stateKeyUser: stateKeyUser.displayname,
+ stateKeyUserGender
+ });
+ }
+ } else if (newState === 'ban') {
+ return l10n.get('member-state-banned', { gender,
+ stateKeyUser: stateKeyUser.displayname,
+ stateKeyUserGender
+ });
}
+
+ return ''; // not implemented
}
}
diff --git a/src/l10n/cmn-Hans/100-ui.ftl b/src/l10n/cmn-Hans/100-ui.ftl
index 0d0b9c4..1edd4f6 100644
--- a/src/l10n/cmn-Hans/100-ui.ftl
+++ b/src/l10n/cmn-Hans/100-ui.ftl
@@ -1,51 +1,56 @@
### 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 = 修改了头像。
+member-state-invited = 把 { $stateKeyUser } 邀请到了本房间。
+member-state-left = 离开了房间。
+member-state-kicked = 踢出了 { $stateKeyUser }。
+member-state-banned = 封禁了 { $stateKeyUser }。
+member-state-unbanned = 解封了 { $stateKeyUser }。
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
index cf9b4d9..c4c0052 100644
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -1,63 +1,68 @@
### 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.
+member-state-invited = invited { $stateKeyUser } to the room.
+member-state-left = left the room.
+member-state-kicked = kicked { $stateKeyUser }.
+member-state-banned = banned { $stateKeyUser }.
+member-state-unbanned = unbanned { $stateKeyUser }.

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 12:42 PM (8 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55170
Default Alt Text
(15 KB)

Event Timeline