Merge lp:~nikwen/ubuntu-filemanager-app/zips into lp:ubuntu-filemanager-app

Proposed by Niklas Wenzel
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 320
Merged at revision: 333
Proposed branch: lp:~nikwen/ubuntu-filemanager-app/zips
Merge into: lp:ubuntu-filemanager-app
Diff against target: 733 lines (+432/-44)
11 files modified
debian/control (+11/-0)
debian/qtdeclarative5-archives0.1.install (+1/-0)
po/com.ubuntu.filemanager.pot (+75/-44)
src/app/qml/ui/FolderListPage.qml (+133/-0)
src/plugin/CMakeLists.txt (+1/-0)
src/plugin/archives/CMakeLists.txt (+35/-0)
src/plugin/archives/archives.cpp (+57/-0)
src/plugin/archives/archives.h (+44/-0)
src/plugin/archives/archives_plugin.cpp (+34/-0)
src/plugin/archives/archives_plugin.h (+39/-0)
src/plugin/archives/qmldir (+2/-0)
To merge this branch: bzr merge lp:~nikwen/ubuntu-filemanager-app/zips
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Needs Fixing
Niklas Wenzel (community) Approve
Carlos Jose Mazieri Approve
Arto Jalkanen Approve
Review via email: mp+239662@code.launchpad.net

Commit message

Add the ability to extract zip files. Like the ubuntu-download-manager this uses the unzip command line tool to extract the archives (http://bazaar.launchpad.net/~phablet-team/ubuntu-download-manager/trunk/revision/325).

Description of the change

Add the ability to extract zip files. Like the ubuntu-download-manager this uses the unzip command line tool to extract the archives (http://bazaar.launchpad.net/~phablet-team/ubuntu-download-manager/trunk/revision/325).

To post a comment you must log in.
Revision history for this message
Niklas Wenzel (nikwen) wrote :

This one should contain all new files now. :)

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

I have freshly updated image (r299) and I don't have unzip on my phone. So I can't say this or that to this merge request for now, perhaps it's coming in a later image?

Other than that, I'm just pondering... might it be more logical to have an Archiver application, that would register itself for Content-Hub for archives. Then clicking on a zip/tar/tar.gz file could have as target the Archiver where you could extract it. That way archives could be handled from other apps also not just from File Manager. I'm not sure how well Content-Hub is suited for such scenario, so this is just me thinking aloud.

review: Needs Information
Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

Hello guys,

How about having all open files stuff available to all applications not only for file manager?

It could be part of Content-Hub or a separated module, as Qt provides Qt::openUrlExternally() we would have something similar as Ubuntu API, so all applications can open files just calling one method.

review: Needs Information
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

unzip landed in the rtm image back on 16th Oct. See http://people.canonical.com/~ogra/touch-image-stats/rtm/112.changes

I'd recommend re-flashing (without wiping) your device using the "ubuntu-touch/ubuntu-rtm/14.09-proposed" channel.

Something like this should do it:-

ubuntu-device-flash --channel=ubuntu-touch/ubuntu-rtm/14.09-proposed

As an aside I'll find out why it didn't land in devel-proposed.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

With Alan Pope's instructions I got this branch working. Thanks a lot for the good work!

Is it possible to add a "cancel" button to the dialog where it's extracting files? Doing a call on external programs there's always a chance that things get stuck for a variety of reasons. Being able to cancel the operation in such situations is much preferable compared to user having to kill whole FileManager and starting anew.

But if the above suggestion is too much work for this merge proposal, I'll happily approve the current one. It's a great feature.

The image contains many more possibilities for extracting files, containing at least tar, gunzip and bzip2. After this commit lands to trunk I will file bugs to add support for more supported archives. If you can work on those too that'd be just great.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thank you very much for reviewing this.
A cancel button looks like a good addition. I won't be able to look into this before the weekend but then I'll finally do it. I'll check how easy aborting a QProccess is.
I planned to enable extracting for more archive types anyway but I first wanted to make sure this one gets merged. Expect me to do some work on that matter. ;)

Some time ago, I looked into building an archiver application to push to the store as well but that proved to be fairly difficult as running commands like "unzip" or "tar" requires the application to run unconfined. One would therefore have to write a wrapper for respective Qt libraries so adding this functionality to the file manager seemed to be easier.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Just found a close() function so it should be possible: http://qt-project.org/doc/qt-5/qprocess.html#close

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> Just found a close() function so it should be possible: http://qt-
> project.org/doc/qt-5/qprocess.html#close

Great! If you can try to include that cancel into this merge request, that would be awesome. If it's not straightforward and requires more time then do comment and we'll merge this as it is, and you can continue on another branch on the cancel button.

