1
/****************************************************************************
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the Qt Mobility Components.
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
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.
26
** In addition, as a special exception, Digia gives you certain additional
27
** rights. These rights are described in the Digia Qt LGPL Exception
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
32
****************************************************************************/
35
import Qt.labs.folderlistmodel 2.0
41
property string folder
43
property int itemHeight: Math.min(parent.width, parent.height) / 15
44
property int buttonHeight: Math.min(parent.width, parent.height) / 12
46
signal fileSelected(string file)
48
function selectFile(file) {
50
folder = loader.item.folders.folder
51
fileBrowser.fileSelected(file)
53
loader.sourceComponent = undefined
61
loader.sourceComponent = fileBrowserComponent
62
loader.item.parent = fileBrowser
63
loader.item.anchors.fill = fileBrowser
64
loader.item.folder = fileBrowser.folder
68
id: fileBrowserComponent
73
property bool showFocusHighlight: false
74
property variant folders: folders1
75
property variant view: view1
76
property alias folder: folders1.folder
77
property color textColor: "white"
100
if (filePath.length > 2 && filePath[1] === ':') // Windows drive logic, see QUrl::fromLocalFile()
103
if (folders.isFolder(index))
106
fileBrowser.selectFile(path)
109
height: folderImage.height
116
anchors.leftMargin: 5
117
anchors.rightMargin: 5
127
source: "qrc:/folder.png"
128
width: itemHeight * 0.9
129
height: itemHeight * 0.9
130
anchors.left: parent.left
132
visible: folders.isFolder(index)
138
anchors.fill: parent;
139
verticalAlignment: Text.AlignVCenter
141
anchors.leftMargin: itemHeight + 10
142
color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor
143
elide: Text.ElideRight
150
root.showFocusHighlight = false;
151
wrapper.ListView.view.currentIndex = index;
153
onClicked: { if (folders === wrapper.ListView.view.model) launch() }
159
when: mouseRegion.pressed
160
PropertyChanges { target: highlight; visible: true }
161
PropertyChanges { target: nameText; color: palette.highlightedText }
169
anchors.top: titleBar.bottom
170
anchors.bottom: cancelButton.top
173
delegate: folderDelegate
174
highlight: Rectangle {
176
visible: root.showFocusHighlight && view1.count != 0
177
width: view1.currentItem == null ? 0 : view1.currentItem.width
179
highlightMoveVelocity: 1000
186
PropertyChanges { target: view1; x: 0 }
190
PropertyChanges { target: view1; x: -root.width }
194
PropertyChanges { target: view1; x: root.width }
200
SequentialAnimation {
201
NumberAnimation { properties: "x"; duration: 250 }
205
NumberAnimation { properties: "x"; duration: 250 }
206
NumberAnimation { properties: "x"; duration: 250 }
209
Keys.onPressed: root.keyPressed(event.key)
214
anchors.top: titleBar.bottom
215
anchors.bottom: parent.bottom
219
delegate: folderDelegate
220
highlight: Rectangle {
222
visible: root.showFocusHighlight && view2.count != 0
223
width: view1.currentItem == null ? 0 : view1.currentItem.width
225
highlightMoveVelocity: 1000
230
PropertyChanges { target: view2; x: 0 }
234
PropertyChanges { target: view2; x: -root.width }
238
PropertyChanges { target: view2; x: root.width }
244
SequentialAnimation {
245
NumberAnimation { properties: "x"; duration: 250 }
249
NumberAnimation { properties: "x"; duration: 250 }
252
Keys.onPressed: root.keyPressed(event.key)
257
height: buttonHeight + 10
258
anchors.bottom: parent.bottom
267
anchors.bottom: parent.bottom
268
anchors.left: parent.left
269
anchors.right: parent.right
271
radius: buttonHeight / 15
277
horizontalAlignment: Text.AlignHCenter
278
verticalAlignment: Text.AlignVCenter
283
onClicked: fileBrowser.selectFile("")
288
root.keyPressed(event.key);
289
if (event.key === Qt.Key_Return || event.key === Qt.Key_Select || event.key === Qt.Key_Right) {
290
view.currentItem.launch();
291
event.accepted = true;
292
} else if (event.key === Qt.Key_Left) {
301
height: buttonHeight + 10
302
anchors.top: parent.top
310
anchors.top: parent.top
311
anchors.left: parent.left
312
anchors.right: parent.right
313
radius: buttonHeight / 15
323
anchors.centerIn: parent
324
source: "qrc:/up.png"
326
MouseArea { id: upRegion; anchors.centerIn: parent
334
when: upRegion.pressed
335
PropertyChanges { target: upButton; color: palette.highlight }
341
anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
342
anchors.leftMargin: 5; anchors.rightMargin: 5
345
elide: Text.ElideLeft;
346
horizontalAlignment: Text.AlignLeft;
347
verticalAlignment: Text.AlignVCenter
352
function down(path) {
353
if (folders == folders1) {
356
view1.state = "exitLeft";
360
view2.state = "exitLeft";
363
view.state = "current";
365
folders.folder = path;
369
var path = folders.parentFolder;
370
if (path.toString().length === 0 || path.toString() === 'file:')
372
if (folders == folders1) {
375
view1.state = "exitRight";
379
view2.state = "exitRight";
381
view.x = -root.width;
382
view.state = "current";
384
folders.folder = path;
387
function keyPressed(key) {
393
root.showFocusHighlight = true;