Kirigami-addons

android/FormIconDelegate.qml
1// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
3
4import QtQuick
5import QtQuick.Controls as Controls
6import QtQuick.Layouts
7
8import org.kde.kirigamiaddons.formcard as FormCard
9import org.kde.kirigami as Kirigami
10
11/**
12 \brief A FormCard delegate for icons.
13
14 Allow users to select icons. By default "Icon" is the default label
15 but this can be overwritten with the `text` property.
16
17 \code{qml}
18 FormCard.FormCard {
19 FormCard.FormIconDelegate {}
20
21 FormCard.FormDelegateSeparator {}
22
23 FormCard.FormIconDelegate {
24 text: i18nc("@label", "Active icon")
25 iconName: "actor-symbolic"
26 }
27 }
28 \endcode
29 \image html formcardicon.png
30
31 \note This element is readonly on Android.
33 \since 1.8.0
34 */
35FormCard.AbstractFormDelegate {
36 id: root
38 /**
39 * This property holds the name of the selected icon.
40 */
41 property alias iconName: buttonIcon.source
42
43 text: i18nc("@action:button", "Icon")
44 icon.name: "preferences-desktop-emoticons-symbolic"
45 onClicked: iconDialog.open()
46
47 background: null
48 contentItem: RowLayout {
49 spacing: 0
50
51 Kirigami.Icon {
52 source: root.icon.name
53 Layout.rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
54 implicitWidth: Kirigami.Units.iconSizes.small
55 implicitHeight: Kirigami.Units.iconSizes.small
56 }
57
58 Controls.Label {
59 Layout.fillWidth: true
60 text: iconButton.text
61 elide: Text.ElideRight
62 wrapMode: Text.Wrap
63 maximumLineCount: 2
64 Accessible.ignored: true // base class sets this text on root already
65 }
66
67 Kirigami.Icon {
68 id: buttonIcon
69
70 source: "addressbook-details-symbolic"
71 Layout.preferredWidth: Kirigami.Units.iconSizes.small
72 Layout.preferredHeight: Kirigami.Units.iconSizes.small
73 Layout.rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
74 }
75 }
76}
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:56:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.