Regarding the Content-Hub stuff me and Carlos were talking about. I think that would be better, but since it's not clear how well Content-Hub is suited for this kind of stuff it's probably best to leave for future to ponder about.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Hi, I'm sorry to say that but I didn't have the time to work on the cancel button (well, to do any coding) this weekend. I'll try to do it as soon as possible but I'll probably not be able to do it before next weekend.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> Hi, I'm sorry to say that but I didn't have the time to work on the cancel
> button (well, to do any coding) this weekend. I'll try to do it as soon as
> possible but I'll probably not be able to do it before next weekend.

Thanks for the heads-up! Let's approve this change, and when you have time to work on the cancel button that would be a great improvement.

Thank you!

review: Approve
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thanks for approving this. I will for sure look into adding a cancel button and into adding more archive formats like tars as soon as I have time for that. :)

Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

OK. Let's release one more improvement to the filemanager.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~nikwen/ubuntu-filemanager-app/zips/+merge/239662/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Rerun autolanding

review: Approve
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Hm, the comment above says the following: "You can approve the merge proposal yourself to rerun."
However, autolanding hasn't been rerun yet. Does anyone know how to trigger that properly?

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Needs top-level approve I think to rerun the tests. Done, let's see what happens.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ah, thanks for doing this. I've never contributed code to the core apps before so I didn't know that.
Did I break the tests with my changes or have they been broken before as well?

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Can someone with autopilot/Jenkins test experience help with that? It seems like a newQML plugin "Archives" is not detected when running Jenkins. It's nevertheless built without problems locally.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

@ajalkane: Would you mind retriggering the tests by doing another top-level approve? I don't seem to have the rights to do this.
The reason why I didn't look into this earlier was that I didn't find the test logs before...

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Oh, sorry. I forgot to add a file. I'll add it now.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

There you go. ;)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ah, great. At least that worked now. Still two tests to fix though. I'll look into them later. ;)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Does anyone know what was wrong with the tests? I've never done automatic testing before and haven't managed to get the tests to run on my device. Anyone who could help me with that?
I just merged trunk as well. Maybe that will fix the tests. Would require another top-level approve to run them again though...

Thank you for your patience. :)

Revision history for this message
Arto Jalkanen (ajalkane) wrote :
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Looks like the test failures show 'cut'-ing a file brings up the extract archive prompt, which it shouldn't.

review: Needs Fixing
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I would also like to see some tests added to support this new functionality. Ideally the tests would extract and verify a zip, but at least running through the menu options would be good.

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ah, thank you very much for looking into this. That's something which I should be able to fix and I think I know why it happens. There is some strange behaviour regarding the visible attribute of an Action in an ActionList. Let me have a look at it this weekend. ;)

Regarding tests for archive extraction: I've never worked with autopilot before and, sadly, I don't have enough time to learn about automatic testing at the moment. (I'd love to do so much more coding but I can't...)
So if you really need them, someone else will have to do it for now.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> Ah, thank you very much for looking into this. That's something which I should
> be able to fix and I think I know why it happens. There is some strange
> behaviour regarding the visible attribute of an Action in an ActionList. Let
> me have a look at it this weekend. ;)

Thanks!

> Regarding tests for archive extraction: I've never worked with autopilot
> before and, sadly, I don't have enough time to learn about automatic testing
> at the moment. (I'd love to do so much more coding but I can't...)
> So if you really need them, someone else will have to do it for now.

That's understandable. If you can fix it so that existing tests run, maybe we can file a bug about the missing test cases for later implementation if that's okay with all parties?

Revision history for this message
Niklas Wenzel (nikwen) wrote :

I think my latest commit should fix the issue for now. It's actually a workaround since the bug is in the code for the ActionSelectionPopover. It doesn't set the visible property of the list items to false according to the visible property of the Action.
I'll file a bug and submit a merge proposal to upstream tomorrow. Please don't approve that change until then so that I can add the issue and MP links to the comment in the code. ;)

Thanks. :)

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Can you link the bug you worked around in source please?

Revision history for this message
Niklas Wenzel (nikwen) wrote :

> Can you link the bug you worked around in source please?

That's exactly what I wanted to do. I just filed the bug report, created a merge proposal for the UI Toolkit and adjusted the comment (as well as the workaround code so that it's like in the other MP).
Could someone please do a top-level approve again to see whether it passes the tests? I think it will.
Thanks to all of you for your help and patience. :)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
320. By Niklas Wenzel

Fixed variable name

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ah, sorry. I forgot to change a variable name when copying the workaround code into the filemanager code.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thanks for approving it again. I'm glad it finally passed the tests.
Why is its status still "Needs review"? May I change it to "Approved"? (I do now have the ability to do that for some reason.)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ah, I know why I am able to approve this now if I want to. For some reason I was added to the "Ubuntu Core Apps Test Writers" team which makes me an indirect member of the file manager app team.
Nicholas, would you mind telling me why I was added to that team (not that I want to leave it :p)?

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Niklas I added you to the team so jenkins would automatically build things for you. You've helped out in several core apps, it makes sense to have jenkins autorun on your mp's :-)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thank you very much, Nicholas. I really appreciate it. :)

