Warning, /frameworks/kirigami/src/delegates/RadioSubtitleDelegate.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 RadioDelegate and IconTitleSubtitle
0014  *
0015  * This is an intentionally minimal wrapper that replaces the RadioDelegate's
0016  * contentItem with an IconTitleSubtitle and adds a subtitle property.
0017  *
0018  * If you wish to customize the layout further, create your own `RadioDelegate`
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 `RadioDelegate` directly.
0023  *
0024  * \sa Kirigami::Delegates::TitleSubtitle
0025  * \sa Kirigami::Delegates::IconTitleSubtitle
0026  */
0027 QQC2.RadioDelegate {
0028     id: delegate
0029 
0030     // Please see the developer note in ItemDelegate
0031 
0032     /**
0033      * The subtitle to display.
0034      */
0035     property string subtitle
0036 
0037     QQC2.ToolTip.text: text + (subtitle.length > 0 ? "\n\n" + subtitle : "")
0038     QQC2.ToolTip.visible: (Kirigami.Settings.tabletMode ? down : hovered) && (contentItem?.truncated ?? false)
0039     QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0040 
0041     contentItem: KD.IconTitleSubtitle {
0042         icon: icon.fromControlsIcon(delegate.icon)
0043         title: delegate.text
0044         subtitle: delegate.subtitle
0045         selected: delegate.highlighted || delegate.down
0046         font: delegate.font
0047     }
0048 }