Warning, file /include/QtCore/qcoreapplication.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QCOREAPPLICATION_H
0005 #define QCOREAPPLICATION_H
0006
0007 #include <QtCore/qglobal.h>
0008 #include <QtCore/qstring.h>
0009 #ifndef QT_NO_QOBJECT
0010 #include <QtCore/qcoreevent.h>
0011 #include <QtCore/qdeadlinetimer.h>
0012 #include <QtCore/qeventloop.h>
0013 #include <QtCore/qobject.h>
0014 #else
0015 #include <QtCore/qscopedpointer.h>
0016 #endif
0017 #include <QtCore/qnativeinterface.h>
0018
0019 #ifndef QT_NO_QOBJECT
0020 #if defined(Q_OS_WIN) && !defined(tagMSG)
0021 typedef struct tagMSG MSG;
0022 #endif
0023 #endif
0024
0025 QT_BEGIN_NAMESPACE
0026
0027
0028 class QCoreApplicationPrivate;
0029 class QDebug;
0030 class QTranslator;
0031 class QPostEventList;
0032 class QAbstractEventDispatcher;
0033 class QAbstractNativeEventFilter;
0034 class QEventLoopLocker;
0035
0036 #if QT_CONFIG(permissions) || defined(Q_QDOC)
0037 class QPermission;
0038 #endif
0039
0040 #define qApp QCoreApplication::instance()
0041
0042 class Q_CORE_EXPORT QCoreApplication
0043 #ifndef QT_NO_QOBJECT
0044 : public QObject
0045 #endif
0046 {
0047 #ifndef QT_NO_QOBJECT
0048 Q_OBJECT
0049 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName
0050 NOTIFY applicationNameChanged)
0051 Q_PROPERTY(QString applicationVersion READ applicationVersion WRITE setApplicationVersion
0052 NOTIFY applicationVersionChanged)
0053 Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName
0054 NOTIFY organizationNameChanged)
0055 Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain
0056 NOTIFY organizationDomainChanged)
0057 Q_PROPERTY(bool quitLockEnabled READ isQuitLockEnabled WRITE setQuitLockEnabled)
0058 #endif
0059
0060 Q_DECLARE_PRIVATE(QCoreApplication)
0061 friend class QEventLoopLocker;
0062 #if QT_CONFIG(permissions)
0063 using RequestPermissionPrototype = void(*)(QPermission);
0064 #endif
0065
0066 public:
0067 enum { ApplicationFlags = QT_VERSION
0068 };
0069
0070 QCoreApplication(int &argc, char **argv
0071 #ifndef Q_QDOC
0072 , int = ApplicationFlags
0073 #endif
0074 );
0075
0076 ~QCoreApplication();
0077
0078 static QStringList arguments();
0079
0080 static void setAttribute(Qt::ApplicationAttribute attribute, bool on = true);
0081 static bool testAttribute(Qt::ApplicationAttribute attribute);
0082
0083 static void setOrganizationDomain(const QString &orgDomain);
0084 static QString organizationDomain();
0085 static void setOrganizationName(const QString &orgName);
0086 static QString organizationName();
0087 static void setApplicationName(const QString &application);
0088 static QString applicationName();
0089 static void setApplicationVersion(const QString &version);
0090 static QString applicationVersion();
0091
0092 static void setSetuidAllowed(bool allow);
0093 static bool isSetuidAllowed();
0094
0095 #if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
0096 static QCoreApplication *instance() noexcept { return self.loadRelaxed(); }
0097 #else
0098 static QCoreApplication *instance() noexcept { return self; }
0099 #endif
0100
0101 #ifndef QT_NO_QOBJECT
0102 static int exec();
0103 static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
0104 static void processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime);
0105 static void processEvents(QEventLoop::ProcessEventsFlags flags, QDeadlineTimer deadline);
0106
0107 static bool sendEvent(QObject *receiver, QEvent *event);
0108 static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority);
0109 static void sendPostedEvents(QObject *receiver = nullptr, int event_type = 0);
0110 static void removePostedEvents(QObject *receiver, int eventType = 0);
0111 static QAbstractEventDispatcher *eventDispatcher();
0112 static void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
0113
0114 virtual bool notify(QObject *, QEvent *);
0115
0116 static bool startingUp();
0117 static bool closingDown();
0118 #endif
0119
0120 static QString applicationDirPath();
0121 static QString applicationFilePath();
0122 static qint64 applicationPid() Q_DECL_CONST_FUNCTION;
0123
0124 #if QT_CONFIG(permissions) || defined(Q_QDOC)
0125 Qt::PermissionStatus checkPermission(const QPermission &permission);
0126
0127 # ifdef Q_QDOC
0128 template <typename Functor>
0129 void requestPermission(const QPermission &permission, const QObject *context, Functor functor);
0130 # else
0131
0132
0133 template <typename Functor,
0134 std::enable_if_t<
0135 QtPrivate::AreFunctionsCompatible<RequestPermissionPrototype, Functor>::value,
0136 bool> = true>
0137 void requestPermission(const QPermission &permission,
0138 const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *receiver,
0139 Functor &&func)
0140 {
0141 requestPermission(permission,
0142 QtPrivate::makeCallableObject<RequestPermissionPrototype>(std::forward<Functor>(func)),
0143 receiver);
0144 }
0145 # endif
0146
0147 #ifndef QT_NO_CONTEXTLESS_CONNECT
0148 #ifdef Q_QDOC
0149 template <typename Functor>
0150 #else
0151
0152 template <typename Functor,
0153 std::enable_if_t<
0154 QtPrivate::AreFunctionsCompatible<RequestPermissionPrototype, Functor>::value,
0155 bool> = true>
0156 #endif
0157 void requestPermission(const QPermission &permission, Functor &&func)
0158 {
0159 requestPermission(permission, nullptr, std::forward<Functor>(func));
0160 }
0161 #endif
0162
0163 private:
0164
0165 void requestPermission(const QPermission &permission,
0166 QtPrivate::QSlotObjectBase *slotObj, const QObject *context);
0167 public:
0168
0169 #endif
0170
0171 #if QT_CONFIG(library)
0172 static void setLibraryPaths(const QStringList &);
0173 static QStringList libraryPaths();
0174 static void addLibraryPath(const QString &);
0175 static void removeLibraryPath(const QString &);
0176 #endif
0177
0178 #ifndef QT_NO_TRANSLATION
0179 static bool installTranslator(QTranslator * messageFile);
0180 static bool removeTranslator(QTranslator * messageFile);
0181 #endif
0182
0183 static QString translate(const char * context,
0184 const char * key,
0185 const char * disambiguation = nullptr,
0186 int n = -1);
0187
0188 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QCoreApplication)
0189
0190 #ifndef QT_NO_QOBJECT
0191 void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
0192 void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
0193
0194 static bool isQuitLockEnabled();
0195 static void setQuitLockEnabled(bool enabled);
0196
0197 public Q_SLOTS:
0198 static void quit();
0199 static void exit(int retcode = 0);
0200
0201 Q_SIGNALS:
0202 void aboutToQuit(QPrivateSignal);
0203
0204 void organizationNameChanged();
0205 void organizationDomainChanged();
0206 void applicationNameChanged();
0207 void applicationVersionChanged();
0208
0209 protected:
0210 bool event(QEvent *) override;
0211
0212 virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
0213 #endif
0214
0215 protected:
0216 QCoreApplication(QCoreApplicationPrivate &p);
0217
0218 #ifdef QT_NO_QOBJECT
0219 std::unique_ptr<QCoreApplicationPrivate> d_ptr;
0220 #endif
0221
0222 private:
0223 #ifndef QT_NO_QOBJECT
0224 static bool sendSpontaneousEvent(QObject *receiver, QEvent *event);
0225 static bool notifyInternal2(QObject *receiver, QEvent *);
0226 static bool forwardEvent(QObject *receiver, QEvent *event, QEvent *originatingEvent = nullptr);
0227 #endif
0228 #if QT_CONFIG(library)
0229 static QStringList libraryPathsLocked();
0230 #endif
0231
0232 #if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
0233 static QBasicAtomicPointer<QCoreApplication> self;
0234 #else
0235 static QCoreApplication *self;
0236 #endif
0237
0238 Q_DISABLE_COPY(QCoreApplication)
0239
0240 friend class QApplication;
0241 friend class QApplicationPrivate;
0242 friend class QGuiApplication;
0243 friend class QGuiApplicationPrivate;
0244 friend class QWidget;
0245 friend class QWidgetWindow;
0246 friend class QWidgetPrivate;
0247 friend class QWindowPrivate;
0248 #ifndef QT_NO_QOBJECT
0249 friend class QEventDispatcherUNIXPrivate;
0250 friend class QCocoaEventDispatcherPrivate;
0251 friend bool qt_sendSpontaneousEvent(QObject *, QEvent *);
0252 #endif
0253 friend Q_CORE_EXPORT QString qAppName();
0254 friend class QCommandLineParserPrivate;
0255 };
0256
0257 #define Q_DECLARE_TR_FUNCTIONS(context) \
0258 public: \
0259 static inline QString tr(const char *sourceText, const char *disambiguation = nullptr, int n = -1) \
0260 { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
0261 private:
0262
0263 typedef void (*QtStartUpFunction)();
0264 typedef void (*QtCleanUpFunction)();
0265
0266 Q_CORE_EXPORT void qAddPreRoutine(QtStartUpFunction);
0267 Q_CORE_EXPORT void qAddPostRoutine(QtCleanUpFunction);
0268 Q_CORE_EXPORT void qRemovePostRoutine(QtCleanUpFunction);
0269 Q_CORE_EXPORT QString qAppName();
0270
0271 #define Q_COREAPP_STARTUP_FUNCTION(AFUNC) \
0272 static void AFUNC ## _ctor_function() { \
0273 qAddPreRoutine(AFUNC); \
0274 } \
0275 Q_CONSTRUCTOR_FUNCTION(AFUNC ## _ctor_function)
0276
0277 #ifndef QT_NO_QOBJECT
0278 #if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG_STREAM)
0279 Q_CORE_EXPORT QString decodeMSG(const MSG &);
0280 Q_CORE_EXPORT QDebug operator<<(QDebug, const MSG &);
0281 #endif
0282 #endif
0283
0284 QT_END_NAMESPACE
0285
0286 #include <QtCore/qcoreapplication_platform.h>
0287
0288 #endif