My other question still remains though: Is there still anything missing to get this merged? Or will it be done automatically later?

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> My other question still remains though: Is there still anything missing to get
> this merged?

Nope, I will try top-approving again and it should get merged if there's no issues.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> My other question still remains though: Is there still anything missing to get
> this merged?

Nope, I will try top-approving again and it should get merged if there's no issues.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ok, great. So it was finally merged. :)
I'll file issues for missing features in the extraction process (like the cancel button or other archive types) tomorrow and assign as many as I can deal with to me.

Thank you very, very much. :)

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

No, thank you very much for your great contributions to make File Manager better! I'm very happy that this gets now merged.

Hopeful to see more contributions when you have the time, and it's a big help even if it's filing bug reports as then we have something concrete to track on!

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ok, I didn't have the time today to file those bugs but I will definitely do that as soon as possible.
For now, there's the MP for extracting tar archives. ;)
https://code.launchpad.net/~nikwen/ubuntu-filemanager-app/tars/+merge/240986

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-09-04 02:37:45 +0000
3+++ debian/control 2014-11-23 14:40:50 +0000
4@@ -24,6 +24,7 @@
5 qtdeclarative5-nemo-qml-plugin-folderlistmodel,
6 qtdeclarative5-placesmodel0.1,
7 qtdeclarative5-pamauthentication0.1,
8+ qtdeclarative5-archives0.1,
9 qtdeclarative5-qtquick2-plugin,
10 qtdeclarative5-u1db1.0,
11 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
12@@ -64,6 +65,16 @@
13 This package contains a plugin that enables QML apps to do
14 password authentication via the PAM API.
15
16+Package: qtdeclarative5-archives0.1
17+Architecture: any
18+Multi-Arch: same
19+Depends: ${misc:Depends},
20+ ${shlibs:Depends},
21+ ${misc:Pre-Depends},
22+Description: Archives QML plugin
23+ This package contains a plugin that enables QML apps to extract
24+ archive files.
25+
26 Package: ubuntu-filemanager-app-autopilot
27 Architecture: all
28 Depends: ${misc:Depends},
29
30=== added file 'debian/qtdeclarative5-archives0.1.install'
31--- debian/qtdeclarative5-archives0.1.install 1970-01-01 00:00:00 +0000
32+++ debian/qtdeclarative5-archives0.1.install 2014-11-23 14:40:50 +0000
33@@ -0,0 +1,1 @@
34+usr/lib/*/qt5/qml/com/ubuntu/Archives/
35
36=== modified file 'po/com.ubuntu.filemanager.pot'
37--- po/com.ubuntu.filemanager.pot 2014-11-19 21:03:49 +0000
38+++ po/com.ubuntu.filemanager.pot 2014-11-23 14:40:50 +0000
39@@ -8,7 +8,7 @@
40 msgstr ""
41 "Project-Id-Version: \n"
42 "Report-Msgid-Bugs-To: \n"
43-"POT-Creation-Date: 2014-11-19 21:32+0100\n"
44+"POT-Creation-Date: 2014-11-23 15:38+0100\n"
45 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
46 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
47 "Language-Team: LANGUAGE <LL@li.org>\n"
48@@ -31,7 +31,7 @@
49 msgstr ""
50
51 #: ../src/app/qml/components/PathHistoryRow.qml:84
52-#: ../src/app/qml/ui/FolderListPage.qml:620
53+#: ../src/app/qml/ui/FolderListPage.qml:753
54 msgid "Device"
55 msgstr ""
56
57@@ -44,7 +44,7 @@
58 msgid "Open with"
59 msgstr ""
60
61-#: ../src/app/qml/filemanager.qml:81 ../src/app/qml/ui/FolderListPage.qml:102
62+#: ../src/app/qml/filemanager.qml:81 ../src/app/qml/ui/FolderListPage.qml:103
63 #: ../src/app/qml/ui/SettingsSheet.qml:31
64 msgid "Settings"
65 msgstr ""
66@@ -53,12 +53,12 @@
67 msgid "Change app settings"
68 msgstr ""
69
70-#: ../src/app/qml/filemanager.qml:259 ../src/app/qml/ui/FolderListPage.qml:352
71+#: ../src/app/qml/filemanager.qml:259 ../src/app/qml/ui/FolderListPage.qml:353
72 #: ../src/app/qml/ui/ViewPopover.qml:70
73 msgid "Icons"
74 msgstr ""
75
76-#: ../src/app/qml/filemanager.qml:259 ../src/app/qml/ui/FolderListPage.qml:368
77+#: ../src/app/qml/filemanager.qml:259 ../src/app/qml/ui/FolderListPage.qml:369
78 #: ../src/app/qml/ui/ViewPopover.qml:71
79 msgid "List"
80 msgstr ""
81@@ -87,7 +87,7 @@
82 #: ../src/app/qml/ui/ConfirmDialogWithInput.qml:57
83 #: ../src/app/qml/ui/FileActionDialog.qml:45
84 #: ../src/app/qml/ui/FileOperationProgressDialog.qml:44
85-#: ../src/app/qml/ui/FolderListPage.qml:330
86+#: ../src/app/qml/ui/FolderListPage.qml:331
87 #: ../src/app/qml/ui/GoToDialog.qml:66
88 msgid "Cancel"
89 msgstr ""
90@@ -149,151 +149,182 @@
91 msgid "File operation"
92 msgstr ""
93
94-#: ../src/app/qml/ui/FolderListPage.qml:52
95+#: ../src/app/qml/ui/FolderListPage.qml:53
96 #, qt-format
97 msgid "Paste %1 File"
98 msgid_plural "Paste %1 Files"
99 msgstr[0] ""
100 msgstr[1] ""
101
102-#: ../src/app/qml/ui/FolderListPage.qml:56
103+#: ../src/app/qml/ui/FolderListPage.qml:57
104 msgid "Paste files"
105 msgstr ""
106
107-#: ../src/app/qml/ui/FolderListPage.qml:64
108+#: ../src/app/qml/ui/FolderListPage.qml:65
109 msgid "Clear clipboard"
110 msgstr ""
111
112-#: ../src/app/qml/ui/FolderListPage.qml:74
113-#: ../src/app/qml/ui/FolderListPage.qml:92
114-#: ../src/app/qml/ui/FolderListPage.qml:511
115+#: ../src/app/qml/ui/FolderListPage.qml:75
116+#: ../src/app/qml/ui/FolderListPage.qml:93
117+#: ../src/app/qml/ui/FolderListPage.qml:589
118 msgid "Properties"
119 msgstr ""
120
121-#: ../src/app/qml/ui/FolderListPage.qml:83
122+#: ../src/app/qml/ui/FolderListPage.qml:84
123 msgid "New Folder"
124 msgstr ""
125
126-#: ../src/app/qml/ui/FolderListPage.qml:109
127+#: ../src/app/qml/ui/FolderListPage.qml:110
128 msgid "Go To"
129 msgstr ""
130
131-#: ../src/app/qml/ui/FolderListPage.qml:116
132+#: ../src/app/qml/ui/FolderListPage.qml:117
133 msgid "Unlock full access"
134 msgstr ""
135
136-#: ../src/app/qml/ui/FolderListPage.qml:130
137+#: ../src/app/qml/ui/FolderListPage.qml:131
138 msgid "Authentication failed"
139 msgstr ""
140
141-#: ../src/app/qml/ui/FolderListPage.qml:202
142+#: ../src/app/qml/ui/FolderListPage.qml:203
143 #, qt-format
144 msgid "%1 file"
145 msgid_plural "%1 files"
146 msgstr[0] ""
147 msgstr[1] ""
148
149-#: ../src/app/qml/ui/FolderListPage.qml:227
150+#: ../src/app/qml/ui/FolderListPage.qml:228
151 msgid "Open in a new tab"
152 msgstr ""
153
154-#: ../src/app/qml/ui/FolderListPage.qml:235
155+#: ../src/app/qml/ui/FolderListPage.qml:236
156 msgid "Close this tab"
157 msgstr ""
158
159-#: ../src/app/qml/ui/FolderListPage.qml:248
160+#: ../src/app/qml/ui/FolderListPage.qml:249
161 msgid "Create folder"
162 msgstr ""
163
164-#: ../src/app/qml/ui/FolderListPage.qml:249
165+#: ../src/app/qml/ui/FolderListPage.qml:250
166 msgid "Enter name for new folder"
167 msgstr ""
168
169-#: ../src/app/qml/ui/FolderListPage.qml:265
170+#: ../src/app/qml/ui/FolderListPage.qml:266
171 msgid "Create file"
172 msgstr ""
173
174-#: ../src/app/qml/ui/FolderListPage.qml:266
175+#: ../src/app/qml/ui/FolderListPage.qml:267
176 msgid "Enter name for new file"
177 msgstr ""
178
179-#: ../src/app/qml/ui/FolderListPage.qml:315
180+#: ../src/app/qml/ui/FolderListPage.qml:316
181 msgid "Select"
182 msgstr ""
183
184-#: ../src/app/qml/ui/FolderListPage.qml:383
185+#: ../src/app/qml/ui/FolderListPage.qml:384
186 msgid "No files"
187 msgstr ""
188
189-#: ../src/app/qml/ui/FolderListPage.qml:403
190-#: ../src/app/qml/ui/FolderListPage.qml:485
191+#: ../src/app/qml/ui/FolderListPage.qml:404
192+#: ../src/app/qml/ui/FolderListPage.qml:551
193 msgid "Delete"
194 msgstr ""
195
196-#: ../src/app/qml/ui/FolderListPage.qml:404
197+#: ../src/app/qml/ui/FolderListPage.qml:405
198 #, qt-format
199 msgid "Are you sure you want to permanently delete '%1'?"
200 msgstr ""
201
202-#: ../src/app/qml/ui/FolderListPage.qml:409
203+#: ../src/app/qml/ui/FolderListPage.qml:410
204 msgid "Deleting files"
205 msgstr ""
206
207-#: ../src/app/qml/ui/FolderListPage.qml:427
208-#: ../src/app/qml/ui/FolderListPage.qml:498
209+#: ../src/app/qml/ui/FolderListPage.qml:428
210+#: ../src/app/qml/ui/FolderListPage.qml:564
211 msgid "Rename"
212 msgstr ""
213
214-#: ../src/app/qml/ui/FolderListPage.qml:428
215+#: ../src/app/qml/ui/FolderListPage.qml:429
216 msgid "Enter a new name"
217 msgstr ""
218
219-#: ../src/app/qml/ui/FolderListPage.qml:437
220+#: ../src/app/qml/ui/FolderListPage.qml:438
221 msgid "Could not rename"
222 msgstr ""
223
224-#: ../src/app/qml/ui/FolderListPage.qml:438
225+#: ../src/app/qml/ui/FolderListPage.qml:439
226 msgid "Insufficient permissions or name already exists?"
227 msgstr ""
228
229-#: ../src/app/qml/ui/FolderListPage.qml:462
230+#: ../src/app/qml/ui/FolderListPage.qml:456
231+msgid "Extract Archive"
232+msgstr ""
233+
234+#: ../src/app/qml/ui/FolderListPage.qml:457
235+#, qt-format
236+msgid "Are you sure you want to extract '%1' here?"
237+msgstr ""
238+
239+#: ../src/app/qml/ui/FolderListPage.qml:528
240 msgid "Cut"
241 msgstr ""
242
243-#: ../src/app/qml/ui/FolderListPage.qml:473
244+#: ../src/app/qml/ui/FolderListPage.qml:539
245 msgid "Copy"
246 msgstr ""
247
248-#: ../src/app/qml/ui/FolderListPage.qml:531
249+#: ../src/app/qml/ui/FolderListPage.qml:579
250+msgid "Extract archive"
251+msgstr ""
252+
253+#: ../src/app/qml/ui/FolderListPage.qml:609
254 msgid "File operation error"
255 msgstr ""
256
257-#: ../src/app/qml/ui/FolderListPage.qml:591
258+#: ../src/app/qml/ui/FolderListPage.qml:640
259+#, qt-format
260+msgid "Extracting archive '%1'"
261+msgstr ""
262+
263+#: ../src/app/qml/ui/FolderListPage.qml:652
264+msgid "OK"
265+msgstr ""
266+
267+#: ../src/app/qml/ui/FolderListPage.qml:666
268+msgid "Extracting failed"
269+msgstr ""
270+
271+#: ../src/app/qml/ui/FolderListPage.qml:667
272+#, qt-format
273+msgid "Extracting the archive '%1' failed."
274+msgstr ""
275+
276+#: ../src/app/qml/ui/FolderListPage.qml:724
277 msgid "~/Desktop"
278 msgstr ""
279
280-#: ../src/app/qml/ui/FolderListPage.qml:601
281+#: ../src/app/qml/ui/FolderListPage.qml:734
282 msgid "~/Public"
283 msgstr ""
284
285-#: ../src/app/qml/ui/FolderListPage.qml:603
286+#: ../src/app/qml/ui/FolderListPage.qml:736
287 msgid "~/Programs"
288 msgstr ""
289
290-#: ../src/app/qml/ui/FolderListPage.qml:605
291+#: ../src/app/qml/ui/FolderListPage.qml:738
292 msgid "~/Templates"
293 msgstr ""
294
295-#: ../src/app/qml/ui/FolderListPage.qml:618
296+#: ../src/app/qml/ui/FolderListPage.qml:751
297 msgid "Home"
298 msgstr ""
299
300-#: ../src/app/qml/ui/FolderListPage.qml:688
301+#: ../src/app/qml/ui/FolderListPage.qml:821
302 msgid "Folder not accessible"
303 msgstr ""
304
305 #. TRANSLATORS: this refers to a folder name
306-#: ../src/app/qml/ui/FolderListPage.qml:690
307+#: ../src/app/qml/ui/FolderListPage.qml:823
308 #, qt-format
309 msgid "Can not access %1"
310 msgstr ""
311
312=== modified file 'src/app/qml/ui/FolderListPage.qml'
313--- src/app/qml/ui/FolderListPage.qml 2014-11-01 23:44:58 +0000
314+++ src/app/qml/ui/FolderListPage.qml 2014-11-23 14:40:50 +0000
315@@ -21,6 +21,7 @@
316 import Ubuntu.Components.ListItems 1.0
317 import org.nemomobile.folderlistmodel 1.0
318 import com.ubuntu.PlacesModel 0.1
319+import com.ubuntu.Archives 0.1
320 import "../components"
321 import "../upstream"
322
323@@ -448,6 +449,45 @@
324 }
325
326 Component {
327+ id: confirmExtractDialog
328+ ConfirmDialog {
329+ property string filePath
330+ property string fileName
331+ title: i18n.tr("Extract Archive")
332+ text: i18n.tr("Are you sure you want to extract '%1' here?").arg(fileName)
333+
334+ onAccepted: {
335+ console.log("Extract accepted for filePath, fileName", filePath, fileName)
336+ PopupUtils.open(extractingDialog, mainView, { "fileName" : fileName })
337+ console.log("Extracting...")
338+
339+ var parentDirectory = filePath.substring(0, filePath.lastIndexOf("/"))
340+ var fileNameWithoutExtension = fileName.substring(0, fileName.lastIndexOf("."))
341+ var extractDirectory = parentDirectory + "/" + fileNameWithoutExtension
342+
343+ // Add numbers if the directory already exist: myfile, myfile-1, myfile-2, etc.
344+ while (pageModel.existsDir(extractDirectory)) {
345+ var i = 0
346+ while ("1234567890".indexOf(extractDirectory.charAt(extractDirectory.length - i - 1)) !== -1) {
347+ i++
348+ }
349+ if (i === 0 || extractDirectory.charAt(extractDirectory.length - i - 1) !== "-") {
350+ extractDirectory += "-1"
351+ } else {
352+ extractDirectory = extractDirectory.substring(0, extractDirectory.lastIndexOf("-") + 1) + (parseInt(extractDirectory.substring(extractDirectory.length - i)) + 1)
353+ }
354+ }
355+
356+ archives.extractZip(filePath, extractDirectory)
357+ }
358+ }
359+ }
360+
361+ Archives {
362+ id: archives
363+ }
364+
365+ Component {
366 id: actionSelectionPopoverComponent
367
368 ActionSelectionPopover {
369@@ -457,6 +497,32 @@
370 grabDismissAreaEvents: true
371
372 property var model
373+
374+ property bool isArchive: false
375+
376+ Component.onCompleted: {
377+ var splitName = actionSelectionPopover.model.fileName.split(".")
378+ var fileExtension = splitName[splitName.length - 1]
379+ isArchive = fileExtension === "zip"
380+ }
381+
382+ delegate: Empty { // NOTE: This is a workaround for LP: #1395118 and should be removed as soon as the patch for upstream gets released (https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1395118)
383+ id: listItem
384+ Label {
385+ text: listItem.text
386+ anchors {
387+ verticalCenter: parent.verticalCenter
388+ horizontalCenter: parent.horizontalCenter
389+ }
390+ wrapMode: Text.Wrap
391+ color: Theme.palette.normal.overlayText
392+ }
393+ /*! \internal */
394+ onTriggered: actionSelectionPopover.hide()
395+ visible: enabled && ((action === undefined) || action.visible)
396+ height: visible ? implicitHeight : 0
397+ }
398+
399 actions: ActionList {
400 Action {
401 text: i18n.tr("Cut")
402@@ -508,6 +574,18 @@
403 }
404
405 Action {
406+ id: extractAction
407+ visible: actionSelectionPopover.isArchive
408+ text: i18n.tr("Extract archive")
409+ onTriggered: {
410+ PopupUtils.open(confirmExtractDialog, actionSelectionPopover.caller,
411+ { "filePath" : actionSelectionPopover.model.filePath,
412+ "fileName" : actionSelectionPopover.model.fileName }
413+ )
414+ }
415+ }
416+
417+ Action {
418 text: i18n.tr("Properties")
419
420 onTriggered: {
421@@ -539,6 +617,61 @@
422 model: pageModel
423 }
424
425+ Component {
426+ id: extractingDialog
427+
428+ Dialog {
429+ id: dialog
430+ modal: true
431+ property string fileName: ""
432+
433+ Row {
434+ id: row
435+ width: parent.width
436+ spacing: units.gu(2)
437+
438+ ActivityIndicator {
439+ id: loadingSpinner
440+ running: true
441+ anchors.verticalCenter: parent.verticalCenter
442+ }
443+
444+ Label {
445+ text: qsTr(i18n.tr("Extracting archive '%1'")).arg(fileName)
446+ color: UbuntuColors.darkGrey
447+ anchors.verticalCenter: parent.verticalCenter
448+ width: row.width - loadingSpinner.width - row.spacing
449+ maximumLineCount: 2
450+ wrapMode: Text.WrapAnywhere
451+ elide: Text.ElideRight
452+ }
453+ }
454+
455+ Button {
456+ id: button
457+ text: i18n.tr("OK")
458+ visible: false
459+ onClicked: {
460+ PopupUtils.close(dialog)
461+ }
462+ }
463+
464+ Connections {
465+ target: archives
466+ onFinished: {
467+ if (success) {
468+ PopupUtils.close(dialog)
469+ } else {
470+ row.visible = false
471+ title = i18n.tr("Extracting failed")
472+ text = qsTr(i18n.tr("Extracting the archive '%1' failed.")).arg(fileName)
473+ button.visible = true
474+ }
475+ }
476+ }
477+ }
478+ }
479+
480 function goTo(location) {
481 // This allows us to enter "~" as a shortcut to the home folder
482 // when entering a location on the Go To dialog
483
484=== modified file 'src/plugin/CMakeLists.txt'
485--- src/plugin/CMakeLists.txt 2014-08-01 21:02:45 +0000
486+++ src/plugin/CMakeLists.txt 2014-11-23 14:40:50 +0000
487@@ -7,3 +7,4 @@
488 add_subdirectory(folderlistmodel)
489 add_subdirectory(placesmodel)
490 add_subdirectory(pamauthentication)
491+add_subdirectory(archives)
492
493=== added directory 'src/plugin/archives'
494=== added file 'src/plugin/archives/CMakeLists.txt'
495--- src/plugin/archives/CMakeLists.txt 1970-01-01 00:00:00 +0000
496+++ src/plugin/archives/CMakeLists.txt 2014-11-23 14:40:50 +0000
497@@ -0,0 +1,35 @@
498+include_directories(
499+ ${CMAKE_CURRENT_SOURCE_DIR}
500+)
501+
502+set(PLUGIN_DIR com/ubuntu/Archives)
503+
504+set(archives_SRCS
505+ archives.cpp
506+ archives.h
507+ archives_plugin.cpp
508+ archives_plugin.h
509+)
510+
511+add_library(Archives MODULE
512+ ${archives_SRCS}
513+)
514+
515+qt5_use_modules(Archives Gui Qml Quick Widgets)
516+
517+# Copy the plugin, the qmldir file and other assets to the build dir for running in QtCreator
518+if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
519+ add_custom_command(TARGET Archives POST_BUILD
520+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR}
521+ COMMENT "Creating plugin directory layout in the build directory"
522+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR}
523+ COMMENT "Copying the qmldir file to the build directory"
524+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Archives> ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR}
525+ COMMENT "Copying the plugin binary to the build directory"
526+ )
527+endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
528+
529+# Install plugin file
530+install(TARGETS Archives DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
531+install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
532+
533
534=== added file 'src/plugin/archives/archives.cpp'
535--- src/plugin/archives/archives.cpp 1970-01-01 00:00:00 +0000
536+++ src/plugin/archives/archives.cpp 2014-11-23 14:40:50 +0000
537@@ -0,0 +1,57 @@
538+/*
539+ * Copyright (C) 2014 Canonical Ltd
540+ *
541+ * This program is free software: you can redistribute it and/or modify
542+ * it under the terms of the GNU General Public License version 3 as
543+ * published by the Free Software Foundation.
544+ *
545+ * This program is distributed in the hope that it will be useful,
546+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
547+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
548+ * GNU General Public License for more details.
549+ *
550+ * You should have received a copy of the GNU General Public License
551+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
552+ *
553+ * Author : Niklas Wenzel <nikwen.developer@gmail.com>
554+ */
555+
556+#include "archives.h"
557+#include "QDebug"
558+
559+void Archives::extractZip(const QString path, const QString destination)
560+{
561+ if (_process != nullptr && _process->state() == QProcess::ProcessState::Running) {
562+ return; // Do not allow two extractions running in parallel. Due to the way this is used in QML parallelization is not needed.
563+ }
564+
565+ QString program = "unzip"; // This programm is available in the images as it is one of the dependencies of the ubuntu-download-manager package.
566+ QStringList arguments;
567+ arguments << path << "-d" << destination;
568+
569+ _process = new QProcess(this);
570+
571+ // Connect to internal slots in order to have one unified onFinished slot handling both events for QML.
572+ connect(_process,
573+ static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>
574+ (&QProcess::finished), this, &Archives::_onFinished);
575+ connect(_process,
576+ static_cast<void(QProcess::*)(QProcess::ProcessError)>
577+ (&QProcess::error), this, &Archives::_onError);
578+
579+ _process->start(program, arguments);
580+}
581+
582+void Archives::_onError(QProcess::ProcessError error)
583+{
584+ emit finished(false, error);
585+}
586+
587+void Archives::_onFinished(int exitCode, QProcess::ExitStatus exitStatus)
588+{
589+ if ((exitStatus == QProcess::NormalExit || exitCode == 0) && _process->readAllStandardError().isEmpty()) {
590+ emit finished(true, -1);
591+ } else {
592+ emit finished(false, -1);
593+ }
594+}
595
596=== added file 'src/plugin/archives/archives.h'
597--- src/plugin/archives/archives.h 1970-01-01 00:00:00 +0000
598+++ src/plugin/archives/archives.h 2014-11-23 14:40:50 +0000
599@@ -0,0 +1,44 @@
600+/*
601+ * Copyright (C) 2014 Canonical Ltd
602+ *
603+ * This program is free software: you can redistribute it and/or modify
604+ * it under the terms of the GNU General Public License version 3 as
605+ * published by the Free Software Foundation.
606+ *
607+ * This program is distributed in the hope that it will be useful,
608+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
609+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
610+ * GNU General Public License for more details.
611+ *
612+ * You should have received a copy of the GNU General Public License
613+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
614+ *
615+ * Author : Niklas Wenzel <nikwen.developer@gmail.com>
616+ */
617+
618+#ifndef ARCHIVES_H
619+#define ARCHIVES_H
620+
621+#include <QObject>
622+#include <QProcess>
623+
624+class Archives : public QObject
625+{
626+ Q_OBJECT
627+
628+public:
629+ Q_INVOKABLE void extractZip(const QString path, const QString destination);
630+
631+signals:
632+ void finished(bool success, int errorCode);
633+
634+private slots:
635+ void _onError(QProcess::ProcessError error);
636+ void _onFinished(int exitCode, QProcess::ExitStatus exitStatus);
637+
638+private:
639+ QProcess* _process = nullptr;
640+};
641+
642+
643+#endif // ARCHIVES_H
644
645=== added file 'src/plugin/archives/archives_plugin.cpp'
646--- src/plugin/archives/archives_plugin.cpp 1970-01-01 00:00:00 +0000
647+++ src/plugin/archives/archives_plugin.cpp 2014-11-23 14:40:50 +0000
648@@ -0,0 +1,34 @@
649+/*
650+ * Copyright (C) 2014 Canonical Ltd
651+ *
652+ * This program is free software: you can redistribute it and/or modify
653+ * it under the terms of the GNU General Public License version 3 as
654+ * published by the Free Software Foundation.
655+ *
656+ * This program is distributed in the hope that it will be useful,
657+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
658+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
659+ * GNU General Public License for more details.
660+ *
661+ * You should have received a copy of the GNU General Public License
662+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
663+ *
664+ * Author : Niklas Wenzel <nikwen.developer@gmail.com>
665+ */
666+
667+#include <QtQml>
668+#include <QtQml/QQmlContext>
669+#include "archives_plugin.h"
670+#include "archives.h"
671+
672+void BackendPlugin::registerTypes(const char *uri)
673+{
674+ Q_ASSERT(uri == QLatin1String("com.ubuntu.Archives"));
675+
676+ qmlRegisterType<Archives>(uri, 0, 1, "Archives");
677+}
678+
679+void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
680+{
681+ QQmlExtensionPlugin::initializeEngine(engine, uri);
682+}
683
684=== added file 'src/plugin/archives/archives_plugin.h'
685--- src/plugin/archives/archives_plugin.h 1970-01-01 00:00:00 +0000
686+++ src/plugin/archives/archives_plugin.h 2014-11-23 14:40:50 +0000
687@@ -0,0 +1,39 @@
688+/*
689+ * Copyright (C) 2014 Canonical Ltd
690+ *
691+ * This program is free software: you can redistribute it and/or modify
692+ * it under the terms of the GNU General Public License version 3 as
693+ * published by the Free Software Foundation.
694+ *
695+ * This program is distributed in the hope that it will be useful,
696+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
697+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
698+ * GNU General Public License for more details.
699+ *
700+ * You should have received a copy of the GNU General Public License
701+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
702+ *
703+ * Author : Niklas Wenzel <nikwen.developer@gmail.com>
704+ */
705+
706+#ifndef ARCHIVES_PLUGIN_H
707+#define ARCHIVES_PLUGIN_H
708+
709+#include <QtQml/QQmlEngine>
710+#include <QtQml/QQmlExtensionPlugin>
711+
712+class BackendPlugin : public QQmlExtensionPlugin
713+{
714+ Q_OBJECT
715+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
716+
717+public:
718+ void registerTypes(const char *uri);
719+ void initializeEngine(QQmlEngine *engine, const char *uri);
720+};
721+#endif // ARCHIVES_PLUGIN_H
722+
723+
724+
725+
726+
727
728=== added file 'src/plugin/archives/qmldir'
729--- src/plugin/archives/qmldir 1970-01-01 00:00:00 +0000
730+++ src/plugin/archives/qmldir 2014-11-23 14:40:50 +0000
731@@ -0,0 +1,2 @@
732+module com.ubuntu.Archives
733+plugin Archives

Subscribers

People subscribed via source and target branches