Debian Codegraph @

rc/qml/Components/MediaSelector.qml

raw
1 /*
2 * Copyright (C) 2013-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.9
18 import Gallery 1.0
19 import Lomiri.Components 1.3
20 import "../../js/Gallery.js" as Gallery
21 import "../OrganicView"
22 import "../Utility"
23
24 /*!
25 MediaSelector provides a view, with all photos. And these can be selected.
26 */
27 OrganicView {
28 id: mediaSelector
29
30 /// Is true, while the animation tto show/hide the media selector is running
31 property alias animationRunning: blendAnimation.running
32
33 /// Emitted when the user clicked the add button
34 signal addClicked()
35 /// Emitted when fully shown
36 signal shown()
37 /// Emitted when fully hidden
38 signal hidden()
39
40 onActiveChanged: {
41 if (active)
42 header.show();
43 }
44
45 /// Shows the item in an animated way
46 function show() {
47 visible = true;
48 opacity = 0;
49 blendAnimation.to = 1;
50 blendAnimation.start();
51 header.show();
52 }
53 /// Hides the item in an animated way
54 function hide() {
55 blendAnimation.to = 0;
56 blendAnimation.start();
57 }
58
59 title: i18n.tr("Add to Album")
60 visible: false
61
62 selection: SelectionState {
63 id: select
64 inSelectionMode: true
65 allowSelectionModeChange: false
66 }
67
68 model: EventCollectionModel {
69 }
70
71 delegate: OrganicMediaList {
72 objectName: "mediaSelectorList" + index
73 width: mediaSelector.width
74 event: model.event
75 selection: mediaSelector.selection
76 }
77
78 head.actions: [
79 Action {
80 objectName: "addButton"
81 text: i18n.tr("Add to Album")
82 iconName: "ok"
83 enabled: mediaSelector.selection.selectedCount
84 onTriggered: {
85 mediaSelector.addClicked();
86 mediaSelector.hide();
87 }
88 }
89 ]
90
91 head.backAction: Action {
92 objectName: "cancelButton"
93 text: i18n.tr("Cancel")
94 iconName: "back"
95 onTriggered: {
96 mediaSelector.hide();
97 }
98 }
99
100 PropertyAnimation {
101 id: blendAnimation
102 target: mediaSelector
103 property: "opacity"
104 duration: Gallery.FAST_DURATION
105 easing.type: Easing.InQuint
106 onStopped: {
107 if (mediaSelector.opacity === 1) {
108 mediaSelector.shown();
109 } else {
110 selection.unselectAll();
111 visible = false;
112 mediaSelector.hidden();
113 }
114 }
115 }
116 }