Kirigami2

RadioSubtitleDelegate.qml
1/*
2 * SPDX-FileCopyrightText: 2023 Arjen Hiemstra <ahiemstra@heimr.nl>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7import QtQuick
8import QtQuick.Controls as QQC2
9
10import org.kde.kirigami.platform as Platform
11
12/**
13 * A convenience wrapper combining QtQuick Controls RadioDelegate and IconTitleSubtitle
14 *
15 * This is an intentionally minimal wrapper that replaces the RadioDelegate's
16 * contentItem with an IconTitleSubtitle and adds a subtitle property.
17 *
18 * If you wish to customize the layout further, create your own `RadioDelegate`
19 * subclass with the `contentItem:` property set to the content of your choice.
20 * This can include `IconTitleSubtitle` inside a Layout, for example.
21 *
22 * \note If you don't need a subtitle, use `RadioDelegate` directly.
23 *
24 * \sa Kirigami::Delegates::TitleSubtitle
25 * \sa Kirigami::Delegates::IconTitleSubtitle
26 */
27QQC2.RadioDelegate {
28 id: delegate
29
30 // Please see the developer note in ItemDelegate
31
32 /**
33 * The subtitle to display.
34 */
35 property string subtitle
36
37 QQC2.ToolTip.text: text + (subtitle.length > 0 ? "\n\n" + subtitle : "")
38 QQC2.ToolTip.visible: (Platform.Settings.tabletMode ? down : hovered) && (contentItem?.truncated ?? false)
39 QQC2.ToolTip.delay: Platform.Units.toolTipDelay
40
41 contentItem: IconTitleSubtitle {
42 icon: icon.fromControlsIcon(delegate.icon)
43 title: delegate.text
44 subtitle: delegate.subtitle
45 selected: delegate.highlighted || delegate.down
46 font: delegate.font
47 }
48}
A simple item containing an icon, title and subtitle.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Nov 17 2024 19:26:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.