Remember the dir when opening/saving attachments.

This commit is contained in:
Felix Geyer 2013-07-04 13:41:51 +02:00
parent 1f47033835
commit 74e912ccd3

View File

@ -26,6 +26,7 @@
#include <QMenu> #include <QMenu>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "core/Config.h"
#include "core/Database.h" #include "core/Database.h"
#include "core/Entry.h" #include "core/Entry.h"
#include "core/Metadata.h" #include "core/Metadata.h"
@ -605,9 +606,11 @@ void EditEntryWidget::insertAttachment()
{ {
Q_ASSERT(!m_history); Q_ASSERT(!m_history);
// TODO: save last used dir QString defaultDir = config()->get("LastAttachmentDir").toString();
QString filename = fileDialog()->getOpenFileName(this, tr("Select file"), if (defaultDir.isEmpty() || !QDir(defaultDir).exists()) {
QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); defaultDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
}
QString filename = fileDialog()->getOpenFileName(this, tr("Select file"), defaultDir);
if (filename.isEmpty() || !QFile::exists(filename)) { if (filename.isEmpty() || !QFile::exists(filename)) {
return; return;
} }
@ -637,8 +640,11 @@ void EditEntryWidget::saveCurrentAttachment()
} }
QString filename = m_attachmentsModel->keyByIndex(index); QString filename = m_attachmentsModel->keyByIndex(index);
// TODO: save last used dir QString defaultDirName = config()->get("LastAttachmentDir").toString();
QDir dir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); if (defaultDirName.isEmpty() || !QDir(defaultDirName).exists()) {
defaultDirName = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
}
QDir dir(defaultDirName);
QString savePath = fileDialog()->getSaveFileName(this, tr("Save attachment"), QString savePath = fileDialog()->getSaveFileName(this, tr("Save attachment"),
dir.filePath(filename)); dir.filePath(filename));
if (!savePath.isEmpty()) { if (!savePath.isEmpty()) {