2
import Ubuntu.Components 1.1
4
import Ubuntu.Content 0.1
5
import Ubuntu.Components.Popups 1.0
10
\brief MainView with Tabs element.
11
First Tab has a single Label and
12
second Tab has a single ToolbarAction.
16
// objectName for functional testing purposes (autopilot-qt5)
17
objectName: "mainView"
19
// Note! applicationName needs to match the "name" field of the click manifest
20
applicationName: "com.ubuntu.developer.pawstr.edit"
23
This property enables the application to change orientation
24
when the device is rotated. The default is false.
26
//automaticOrientation: true
28
// Removes the old toolbar and enables new features of the new header.
29
useDeprecatedToolbar: false
31
anchorToKeyboard: true
36
property string infoText: ""
43
anchors.centerIn: parent
48
onClicked: PopupUtils.close(po)
54
onTriggered: PopupUtils.close(po)
61
function moveFile(item,dir) {
62
var initialUrl = item.url;
64
if(fileIO.isWritable(dir)) {
65
if(item.url === initialUrl) {
66
var name = fileIO.getFileName(initialUrl);
67
var suffix = fileIO.getSuffix(initialUrl);
71
item.move(dir, name + "(" + i + ")" + "." + suffix);
72
} while(item.url === initialUrl);
73
showInfo("Couldn't overwrite.\nSaved as " + name + "(" + i + ")" + "." + suffix)
74
root.title = fileIO.getFullName(root.importItems[0].url)
78
showInfo("Location isn't writable")
81
function saveFile(item,dir) {
83
PopupUtils.open(saveAsDialog)
85
var newFileName = "file://" + dir + fileIO.getFullName(item.url);
86
if(newFileName != item.url || !fileIO.write(newFileName, textArea.text)) {
88
fileIO.write(item.url, textArea.text);
95
function showInfo(info) {
96
infoText = "\n" + info + "\n";
97
PopupUtils.open(popover);
102
Component.onCompleted: pageStack.push(root)
107
root.activeTransfer = transfer;
108
console.log ("onExportRequested: " + root.activeTransfer.state);
114
title: i18n.tr("edIt")
121
property list<ContentItem> importItems: [ContentItem{url: ""}]
122
property var fileList;
123
property var activeTransfer;
124
property bool saved: true
126
NewFileDialog {id: newFileDialog}
127
UnsavedDialog {id: unsavedDialog}
128
SaveAsDialog {id: saveAsDialog }
130
tools: Toolbar{id: toolbar}
143
textFormat: TextEdit.AutoText
144
inputMethodHints: Qt.ImhMultiLine | Qt.ImhNoPredictiveText
146
onTextChanged: root.saved = false;
149
ContentTransferHint {
152
activeTransfer: root.activeTransfer
155
target: root.activeTransfer
157
if (root.activeTransfer.state === ContentTransfer.Charged &&
158
root.activeTransfer.direction === ContentTransfer.Import) {
159
root.importItems = root.activeTransfer.items;
161
textArea.text = fileIO.read(root.importItems[0].url);
162
root.title = fileIO.getFullName(root.importItems[0].url);
168
Settings {id: settings}
169
LocalFilePicker {id: localFilePicker}
176
visible: parent.visible
178
// Type of handler: Source, Destination, or Share
179
handler: ContentHandler.Source
180
// well know content type
181
contentType: ContentType.Documents
184
peer.selectionType = ContentTransfer.Single;
185
root.activeTransfer = peer.request();
188
onCancelPressed: pageStack.pop()
195
// property var curTransfer
197
// property var handler: ContentHandler.Destination
198
// property alias contentType: exportPeerPicker.contentType
200
// function __exportItems(url) {
201
// if (exportPicker.curTransfer.state === ContentTransfer.InProgress)
203
// exportPicker.curTransfer.items = [ resultComponent.createObject(root, {"url": url}) ];
204
// exportPicker.curTransfer.state = ContentTransfer.Charged;
208
// ContentPeerPicker {
209
// id: exportPeerPicker
211
// visible: parent.visible
212
// contentType: ContentType.Documents
213
// handler: exportPicker.handler
216
// exportPicker.curTransfer = peer.request();
218
// if (exportPicker.curTransfer.state === ContentTransfer.InProgress)
219
// exportPicker.__exportItems(exportPicker.url);
221
// onCancelPressed: pageStack.pop()
224
// target: exportPicker.curTransfer
226
// console.log("curTransfer StateChanged: " + exportPicker.curTransfer.state);
227
// if (exportPicker.curTransfer.state === ContentTransfer.InProgress)
229
// exportPicker.__exportItems(exportPicker.url);