From a26e66be4bd42fabdc42ef88690012cc0ae26744 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Wed, 6 Dec 2023 15:59:41 +0100 Subject: [PATCH] kcms: Port away from SwipeListItem to ItemDelegate Let's port the remaining uses to the upstream simpler alternative `ItemDelegate`, which provides a consistent styling and fixes some issues such as the background and highlighting. This affects the rules, efects and virtual desktops KCMs. --- src/kcms/desktop/ui/main.qml | 42 ++++++++++-------- src/kcms/effects/ui/Effect.qml | 27 +++++++----- src/kcms/rules/ui/RuleItemDelegate.qml | 1 + src/kcms/rules/ui/main.qml | 59 +++++++++++++------------- 4 files changed, 71 insertions(+), 58 deletions(-) diff --git a/src/kcms/desktop/ui/main.qml b/src/kcms/desktop/ui/main.qml index 577a73a87f..ad26bfd6d6 100644 --- a/src/kcms/desktop/ui/main.qml +++ b/src/kcms/desktop/ui/main.qml @@ -31,8 +31,10 @@ KCM.ScrollViewKCM { Component { id: desktopsListItemComponent - Kirigami.SwipeListItem { - id: listItem + QQC2.ItemDelegate { + width: ListView.view.width + down: false // Disable press effect + hoverEnabled: false contentItem: RowLayout { QQC2.TextField { @@ -64,7 +66,7 @@ KCM.ScrollViewKCM { enabled: nameField.readOnly onDoubleClicked: { - renameAction.trigger(); + renameAction.clicked(); } } } @@ -78,40 +80,46 @@ KCM.ScrollViewKCM { opacity: model ? !model.IsDefault : 0.0 color: Kirigami.Theme.neutralTextColor } - } - actions: [ - Kirigami.Action { + DelegateButton { id: renameAction enabled: model && !model.IsMissing visible: !applyAction.visible icon.name: "edit-rename" - tooltip: i18nc("@info:tooltip", "Rename") - onTriggered: { + text: i18nc("@info:tooltip", "Rename") + onClicked: { nameField.readOnly = false; nameField.selectAll(); nameField.forceActiveFocus(); } - }, - Kirigami.Action { + } + + DelegateButton { id: applyAction visible: !nameField.readOnly icon.name: "dialog-ok-apply" - tooltip: i18nc("@info:tooltip", "Confirm new name") - onTriggered: { + text: i18nc("@info:tooltip", "Confirm new name") + onClicked: { nameField.readOnly = true; } - }, - Kirigami.Action { + } + + DelegateButton { enabled: model && !model.IsMissing && desktopsList.count !== 1 icon.name: "edit-delete" - tooltip: i18nc("@info:tooltip", "Remove") - onTriggered: kcm.desktopsModel.removeDesktop(model.Id) + text: i18nc("@info:tooltip", "Remove") + onClicked: kcm.desktopsModel.removeDesktop(model.Id) } - ] + } } } + component DelegateButton: QQC2.ToolButton { + display: QQC2.AbstractButton.IconOnly + QQC2.ToolTip.text: text + QQC2.ToolTip.visible: hovered + } + header: ColumnLayout { id: messagesLayout diff --git a/src/kcms/effects/ui/Effect.qml b/src/kcms/effects/ui/Effect.qml index c973afb941..e4a7daca7e 100644 --- a/src/kcms/effects/ui/Effect.qml +++ b/src/kcms/effects/ui/Effect.qml @@ -13,7 +13,7 @@ import QtQuick.Layouts import org.kde.kirigami 2 as Kirigami import org.kde.kcmutils as KCM -Kirigami.SwipeListItem { +QQC2.ItemDelegate { id: listItem hoverEnabled: true @@ -118,21 +118,26 @@ Kirigami.SwipeListItem { } } } - } - actions: [ - Kirigami.Action { + QQC2.ToolButton { visible: model.VideoRole.toString() !== "" icon.name: "videoclip-amarok" - tooltip: i18nc("@info:tooltip", "Show/Hide Video") - onTriggered: videoItem.showHide() - }, - Kirigami.Action { + text: i18nc("@info:tooltip", "Show/Hide Video") + display: QQC2.AbstractButton.IconOnly + QQC2.ToolTip.text: text + QQC2.ToolTip.visible: hovered + onClicked: videoItem.showHide() + } + + QQC2.ToolButton { visible: model.ConfigurableRole enabled: model.StatusRole != Qt.Unchecked icon.name: "configure" - tooltip: i18nc("@info:tooltip", "Configure…") - onTriggered: kcm.configure(model.ServiceNameRole, listItem) + text: i18nc("@info:tooltip", "Configure…") + display: QQC2.AbstractButton.IconOnly + QQC2.ToolTip.text: text + QQC2.ToolTip.visible: hovered + onClicked: kcm.configure(model.ServiceNameRole, listItem) } - ] + } } diff --git a/src/kcms/rules/ui/RuleItemDelegate.qml b/src/kcms/rules/ui/RuleItemDelegate.qml index 3873d71678..f33c6f215b 100644 --- a/src/kcms/rules/ui/RuleItemDelegate.qml +++ b/src/kcms/rules/ui/RuleItemDelegate.qml @@ -20,6 +20,7 @@ QQC2.ItemDelegate { width: ListView.view.width highlighted: false hoverEnabled: false + down: false contentItem: RowLayout { diff --git a/src/kcms/rules/ui/main.qml b/src/kcms/rules/ui/main.qml index 8a18ff3ab2..047a015d3a 100644 --- a/src/kcms/rules/ui/main.qml +++ b/src/kcms/rules/ui/main.qml @@ -140,9 +140,12 @@ KCM.ScrollViewKCM { } } - Kirigami.SwipeListItem { + QQC2.ItemDelegate { id: ruleBookItem + width: ruleBookView.width + down: false // Disable press effect + contentItem: RowLayout { Kirigami.ListItemDragHandle { visible: !exportInfo.visible @@ -188,6 +191,24 @@ KCM.ScrollViewKCM { } } + DelegateButton { + text: i18n("Edit") + icon.name: "edit-entry" + onClicked: kcm.editRule(index); + } + + DelegateButton { + text: i18n("Duplicate") + icon.name: "edit-duplicate" + onClicked: kcm.duplicateRule(index); + } + + DelegateButton { + text: i18n("Delete") + icon.name: "entry-delete" + onClicked: kcm.removeRule(index); + } + QQC2.CheckBox { id: itemSelectionCheck visible: exportInfo.visible @@ -203,38 +224,16 @@ KCM.ScrollViewKCM { } } } - - actions: [ - Kirigami.Action { - text: i18n("Edit") - icon.name: "edit-entry" - visible: !exportInfo.visible - onTriggered: { - kcm.editRule(index); - } - } - , - Kirigami.Action { - text: i18n("Duplicate") - icon.name: "edit-duplicate" - visible: !exportInfo.visible - onTriggered: { - kcm.duplicateRule(index); - } - } - , - Kirigami.Action { - text: i18n("Delete") - icon.name: "entry-delete" - visible: !exportInfo.visible - onTriggered: { - kcm.removeRule(index); - } - } - ] } } + component DelegateButton: QQC2.ToolButton { + visible: !exportInfo.visible + display: QQC2.AbstractButton.IconOnly + QQC2.ToolTip.text: text + QQC2.ToolTip.visible: hovered + } + FileDialogLoader { id: importDialog title: i18n("Import Rules")