Port away from BasicListItem
This commit is contained in:
committed by
Tobias Fella
parent
091c8806db
commit
443661d113
@@ -16,6 +16,7 @@ Delegates.RoundedItemDelegate {
|
||||
required property url source
|
||||
|
||||
signal contextMenuRequested()
|
||||
signal selected()
|
||||
|
||||
padding: Kirigami.Units.largeSpacing
|
||||
|
||||
@@ -23,14 +24,21 @@ Delegates.RoundedItemDelegate {
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
|
||||
Accessible.onPressAction: selected();
|
||||
Keys.onSpacePressed: selected();
|
||||
Keys.onEnterPressed: selected();
|
||||
|
||||
onPressAndHold: root.contextMenuRequested()
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
acceptedDevices: PointerDevice.Mouse
|
||||
grabPermissions: PointerHandler.TakeOverForbidden
|
||||
gesturePolicy: TapHandler.WithinBounds
|
||||
onTapped: root.contextMenuRequested()
|
||||
acceptedButtons: Qt.RightButton | Qt.LeftButton
|
||||
onTapped: (eventPoint, button) => {
|
||||
if (button === Qt.RightButton) {
|
||||
root.contextMenuRequested();
|
||||
} else {
|
||||
root.selected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: KirigamiComponents.Avatar {
|
||||
|
||||
@@ -7,6 +7,7 @@ import QtQuick.Layouts
|
||||
import QtQml
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.delegates as Delegates
|
||||
import org.kde.neochat
|
||||
|
||||
Kirigami.Page {
|
||||
@@ -48,14 +49,16 @@ Kirigami.Page {
|
||||
icon: "security-medium-symbolic"
|
||||
text: i18n("Waiting for other party to verify.")
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
Delegates.RoundedItemDelegate {
|
||||
id: emojiVerification
|
||||
text: "Emoji Verification"
|
||||
text: i18n("Emoji Verification")
|
||||
visible: root.session.state === KeyVerificationSession.READY
|
||||
subtitle: i18n("Compare a set of emoji on both devices")
|
||||
onClicked: {
|
||||
root.session.sendStartSas()
|
||||
contentItem: Delegates.SubtitleContentItem {
|
||||
subtitle: i18n("Compare a set of emoji on both devices")
|
||||
itemDelegate: emojiVerification
|
||||
}
|
||||
onClicked: root.session.sendStartSas()
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
Message {
|
||||
visible: root.session.state === KeyVerificationSession.DONE
|
||||
|
||||
@@ -6,7 +6,8 @@ import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
@@ -20,8 +21,8 @@ Kirigami.Dialog {
|
||||
|
||||
parent: applicationWindow().overlay
|
||||
|
||||
leftPadding: Kirigami.Units.smallSpacing
|
||||
rightPadding: Kirigami.Units.smallSpacing
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
@@ -74,7 +75,7 @@ Kirigami.Dialog {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Kirigami.BasicListItem {
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser
|
||||
action: Kirigami.Action {
|
||||
text: room.connection.isIgnored(root.user.object) ? i18n("Unignore this user") : i18n("Ignore this user")
|
||||
@@ -85,7 +86,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser && room.canSendState("kick") && room.containsUser(root.user.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
@@ -97,7 +99,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser && room.canSendState("invite") && !room.containsUser(root.user.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
@@ -110,7 +113,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser && room.canSendState("ban") && !room.isUserBanned(root.user.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
@@ -126,7 +130,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser && room.canSendState("ban") && room.isUserBanned(root.user.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
@@ -139,7 +144,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: room.canSendState("m.room.power_levels")
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Set user power level")
|
||||
@@ -162,7 +168,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.user.isLocalUser || room.canSendState("redact")
|
||||
|
||||
action: Kirigami.Action {
|
||||
@@ -178,7 +185,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Open a private chat")
|
||||
@@ -189,7 +197,8 @@ Kirigami.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Copy link")
|
||||
icon.name: "username-copy"
|
||||
|
||||
@@ -6,7 +6,8 @@ import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
@@ -270,9 +271,9 @@ Loader {
|
||||
id: listViewAction
|
||||
model: actionLayout.actions
|
||||
|
||||
Kirigami.BasicListItem {
|
||||
icon: modelData.icon.name
|
||||
iconColor: modelData.icon.color ?? undefined
|
||||
FormCard.FormButtonDelegate {
|
||||
icon.name: modelData.icon.name
|
||||
icon.color: modelData.icon.color ?? undefined
|
||||
enabled: modelData.enabled
|
||||
visible: modelData.visible
|
||||
text: modelData.text
|
||||
@@ -280,7 +281,6 @@ Loader {
|
||||
modelData.triggered()
|
||||
root.item.close();
|
||||
}
|
||||
implicitHeight: visible ? Kirigami.Units.gridUnit * 3 : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,9 +353,9 @@ Loader {
|
||||
id: listViewAction
|
||||
model: root.actions
|
||||
|
||||
Kirigami.BasicListItem {
|
||||
icon: modelData.icon.name
|
||||
iconColor: modelData.icon.color ?? undefined
|
||||
FormCard.FormButtonDelegate {
|
||||
icon.name: modelData.icon.name
|
||||
icon.color: modelData.icon.color ?? undefined
|
||||
enabled: modelData.enabled
|
||||
visible: modelData.visible
|
||||
text: modelData.text
|
||||
@@ -363,17 +363,15 @@ Loader {
|
||||
modelData.triggered()
|
||||
root.item.close();
|
||||
}
|
||||
implicitHeight: visible ? Kirigami.Units.gridUnit * 3 : 0
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: root.nestedActions
|
||||
|
||||
Kirigami.BasicListItem {
|
||||
FormCard.FormButtonDelegate {
|
||||
action: modelData
|
||||
visible: modelData.visible
|
||||
implicitHeight: visible ? Kirigami.Units.gridUnit * 3 : 0
|
||||
onClicked: {
|
||||
stackView.push(nestedActionsComponent, {
|
||||
title: modelData.text,
|
||||
|
||||
@@ -52,13 +52,17 @@ Delegates.RoundedItemDelegate {
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
Components.Avatar {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
source: root.avatarUrl
|
||||
name: root.displayName
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
RowLayout {
|
||||
|
||||
@@ -8,7 +8,7 @@ import QtQuick.Layouts
|
||||
import Qt.labs.qmlmodels
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.delegates as Delegates
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
@@ -92,34 +92,53 @@ Kirigami.ScrollablePage {
|
||||
id: serverListModel
|
||||
}
|
||||
|
||||
delegate: Kirigami.BasicListItem {
|
||||
delegate: Delegates.RoundedItemDelegate {
|
||||
id: serverItem
|
||||
|
||||
label: isAddServerDelegate ? i18n("Add New Server") : url
|
||||
subtitle: isHomeServer ? i18n("Home Server") : ""
|
||||
required property int index
|
||||
required property string url
|
||||
required property bool isAddServerDelegate
|
||||
required property bool isHomeServer
|
||||
required property bool isDeletable
|
||||
|
||||
text: isAddServerDelegate ? i18n("Add New Server") : url
|
||||
highlighted: false
|
||||
|
||||
topInset: index === 0 ? Kirigami.Units.smallSpacing : Math.round(Kirigami.Units.smallSpacing / 2)
|
||||
bottomInset: index === ListView.view.count - 1 ? Kirigami.Units.smallSpacing : Math.round(Kirigami.Units.smallSpacing / 2)
|
||||
|
||||
onClicked: if (isAddServerDelegate) {
|
||||
addServerSheet.open()
|
||||
}
|
||||
|
||||
trailing: QQC2.ToolButton {
|
||||
visible: isAddServerDelegate || isDeletable
|
||||
icon.name: isAddServerDelegate ? "list-add" : "dialog-close"
|
||||
text: i18n("Add new server")
|
||||
Accessible.name: text
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
contentItem: RowLayout {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
onClicked: {
|
||||
if (serverField.currentIndex === index && isDeletable) {
|
||||
serverField.currentIndex = 0
|
||||
server = serverField.currentValue
|
||||
serverField.popup.close()
|
||||
}
|
||||
if (isAddServerDelegate) {
|
||||
addServerSheet.open()
|
||||
serverItem.clicked()
|
||||
} else {
|
||||
serverListModel.removeServerAtIndex(index)
|
||||
Delegates.SubtitleContentItem {
|
||||
itemDelegate: serverItem
|
||||
subtitle: serverItem.isHomeServer ? i18n("Home Server") : ""
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
QQC2.ToolButton {
|
||||
visible: serverItem.isAddServerDelegate || serverItem.isDeletable
|
||||
icon.name: serverItem.isAddServerDelegate ? "list-add" : "dialog-close"
|
||||
text: i18nc("@action:button", "Add new server")
|
||||
Accessible.name: text
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
|
||||
onClicked: {
|
||||
if (serverField.currentIndex === serverItem.index && serverItem.isDeletable) {
|
||||
serverField.currentIndex = 0;
|
||||
server = serverField.currentValue;
|
||||
serverField.popup.close();
|
||||
}
|
||||
if (serverItem.isAddServerDelegate) {
|
||||
addServerSheet.open();
|
||||
serverItem.clicked();
|
||||
} else {
|
||||
serverListModel.removeServerAtIndex(serverItem.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,8 +229,10 @@ Kirigami.ScrollablePage {
|
||||
|
||||
ListView {
|
||||
id: publicRoomsListView
|
||||
topMargin: Kirigami.Units.smallSpacing
|
||||
clip: true
|
||||
|
||||
topMargin: Math.round(Kirigami.Units.smallSpacing / 2)
|
||||
bottomMargin: Math.round(Kirigami.Units.smallSpacing / 2)
|
||||
|
||||
model: PublicRoomListModel {
|
||||
id: publicRoomListModel
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ QQC2.Control {
|
||||
text: displayName
|
||||
source: avatar ? ("image://mxc/" + avatar) : ""
|
||||
|
||||
onClicked: root.selectedSpaceId = roomId
|
||||
onSelected: root.selectedSpaceId = roomId
|
||||
checked: root.selectedSpaceId === roomId
|
||||
onContextMenuRequested: root.createContextMenu(currentRoom)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.components as KirigamiComponents
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
@@ -79,13 +80,16 @@ Loader {
|
||||
|
||||
ColumnLayout {
|
||||
id: popupContent
|
||||
|
||||
width: parent.width
|
||||
spacing: 0
|
||||
|
||||
RowLayout {
|
||||
id: headerLayout
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: Kirigami.Units.largeSpacing
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
KirigamiComponents.Avatar {
|
||||
id: avatar
|
||||
source: room.avatarMediaId ? ("image://mxc/" + room.avatarMediaId) : ""
|
||||
@@ -93,22 +97,40 @@ Loader {
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
|
||||
Layout.alignment: Qt.AlignTop
|
||||
}
|
||||
|
||||
Kirigami.Heading {
|
||||
level: 5
|
||||
Layout.fillWidth: true
|
||||
text: room.displayName
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.ToolButton {
|
||||
icon.name: 'settings-configure'
|
||||
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Space Settings") })
|
||||
FormCard.FormButtonDelegate {
|
||||
text: i18nc("'Space' is a matrix space", "View Space")
|
||||
icon.name: "view-list-details"
|
||||
onClicked: RoomManager.enterRoom(room);
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
text: i18nc("@action:inmenu", "Copy Address to Clipboard")
|
||||
icon.name: "edit-copy"
|
||||
onClicked: if (room.canonicalAlias.length === 0) {
|
||||
Clipboard.saveText(room.id);
|
||||
} else {
|
||||
Clipboard.saveText(room.canonicalAlias);
|
||||
}
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
text: i18nc("'Space' is a matrix space", "Space Settings")
|
||||
icon.name: 'settings-configure'
|
||||
onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: connection}, { title: i18n("Space Settings") })
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
text: i18nc("'Space' is a matrix space", "Leave Space")
|
||||
onClicked: RoomManager.leaveRoom(room)
|
||||
implicitHeight: visible ? Kirigami.Units.gridUnit * 3 : 0
|
||||
}
|
||||
}
|
||||
onClosed: root.closed()
|
||||
|
||||
@@ -8,6 +8,7 @@ import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.sonnet as Sonnet
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kirigamiaddons.delegates as Delegates
|
||||
|
||||
Kirigami.ScrollablePage {
|
||||
id: root
|
||||
@@ -170,19 +171,39 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
topMargin: Math.round(Kirigami.Units.smallSpacing / 2)
|
||||
bottomMargin: Math.round(Kirigami.Units.smallSpacing / 2)
|
||||
|
||||
model: settings.currentIgnoreList
|
||||
delegate: Kirigami.BasicListItem {
|
||||
label: model.modelData
|
||||
trailing: QQC2.ToolButton {
|
||||
icon.name: "delete"
|
||||
onClicked: {
|
||||
remove(modelData)
|
||||
if (instantApply) {
|
||||
settings.save();
|
||||
}
|
||||
delegate: Delegates.RoundedItemDelegate {
|
||||
id: wordDelegate
|
||||
|
||||
required property var modelData
|
||||
|
||||
text: modelData
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
Delegates.DefaultContentItem {
|
||||
itemDelegate: wordDelegate
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
QQC2.ToolTip {
|
||||
text: i18n("Delete word")
|
||||
|
||||
QQC2.ToolButton {
|
||||
text: i18nc("@action:button", "Delete word")
|
||||
icon.name: "delete"
|
||||
display: QQC2.ToolButton.IconOnly
|
||||
onClicked: {
|
||||
remove(wordDelegate.modelData);
|
||||
if (instantApply) {
|
||||
settings.save();
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.visible: hovered
|
||||
QQC2.ToolTip.delay: Kirigami.ToolTip.toolTipDelay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user