1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
3 import "UIConstants.js" as Const
4 import "ISOdate.js" as ISOdate
5 import "bytesconv.js" as Conv
12 property variant secrets
13 property variant properties
14 property bool isPublic
16 property alias taskMenu: taskMenu
19 [qsTr("Download"),false],
20 [qsTr("Publish"),false],
21 [qsTr("Rename"),false],
22 [qsTr("Delete"),false]
25 function menuFun(id) {
26 if(id==qsTr("Download")) {
27 fileSelector.state = "visible";
29 if(id==qsTr("Publish")) {
31 dialogStopPublish.open();
33 dialogStartPublish.open();
36 if(id==qsTr("Rename")) {
39 if(id==qsTr("Delete")) {
48 tip.show(qsTr("File deleted!"));
50 pageStack.currentPage.init();
55 tip.show(qsTr("Ubuntu One authorization has failed. Try once again or check login settings."));
57 tip.show(qsTr("Unknown error: ")+status);
66 secret: Utils.tokenSecret(),
67 consumer_key : Utils.customerKey(),
68 consumer_secret: Utils.customerSecret()
72 var name = U1.fixFilename(prop.path);
75 var crd = new Date(); crd.setISO8601(prop.when_created);
76 var chd = new Date(); chd.setISO8601(prop.when_changed);
77 created.text = Qt.formatDateTime(crd, "d/M/yyyy h:mm");
78 changed.text = Qt.formatDateTime(chd, "d/M/yyyy h:mm");
79 size.text = Conv.bytesToSize(prop.size);
80 if(prop && prop.is_public) {
81 url.text = prop.public_url;
85 tip.show(qsTr("Internal error!"));
87 root.properties = prop;
88 if(root.properties && root.properties.is_public) {
91 root.isPublic = false;
95 function setContentType(type)
98 //ctype.font.italic = false;
101 function onErr(status)
105 tip.show(qsTr("Ubuntu One authorization has failed. Try once again or check login settings."));
106 } else if(status==0) {
107 tip.show(qsTr("Unable to connect. Check internet connection."));
109 tip.show(qsTr("Unknown error: ")+status);
113 function onRespRename(prop)
115 //console.log("onRespRename");
117 init(prop); pageStack.prevPage().init();
118 tip.show(qsTr("File renamed!"));
121 function onErrRename(status)
126 function onRespStopPublishing(prop)
128 //console.log("onRespStopPublishing");
130 init(prop); pageStack.prevPage().init();
131 tip.show(qsTr("Publishing stopped!"));
134 function onErrStopPublishing(status)
139 function onRespStartPublishing(prop)
141 //console.log("onRespStartPublishing");
143 init(prop); pageStack.prevPage().init();
144 tip.show(qsTr("Publishing started!"));
147 function onErrStartPublishing(status)
155 contentHeight: content.height+Const.TOP_BAR_HEIGHT+Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
156 y: Const.TOP_BAR_HEIGHT
160 spacing: Const.DEFAULT_MARGIN
166 text: qsTr("File name:")
173 width: root.width - 6*Const.DEFAULT_MARGIN
176 width: root.width-2*Const.TEXT_MARGIN
190 width: root.width-2*Const.TEXT_MARGIN
195 text: qsTr("Created:")
203 width: root.width-2*Const.TEXT_MARGIN
208 text: qsTr("Changed:")
216 width: root.width-2*Const.TEXT_MARGIN
217 visible: root.isPublic
222 text: qsTr("Public URL:")
223 visible: root.isPublic
230 width: root.width - 6*Const.DEFAULT_MARGIN
231 visible: root.isPublic
236 visible: root.isPublic
238 Utils.setClipboardText(url.text);
239 tip.show(qsTr("Public URL copied to clipboard!"));
246 text: qsTr("Preview:")
249 color: Const.TRANSPARENT
250 height: 200; width: 200
251 border.color: Const.DEFAULT_FOREGROUND_COLOR
265 folder: Utils.lastFolder()=="" ? Const.DEFAULT_FOLDER : Utils.lastFolder()
267 fileSelector.state = "invisible";
268 U1.getFileContent(secrets,root,properties.content_path,folder,properties.size,Utils);
269 Utils.setLastFolder(folder);
277 folder: Utils.lastFolder()=="" ? Const.DEFAULT_FOLDER : Utils.lastFolder()
280 fileSelector.close();
281 U1.getFileContent(secrets,root,properties.content_path,folder,properties.size,Utils);
282 Utils.setLastFolder(folder);
290 text: qsTr("Delete file?")
291 onOpened: mask.state = "dialog"
296 U1.deleteFile(secrets,properties.resource_path,root,Utils);
299 onCanceled: mask.state = "idle"
303 id: dialogStopPublish
305 text: qsTr("Stop publishing?")
306 onOpened: mask.state = "dialog"
311 var currentPath = root.properties.resource_path;
312 U1.stopPublishing(root.secrets,currentPath,root);
315 onCanceled: mask.state = "idle"
319 id: dialogStartPublish
321 text: qsTr("Start publishing?")
322 onOpened: mask.state = "dialog"
327 var currentPath = root.properties.resource_path;
328 U1.startPublishing(root.secrets,currentPath,root);
331 onCanceled: mask.state = "idle"
335 function getParentPath(path) {
338 var ind = path.lastIndexOf("/");
340 ppath = path.substr(0,ind);
342 if(path=="") ppath = "/";
344 //console.log(ppath);
349 var l=0; var r=s.length -1;
350 while(l < s.length && s[l] == ' ')
352 while(r > l && s[r] == ' ')
354 return s.substring(l, r+1);
360 textWidth: root.width - 4*Const.DEFAULT_MARGIN
361 label: qsTr("Enter new file name:")
362 placeholderText: filename.text
365 Utils.setOrientation("auto");
366 mask.state = "dialog";
370 Utils.setOrientation(root.orientation);
374 var currentPath = root.properties.resource_path;
375 var targetPath = getParentPath(root.properties.path)+"/"+resp;
376 //console.log("targetPath: "+targetPath);
377 U1.renameFile(secrets,currentPath,targetPath,root);;
379 tip.show(qsTr("Invalid file name!"))
383 Utils.setOrientation(root.orientation);
390 [qsTr("Download"),false],
391 [qsTr("Publish"),false],
392 [qsTr("Rename"),false],
393 [qsTr("Delete"),false]
396 function menuFun(id) {
397 if(id==qsTr("Download")) {
398 fileSelector.state = "visible";
400 if(id==qsTr("Publish")) {
402 dialogStopPublish.open();
404 dialogStartPublish.open();
407 if(id==qsTr("Rename")) {
410 if(id==qsTr("Delete")) {
420 menuDynamic: _menuDyn
421 menuHeight: menuDynamic.height+menuFixed.height+7*Const.DEFAULT_MARGIN
426 y: root.height-taskMenu.menuHeight-Const.SYSTEM_BAR_HEIGHT+2*Const.DEFAULT_MARGIN
427 x: Const.DEFAULT_MARGIN
429 width: parent.width-2*Const.DEFAULT_MARGIN
430 spacing: Const.DEFAULT_MARGIN
433 label: qsTr("Download");
441 label: qsTr("Publish");
445 dialogStopPublish.open();
447 dialogStartPublish.open();
453 label: qsTr("Rename");
461 label: qsTr("Delete");