QDesktopServices::storageLocation() calls to QStandardPaths.

This commit is contained in:
Felix Geyer 2015-07-22 17:19:48 +02:00
parent c714fc89f1
commit 5ad9edc3fd
3 changed files with 7 additions and 6 deletions

View File

@ -18,9 +18,9 @@
#include "Config.h"
#include <QCoreApplication>
#include <QDesktopServices>
#include <QDir>
#include <QSettings>
#include <QStandardPaths>
#include <QTemporaryFile>
Config* Config::m_instance(Q_NULLPTR);
@ -53,7 +53,7 @@ Config::Config(QObject* parent)
QString homePath = QDir::homePath();
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
// we can't use QDesktopServices on X11 as it uses XDG_DATA_HOME instead of XDG_CONFIG_HOME
// we can't use QStandardPaths on X11 as it uses XDG_DATA_HOME instead of XDG_CONFIG_HOME
QByteArray env = qgetenv("XDG_CONFIG_HOME");
if (env.isEmpty()) {
userPath = homePath;
@ -70,7 +70,7 @@ Config::Config(QObject* parent)
userPath += "/keepassx/";
#else
userPath = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
userPath = QDir::fromNativeSeparators(QStandardPaths::writableLocation(QDesktopServices::AppDataLocation));
// storageLocation() appends the application name ("/keepassx") to the end
userPath += "/";
#endif

View File

@ -23,6 +23,7 @@
#include <QDesktopServices>
#include <QStackedLayout>
#include <QStandardPaths>
#include <QMenu>
#include <QSortFilterProxyModel>
#include <QTemporaryFile>
@ -589,7 +590,7 @@ void EditEntryWidget::insertAttachment()
QString defaultDir = config()->get("LastAttachmentDir").toString();
if (defaultDir.isEmpty() || !QDir(defaultDir).exists()) {
defaultDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
defaultDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).value(0);
}
QString filename = fileDialog()->getOpenFileName(this, tr("Select file"), defaultDir);
if (filename.isEmpty() || !QFile::exists(filename)) {
@ -623,7 +624,7 @@ void EditEntryWidget::saveCurrentAttachment()
QString filename = m_attachmentsModel->keyByIndex(index);
QString defaultDirName = config()->get("LastAttachmentDir").toString();
if (defaultDirName.isEmpty() || !QDir(defaultDirName).exists()) {
defaultDirName = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
defaultDirName = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
}
QDir dir(defaultDirName);
QString savePath = fileDialog()->getSaveFileName(this, tr("Save attachment"),

View File

@ -37,7 +37,7 @@ int main(int argc, char** argv)
Application::setApplicationName("keepassx");
Application::setApplicationVersion(KEEPASSX_VERSION);
// don't set organizationName as that changes the return value of
// QDesktopServices::storageLocation(QDesktopServices::DataLocation)
// QStandardPaths::writableLocation(QDesktopServices::AppDataLocation)
QApplication::setQuitOnLastWindowClosed(false);