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)
116 init(prop); pageStack.prevPage().init();
117 tip.show(qsTr("File renamed!"));
120 function onErrRename(status)
125 function onRespStopPublishing(prop)
128 init(prop); pageStack.prevPage().init();
129 tip.show(qsTr("Publishing stopped!"));
132 function onErrStopPublishing(status)
137 function onRespStartPublishing(prop)
140 init(prop); pageStack.prevPage().init();
141 tip.show(qsTr("Publishing started!"));
144 function onErrStartPublishing(status)
152 contentHeight: content.height+Const.TOP_BAR_HEIGHT+Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
153 y: Const.TOP_BAR_HEIGHT
157 spacing: Const.DEFAULT_MARGIN
163 text: qsTr("File name:")
170 width: root.width - 6*Const.DEFAULT_MARGIN
173 width: root.width-2*Const.TEXT_MARGIN
187 width: root.width-2*Const.TEXT_MARGIN
192 text: qsTr("Created:")
200 width: root.width-2*Const.TEXT_MARGIN
205 text: qsTr("Changed:")
213 width: root.width-2*Const.TEXT_MARGIN
214 visible: root.isPublic
219 text: qsTr("Public URL:")
220 visible: root.isPublic
227 width: root.width - 6*Const.DEFAULT_MARGIN
228 visible: root.isPublic
233 visible: root.isPublic
235 Utils.setClipboardText(url.text);
236 tip.show(qsTr("Public URL copied to clipboard!"));
247 folder: Utils.lastFolder()=="" ? Const.DEFAULT_FOLDER : Utils.lastFolder()
250 fileSelector.close();
251 U1.getFileContent(secrets,root,properties.content_path,folder,properties.size,Utils);
252 Utils.setLastFolder(folder);
260 text: qsTr("Delete file?")
261 onOpened: mask.state = "dialog"
266 U1.deleteFile(secrets,properties.resource_path,root,Utils);
269 onCanceled: mask.state = "idle"
273 id: dialogStopPublish
275 text: qsTr("Stop publishing?")
276 onOpened: mask.state = "dialog"
281 var currentPath = root.properties.resource_path;
282 U1.stopPublishing(root.secrets,currentPath,root);
285 onCanceled: mask.state = "idle"
289 id: dialogStartPublish
291 text: qsTr("Start publishing?")
292 onOpened: mask.state = "dialog"
297 var currentPath = root.properties.resource_path;
298 U1.startPublishing(root.secrets,currentPath,root);
301 onCanceled: mask.state = "idle"
305 function getParentPath(path) {
307 var ind = path.lastIndexOf("/");
309 ppath = path.substr(0,ind);
311 if(path=="") ppath = "/";
316 var l=0; var r=s.length -1;
317 while(l < s.length && s[l] == ' ')
319 while(r > l && s[r] == ' ')
321 return s.substring(l, r+1);
327 textWidth: root.width - 4*Const.DEFAULT_MARGIN
328 label: qsTr("Enter new file name:")
329 placeholderText: filename.text
332 mask.state = "dialog";
339 var currentPath = root.properties.resource_path;
340 var targetPath = getParentPath(root.properties.path)+"/"+resp;
341 U1.renameFile(secrets,currentPath,targetPath,root);;
343 tip.show(qsTr("Invalid file name!"))
356 menuDynamic: _menuDyn
357 menuHeight: menuDynamic.height+menuFixed.height+7*Const.DEFAULT_MARGIN
362 y: root.height-taskMenu.menuHeight-Const.SYSTEM_BAR_HEIGHT+2*Const.DEFAULT_MARGIN
363 x: Const.DEFAULT_MARGIN
365 width: parent.width-2*Const.DEFAULT_MARGIN
366 spacing: Const.DEFAULT_MARGIN
369 label: qsTr("Download");
377 label: qsTr("Publish");
381 dialogStopPublish.open();
383 dialogStartPublish.open();
389 label: qsTr("Rename");
397 label: qsTr("Delete");