get rid of QDesktopServices [ci reset]

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-11-21 17:48:14 +02:00
parent d4d6a17e8d
commit 20443178a9
17 changed files with 17 additions and 426 deletions

View file

@ -643,7 +643,6 @@ include/katie/QtGui/QCursor
include/katie/QtGui/QDataWidgetMapper
include/katie/QtGui/QDateEdit
include/katie/QtGui/QDateTimeEdit
include/katie/QtGui/QDesktopServices
include/katie/QtGui/QDesktopWidget
include/katie/QtGui/QDial
include/katie/QtGui/QDialog
@ -1010,7 +1009,6 @@ include/katie/QtGui/qcompleter.h
include/katie/QtGui/qcursor.h
include/katie/QtGui/qdatawidgetmapper.h
include/katie/QtGui/qdatetimeedit.h
include/katie/QtGui/qdesktopservices.h
include/katie/QtGui/qdesktopwidget.h
include/katie/QtGui/qdial.h
include/katie/QtGui/qdialog.h

View file

@ -646,7 +646,6 @@ include/katie/QtGui/QCursor
include/katie/QtGui/QDataWidgetMapper
include/katie/QtGui/QDateEdit
include/katie/QtGui/QDateTimeEdit
include/katie/QtGui/QDesktopServices
include/katie/QtGui/QDesktopWidget
include/katie/QtGui/QDial
include/katie/QtGui/QDialog
@ -1013,7 +1012,6 @@ include/katie/QtGui/qcompleter.h
include/katie/QtGui/qcursor.h
include/katie/QtGui/qdatawidgetmapper.h
include/katie/QtGui/qdatetimeedit.h
include/katie/QtGui/qdesktopservices.h
include/katie/QtGui/qdesktopwidget.h
include/katie/QtGui/qdial.h
include/katie/QtGui/qdialog.h

View file

@ -651,7 +651,6 @@ include/katie/QtGui/QCursor
include/katie/QtGui/QDataWidgetMapper
include/katie/QtGui/QDateEdit
include/katie/QtGui/QDateTimeEdit
include/katie/QtGui/QDesktopServices
include/katie/QtGui/QDesktopWidget
include/katie/QtGui/QDial
include/katie/QtGui/QDialog
@ -1018,7 +1017,6 @@ include/katie/QtGui/qcompleter.h
include/katie/QtGui/qcursor.h
include/katie/QtGui/qdatawidgetmapper.h
include/katie/QtGui/qdatetimeedit.h
include/katie/QtGui/qdesktopservices.h
include/katie/QtGui/qdesktopwidget.h
include/katie/QtGui/qdial.h
include/katie/QtGui/qdialog.h

View file

