Warning, /graphics/krita/libs/libqml/plugins/components/ExpandingListView.qml is written in an unsupported language. File is not indexed.
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2012 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.3 0008 import org.krita.sketch 1.0 0009 0010 Item { 0011 id: base 0012 property alias model: listView.model; 0013 property alias currentIndex: listView.currentIndex; 0014 signal newIndex(int index); 0015 height: topButton.height; 0016 0017 Rectangle { 0018 id: topButton 0019 border { 0020 width: 2; 0021 color: Settings.theme.color("components/expandingListView/selection/border"); 0022 } 0023 radius: height * 0.5; 0024 anchors { 0025 top: base.expandToTop ? undefined : parent.top; 0026 bottom: base.expandToTop ? parent.bottom : undefined; 0027 right: parent.right; 0028 left: parent.left; 0029 } 0030 width: (Constants.GridWidth * 2) - 8 ; 0031 height: Constants.GridHeight * 0.75; 0032 color: Settings.theme.color("components/expandingListView/selection/fill"); 0033 z: 10; 0034 0035 0036 Image { 0037 id: arrowsList 0038 anchors { 0039 right: parent.right; 0040 verticalCenter: parent.verticalCenter; 0041 rightMargin: -1; 0042 } 0043 height: parent.height; 0044 width: height; 0045 sourceSize.height: height 0046 source: Settings.theme.icon("combo-arrows-white"); 0047 smooth: true 0048 } 0049 0050 Label { 0051 id: buttonText; 0052 anchors { 0053 verticalCenter: parent.verticalCenter; 0054 left: parent.left; 0055 leftMargin: parent.radius; 0056 right: arrowsList.left; 0057 } 0058 text: listView.currentItem ? listView.currentItem.text : "(tap to select)"; 0059 color: Settings.theme.color("components/expandingListView/selection/text"); 0060 } 0061 0062 MouseArea { 0063 anchors.fill: parent; 0064 onClicked: { 0065 if (base.state === "expanded") { 0066 base.state = ""; 0067 } 0068 else { 0069 base.state = "expanded"; 0070 } 0071 } 0072 } 0073 } 0074 0075 Rectangle { 0076 id: listContainer 0077 anchors { 0078 top: base.expandToTop ? parent.top : topButton.bottom; 0079 left: parent.left; 0080 right: parent.right; 0081 bottom: base.expandToTop ? topButton.top : parent.bottom; 0082 leftMargin: topButton.radius; 0083 rightMargin: topButton.radius; 0084 } 0085 clip: true; 0086 opacity: 0; 0087 color: Settings.theme.color("components/expandingListView/list/background"); 0088 ListView { 0089 id: listView; 0090 anchors.fill: parent; 0091 delegate: Item { 0092 property alias text: delegateLabel.text 0093 anchors { 0094 left: parent.left; 0095 right: parent.right; 0096 } 0097 height: Constants.DefaultFontSize + Constants.DefaultMargin * 2; 0098 Rectangle { 0099 anchors.fill: parent; 0100 radius: height / 2; 0101 border.width: 2; 0102 border.color: Settings.theme.color("components/expandingListView/list/itemBorder"); 0103 color: Settings.theme.color("components/expandingListView/list/item"); 0104 opacity: model.isCategory ? 0.3 : 0; 0105 } 0106 Shadow { 0107 anchors { 0108 bottom: delegateLabel.bottom; 0109 left: delegateLabel.left; 0110 right: delegateLabel.right; 0111 } 0112 visible: listView.currentIndex === index; 0113 } 0114 Label { 0115 id: delegateLabel 0116 anchors.fill: parent 0117 anchors.leftMargin: model.isCategory ? Constants.DefaultFontSize / 2 : 0; 0118 text: model.text ? model.text : index + " (no text field in model)"; 0119 color: Settings.theme.color("components/expandingListView/list/itemText"); 0120 } 0121 MouseArea { 0122 anchors.fill: parent; 0123 onClicked: { 0124 if (model.isCategory) { 0125 return; 0126 } 0127 listView.currentIndex = index; 0128 base.newIndex(index); 0129 base.state = ""; 0130 } 0131 } 0132 } 0133 ScrollDecorator { 0134 flickableItem: parent; 0135 } 0136 } 0137 } 0138 0139 property bool expandToTop: false; 0140 property int expandedHeight: base.parent.height - base.y - (Constants.GridHeight / 2); 0141 states: [ 0142 State { 0143 name: "expanded"; 0144 PropertyChanges { 0145 target: base; 0146 height: expandedHeight > 0 ? expandedHeight : Constants.GridHeight * 2; 0147 } 0148 PropertyChanges { 0149 target: listContainer; 0150 opacity: 1; 0151 } 0152 } 0153 ] 0154 transitions: [ 0155 Transition { 0156 from: "" 0157 to: "expanded" 0158 reversible: true; 0159 PropertyAnimation { properties: "height,opacity"; duration: Constants.AnimationDuration; easing.type: Easing.InOutCubic } 0160 } 0161 ] 0162 }