~dpm/ubuntu-filemanager-app/run-ap-from-out-of-source-build

« back to all changes in this revision

Viewing changes to PlacesPopover.qml

  • Committer: Michael Spencer
  • Date: 2014-02-19 00:00:15 UTC
  • mto: This revision was merged to the branch mainline in revision 132.
  • Revision ID: sonrisesoftware@gmail.com-20140219000015-3ogzcc7roicfqbyi
Refactored files into sub-directories

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013 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
 
 * Authored by: Michael Spencer <sonrisesoftware@gmail.com>
17
 
 */
18
 
import QtQuick 2.0
19
 
import Ubuntu.Components 0.1
20
 
import Ubuntu.Components.Popups 0.1
21
 
import Ubuntu.Components.ListItems 0.1
22
 
 
23
 
Popover {
24
 
    id: root
25
 
    objectName: "placesPopover"
26
 
 
27
 
    ListModel {
28
 
        id: places
29
 
 
30
 
        ListElement {
31
 
            path: "~"
32
 
        }
33
 
 
34
 
        ListElement {
35
 
            path: "~/Documents"
36
 
        }
37
 
 
38
 
        ListElement {
39
 
            path: "~/Downloads"
40
 
        }
41
 
 
42
 
        ListElement {
43
 
            path: "~/Music"
44
 
        }
45
 
 
46
 
        ListElement {
47
 
            path: "~/Pictures"
48
 
        }
49
 
 
50
 
        ListElement {
51
 
            path: "~/Videos"
52
 
        }
53
 
 
54
 
        ListElement {
55
 
            path: "/"
56
 
        }
57
 
    }
58
 
 
59
 
    Column {
60
 
        anchors {
61
 
            left: parent.left
62
 
            right: parent.right
63
 
            top: parent.top
64
 
        }
65
 
 
66
 
        Empty {
67
 
 
68
 
            TextField {
69
 
                id: locationField
70
 
                objectName: "inputField"
71
 
                anchors {
72
 
                    verticalCenter: parent.verticalCenter
73
 
                    left: parent.left
74
 
                    right: goButton.left
75
 
                    margins: units.gu(1)
76
 
                }
77
 
 
78
 
                inputMethodHints: Qt.ImhNoAutoUppercase
79
 
 
80
 
                property bool valid: pathExists(text)
81
 
 
82
 
                text: fileView.path
83
 
 
84
 
                placeholderText: i18n.tr("Location...")
85
 
 
86
 
                onAccepted: goButton.clicked()
87
 
            }
88
 
 
89
 
            Button {
90
 
                id: goButton
91
 
                objectName: "okButton"
92
 
                anchors {
93
 
                    top: locationField.top
94
 
                    bottom: locationField.bottom
95
 
                    right: parent.right
96
 
                    rightMargin: units.gu(1)
97
 
                }
98
 
 
99
 
                text: i18n.tr("Go")
100
 
                enabled: locationField.acceptableInput && locationField.valid
101
 
 
102
 
                onClicked: {
103
 
                    print("User switched to:", locationField.text)
104
 
                    goTo(locationField.text)
105
 
                    PopupUtils.close(root)
106
 
                }
107
 
            }
108
 
        }
109
 
 
110
 
        Repeater {
111
 
            id: placesList
112
 
            objectName: "placesList"
113
 
 
114
 
            model: places
115
 
 
116
 
            delegate: Standard {
117
 
                property string name: folderName(path)
118
 
 
119
 
                Label {
120
 
                    anchors.left: parent.left
121
 
                    anchors.leftMargin: units.gu(8)
122
 
                    anchors.verticalCenter: parent.verticalCenter
123
 
                    text: folderName(path)
124
 
                    color: selected ? UbuntuColors.orange : Theme.palette.normal.overlayText
125
 
                }
126
 
 
127
 
                iconSource: model.icon || fileIcon(model.path, true)
128
 
 
129
 
                onClicked: {
130
 
                    PopupUtils.close(root)
131
 
                    goTo(model.path)
132
 
                }
133
 
 
134
 
                selected: folder === path
135
 
                iconFrame: false
136
 
                showDivider: index < (placesList.count - 1)
137
 
            }
138
 
        }
139
 
    }
140
 
}