@ -187,7 +187,6 @@ classlist = [
"QDesignerWidgetDataBaseInterface",
"QDesignerWidgetDataBaseItemInterface",
"QDesignerWidgetFactoryInterface",
"QDesktopServices",
"QDesktopWidget",
"QDial",
"QDialog",

View file

@ -172,7 +172,6 @@
#cmakedefine QT_NO_DEBUG
#cmakedefine QT_NO_DEBUG_PLUGIN_CHECK
#cmakedefine QT_NO_DEBUG_STREAM
#cmakedefine QT_NO_DESKTOPSERVICES
#cmakedefine QT_NO_DIAL
#cmakedefine QT_NO_DIALOGBUTTONBOX
#cmakedefine QT_NO_DIRMODEL

View file

@ -55,7 +55,7 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QDesktopServices>
#include <QStandardPaths>
#include <QTimer>
#include <QList>
#include <QPair>
@ -1738,10 +1738,7 @@ QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QSc
{
if(ctxt->argumentCount() < 1)
return QScriptValue(e, false);
bool ret = false;
#ifndef QT_NO_DESKTOPSERVICES
ret = QDesktopServices::openUrl(QDeclarativeScriptEngine::get(e)->resolvedUrl(ctxt, QUrl(ctxt->argument(0).toString())));
#endif
bool ret = StandardPaths::openUrl(QDeclarativeScriptEngine::get(e)->resolvedUrl(ctxt, QUrl(ctxt->argument(0).toString())));
return QScriptValue(e, ret);
}

View file

@ -51,7 +51,6 @@ set(GUI_PUBLIC_HEADERS
QCursor
QDataWidgetMapper
QDateTimeEdit
QDesktopServices
QDesktopWidget
QDial
QDialog
@ -522,7 +521,6 @@ set(GUI_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/util/qsystemtrayicon.h
${CMAKE_CURRENT_SOURCE_DIR}/util/qcompleter.h
${CMAKE_CURRENT_SOURCE_DIR}/util/qcompleter_p.h
${CMAKE_CURRENT_SOURCE_DIR}/util/qdesktopservices.h
${CMAKE_CURRENT_SOURCE_DIR}/util/qsystemtrayicon_p.h
${CMAKE_CURRENT_SOURCE_DIR}/util/qundogroup.h
${CMAKE_CURRENT_SOURCE_DIR}/util/qundostack.h
@ -844,7 +842,6 @@ set(GUI_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/text/qunicodetables.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/qsystemtrayicon.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/qcompleter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/qdesktopservices.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/qundogroup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/qundostack.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/qundoview.cpp

View file

@ -9840,7 +9840,7 @@ bool QGraphicsTextItem::tabChangesFocus() const
\property QGraphicsTextItem::openExternalLinks
Specifies whether QGraphicsTextItem should automatically open links using
QDesktopServices::openUrl() instead of emitting the
QStandardPaths::openUrl() instead of emitting the
linkActivated signal.
The default value is false.

View file

@ -53,7 +53,7 @@
#include "qtexttable.h"
#include "qvariant.h"
#include "qurl.h"
#include "qdesktopservices.h"
#include "qstandardpaths.h"
#include "qtooltip.h"
#include "qstyleoption.h"
#include "qlineedit.h"
@ -2454,11 +2454,9 @@ void QTextControlPrivate::activateLinkUnderCursor(QString href)
}
repaintOldAndNewSelection(oldCursor);
#ifndef QT_NO_DESKTOPSERVICES
if (openExternalLinks)
QDesktopServices::openUrl(href);
QStandardPaths::openUrl(href);
else
#endif
emit q_func()->linkActivated(href);
}

View file

@ -1,317 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtGui module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdesktopservices.h"
#ifndef QT_NO_DESKTOPSERVICES
#include "qdebug.h"
#include "qhash.h"
#include "qobject.h"
#include "qcoreapplication.h"
#include "qurl.h"
#include "qmutex.h"
#include "qprocess.h"
#include "qstandardpaths.h"
QT_BEGIN_NAMESPACE
class QOpenUrlHandlerRegistry : public QObject
{
Q_OBJECT
public:
QMutex mutex;
struct Handler
{
QObject *receiver;
QByteArray name;
};
typedef QHash<QString, Handler> HandlerHash;
HandlerHash handlers;
public Q_SLOTS:
void handlerDestroyed(QObject *handler);
};
Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
{
HandlerHash::Iterator it = handlers.begin();
while (it != handlers.end()) {
if (it->receiver == handler) {
it = handlers.erase(it);
} else {
++it;
}
}
}
/*!
\class QDesktopServices
\brief The QDesktopServices class provides methods for accessing common desktop services.
\since 4.2
\ingroup desktop
Many desktop environments provide services that can be used by applications to
perform common tasks, such as opening a web page, in a way that is both consistent
and takes into account the user's application preferences.
This class contains functions that provide simple interfaces to these services
that indicate whether they succeeded or failed.
The openUrl() function is used to open files located at arbitrary URLs in external
applications. For URLs that correspond to resources on the local filing system
(where the URL scheme is "file"), a suitable application will be used to open the
file; otherwise, a web browser will be used to fetch and display the file.
The user's desktop settings control whether certain executable file types are
opened for browsing, or if they are executed instead. Some desktop environments
are configured to prevent users from executing files obtained from non-local URLs,
or to ask the user's permission before doing so.
\section1 URL Handlers
The behavior of the openUrl() function can be customized for individual URL
schemes to allow applications to override the default handling behavior for
certain types of URLs.
The dispatch mechanism allows only one custom handler to be used for each URL
scheme; this is set using the setUrlHandler() function. Each handler is
implemented as a slot which accepts only a single QUrl argument.
The existing handlers for each scheme can be removed with the
unsetUrlHandler() function. This returns the handling behavior for the given
scheme to the default behavior.
This system makes it easy to implement a help system, for example. Help could be
provided in labels and text browsers using \gui{help://myapplication/mytopic}
URLs, and by registering a handler it becomes possible to display the help text
inside the application:
\snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 0
If inside the handler you decide that you can't open the requested
URL, you can just call QDesktopServices::openUrl() again with the
same argument, and it will try to open the URL using the
appropriate mechanism for the user's desktop environment.
\sa QSystemTrayIcon, QProcess
*/
/*!
Opens the given \a url in the appropriate Web browser for the user's desktop
environment, and returns true if successful; otherwise returns false.
If the URL is a reference to a local file (i.e., the URL scheme is "file") then
it will be opened with a suitable application instead of a Web browser.
The following example opens a file on the Windows file system residing on a path
that contains spaces:
\snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2
If a \c mailto URL is specified, the user's e-mail client will be used to open a
composer window containing the options specified in the URL, similar to the way
\c mailto links are handled by a Web browser.
For example, the following URL contains a recipient (\c{user@foo.com}), a
subject (\c{Test}), and a message body (\c{Just a test}):
\snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 1
\warning Although many e-mail clients can send attachments and are
Unicode-aware, the user may have configured their client without these features.
Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs.
\sa setUrlHandler()
*/
bool QDesktopServices::openUrl(const QUrl &url)
{
QOpenUrlHandlerRegistry *registry = handlerRegistry();
QMutexLocker locker(&registry->mutex);
static bool insideOpenUrlHandler = false;
if (!insideOpenUrlHandler) {
QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme());
if (handler != registry->handlers.constEnd()) {
insideOpenUrlHandler = true;
bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, Q_ARG(QUrl, url));
insideOpenUrlHandler = false;
return result; // ### support bool slot return type
}
}
if (!url.isValid())
return false;
const QString command = QLatin1String("xdg-open ") + url.toEncoded();
return QProcess::startDetached(command);
}
/*!
Sets the handler for the given \a scheme to be the handler \a method provided by
the \a receiver object.
This function provides a way to customize the behavior of openUrl(). If openUrl()
is called with a URL with the specified \a scheme then the given \a method on the
\a receiver object is called instead of QDesktopServices launching an external
application.
The provided method must be implemented as a slot that only accepts a single QUrl
argument.
If setUrlHandler() is used to set a new handler for a scheme which already
has a handler, the existing handler is simply replaced with the new one.
Since QDesktopServices does not take ownership of handlers, no objects are
deleted when a handler is replaced.
Note that the handler will always be called from within the same thread that
calls QDesktopServices::openUrl().
\sa openUrl(), unsetUrlHandler()
*/
void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method)
{
QOpenUrlHandlerRegistry *registry = handlerRegistry();
QMutexLocker locker(&registry->mutex);
if (!receiver) {
registry->handlers.remove(scheme);
return;
}
QOpenUrlHandlerRegistry::Handler h;
h.receiver = receiver;
h.name = method;
registry->handlers.insert(scheme, h);
QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
registry, SLOT(handlerDestroyed(QObject*)));
}
/*!
Removes a previously set URL handler for the specified \a scheme.
\sa setUrlHandler()
*/
void QDesktopServices::unsetUrlHandler(const QString &scheme)
{
setUrlHandler(scheme, 0, 0);
}
/*!
\enum QDesktopServices::StandardLocation
\since 4.4
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 MusicLocation Returns the users music.
\value MoviesLocation Returns the user's movies.
\value PicturesLocation Returns the user's pictures.
\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()
*/
/*!
\since 4.4
Returns the default system directory where files of \a type belong, or an empty string
if the location cannot be determined.
\note The storage location returned can be a directory that does not exist; i.e., it
may need to be created by the system or the user.
*/
QString QDesktopServices::storageLocation(StandardLocation type)
{
switch (type) {
case StandardLocation::DesktopLocation: {
return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
}
case StandardLocation::DocumentsLocation: {
return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
}
case StandardLocation::MusicLocation: {
return QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
}
case StandardLocation::MoviesLocation: {
return QStandardPaths::writableLocation(QStandardPaths::VideosLocation);
}
case StandardLocation::PicturesLocation: {
return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
}
case StandardLocation::DataLocation: {
return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
}
case StandardLocation::CacheLocation: {
return QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
}
}
Q_UNREACHABLE();
}
/*!
Returns a localized display name for the given location \a type or
an empty QString if no relevant location can be found.
*/
QString QDesktopServices::displayName(StandardLocation type)
{
switch (type) {
case StandardLocation::DesktopLocation: {
return QStandardPaths::displayName(QStandardPaths::DesktopLocation);
}
case StandardLocation::DocumentsLocation: {
return QStandardPaths::displayName(QStandardPaths::DocumentsLocation);
}
case StandardLocation::MusicLocation: {
return QStandardPaths::displayName(QStandardPaths::MusicLocation);
}
case StandardLocation::MoviesLocation: {
return QStandardPaths::displayName(QStandardPaths::VideosLocation);
}
case StandardLocation::PicturesLocation: {
return QStandardPaths::displayName(QStandardPaths::PicturesLocation);
}
case StandardLocation::DataLocation: {
return QStandardPaths::displayName(QStandardPaths::DataLocation);
}
case StandardLocation::CacheLocation: {
return QStandardPaths::displayName(QStandardPaths::CacheLocation);
}
}
Q_UNREACHABLE();
}
QT_END_NAMESPACE
#endif // QT_NO_DESKTOPSERVICES
#include "moc_qdesktopservices.cpp"

