Warning, /frameworks/kirigami/src/delegates/SubtitleDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2023 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls as QQC2
0009 import org.kde.kirigami as Kirigami
0010 import org.kde.kirigami.delegates as KD
0011 
0012 /**
0013  * A convenience wrapper combining QtQuick Controls ItemDelegate and IconTitleSubtitle
0014  *
0015  * This is an intentionally minimal wrapper that replaces the ItemDelegate's
0016  * contentItem with an IconTitleSubtitle and adds a subtitle property.
0017  *
0018  * If you wish to customize the layout further, create your own `ItemDelegate`
0019  * subclass with the `contentItem:` property set to the content of your choice.
0020  * This can include `IconTitleSubtitle` inside a Layout, for example.
0021  *
0022  * \note If you don't need a subtitle, use `ItemDelegate` directly.
0023  *
0024  * \sa Kirigami::Delegates::TitleSubtitle
0025  * \sa Kirigami::Delegates::IconTitleSubtitle
0026  */
0027 QQC2.ItemDelegate {
0028     id: delegate
0029 
0030     // Developer note: This is intentional kept incredibly minimal as we want to
0031     // reuse as much of upstream ItemDelegate as possible, the only extra thing
0032     // being the subtitle property. Should that ever become an upstream feature,
0033     // these controls will be removed in favour of using upstream's implementation
0034     // directly.
0035 
0036     /**
0037      * The subtitle to display.
0038      */
0039     property string subtitle
0040 
0041     QQC2.ToolTip.text: text + (subtitle.length > 0 ? "\n\n" + subtitle : "")
0042     QQC2.ToolTip.visible: (Kirigami.Settings.tabletMode ? down : hovered) && (contentItem?.truncated ?? false)
0043     QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0044 
0045     contentItem: KD.IconTitleSubtitle {
0046         icon: icon.fromControlsIcon(delegate.icon)
0047         title: delegate.text
0048         subtitle: delegate.subtitle
0049         selected: delegate.highlighted || delegate.down
0050         font: delegate.font
0051     }
0052 }