diff --git a/Mainpage.dox b/Mainpage.dox --- a/Mainpage.dox +++ b/Mainpage.dox @@ -44,6 +44,7 @@ - \link org::kde::kirigami::AbstractListItem AbstractListItem \endlink - \link org::kde::kirigami::ApplicationHeader ApplicationHeader \endlink - \link org::kde::kirigami::BasicListItem BasicListItem \endlink +- \link org::kde::kirigami::ListSection ListSection \endlink - \link org::kde::kirigami::SwipeListItem SwipeListItem \endlink - \link org::kde::kirigami::Heading Heading \endlink - \link org::kde::kirigami::Label Label \endlink diff --git a/kirigami.qrc.in b/kirigami.qrc.in --- a/kirigami.qrc.in +++ b/kirigami.qrc.in @@ -73,6 +73,7 @@ @kirigami_QML_DIR@/src/controls/LinkButton.qml @kirigami_QML_DIR@/src/controls/Label.qml @kirigami_QML_DIR@/src/controls/BasicListItem.qml + @kirigami_QML_DIR@/src/controls/ListSection.qml @kirigami_QML_DIR@/src/controls/AbstractApplicationHeader.qml @kirigami_QML_DIR@/src/controls/FormLayout.qml @kirigami_QML_DIR@/src/controls/ListItemDragHandle.qml diff --git a/src/controls/ListSection.qml b/src/controls/ListSection.qml new file mode 100644 --- /dev/null +++ b/src/controls/ListSection.qml @@ -0,0 +1,51 @@ +/* + * Copyright 2019 Björn Feber + * + * 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 2.010-1301, USA. + */ + +import QtQuick 2.1 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 2.0 as QQC2 +import org.kde.kirigami 2.4 + +/** + * A section delegate for the primitive ListView component. + * + * It's intended to make all listviews look coherent. + * + */ +AbstractListItem { + id: listSection + + /** + * string: bool + * A single text label the list section will contain + */ + property alias label: listSection.text + + backgroundColor: Kirigami.Theme.backgroundColor + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Window + + hoverEnabled: false + supportsMouseEvents: false + + contentItem: Kirigami.Heading { + level: 3 + text: listSection.text + } +} diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -524,6 +524,24 @@ Property { name: "containsMouse"; type: "bool"; isReadonly: true } Property { name: "_default"; type: "QQuickItem"; isPointer: true } } + Component { + prototype: "QQuickItemDelegate" + name: "org.kde.kirigami/ListSection 2.0" + exports: ["org.kde.kirigami/ListSection 2.0"] + exportMetaObjectRevisions: [0] + isComposite: true + defaultProperty: "_default" + Property { name: "label"; type: "string" } + Property { name: "supportsMouseEvents"; type: "bool" } + Property { name: "sectionDelegate"; type: "bool" } + Property { name: "separatorVisible"; type: "bool" } + Property { name: "textColor"; type: "QColor" } + Property { name: "backgroundColor"; type: "QColor" } + Property { name: "activeTextColor"; type: "QColor" } + Property { name: "activeBackgroundColor"; type: "QColor" } + Property { name: "containsMouse"; type: "bool"; isReadonly: true } + Property { name: "_default"; type: "QQuickItem"; isPointer: true } + } Component { prototype: "QQuickItem" name: "QtQuick.Controls.Material.impl/BoxShadow 2.0" diff --git a/src/kirigamiplugin.cpp b/src/kirigamiplugin.cpp --- a/src/kirigamiplugin.cpp +++ b/src/kirigamiplugin.cpp @@ -128,6 +128,7 @@ qmlRegisterType(componentUrl(QStringLiteral("ToolBarApplicationHeader.qml")), uri, 2, 0, "ToolBarApplicationHeader"); qmlRegisterType(componentUrl(QStringLiteral("ApplicationWindow.qml")), uri, 2, 0, "ApplicationWindow"); qmlRegisterType(componentUrl(QStringLiteral("BasicListItem.qml")), uri, 2, 0, "BasicListItem"); + qmlRegisterType(componentUrl(QStringLiteral("ListSection.qml")), uri, 2, 0, "ListSection"); qmlRegisterType(componentUrl(QStringLiteral("OverlayDrawer.qml")), uri, 2, 0, "OverlayDrawer"); qmlRegisterType(componentUrl(QStringLiteral("ContextDrawer.qml")), uri, 2, 0, "ContextDrawer"); qmlRegisterType(componentUrl(QStringLiteral("GlobalDrawer.qml")), uri, 2, 0, "GlobalDrawer"); diff --git a/src/qmldir b/src/qmldir --- a/src/qmldir +++ b/src/qmldir @@ -16,6 +16,7 @@ GlobalDrawer 2.5 GlobalDrawer.qml OverlayDrawer 2.5 OverlayDrawer.qml BasicListItem 2.5 BasicListItem.qml +ListSection 2.5 ListSection.qml AbstractItemViewHeader 2.1 AbstractItemViewHeader.qml Heading 2.5 Heading.qml Action 2.5 Action.qml