View file

@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtGui module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDESKTOPSERVICES_H
#define QDESKTOPSERVICES_H
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DESKTOPSERVICES
class QStringList;
class QUrl;
class QObject;
class Q_GUI_EXPORT QDesktopServices
{
public:
static bool openUrl(const QUrl &url);
static void setUrlHandler(const QString &scheme, QObject *receiver, const char *method);
static void unsetUrlHandler(const QString &scheme);
enum StandardLocation {
DesktopLocation,
DocumentsLocation,
MusicLocation,
MoviesLocation,
PicturesLocation,
DataLocation,
CacheLocation
};
static QString storageLocation(StandardLocation type);
static QString displayName(StandardLocation type);
};
#endif // QT_NO_DESKTOPSERVICES
QT_END_NAMESPACE
#endif // QDESKTOPSERVICES_H

View file

@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE
of type QEvent::ToolTip. Additionally, the QSystemTrayIcon receives wheel events of
type QEvent::Wheel. These are not supported on any other platform.
\sa QDesktopServices, QDesktopWidget, {Desktop Integration}, {System Tray Icon Example}
\sa QStandardPaths, QDesktopWidget, {Desktop Integration}, {System Tray Icon Example}
*/
/*!

View file

@ -586,7 +586,7 @@ int QLabel::heightForWidth(int w) const
\since 4.2
Specifies whether QLabel should automatically open links using
QDesktopServices::openUrl() instead of emitting the
QStandardPaths::openUrl() instead of emitting the
linkActivated() signal.
\bold{Note:} The textInteractionFlags set on the label need to include

View file

@ -36,7 +36,7 @@
#include "qdir.h"
#include "qwhatsthis.h"
#include "qtextobject.h"
#include "qdesktopservices.h"
#include "qstandardpaths.h"
QT_BEGIN_NAMESPACE
@ -186,7 +186,6 @@ void QTextBrowserPrivate::_q_activateAnchor(const QString &href)
textOrSourceChanged = false;
#ifndef QT_NO_DESKTOPSERVICES
if ((openExternalLinks
&& url.scheme() != QLatin1String("file")
&& url.scheme() != QLatin1String("qrc")
@ -194,10 +193,9 @@ void QTextBrowserPrivate::_q_activateAnchor(const QString &href)
|| (url.isRelative() && !currentURL.isRelative()
&& currentURL.scheme() != QLatin1String("file")
&& currentURL.scheme() != QLatin1String("qrc"))) {
QDesktopServices::openUrl(url);
QStandardPaths::openUrl(url);
return;
}
#endif
emit q->anchorClicked(url);
@ -891,7 +889,7 @@ int QTextBrowser::backwardHistoryCount() const
\since 4.2
Specifies whether QTextBrowser should automatically open links to external
sources using QDesktopServices::openUrl() instead of emitting the
sources using QStandardPaths::openUrl() instead of emitting the
anchorClicked signal. Links are considered external if their scheme is
neither file or qrc.

View file

@ -120,7 +120,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

@ -216,7 +216,6 @@ static const struct ClassTblData {
{ QLatin1String("QDesignerWidgetBoxInterface"), QLatin1String("QtDesigner/abstractwidgetbox.h") },
{ QLatin1String("QDesignerWidgetDataBaseInterface"), QLatin1String("QtDesigner/abstractwidgetdatabase.h") },
{ QLatin1String("QDesignerWidgetFactoryInterface"), QLatin1String("QtDesigner/abstractwidgetfactory.h") },
{ QLatin1String("QDesktopServices"), QLatin1String("QtGui/qdesktopservices.h") },
{ QLatin1String("QDesktopWidget"), QLatin1String("QtGui/qdesktopwidget.h") },
{ QLatin1String("QDial"), QLatin1String("QtGui/qdial.h") },
{ QLatin1String("QDialog"), QLatin1String("QtGui/qdialog.h") },

View file

@ -27,7 +27,7 @@
#include <QDebug>
#include <QtTest/QtTest>
#include <QIODevice>
#include <QDesktopServices>
#include <QStandardPaths>
#include <QDirIterator>
@ -89,8 +89,8 @@ void tst_qnetworkdiskcache::timeInsertion_data()
{
QTest::addColumn<QString>("cacheRootDirectory");
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
QString cacheLoc = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
QTest::newRow("QStandardPaths Cache Location") << cacheLoc;
}
//This functions times an insert() operation.
@ -148,10 +148,7 @@ void tst_qnetworkdiskcache::timeInsertion()
void tst_qnetworkdiskcache::timeRead_data()
{
QTest::addColumn<QString>("cacheRootDirectory");
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
timeInsertion_data();
}
//Times metadata as well payload lookup
@ -207,10 +204,7 @@ void tst_qnetworkdiskcache::timeRead()
void tst_qnetworkdiskcache::timeRemoval_data()
{
QTest::addColumn<QString>("cacheRootDirectory");
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
timeInsertion_data();
}
void tst_qnetworkdiskcache::timeRemoval()
@ -257,10 +251,7 @@ void tst_qnetworkdiskcache::timeRemoval()
void tst_qnetworkdiskcache::timeExpiration_data()
{
QTest::addColumn<QString>("cacheRootDirectory");
QString cacheLoc = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
QTest::newRow("QDesktopServices Cache Location") << cacheLoc;
timeInsertion_data();
}
void tst_qnetworkdiskcache::timeExpiration()
{