Bug 358208 - Remember last-used location for attachment storage and downloads
Summary: Remember last-used location for attachment storage and downloads
Status: RESOLVED FIXED
Alias: None
Product: trojita
Classification: Applications
Component: Desktop GUI (other bugs)
Version First Reported In: git
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Trojita default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-19 12:28 UTC by Jan Kundrát
Modified: 2016-01-21 13:33 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kundrát 2016-01-19 12:28:34 UTC
When attaching multiple files from the same directory, the path is not remembered, so one has to navigate all the way from whatever the cwd happens to be.

I also suppose that a similar thing happens when downloading these attachments.
Comment 1 Thomas Lübking 2016-01-19 12:42:46 UTC
diff --git a/src/Gui/AttachmentView.cpp b/src/Gui/AttachmentView.cpp
index 4757cf5..39b288a 100644
--- a/src/Gui/AttachmentView.cpp
+++ b/src/Gui/AttachmentView.cpp
@@ -224,8 +224,13 @@ void AttachmentView::slotFileNameRequestedOnOpen(QString *fileName)
 
 void AttachmentView::slotFileNameRequested(QString *fileName)
 {
-    QString fileLocation = QDir(Common::writablePath(Common::LOCATION_DOWNLOAD)).filePath(*fileName);
+    static QDir lastDir = QDir(Common::writablePath(Common::LOCATION_DOWNLOAD));
+    if (!lastDir.exists())
+        lastDir = QDir(Common::writablePath(Common::LOCATION_DOWNLOAD));
+    QString fileLocation = lastDir.filePath(*fileName);
     *fileName = QFileDialog::getSaveFileName(this, tr("Save Attachment"), fileLocation, QString(), 0, QFileDialog::HideNameFilterDetails);
+    if (!fileName->isEmpty())
+        lastDir = QFileInfo(*fileName).absoluteDir();
 }
 
 void AttachmentView::enableDownloadAgain()
Comment 2 Jan Kundrát 2016-01-19 12:53:53 UTC
Gerrit?
Comment 3 Thomas Lübking 2016-01-19 13:02:37 UTC
lacking ssh key atm.
Comment 4 Jan Kundrát 2016-01-20 10:55:17 UTC
Git commit ad89c0fa5c035774ca6b4eed9b72c62a5e506e21 by Jan Kundrát, on behalf of Thomas Lübking.
Committed on 20/01/2016 at 10:06.
Pushed by gerrit into branch 'master'.

remember last dir for saving attachments
Change-Id: I20322cc72d9aa2a742b951b49041807b5b739129

M  +6    -1    src/Gui/AttachmentView.cpp

http://commits.kde.org/trojita/ad89c0fa5c035774ca6b4eed9b72c62a5e506e21
Comment 5 Jan Kundrát 2016-01-21 13:33:09 UTC
Git commit 379fe2a8eb01eae06d77836de2689bc061fa729a by Jan Kundrát.
Committed on 21/01/2016 at 12:03.
Pushed by gerrit into branch 'master'.

GUI: remember last dir when adding attachments
Change-Id: Id54a718a77105ae4deffa31f87b3c0a98fa325f1

M  +3    -1    src/Gui/ComposeWidget.cpp

http://commits.kde.org/trojita/379fe2a8eb01eae06d77836de2689bc061fa729a