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 "Config.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDesktopServices>
#include <QDir> #include <QDir>
#include <QSettings> #include <QSettings>
#include <QStandardPaths>
#include <QTemporaryFile> #include <QTemporaryFile>
Config* Config::m_instance(Q_NULLPTR); Config* Config::m_instance(Q_NULLPTR);
@ -53,7 +53,7 @@ Config::Config(QObject* parent)
QString homePath = QDir::homePath(); QString homePath = QDir::homePath();
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) #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"); QByteArray env = qgetenv("XDG_CONFIG_HOME");
if (env.isEmpty()) { if (env.isEmpty()) {
userPath = homePath; userPath = homePath;
@ -70,7 +70,7 @@ Config::Config(QObject* parent)
userPath += "/keepassx/"; userPath += "/keepassx/";
#else #else
userPath = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); userPath = QDir::fromNativeSeparators(QStandardPaths::writableLocation(QDesktopServices::AppDataLocation));
// storageLocation() appends the application name ("/keepassx") to the end // storageLocation() appends the application name ("/keepassx") to the end
userPath += "/"; userPath += "/";
#endif #endif

View File

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

View File

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