Remove deprecated QDesktopServices APIs

Change-Id: Ic21ad2938b20c1aa3ae499a921c9cff92f615816
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Volker Hilsheimer 2020-05-12 14:30:36 +02:00
parent c856033851
commit 082eebe6a4
5 changed files with 2 additions and 158 deletions

View File

@ -2606,12 +2606,6 @@ QString QCoreApplication::applicationName()
return coreappdata() ? coreappdata()->application : QString();
}
// Exported for QDesktopServices (Qt4 behavior compatibility)
Q_CORE_EXPORT QString qt_applicationName_noFallback()
{
return coreappdata()->applicationNameSet ? coreappdata()->application : QString();
}
/*!
\property QCoreApplication::applicationVersion
\since 4.4

View File

@ -145,9 +145,6 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
openUrl() function can also be exposed to other applications, opening up
for application deep linking or a very basic URL-based IPC mechanism.
\note Since Qt 5, storageLocation() and displayName() are replaced by functionality
provided by the QStandardPaths class.
\sa QSystemTrayIcon, QProcess, QStandardPaths
*/
@ -290,89 +287,6 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme)
setUrlHandler(scheme, nullptr, nullptr);
}
#if QT_DEPRECATED_SINCE(5, 0)
/*!
\enum QDesktopServices::StandardLocation
\since 4.4
\obsolete
Use QStandardPaths::StandardLocation (see storageLocation() for porting notes)
This enum describes the different locations that can be queried by
QDesktopServices::storageLocation and QDesktopServices::displayName.
\value DesktopLocation Returns the user's desktop directory.
\value DocumentsLocation Returns the user's document.
\value FontsLocation Returns the user's fonts.
\value ApplicationsLocation Returns the user's applications.
\value MusicLocation Returns the users music.
\value MoviesLocation Returns the user's movies.
\value PicturesLocation Returns the user's pictures.
\value TempLocation Returns the system's temporary directory.
\value HomeLocation Returns the user's home directory.
\value DataLocation Returns a directory location where persistent
application data can be stored. QCoreApplication::applicationName
and QCoreApplication::organizationName should work on all
platforms.
\value CacheLocation Returns a directory location where user-specific
non-essential (cached) data should be written.
\sa storageLocation(), displayName()
*/
/*!
\fn QString QDesktopServices::storageLocation(StandardLocation type)
\obsolete
Use QStandardPaths::writableLocation()
\note when porting QDesktopServices::DataLocation to QStandardPaths::DataLocation,
a different path will be returned.
\c{QDesktopServices::DataLocation} was \c{GenericDataLocation + "/data/organization/application"},
while QStandardPaths::DataLocation is \c{GenericDataLocation + "/organization/application"}.
Also note that \c{application} could be empty in Qt 4, if QCoreApplication::setApplicationName()
wasn't called, while in Qt 5 it defaults to the name of the executable.
Therefore, if you still need to access the Qt 4 path (for example for data migration to Qt 5), replace
\snippet code/src_gui_util_qdesktopservices.cpp 5
with
\snippet code/src_gui_util_qdesktopservices.cpp 6
(assuming an organization name and an application name were set).
*/
/*!
\fn QString QDesktopServices::displayName(StandardLocation type)
\obsolete
Use QStandardPaths::displayName()
*/
#endif
extern Q_CORE_EXPORT QString qt_applicationName_noFallback();
QString QDesktopServices::storageLocationImpl(QStandardPaths::StandardLocation type)
{
if (type == QStandardPaths::AppLocalDataLocation) {
// Preserve Qt 4 compatibility:
// * QCoreApplication::applicationName() must default to empty
// * Unix data location is under the "data/" subdirectory
const QString compatAppName = qt_applicationName_noFallback();
const QString baseDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
const QString organizationName = QCoreApplication::organizationName();
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
QString result = baseDir;
if (!organizationName.isEmpty())
result += QLatin1Char('/') + organizationName;
if (!compatAppName.isEmpty())
result += QLatin1Char('/') + compatAppName;
return result;
#elif defined(Q_OS_UNIX)
return baseDir + QLatin1String("/data/")
+ organizationName + QLatin1Char('/') + compatAppName;
#endif
}
return QStandardPaths::writableLocation(type);
}
QT_END_NAMESPACE
#include "qdesktopservices.moc"

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@ -42,7 +42,6 @@
#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qstandardpaths.h>
QT_BEGIN_NAMESPACE
@ -59,32 +58,6 @@ public:
static bool openUrl(const QUrl &url);
static void setUrlHandler(const QString &scheme, QObject *receiver, const char *method);
static void unsetUrlHandler(const QString &scheme);
#if QT_DEPRECATED_SINCE(5, 0)
//Must match QStandardPaths::StandardLocation
enum StandardLocation {
DesktopLocation,
DocumentsLocation,
FontsLocation,
ApplicationsLocation,
MusicLocation,
MoviesLocation,
PicturesLocation,
TempLocation,
HomeLocation,
DataLocation,
CacheLocation
};
QT_DEPRECATED static QString storageLocation(StandardLocation type) {
return storageLocationImpl(static_cast<QStandardPaths::StandardLocation>(type));
}
QT_DEPRECATED static QString displayName(StandardLocation type) {
return QStandardPaths::displayName(static_cast<QStandardPaths::StandardLocation>(type));
}
#endif
private:
static QString storageLocationImpl(QStandardPaths::StandardLocation type);
};
#endif // QT_NO_DESKTOPSERVICES

View File

@ -132,7 +132,7 @@ QString QNetworkDiskCache::cacheDirectory() const
Prepared cache items will be stored in the new cache directory when
they are inserted.
\sa QDesktopServices::CacheLocation
\sa QStandardPaths::CacheLocation
*/
void QNetworkDiskCache::setCacheDirectory(const QString &cacheDir)
{

View File

@ -28,7 +28,6 @@
#include <QtTest/QtTest>
#include <qdebug.h>
#include <qdesktopservices.h>
#include <qregularexpression.h>
@ -39,9 +38,6 @@ class tst_qdesktopservices : public QObject
private slots:
void openUrl();
void handlers();
#if QT_DEPRECATED_SINCE(5, 0)
void testDataLocation();
#endif
};
void tst_qdesktopservices::openUrl()
@ -87,39 +83,6 @@ void tst_qdesktopservices::handlers()
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString());
}
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
#define Q_XDG_PLATFORM
#endif
#if QT_DEPRECATED_SINCE(5, 0)
void tst_qdesktopservices::testDataLocation()
{
// This is the one point where QDesktopServices and QStandardPaths differ.
// QDesktopServices on unix returns "data"/orgname/appname for DataLocation, for Qt4 compat.
// And the appname in qt4 defaulted to empty, not to argv[0].
{
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
const QString app = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#ifdef Q_XDG_PLATFORM
QCOMPARE(app, base + "/data//"); // as ugly as in Qt4
#else
QCOMPARE(app, base);
#endif
}
QCoreApplication::instance()->setOrganizationName("Qt");
QCoreApplication::instance()->setApplicationName("QtTest");
{
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
const QString app = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#ifdef Q_XDG_PLATFORM
QCOMPARE(app, base + "/data/Qt/QtTest");
#else
QCOMPARE(app, base + "/Qt/QtTest");
#endif
}
}
#endif
QTEST_MAIN(tst_qdesktopservices)
#include "tst_qdesktopservices.moc"