Refactor room list in multiple sub components

Also modernize the codebase where possible (e.g use required properties,
reorder properties, fix warnings, don't use Action when not needed)

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan
2023-03-31 16:36:15 +02:00
parent a67f3334ea
commit 3ccff4f337
14 changed files with 624 additions and 515 deletions

View File

@@ -0,0 +1,47 @@
// SPDX-FileCopyrightText: 2022 Snehit Sah <snehitsah@protonmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami
import org.kde.neochat 1.0
QQC2.ItemDelegate {
id: root
required property string avatar
required property var currentRoom
required property int index
required property string id
signal createContextMenu(currentRoom: var)
signal spaceSelected(spaceId: string)
height: ListView.view.height
width: height
leftPadding: topPadding
rightPadding: topPadding
contentItem: Kirigami.Avatar {
name: currentRoom.displayName
source: avatar !== "" ? "image://mxc/" + avatar : ""
}
onClicked: root.spaceSelected(id)
onPressAndHold: root.createContextMenu(root.currentRoom)
Accessible.name: currentRoom.displayName
QQC2.ToolTip.text: currentRoom.displayName
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
TapHandler {
acceptedButtons: Qt.RightButton
acceptedDevices: PointerDevice.Mouse
onTapped: root.createContextMenu(root.currentRoom)
}
}