-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.qml
179 lines (151 loc) · 5.42 KB
/
App.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import QtQuick
import QtQuick.Controls.Basic
import QtQuick.Layouts
import DivView
ApplicationWindow {
id: root
width: 1100
height: 600
visible: true
flags: Qt.Window | Qt.FramelessWindowHint
title: qsTr("Qt Quick Controls 2 - File System Explorer")
property string currentFilePath: ""
property bool expandPath: false
menuBar: MyMenuBar {
rootWindow: root
infoText: currentFilePath
? (expandPath
? currentFilePath
: currentFilePath.substring(currentFilePath.lastIndexOf("/") + 1, currentFilePath.length))
: "File System Explorer"
MyMenu {
title: qsTr("File")
Action {
text: qsTr("Increase Font")
shortcut: "Ctrl++"
onTriggered: textArea.font.pixelSize += 1
}
Action {
text: qsTr("Decrease Font")
shortcut: "Ctrl+-"
onTriggered: textArea.font.pixelSize -= 1
}
Action {
text: expandPath ? qsTr("Toggle Short Path") : qsTr("Toggle Expand Path")
enabled: currentFilePath
onTriggered: expandPath = !expandPath
}
Action {
text: qsTr("Exit")
onTriggered: Qt.exit(0)
}
}
MyMenu {
title: qsTr("Edit")
Action {
text: qsTr("Cut")
shortcut: StandardKey.Cut
enabled: textArea.selectedText.length > 0
onTriggered: textArea.cut()
}
Action {
text: qsTr("Copy")
shortcut: StandardKey.Copy
enabled: textArea.selectedText.length > 0
onTriggered: textArea.copy()
}
Action {
text: qsTr("Paste")
shortcut: StandardKey.Paste
enabled: textArea.canPaste
onTriggered: textArea.paste()
}
Action {
text: qsTr("Select All")
shortcut: StandardKey.SelectAll
enabled: textArea.length > 0
onTriggered: textArea.selectAll()
}
Action {
text: qsTr("Undo")
shortcut: StandardKey.Undo
enabled: textArea.canUndo
onTriggered: textArea.undo()
}
}
}
Rectangle {
anchors.fill: parent
color: Colors.background
RowLayout {
anchors.fill: parent
spacing: 0
Sidebar {
id: sidebar
rootWindow: root
Layout.preferredWidth: 60
Layout.fillHeight: true
}
SplitView {
Layout.fillWidth: true
Layout.fillHeight: true
handle: Rectangle {
implicitWidth: 10
color: SplitHandle.pressed ? Colors.color2 : Colors.background
border.color: Colors.color2
opacity: SplitHandle.hovered || SplitHandle.pressed ? 1.0 : 0.0
Behavior on opacity {
OpacityAnimator {
duration: 900
}
}
}
component MyTextArea: TextArea {
antialiasing: true
color: Colors.textFile
selectedTextColor: Colors.textFile
selectionColor: Colors.selection
renderType: Text.QtRendering
textFormat: TextEdit.PlainText
background: null
}
Rectangle {
color: Colors.surface1
SplitView.preferredWidth: 250
SplitView.fillHeight: true
StackLayout {
currentIndex: sidebar.currentTabIndex
anchors.fill: parent
MyTextArea {
readOnly: true
text: qsTr("This example shows how to use and visualize the file system.\n\n"
+ "Customized Qt Quick Components have been used to achieve this look.\n\n"
+ "You can edit the files but they won't be changed on the file system.\n\n"
+ "Click on the folder icon to the left to get started.")
wrapMode: TextArea.Wrap
}
FileSystemView {
id: fileSystemView
color: Colors.surface1
onFileClicked: (path) => root.currentFilePath = path
}
}
}
ScrollView {
leftPadding: 20
topPadding: 20
bottomPadding: 20
clip: true
SplitView.fillWidth: true
SplitView.fillHeight: true
property alias textArea: textArea
MyTextArea {
id: textArea
text: FileSystemModel.readFile(root.currentFilePath)
}
}
}
}
ResizeButton {}
}
}