Warning, /frameworks/kirigami/src/delegates/IconTitleSubtitle.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Marco Martin <notmart@gmail.com> 0003 * SPDX-FileCopyrightText: 2022 ivan tkachenko <me@ratijas.tk> 0004 * SPDX-FileCopyrightText: 2023 Arjen Hiemstra <ahiemstra@heimr.nl> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 import QtQuick 0010 import org.kde.kirigami as Kirigami 0011 import org.kde.kirigami.delegates as KD 0012 import org.kde.kirigami.templates.private as KTP 0013 0014 /** 0015 * A simple item containing an icon, title and subtitle. 0016 * 0017 * This is an extension of TitleSubtitle that adds an icon to the side. 0018 * It is intended as a contentItem for ItemDelegate and related controls. 0019 * 0020 * When using it as a contentItem, make sure to bind the appropriate properties 0021 * to those of the Control. Prefer binding to the Control's properties over 0022 * setting the properties directly, as the Control's properties may affect other 0023 * things like setting accessible names. 0024 * 0025 * This (and TitleSubtitle) can be combined with other controls in a layout to 0026 * create complex content items for controls. 0027 * 0028 * Example usage creating a CheckDelegate with an extra button on the side: 0029 * 0030 * ```qml 0031 * CheckDelegate { 0032 * id: delegate 0033 * 0034 * text: "Example" 0035 * icon.name: "document-new" 0036 * 0037 * contentItem: RowLayout { 0038 * spacing: Kirigami.Theme.smallSpacing 0039 * 0040 * Kirigami.IconTitleSubtitle { 0041 * Layout.fillWidth: true 0042 * 0043 * icon: icon.fromControlsIcon(delegate.icon) 0044 * title: delegate.text 0045 * selected: delegate.highlighted || delegate.down 0046 * font: delegate.font 0047 * } 0048 * 0049 * Button { 0050 * icon.name: "document-open" 0051 * text: "Extra Action" 0052 * } 0053 * } 0054 * } 0055 * ``` 0056 * 0057 * \sa Kirigami::Delegates::TitleSubtitle 0058 * \sa Kirigami::Delegates::ItemDelegate 0059 */ 0060 Item { 0061 id: root 0062 0063 /** 0064 * @copydoc Kirigami::TitleSubtitle::title 0065 */ 0066 required property string title 0067 /** 0068 * @copydoc Kirigami::TitleSubtitle::subtitle 0069 */ 0070 property alias subtitle: titleSubtitle.subtitle 0071 /** 0072 * @copydoc Kirigami::TitleSubtitle::color 0073 */ 0074 property alias color: titleSubtitle.color 0075 /** 0076 * @copydoc Kirigami::TitleSubtitle::subtitleColor 0077 */ 0078 property alias subtitleColor: titleSubtitle.subtitleColor 0079 /** 0080 * @copydoc Kirigami::TitleSubtitle::font 0081 */ 0082 property alias font: titleSubtitle.font 0083 /** 0084 * @copydoc Kirigami::TitleSubtitle::subtitleFont 0085 */ 0086 property alias subtitleFont: titleSubtitle.subtitleFont 0087 /** 0088 * @copydoc Kirigami::TitleSubtitle::reserveSpaceForSubtitle 0089 */ 0090 property alias reserveSpaceForSubtitle: titleSubtitle.reserveSpaceForSubtitle 0091 /** 0092 * @copydoc Kirigami::TitleSubtitle::selected 0093 */ 0094 property alias selected: titleSubtitle.selected 0095 /** 0096 * @copydoc Kirigami::TitleSubtitle::elide 0097 */ 0098 property alias elide: titleSubtitle.elide 0099 /** 0100 * @copydoc Kirigami::TitleSubtitle::wrapMode 0101 */ 0102 property alias wrapMode: titleSubtitle.wrapMode 0103 /** 0104 * @copydoc Kirigami::TitleSubtitle::truncated 0105 */ 0106 property alias truncated: titleSubtitle.truncated 0107 0108 /** 0109 * Grouped property for icon properties. 0110 * 0111 * \note By default, IconTitleSubtitle will reserve the space for the icon, 0112 * even if it is not set. To remove that space, set `icon.width` to 0. 0113 */ 0114 property KTP.IconPropertiesGroup icon: KTP.IconPropertiesGroup { 0115 width: titleSubtitle.subtitleVisible ? Kirigami.Units.iconSizes.medium : Kirigami.Units.iconSizes.smallMedium 0116 height: width 0117 } 0118 0119 implicitWidth: iconItem.implicitWidth + titleSubtitle.anchors.leftMargin + titleSubtitle.implicitWidth 0120 implicitHeight: Math.max(iconItem.implicitHeight, titleSubtitle.implicitHeight) 0121 0122 Kirigami.Icon { 0123 id: iconItem 0124 0125 anchors { 0126 left: parent.left 0127 top: parent.top 0128 bottom: parent.bottom 0129 } 0130 0131 source: root.icon.name.length > 0 ? root.icon.name : root.icon.source 0132 implicitWidth: root.icon.width 0133 implicitHeight: root.icon.height 0134 selected: root.selected 0135 color: root.icon.color 0136 } 0137 0138 KD.TitleSubtitle { 0139 id: titleSubtitle 0140 0141 anchors { 0142 left: iconItem.right 0143 leftMargin: root.icon.width > 0 ? Kirigami.Units.mediumSpacing : 0 0144 top: parent.top 0145 bottom: parent.bottom 0146 right: parent.right 0147 } 0148 0149 title: root.title 0150 } 0151 }