mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Render community items
This commit is contained in:
parent
2cd1a931c2
commit
d8c0d4874b
9 changed files with 180 additions and 14 deletions
|
@ -14,6 +14,7 @@ Rectangle {
|
|||
property alias url: img.source
|
||||
property string userid
|
||||
property string displayName
|
||||
property alias textColor: label.color
|
||||
|
||||
signal clicked(var mouse)
|
||||
|
||||
|
@ -26,6 +27,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
Label {
|
||||
id: label
|
||||
anchors.fill: parent
|
||||
text: TimelineManager.escapeEmoji(displayName ? String.fromCodePoint(displayName.codePointAt(0)) : "")
|
||||
textFormat: Text.RichText
|
||||
|
|
|
@ -23,13 +23,14 @@ Rectangle {
|
|||
AdaptiveLayoutElement {
|
||||
id: communityListC
|
||||
|
||||
minimumWidth: Nheko.avatarSize * 2 + Nheko.paddingSmall * 2
|
||||
collapsedWidth: Nheko.avatarSize + Nheko.paddingSmall * 2
|
||||
preferredWidth: Nheko.avatarSize + Nheko.paddingSmall * 2
|
||||
maximumWidth: Nheko.avatarSize * 7 + Nheko.paddingSmall * 2
|
||||
minimumWidth: communitiesList.avatarSize * 4 + Nheko.paddingMedium * 2
|
||||
collapsedWidth: communitiesList.avatarSize + 2* Nheko.paddingMedium
|
||||
preferredWidth: collapsedWidth
|
||||
maximumWidth: communitiesList.avatarSize * 10 + 2* Nheko.paddingMedium
|
||||
|
||||
Rectangle {
|
||||
color: Nheko.theme.sidebarBackground
|
||||
CommunitiesList {
|
||||
id: communitiesList
|
||||
collapsed: parent.collapsed
|
||||
}
|
||||
|
||||
}
|
||||
|
|
151
resources/qml/CommunitiesList.qml
Normal file
151
resources/qml/CommunitiesList.qml
Normal file
|
@ -0,0 +1,151 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import "./dialogs"
|
||||
import Qt.labs.platform 1.1 as Platform
|
||||
import QtQml 2.13
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.3
|
||||
import im.nheko 1.0
|
||||
|
||||
|
||||
Page {
|
||||
//leftPadding: Nheko.paddingSmall
|
||||
//rightPadding: Nheko.paddingSmall
|
||||
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 1.6)
|
||||
property bool collapsed: false
|
||||
|
||||
ListView {
|
||||
id: communitiesList
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: parent.height
|
||||
model: Communities
|
||||
|
||||
ScrollHelper {
|
||||
flickable: parent
|
||||
anchors.fill: parent
|
||||
enabled: !Settings.mobileMode
|
||||
}
|
||||
|
||||
Platform.Menu {
|
||||
id: communityContextMenu
|
||||
|
||||
property string id
|
||||
|
||||
function show(id_, tags_) {
|
||||
id = id_;
|
||||
open();
|
||||
}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: qsTr("Leave room")
|
||||
onTriggered: Rooms.leave(roomContextMenu.roomid)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
id: communityItem
|
||||
|
||||
property color background: Nheko.colors.window
|
||||
property color importantText: Nheko.colors.text
|
||||
property color unimportantText: Nheko.colors.buttonText
|
||||
property color bubbleBackground: Nheko.colors.highlight
|
||||
property color bubbleText: Nheko.colors.highlightedText
|
||||
|
||||
color: background
|
||||
height: avatarSize + 2 * Nheko.paddingMedium
|
||||
width: ListView.view.width
|
||||
state: "normal"
|
||||
ToolTip.visible: hovered.hovered && collapsed
|
||||
ToolTip.text: model.tooltip
|
||||
states: [
|
||||
State {
|
||||
name: "highlight"
|
||||
when: hovered.hovered && !(Communities.currentTagId == model.id)
|
||||
|
||||
PropertyChanges {
|
||||
target: communityItem
|
||||
background: Nheko.colors.dark
|
||||
importantText: Nheko.colors.brightText
|
||||
unimportantText: Nheko.colors.brightText
|
||||
bubbleBackground: Nheko.colors.highlight
|
||||
bubbleText: Nheko.colors.highlightedText
|
||||
}
|
||||
|
||||
},
|
||||
State {
|
||||
name: "selected"
|
||||
when: Communities.currentTagId == model.id
|
||||
|
||||
PropertyChanges {
|
||||
target: communityItem
|
||||
background: Nheko.colors.highlight
|
||||
importantText: Nheko.colors.highlightedText
|
||||
unimportantText: Nheko.colors.highlightedText
|
||||
bubbleBackground: Nheko.colors.highlightedText
|
||||
bubbleText: Nheko.colors.highlight
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
TapHandler {
|
||||
margin: -Nheko.paddingSmall
|
||||
acceptedButtons: Qt.RightButton
|
||||
onSingleTapped: communityContextMenu.show(model.id);
|
||||
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
margin: -Nheko.paddingSmall
|
||||
onSingleTapped: Communities.setCurrentTagId(model.id)
|
||||
onLongPressed: communityContextMenu.show(model.id)
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: hovered
|
||||
|
||||
margin: -Nheko.paddingSmall
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: Nheko.paddingMedium
|
||||
anchors.fill: parent
|
||||
anchors.margins: Nheko.paddingMedium
|
||||
|
||||
Avatar {
|
||||
id: avatar
|
||||
|
||||
enabled: false
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
height: avatarSize
|
||||
width: avatarSize
|
||||
url: {
|
||||
if (model.avatarUrl.startsWith("mxc://")) {
|
||||
return model.avatarUrl.replace("mxc://", "image://MxcImage/")
|
||||
} else {
|
||||
return "image://colorimage/"+model.avatarUrl+"?" + communityItem.unimportantText
|
||||
}
|
||||
}
|
||||
displayName: model.displayName
|
||||
color: communityItem.background
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Nheko.theme.sidebarBackground
|
||||
}
|
||||
|
||||
}
|
|
@ -32,8 +32,8 @@ Page {
|
|||
|
||||
Connections {
|
||||
onActiveTimelineChanged: {
|
||||
roomlist.positionViewAtIndex(Rooms.roomidToIndex(TimelineManager.timeline.roomId()), ListView.Contain);
|
||||
console.log("Test" + TimelineManager.timeline.roomId() + " " + Rooms.roomidToIndex(TimelineManager.timeline.roomId));
|
||||
roomlist.positionViewAtIndex(Rooms.roomidToIndex(Rooms.currentRoom.roomId()), ListView.Contain);
|
||||
console.log("Test" + Rooms.currentRoom.roomId() + " " + Rooms.roomidToIndex(Rooms.currentRoom.roomId()));
|
||||
}
|
||||
target: TimelineManager
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ Page {
|
|||
states: [
|
||||
State {
|
||||
name: "highlight"
|
||||
when: hovered.hovered && !(TimelineManager.timeline && model.roomId == TimelineManager.timeline.roomId())
|
||||
when: hovered.hovered && !(Rooms.currentRoom && model.roomId == Rooms.currentRoom.roomId())
|
||||
|
||||
PropertyChanges {
|
||||
target: roomItem
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import QtQuick 2.3
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.10
|
||||
import im.nheko 1.0
|
||||
|
||||
Pane {
|
||||
property string title: qsTr("Successful Verification")
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
|
||||
<file>qml/Root.qml</file>
|
||||
<file>qml/ChatPage.qml</file>
|
||||
<file>qml/CommunitiesList.qml</file>
|
||||
<file>qml/RoomList.qml</file>
|
||||
<file>qml/TimelineView.qml</file>
|
||||
<file>qml/Avatar.qml</file>
|
||||
|
|
|
@ -3451,6 +3451,10 @@ Cache::updateUserKeys(const std::string &sync_token, const mtx::responses::Query
|
|||
|
||||
if (!updateToWrite.master_keys.keys.empty() &&
|
||||
update.master_keys.keys != updateToWrite.master_keys.keys) {
|
||||
nhlog::db()->debug("Master key of {} changed:\nold: {}\nnew: {}",
|
||||
user,
|
||||
updateToWrite.master_keys.keys.size(),
|
||||
update.master_keys.keys.size());
|
||||
updateToWrite.master_key_changed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,8 +206,11 @@ handle_olm_message(const OlmMessage &msg)
|
|||
|
||||
for (const auto &cipher : msg.ciphertext) {
|
||||
// We skip messages not meant for the current device.
|
||||
if (cipher.first != my_key)
|
||||
if (cipher.first != my_key) {
|
||||
nhlog::crypto()->debug(
|
||||
"Skipping message for {} since we are {}.", cipher.first, my_key);
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto type = cipher.second.type;
|
||||
nhlog::crypto()->info("type: {}", type == 0 ? "OLM_PRE_KEY" : "OLM_MESSAGE");
|
||||
|
@ -661,8 +664,10 @@ try_olm_decryption(const std::string &sender_key, const mtx::events::msg::OlmCip
|
|||
for (const auto &id : session_ids) {
|
||||
auto session = cache::getOlmSession(sender_key, id);
|
||||
|
||||
if (!session)
|
||||
if (!session) {
|
||||
nhlog::crypto()->warn("Unknown olm session: {}:{}", sender_key, id);
|
||||
continue;
|
||||
}
|
||||
|
||||
mtx::crypto::BinaryBuf text;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ CommunitiesModel::roleNames() const
|
|||
{DisplayName, "displayName"},
|
||||
{Tooltip, "tooltip"},
|
||||
{ChildrenHidden, "childrenHidden"},
|
||||
{Id, "id"},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -74,9 +75,9 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
|
|||
case CommunitiesModel::Roles::AvatarUrl:
|
||||
return QString(":/icons/icons/ui/tag.png");
|
||||
case CommunitiesModel::Roles::DisplayName:
|
||||
return tag.right(2);
|
||||
return tag.mid(2);
|
||||
case CommunitiesModel::Roles::Tooltip:
|
||||
return tag.right(2);
|
||||
return tag.mid(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +144,7 @@ void
|
|||
CommunitiesModel::setCurrentTagId(QString tagId)
|
||||
{
|
||||
if (tagId.startsWith("tag:")) {
|
||||
auto tag = tagId.remove(0, 4);
|
||||
auto tag = tagId.mid(4);
|
||||
for (const auto &t : tags_) {
|
||||
if (t == tag) {
|
||||
this->currentTagId_ = tagId;
|
||||
|
|
Loading…
Reference in a new issue