-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditor.qml
More file actions
153 lines (146 loc) · 3.85 KB
/
Copy pathEditor.qml
File metadata and controls
153 lines (146 loc) · 3.85 KB
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
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
ApplicationWindow {
id: root
visible: true
width: 700
height: 600
title: "App JSON Editor"
property bool isNew: false
signal saveApp(var appdata)
property string name: ""
property string path: ""
property string execName: ""
property string desc: ""
property string icon: ""
property string tabName: ""
FileDialog {
id: pathDialog
title: "Select Application Folder"
fileMode: FileDialog.Directory
onAccepted: root.path = fileUrl.toString().replace("file://", "")
}
FileDialog {
id: execDialog
title: "Select Executable"
fileMode: FileDialog.OpenFile
onAccepted: root.execName = fileUrl.toString().split("/").pop()
}
FileDialog {
id: iconDialog
title: "Select Icon"
fileMode: FileDialog.OpenFile
nameFilters: ["Images (*.png *.jpg *.svg)"]
onAccepted: root.icon = fileUrl.toString().replace("file://", "")
}
function loadApp(appName) {
var app = appModel.getApp(appName);
name = app.name || appName;
path = app.path || "";
execName = app.execName || "";
desc = app.desc || "";
icon = app.icon || "";
tabName = app.tabName || "";
}
function clearFields() {
name = "";
path = "";
execName = "";
desc = "";
icon = "";
tabName = "";
}
ColumnLayout {
spacing: 4
anchors.fill: parent
RowLayout {
Label {
text: "Name:"
}
TextField {
text: root.name
onTextChanged: root.name = text
Layout.fillWidth: true
}
}
RowLayout {
Label {
text: "Path:"
}
TextField {
text: root.path
onTextChanged: root.path = text
Layout.fillWidth: true
}
Button {
text: "..."
onClicked: pathDialog.open()
}
}
RowLayout {
Label {
text: "Executable:"
}
TextField {
text: root.execName
onTextChanged: root.execName = text
Layout.fillWidth: true
}
Button {
text: "..."
onClicked: execDialog.open()
}
}
RowLayout {
Label {
text: "Icon:"
}
TextField {
text: root.icon
onTextChanged: root.icon = text
Layout.fillWidth: true
}
Button {
text: "..."
onClicked: iconDialog.open()
}
}
RowLayout {
Label {
text: "Tab:"
}
TextField {
text: root.tabName
onTextChanged: root.tabName = text
Layout.fillWidth: true
}
}
RowLayout {
Label {
text: "Description:"
}
TextEdit {
text: root.desc
onTextChanged: root.desc = text
Layout.fillWidth: true
wrapMode: TextEdit.WordWrap
}
}
Button {
text: root.isNew ? "Add App" : "Save Changes"
onClicked: {
saveApp({
name: root.name,
path: root.path,
execName: root.execName,
desc: root.desc,
icon: root.icon,
tabName: root.tabName
});
}
Layout.alignment: Qt.AlignRight
}
}
}