-
Notifications
You must be signed in to change notification settings - Fork 13
/
FileDialog.qml
109 lines (99 loc) · 3.24 KB
/
FileDialog.qml
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
import QtQuick 2.0
import per.pqy.filedialog 1.0
Image {
id: root
signal chooseFile(string type, string filepath)
property string ftype: null
source: "image://ThemeProvider/bg"
MyFileDialog {
id: fd
Component.onCompleted: {setcurrentPath(mc.currentPath);setFilter("*.png,*.jpg"); }
onFileModelChanged: {
myButton2.enabled = false;
}
onClickFile: {
myButton2.enabled = true;
}
}
Text {
id: text1
x: 229
text: qsTr("Choose a file")
horizontalAlignment: Text.AlignHCenter
anchors.top: parent.top
anchors.topMargin: 0
anchors.horizontalCenter: parent.horizontalCenter
textFormat: Text.PlainText
color: mc.colorValue("user/textColor")
// font.pixelSize: 12
}
MyButton {
id: myButton1
y: 451
width: parent.width/4
height: width/2
text: qsTr("Cancel")
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
onClicked: root.destroy()
}
MyButton {
id: myButton2
x: 459
y: 466
width: parent.width/4
height: width/2
text: qsTr("Choose")
anchors.verticalCenter: myButton1.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 0
onClicked:{ root.chooseFile(ftype, fd.currentPath+"/"+fd.fileModel[listView1.currentIndex].name); root.destroy(); }
}
ListView {
id: listView1
flickDeceleration: 3000
maximumFlickVelocity: 8000
clip: true
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: myButton1.top
anchors.bottomMargin: 10
anchors.top: text1.bottom
anchors.topMargin: 10
model: fd.fileModel
delegate: Image{
id: listItem
height: listView1.height/9
width: listView1.width
source: "image://ThemeProvider/itembg"
opacity: ListView.isCurrentItem ? 1.0:0.7
MouseArea {
anchors.fill: parent
onClicked: {listView1.currentIndex = index; fd.singlePress(model.modelData.name); }
}
Image {
id: icon
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: listItem.height/10
width: height
asynchronous: true
cache: false
source: "image://FileImageProvider/"+fd.currentPath+"/"+model.modelData.name
}
Text {
text: model.modelData.name
color: mc.colorValue("user/textColor")
height: parent.height*2/3
font.pixelSize: height*4/7
anchors.left: icon.right
anchors.verticalCenter: parent.verticalCenter
}
}
}
}