|
| 1 | +/*************************************************************************** |
| 2 | + * * |
| 3 | + * This program is free software; you can redistribute it and/or modify * |
| 4 | + * it under the terms of the GNU General Public License as published by * |
| 5 | + * the Free Software Foundation; either version 2 of the License, or * |
| 6 | + * (at your option) any later version. * |
| 7 | + * * |
| 8 | + ***************************************************************************/ |
| 9 | +pragma ComponentBehavior: Bound |
| 10 | + |
| 11 | +import QtQuick |
| 12 | +import QtQuick.Effects |
| 13 | + |
| 14 | +Item { |
| 15 | + id: root |
| 16 | + |
| 17 | + property alias imageSource: bngImage.photoUrl |
| 18 | + property string text: "" |
| 19 | + property bool textVisible: false |
| 20 | + property int size: 120 * __dp |
| 21 | + |
| 22 | + signal clicked(url path) |
| 23 | + |
| 24 | + height: size |
| 25 | + width: size |
| 26 | + |
| 27 | + layer.enabled: true |
| 28 | + layer.effect: MultiEffect { |
| 29 | + maskEnabled: true |
| 30 | + maskSource: photoMask |
| 31 | + autoPaddingEnabled: false |
| 32 | + } |
| 33 | + |
| 34 | + Rectangle { |
| 35 | + id: photoMask |
| 36 | + width: root.width |
| 37 | + height: root.height |
| 38 | + radius: 20 * __dp |
| 39 | + visible: false |
| 40 | + layer.enabled: true |
| 41 | + } |
| 42 | + |
| 43 | + MMPhoto { |
| 44 | + id: bngImage |
| 45 | + anchors.fill: root |
| 46 | + fillMode: Image.PreserveAspectCrop |
| 47 | + } |
| 48 | + |
| 49 | + MultiEffect{ |
| 50 | + id: blurFooter |
| 51 | + height: root.height * 0.33 |
| 52 | + visible: root.textVisible |
| 53 | + anchors { |
| 54 | + left: root.left |
| 55 | + right: root.right |
| 56 | + bottom: root.bottom |
| 57 | + } |
| 58 | + |
| 59 | + source: ShaderEffectSource { |
| 60 | + sourceItem: bngImage |
| 61 | + sourceRect: Qt.rect(0, bngImage.height - bngImage.height * 0.33, bngImage.width, |
| 62 | + bngImage.height * 0.33) |
| 63 | + recursive: false |
| 64 | + } |
| 65 | + |
| 66 | + autoPaddingEnabled: false |
| 67 | + blurEnabled: true |
| 68 | + blur: 0.8 |
| 69 | + } |
| 70 | + |
| 71 | + // tint overlay |
| 72 | + Rectangle { |
| 73 | + anchors.fill: blurFooter |
| 74 | + color: __style.nightColor |
| 75 | + opacity: 0.35 |
| 76 | + visible: root.textVisible |
| 77 | + } |
| 78 | + |
| 79 | + Text { |
| 80 | + visible: root.textVisible |
| 81 | + text: root.text |
| 82 | + width: root.width - 2 * (root.size * 0.15) |
| 83 | + anchors.centerIn: blurFooter |
| 84 | + |
| 85 | + color: __style.polarColor |
| 86 | + font: __style.t5 |
| 87 | + |
| 88 | + lineHeightMode: Text.FixedHeight |
| 89 | + lineHeight: __style.margin16 |
| 90 | + maximumLineCount: 2 |
| 91 | + |
| 92 | + horizontalAlignment: Text.AlignHCenter | Text.AlignJustify |
| 93 | + verticalAlignment: Text.AlignVCenter |
| 94 | + |
| 95 | + wrapMode: Text.WordWrap |
| 96 | + elide: Text.ElideRight |
| 97 | + } |
| 98 | + |
| 99 | + MMSingleClickMouseArea { |
| 100 | + anchors.fill: root |
| 101 | + onSingleClicked: root.clicked(root.imageSource) |
| 102 | + } |
| 103 | +} |
0 commit comments