qdesktopservices.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/util/qdesktopservices.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8class QOpenUrlHandlerRegistry : public QObject-
9{-
10 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
11#pragma GCC diagnostic push-
12 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
13#pragma GCC diagnostic pop-
14 struct QPrivateSignal {};-
15public:-
16 inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {}-
17-
18 QMutex mutex;-
19-
20 struct Handler-
21 {-
22 QObject *receiver;-
23 QByteArray name;-
24 };-
25 typedef QHash<QString, Handler> HandlerHash;-
26 HandlerHash handlers;-
27-
28public :-
29 void handlerDestroyed(QObject *handler);-
30-
31};-
32-
33namespace { namespace Q_QGS_handlerRegistry { typedef QOpenUrlHandlerRegistry Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QOpenUrlHandlerRegistry, Q_QGS_handlerRegistry::innerFunction, Q_QGS_handlerRegistry::guard> handlerRegistry;-
34-
35void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)-
36{-
37 HandlerHash::Iterator it = handlers.begin();-
38 while (it != handlers.end()) {-
39 if (it->receiver == handler) {-
40 it = handlers.erase(it);-
41 } else {-
42 ++it;-
43 }-
44 }-
45}-
46bool QDesktopServices::openUrl(const QUrl &url)-
47{-
48 QOpenUrlHandlerRegistry *registry = handlerRegistry();-
49 QMutexLocker locker(&registry->mutex);-
50 static bool insideOpenUrlHandler = false;-
51-
52 if (!insideOpenUrlHandler) {-
53 QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme());-
54 if (handler != registry->handlers.constEnd()) {-
55 insideOpenUrlHandler = true;-
56 bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, QArgument<QUrl >("QUrl", url));-
57 insideOpenUrlHandler = false;-
58 return result;-
59 }-
60 }-
61 if (!url.isValid())-
62 return false;-
63-
64 QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();-
65 if (!platformIntegration)-
66 return false;-
67-
68 QPlatformServices *platformServices = platformIntegration->services();-
69 if (!platformServices) {-
70 QMessageLogger(__FILE__, 200206, __PRETTY_FUNCTION__).warning("The platform plugin does not support services.");-
71 return false;-
72 }-
73 return url.scheme() == QLatin1String("file") ?-
74 platformServices->openDocument(url) : platformServices->openUrl(url);-
75}-
76void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method)-
77{-
78 QOpenUrlHandlerRegistry *registry = handlerRegistry();-
79 QMutexLocker locker(&registry->mutex);-
80 if (!receiver) {-
81 registry->handlers.remove(scheme.toLower());-
82 return;-
83 }-
84 QOpenUrlHandlerRegistry::Handler h;-
85 h.receiver = receiver;-
86 h.name = method;-
87 registry->handlers.insert(scheme.toLower(), h);-
88 QObject::connect(receiver, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "241""247"),-
89 registry, qFlagLocation("1""handlerDestroyed(QObject*)" "\0" __FILE__ ":" "242""248"));-
90}-
91-
92-
93-
94-
95-
96-
97void QDesktopServices::unsetUrlHandler(const QString &scheme)-
98{-
99 setUrlHandler(scheme, 0, 0);-
100}-
101extern __attribute__((visibility("default"))) QString qt_applicationName_noFallback();-
102-
103QString QDesktopServices::storageLocationImpl(QStandardPaths::StandardLocation type)-
104{-
105 if (type == QStandardPaths::AppLocalDataLocation
type == QStand...alDataLocationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
106-
107-
108-
109 const QString compatAppName = qt_applicationName_noFallback();-
110 const QString baseDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);-
111 const QString organizationName = QCoreApplication::organizationName();-
112 return
never executed: return baseDir + QLatin1String("/data/") + organizationName + QLatin1Char('/') + compatAppName;
baseDir + QLatin1String("/data/")
never executed: return baseDir + QLatin1String("/data/") + organizationName + QLatin1Char('/') + compatAppName;
0
113 + QCoreApplication::organizationName ()+ QLatin1Char('/') + compatAppName;
never executed: return baseDir + QLatin1String("/data/") + organizationName + QLatin1Char('/') + compatAppName;
0
114-
115 }-
116 return
never executed: return QStandardPaths::writableLocation(type);
QStandardPaths::writableLocation(type);
never executed: return QStandardPaths::writableLocation(type);
0
117}-
118-
119-
120-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9