Warning, /graphics/okular/mobile/app/package/contents/ui/TreeViewDecoration.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
0003 *
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009 import QtQuick.Controls 2.15 as QQC2
0010 import QtQuick.Templates 2.15 as T
0011 import org.kde.kitemmodels 1.0
0012 import org.kde.kirigami 2.17 as Kirigami
0013
0014 /**
0015 * The tree expander decorator for item views.
0016 *
0017 * It will have a "> v" expander button graphics, and will have indentation on the left
0018 * depending on the level of the tree the item is in
0019 */
0020 RowLayout {
0021 id: decorationLayout
0022 /**
0023 * The delegate this decoration will live in.
0024 * It needs to be assigned explicitly by the developer.
0025 */
0026 property T.ItemDelegate parentDelegate
0027
0028 /**
0029 * The KDescendantsProxyModel the view is showing.
0030 * It needs to be assigned explicitly by the developer.
0031 */
0032 property KDescendantsProxyModel model
0033
0034 property color decorationHighlightColor
0035
0036 Layout.topMargin: -parentDelegate.topPadding
0037 Layout.bottomMargin: -parentDelegate.bottomPadding
0038 Repeater {
0039 model: kDescendantLevel-1
0040 delegate: Item {
0041 Layout.preferredWidth: controlRoot.width
0042 Layout.fillHeight: true
0043
0044 Rectangle {
0045 anchors {
0046 horizontalCenter: parent.horizontalCenter
0047 top: parent.top
0048 bottom: parent.bottom
0049 }
0050 visible: kDescendantHasSiblings[modelData]
0051 color: Kirigami.Theme.textColor
0052 opacity: 0.5
0053 width: 1
0054 }
0055 }
0056 }
0057 T.Button {
0058 id: controlRoot
0059 Layout.preferredWidth: Kirigami.Units.gridUnit
0060 Layout.fillHeight: true
0061 enabled: kDescendantExpandable
0062 hoverEnabled: enabled
0063 onClicked: model.toggleChildren(index)
0064 contentItem: Item {
0065 id: styleitem
0066 implicitWidth: Kirigami.Units.gridUnit
0067 Rectangle {
0068 anchors {
0069 horizontalCenter: parent.horizontalCenter
0070 top: parent.top
0071 bottom: expander.visible ? expander.top : parent.verticalCenter
0072 }
0073 color: Kirigami.Theme.textColor
0074 opacity: 0.5
0075 width: 1
0076 }
0077 Kirigami.Icon {
0078 id: expander
0079 anchors.centerIn: parent
0080 width: Kirigami.Units.iconSizes.small
0081 height: width
0082 source: kDescendantExpanded ? "go-down-symbolic" : (Qt.application.layoutDirection == Qt.RightToLeft ? "go-previous-symbolic" : "go-next-symbolic")
0083 isMask: true
0084 color: controlRoot.hovered ? decorationLayout.decorationHighlightColor ? decorationLayout.decorationHighlightColor :
0085 Kirigami.Theme.highlightColor : Kirigami.Theme.textColor
0086 Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.InOutQuad } }
0087 visible: kDescendantExpandable
0088 }
0089 Rectangle {
0090 anchors {
0091 horizontalCenter: parent.horizontalCenter
0092 top: expander.visible ? expander.bottom : parent.verticalCenter
0093 bottom: parent.bottom
0094 }
0095 visible: kDescendantHasSiblings[kDescendantHasSiblings.length - 1]
0096 color: Kirigami.Theme.textColor
0097 opacity: 0.5
0098 width: 1
0099 }
0100 Rectangle {
0101 anchors {
0102 verticalCenter: parent.verticalCenter
0103 left: expander.visible ? expander.right : parent.horizontalCenter
0104 right: parent.right
0105 }
0106 color: Kirigami.Theme.textColor
0107 opacity: 0.5
0108 height: 1
0109 }
0110 }
0111 background: Item {}
0112 }
0113 }