Port runcommand config to ItemDelegate

This commit is contained in:
Nicolas Fella 2024-06-06 02:30:05 +02:00
parent 6366ceb530
commit 811101352f

View file

@ -3,8 +3,10 @@
* *
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
pragma ComponentBehavior: Bound
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts
import QtQuick.Controls 2.15 as QQC2 import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
@ -30,18 +32,33 @@ Kirigami.ScrollablePage {
deviceId: device deviceId: device
} }
delegate: Kirigami.SwipeListItem { delegate: QQC2.ItemDelegate {
width: parent.width id: commandDelegate
enabled: true
contentItem: QQC2.Label { required property string name
text: i18n("%1 <br> <i>%2</i>", name, command) required property string command
} required property int index
actions: Kirigami.Action { text: name
text: i18n("Delete") width: ListView.view.width
icon.name: "delete"
onTriggered: commandModel.removeCommand(index) contentItem: RowLayout {
Kirigami.TitleSubtitle {
title: commandDelegate.text
subtitle: commandDelegate.command
Layout.fillWidth: true
}
QQC2.ToolButton {
text: i18n("Delete")
icon.name: "delete"
onClicked: commandModel.removeCommand(commandDelegate.index)
display: QQC2.ToolButton.IconOnly
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered || activeFocus
}
} }
} }