blob: 6711de49ee504a81ed98fc6ca9c1c2b94d1b044f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
import Qt 4.6
Rectangle {
id: Root
width: parent.width
height: parent.height
color: Palette.base
FolderListModel {
id: folders
nameFilters: [ "*.qml" ]
// folder: "E:"
}
SystemPalette { id: Palette; colorGroup: Qt.Active }
Component {
id: FolderDelegate
Rectangle {
id: Wrapper
function launch() {
if (folders.isFolder(index)) {
folders.folder = filePath;
} else {
qmlLauncher.launch(filePath);
}
}
width: Root.width
height: 32
color: "transparent"
Rectangle {
id: Highlight; visible: false
anchors.fill: parent
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: Palette.highlight }
GradientStop { id: t2; position: 1.0; color: Palette.lighter(Palette.highlight) }
}
}
Item {
width: 32; height: 32
Image { source: "images/fileopen.png"; anchors.centerIn: parent; visible: folders.isFolder(index)}
}
Text {
id: NameText
anchors.fill: parent; verticalAlignment: "AlignVCenter"
text: fileName; anchors.leftMargin: 32
font.pointSize: 10
color: Palette.windowText
}
MouseRegion {
id: Mouse
anchors.fill: parent
onClicked: { launch() }
}
states: [
State {
name: "pressed"
when: Mouse.pressed
PropertyChanges { target: Highlight; visible: true }
PropertyChanges { target: NameText; color: Palette.highlightedText }
}
]
}
}
Script {
function up(path) {
var pos = path.toString().lastIndexOf("/");
return path.toString().substring(0, pos);
}
}
ListView {
id: View
anchors.top: TitleBar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
model: folders
delegate: FolderDelegate
highlight: Rectangle { color: "#FFFBAF" }
clip: true
focus: true
Keys.onPressed: {
if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) {
View.currentItem.launch();
event.accepted = true;
}
}
}
Rectangle {
id: TitleBar
width: parent.width
height: 32
color: Palette.button; border.color: Palette.mid
Rectangle {
id: UpButton
width: 30
height: TitleBar.height
border.color: Palette.mid; color: "transparent"
MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) }
Image { anchors.centerIn: parent; source: "images/up.png" }
}
Text {
anchors.left: UpButton.right; anchors.right: parent.right; height: parent.height
anchors.leftMargin: 4; anchors.rightMargin: 4
text: folders.folder; color: Palette.buttonText
elide: "ElideLeft"; horizontalAlignment: "AlignRight"; verticalAlignment: "AlignVCenter"
}
}
}
|