diff --git a/src/declarativeimports/plasmaextracomponents/qml/ListItem.qml b/src/declarativeimports/plasmaextracomponents/qml/ListItem.qml new file mode 100644 index 000000000..3d4cf63ad --- /dev/null +++ b/src/declarativeimports/plasmaextracomponents/qml/ListItem.qml @@ -0,0 +1,93 @@ +/* + * Copyright 2020 Carson Black + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.12 +import org.kde.kirigami 2.12 as Kirigami +import org.kde.plasma.core 2.0 as PlasmaCore + +Kirigami.AbstractListItem { + id: __listItem + + /** + * content: list + * + * The content of this ListItem. + */ + default property alias content: __innerItem.data + + /** + * separatorVisible: bool + * + * Whether this ListItem displays a separator. + */ + property bool separatorVisible: true + + /** + * sectionDelegate: bool + * + * Whether this ListItem renders as a section header. + */ + property bool sectionDelegate: true + + /** + * containsMouse: bool + * + * Whether this ListItem contains the mouse. + * + * Alias of Control.hovered. + */ + readonly property bool containsMouse: hovered + + leftPadding: __background.margins.left + rightPadding: __background.margins.right + topPadding: __background.margins.top + bottomPadding: __background.margins.bottom + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding) + + // TODO KF6: Make this behave more like the normal Control default. + // Behaving this way for backwards compatibility reasons. + contentItem: Item { + id: __innerItem + } + + background: PlasmaCore.FrameSvgItem { + id : __background + imagePath: "widgets/listitem" + prefix: (__listItem.sectionDelegate ? "section" : + (__listItem.pressed || __listItem.checked) ? "pressed" : "normal") + + anchors.fill: parent + visible: __listItem.ListView.view ? __listItem.ListView.view.highlight === null : true + + PlasmaCore.SvgItem { + svg: PlasmaCore.Svg { + imagePath: "widgets/listitem" + } + elementId: "separator" + anchors { + left: parent.left + right: parent.right + top: parent.top + } + height: naturalSize.height + visible: __listItem.separatorVisible && (__listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !__listItem.checked && !__listItem.pressed)) + } + } +} \ No newline at end of file diff --git a/src/declarativeimports/plasmaextracomponents/qml/qmldir b/src/declarativeimports/plasmaextracomponents/qml/qmldir index 6eb4af8a9..e11f532c8 100644 --- a/src/declarativeimports/plasmaextracomponents/qml/qmldir +++ b/src/declarativeimports/plasmaextracomponents/qml/qmldir @@ -3,6 +3,7 @@ plugin plasmaextracomponentsplugin App 2.0 App.qml ConditionalLoader 2.0 ConditionalLoader.qml +ListItem 2.0 ListItem.qml ExpandableListItem 2.0 ExpandableListItem.qml Heading 2.0 Heading.qml Paragraph 2.0 Paragraph.qml