diff --git a/src/controls/BasicListItem.qml b/src/controls/BasicListItem.qml --- a/src/controls/BasicListItem.qml +++ b/src/controls/BasicListItem.qml @@ -7,7 +7,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.0 as QQC2 -import org.kde.kirigami 2.4 +import org.kde.kirigami 2.12 /** * An item delegate for the primitive ListView component. @@ -25,6 +25,14 @@ */ property alias label: listItem.text + /** + * A subtitle that goes below the main label + * Optional; if not defined, the list item will only have a main label + * @since 5.70 + * @since org.kde.kirigami 2.12 + */ + property alias subtitle: subtitleItem.text + /** * icon: var * A single icon that will be displayed in the list item. @@ -74,7 +82,10 @@ Icon { id: iconItem source: { - if (listItem.icon && listItem.icon.hasOwnProperty) { + if (!listItem.icon) { + return undefined + } + if (listItem.icon.hasOwnProperty) { if (listItem.icon.hasOwnProperty("name") && listItem.icon.name !== "") return listItem.icon.name; if (listItem.icon.hasOwnProperty("source")) @@ -88,15 +99,30 @@ Layout.minimumWidth: size selected: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) opacity: 1 + visible: source != undefined } - QQC2.Label { - id: labelItem - text: listItem.text + ColumnLayout { + spacing: 0 Layout.fillWidth: true - color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor - elide: Text.ElideRight - font: listItem.font - opacity: 1 + Layout.alignment: Qt.AlignVCenter + QQC2.Label { + id: labelItem + text: listItem.text + Layout.fillWidth: true + color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor + elide: Text.ElideRight + opacity: 1 + } + QQC2.Label { + id: subtitleItem + Layout.fillWidth: true + color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor + elide: Text.ElideRight + // TODO: use smallest font size once this is available in Kirigami + // font.pointSize: Theme.smallestFont.pointSize + opacity: 0.6 + visible: text.length > 0 + } } } } diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -518,6 +518,7 @@ defaultProperty: "_basicDefault" Property { name: "icon"; type: "QVariant" } Property { name: "label"; type: "string" } + Property { name: "subtitle"; type: "string" } Property { name: "reserveSpaceForIcon"; type: "bool" } Property { name: "_basicDefault"; type: "QQuickItem"; isList: true; isReadonly: true } Property { name: "supportsMouseEvents"; type: "bool" }