Warning, /graphics/koko/src/qml/AlbumDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2017 Atul Sharma <atulsharma406@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Controls 2.15 as Controls 0009 import org.kde.kquickcontrolsaddons 2.0 as KQA 0010 import org.kde.kirigami 2.12 as Kirigami 0011 import org.kde.koko 0.1 as Koko 0012 0013 Controls.ItemDelegate { 0014 id: root 0015 0016 required property int index 0017 required property bool selected 0018 required property var thumbnail 0019 required property int itemType 0020 required property string content 0021 required property int fileCount 0022 required property string imageurl 0023 0024 leftPadding: Kirigami.Units.gridUnit 0025 rightPadding: Kirigami.Units.gridUnit 0026 topPadding: Kirigami.Units.gridUnit 0027 bottomPadding: Kirigami.Units.gridUnit 0028 0029 leftInset: Kirigami.Units.smallSpacing 0030 rightInset: Kirigami.Units.smallSpacing 0031 topInset: Kirigami.Units.smallSpacing 0032 bottomInset: Kirigami.Units.smallSpacing 0033 0034 readonly property color stateIndicatorColor: if (root.activeFocus || root.hovered || root.selected) { 0035 return Kirigami.Theme.highlightColor; 0036 } else { 0037 return "transparent"; 0038 } 0039 0040 readonly property real stateIndicatorOpacity: if (root.activeFocus || root.hovered) { 0041 return root.selected ? 1 : 0.3; 0042 } else if (root.selected) { 0043 return 0.7 0044 } else { 0045 return 0; 0046 } 0047 0048 width: gridView.cellWidth 0049 height: gridView.cellHeight 0050 0051 function refresh() { 0052 // HACK: force refresh image after it was edited. 0053 const old = image.image; 0054 image.image = undefined; 0055 image.image = old; 0056 } 0057 0058 contentItem: Item { 0059 KQA.QImageItem { 0060 id: image 0061 anchors.centerIn: parent 0062 width: kokoConfig.iconSize 0063 height: width 0064 smooth: true 0065 image: root.thumbnail 0066 fillMode: KQA.QImageItem.PreserveAspectFit 0067 } 0068 0069 Rectangle { 0070 anchors { 0071 top: image.top 0072 left: image.left 0073 right: image.right 0074 } 0075 visible: textLabel.visible 0076 width: image.width 0077 height: textLabel.contentHeight + (Kirigami.Units.smallSpacing * 2) 0078 Kirigami.Theme.colorSet: Kirigami.Theme.View 0079 color: Kirigami.Theme.backgroundColor 0080 opacity: 0.8 0081 } 0082 0083 Controls.Label { 0084 id: textLabel 0085 anchors { 0086 left: image.left 0087 right: image.right 0088 top: image.top 0089 bottom: countRect.visible ? countRect.top : image.bottom 0090 } 0091 visible: root.itemType == Koko.Types.Folder || root.itemType == Koko.Types.Album 0092 verticalAlignment: Text.AlignTop 0093 padding: Kirigami.Units.smallSpacing 0094 elide: Text.ElideRight 0095 maximumLineCount: 4 0096 wrapMode: Text.WordWrap 0097 color: Kirigami.Theme.textColor 0098 text: root.content 0099 } 0100 0101 Rectangle { 0102 id: countRect 0103 anchors { 0104 bottom: image.bottom 0105 left: image.left 0106 right: image.right 0107 } 0108 visible: root.fileCount && root.itemType == Koko.Types.Folder || root.itemType == Koko.Types.Album 0109 height: countLabel.contentHeight + (Kirigami.Units.smallSpacing * 2) 0110 Kirigami.Theme.colorSet: Kirigami.Theme.View 0111 color: Kirigami.Theme.backgroundColor 0112 opacity: 0.8 0113 0114 Controls.Label { 0115 id: countLabel 0116 padding: Kirigami.Units.smallSpacing 0117 elide: Text.ElideRight 0118 maximumLineCount: 4 0119 wrapMode: Text.WordWrap 0120 color: Kirigami.Theme.textColor 0121 text: i18np("1 Image", "%1 Images", root.fileCount) 0122 } 0123 } 0124 } 0125 0126 0127 background: Rectangle { 0128 radius: Kirigami.Settings.isMobile ? Kirigami.Units.smallSpacing : 3 0129 color: stateIndicatorColor 0130 opacity: stateIndicatorOpacity 0131 } 0132 0133 Keys.onPressed: switch (event.key) { 0134 case Qt.Key_Enter: 0135 case Qt.Key_Return: 0136 root.clicked(); 0137 } 0138 }