xref: /OK3568_Linux_fs/app/forlinx/flapp/src/plugins/imxwayland/qmlvideofx/qml/qmlvideofx/Main.qml (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Mobility Components.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34import QtQuick 2.1
35import QtQuick.Window 2.1
36
37Rectangle {
38    id: root
39    color: "black"
40    property string fileName
41    property alias volume: content.volume
42    property bool perfMonitorsLogging: false
43    property bool perfMonitorsVisible: false
44    property int pixDens: Math.ceil(Screen.pixelDensity)
45    property int itemWidth: 25 * pixDens
46    property int itemHeight: 10 * pixDens
47    property int windowWidth: Screen.desktopAvailableWidth
48    property int windowHeight: Screen.desktopAvailableHeight
49    property int scaledMargin: 2 * pixDens
50    property int fontSize: 5 * pixDens
51    QtObject {
52        id: d
53        property real gripSize: 20
54    }
55
56    Content {
57        id: content
58        color: "transparent"
59        anchors {
60            top: parent.top
61            left: parent.left
62            right: parent.right
63            bottom: parameterPanel.top
64            margins: scaledMargin
65            leftMargin: scaledMargin + itemHeight
66        }
67        gripSize: d.gripSize
68    }
69
70    ParameterPanel {
71        id: parameterPanel
72        anchors {
73            left: parent.left
74            right: effectName.left
75            bottom: parent.bottom
76            margins: scaledMargin
77            leftMargin: scaledMargin + itemHeight
78        }
79        gripSize: d.gripSize
80        height: root.itemHeight * 2.5
81        width: root.itemWidth * 3
82    }
83
84    Button {
85        id: effectName
86        anchors {
87                    right: parent.right
88                    bottom: perfHolder.top
89                    margins: scaledMargin
90                }
91
92        text: "No effect"
93        width: itemWidth * 2
94        height: itemHeight
95        onClicked: {
96            effectName.visible = false
97            listview.visible = true
98            lvbg.visible = true
99        }
100        color: "#303030"
101    }
102
103    Rectangle {
104        id: lvbg
105        width: itemWidth * 2
106        color: "black"
107        opacity: 0.8
108        visible: false
109
110        anchors {
111                    right: parent.right
112                    bottom: perfHolder.top
113                    top: parent.top
114                    margins: scaledMargin
115                }
116
117        ListView {
118            id: listview
119            width: itemWidth * 2
120            anchors.fill: parent
121            visible: false
122
123            model: EffectSelectionList {}
124            delegate: effectDelegate
125
126            clip: true
127            focus: true
128
129            Component {
130                id: effectDelegate
131                Button {
132                    text: name
133                    width: itemWidth * 2
134                    onClicked: {
135                        content.effectSource = source
136                        listview.visible = false
137                        lvbg.visible = false
138                        effectName.text = name
139                        effectName.visible = true
140                        parameterPanel.model = content.effect.parameters
141
142                    }
143                }
144            }
145        }
146    }
147
148    Rectangle {
149        id: perfHolder
150        color: "transparent"
151        anchors {
152            right: parent.right
153            bottom: parent.bottom
154            margins: scaledMargin
155        }
156        height: root.itemHeight * 1.5
157        width: root.itemWidth
158
159        Loader {
160            id: performanceLoader
161            function init() {
162                var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
163                source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
164            }
165            onLoaded: {
166                item.parent = perfHolder
167                item.anchors.top = perfHolder.top
168                item.anchors.bottom = perfHolder.bottom
169                item.anchors.left = perfHolder.left
170                item.anchors.right = perfHolder.right
171                item.logging = root.perfMonitorsLogging
172                item.displayed = root.perfMonitorsVisible
173                item.init()
174            }
175        }
176    }
177
178    FileOpen {
179        id: fileOpen
180        state: "collapsed"
181        anchors {
182            left: parent.left
183            top: parent.top
184            bottom: parent.bottom
185            margins: scaledMargin
186        }
187        width: itemHeight + scaledMargin
188        z: 2
189        opacity: 0.9
190
191        states: [
192            State {
193                name: "expanded"
194                PropertyChanges {
195                    target: fileOpen
196                    width: itemWidth * 1.5
197                    opacity: 0.8
198                }
199            },
200            State {
201                name: "collapsed"
202                PropertyChanges {
203                    target: fileOpen
204                    width: itemHeight + scaledMargin
205                    opacity: 0.9
206                }
207            }
208        ]
209
210        transitions: [
211            Transition {
212                NumberAnimation { target: fileOpen; property: "width"; duration: 100 }
213                NumberAnimation { target: fileOpen; property: "opacity"; duration: 100 }
214            }
215        ]
216    }
217
218    FileBrowser {
219        id: imageFileBrowser
220        anchors.fill: root
221        Component.onCompleted: fileSelected.connect(content.openImage)
222    }
223
224    FileBrowser {
225        id: videoFileBrowser
226        anchors.fill: root
227        Component.onCompleted: fileSelected.connect(content.openVideo)
228    }
229
230    Component.onCompleted: {
231        fileOpen.openImage.connect(openImage)
232        fileOpen.openVideo.connect(openVideo)
233        fileOpen.openCamera.connect(openCamera)
234        fileOpen.close.connect(close)
235    }
236
237    function init() {
238        if (Qt.platform.os === "linux" || Qt.platform.os === "windows" || Qt.platform.os === "osx" || Qt.platform.os === "unix") {
239            if (Screen.desktopAvailableWidth > 1280) {
240                windowWidth = 1280
241            }
242            if (Screen.desktopAvailableHeight > 720) {
243                windowHeight = 720
244            }
245        }
246
247        height = windowHeight
248        width = windowWidth
249        imageFileBrowser.folder = imagePath
250        videoFileBrowser.folder = videoPath
251        content.init()
252        performanceLoader.init()
253        if (fileName != "")
254            content.openVideo(fileName)
255    }
256
257    function qmlFramePainted() {
258        if (performanceLoader.item)
259            performanceLoader.item.qmlFramePainted()
260    }
261
262    function openImage() {
263        imageFileBrowser.show()
264    }
265
266    function openVideo() {
267        videoFileBrowser.show()
268    }
269
270    function openCamera() {
271        content.openCamera()
272    }
273
274    function close() {
275        content.init()
276    }
277}
278