-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.qml
134 lines (116 loc) · 3.28 KB
/
main.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
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQuick.Dialogs 1.2
import com.company.backend 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Backend {
id: backend
onPathChanged: console.log("Path:", path)
onDataChanged: console.log("Path:", path)
}
FileDialog {
id: openDialog
title: "Please choose a file"
folder: shortcuts.home
selectMultiple: false
selectExisting: true
onAccepted: {
backend.path = openDialog.fileUrl
editor.text = backend.data
}
}
FileDialog {
id: saveDialog
title: "Please choose a file"
folder: shortcuts.home
selectMultiple: false
selectExisting: false
onAccepted: {
backend.path = saveDialog.fileUrl
backend.data = editor.text
}
}
Action {
id: actionNew
text: qsTr("New")
icon.color: "transparent"
icon.source: "qrc:/flat/outlines/oNew.png"
onTriggered: editor.clear()
}
Action {
id: actionOpen
text: qsTr("Open")
icon.color: "transparent"
icon.source: "qrc:/flat/outlines/oOpen.png"
onTriggered: openDialog.open()
}
Action {
id: actionSave
text: qsTr("Open")
icon.color: "transparent"
icon.source: "qrc:/flat/outlines/oSave.png"
onTriggered: saveDialog.open()
}
Action {
id: actionCopy
text: qsTr("Copy")
icon.color: "transparent"
icon.source: "qrc:/flat/outlines/oCopy.png"
onTriggered: editor.copy()
}
Action {
id: actionCut
text: qsTr("Cut")
icon.color: "transparent"
icon.source: "qrc:/flat/outlines/oCut.png"
onTriggered: editor.cut()
}
Action {
id: actionPaste
text: qsTr("Paste")
icon.color: "transparent"
icon.source: "qrc:/flat/outlines/oPaste.png"
onTriggered: editor.paste()
}
menuBar: MenuBar {
Menu {
id: menuFile
title: qsTr("File")
MenuItem { action: actionNew }
MenuItem { action: actionOpen }
MenuItem { action: actionSave }
}
Menu {
id: menuEdit
title: qsTr("Edit")
MenuItem { action: actionCopy }
MenuItem { action: actionCut }
MenuItem { action: actionPaste }
}
}
header: ToolBar {
Row {
ToolButton {display: AbstractButton.IconOnly; action: actionNew}
ToolButton {display: AbstractButton.IconOnly; action: actionOpen}
ToolButton {display: AbstractButton.IconOnly; action: actionSave}
ToolButton {display: AbstractButton.IconOnly; action: actionCopy}
ToolButton {display: AbstractButton.IconOnly; action: actionCut}
ToolButton {display: AbstractButton.IconOnly; action: actionPaste}
}
}
ScrollView {
anchors.fill: parent
TextArea {
id: editor
focus: true
text: "Hello World"
selectByMouse: true
persistentSelection: true //copy and paste need this!
}
}
}