Kirigami2

SwitchSubtitleDelegate.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
9import org.kde.kirigami.platform as Platform
10
11/**
12 * A convenience wrapper combining QtQuick Controls SwitchDelegate and IconTitleSubtitle
13 *
14 * This is an intentionally minimal wrapper that replaces the SwitchDelegate's
15 * contentItem with an IconTitleSubtitle and adds a subtitle property.
16 *
17 * If you wish to customize the layout further, create your own `SwitchDelegate`
18 * subclass with the `contentItem:` property set to the content of your choice.
19 * This can include `IconTitleSubtitle` inside a Layout, for example.
20 *
21 * \note If you don't need a subtitle, use `SwitchDelegate` directly.
22 *
23 * \sa Kirigami::Delegates::TitleSubtitle
24 * \sa Kirigami::Delegates::IconTitleSubtitle
25 */
26QQC2.SwitchDelegate {
27 id: delegate
28
29 // Please see the developer note in ItemDelegate
31 /**
32 * The subtitle to display.
33 */
34 property string subtitle
35
36 QQC2.ToolTip.text: text + (subtitle.length > 0 ? "\n\n" + subtitle : "")
37 QQC2.ToolTip.visible: (Platform.Settings.tabletMode ? down : hovered) && (contentItem?.truncated ?? false)
38 QQC2.ToolTip.delay: Platform.Units.toolTipDelay
39
40 contentItem: IconTitleSubtitle {
41 icon: icon.fromControlsIcon(delegate.icon)
42 title: delegate.text
43 subtitle: delegate.subtitle
44 selected: delegate.highlighted || delegate.down
45 font: delegate.font
46 }
47}
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 Mon Nov 18 2024 12:16:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.