LCOV - code coverage report
Current view: top level - usr/include/x86_64-linux-gnu/qt5/QtCore - qcoreapplication.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2017-03-02 17:11:10 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /****************************************************************************
       2             : **
       3             : ** Copyright (C) 2016 The Qt Company Ltd.
       4             : ** Contact: https://www.qt.io/licensing/
       5             : **
       6             : ** This file is part of the QtCore module of the Qt Toolkit.
       7             : **
       8             : ** $QT_BEGIN_LICENSE:LGPL$
       9             : ** Commercial License Usage
      10             : ** Licensees holding valid commercial Qt licenses may use this file in
      11             : ** accordance with the commercial license agreement provided with the
      12             : ** Software or, alternatively, in accordance with the terms contained in
      13             : ** a written agreement between you and The Qt Company. For licensing terms
      14             : ** and conditions see https://www.qt.io/terms-conditions. For further
      15             : ** information use the contact form at https://www.qt.io/contact-us.
      16             : **
      17             : ** GNU Lesser General Public License Usage
      18             : ** Alternatively, this file may be used under the terms of the GNU Lesser
      19             : ** General Public License version 3 as published by the Free Software
      20             : ** Foundation and appearing in the file LICENSE.LGPL3 included in the
      21             : ** packaging of this file. Please review the following information to
      22             : ** ensure the GNU Lesser General Public License version 3 requirements
      23             : ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
      24             : **
      25             : ** GNU General Public License Usage
      26             : ** Alternatively, this file may be used under the terms of the GNU
      27             : ** General Public License version 2.0 or (at your option) the GNU General
      28             : ** Public license version 3 or any later version approved by the KDE Free
      29             : ** Qt Foundation. The licenses are as published by the Free Software
      30             : ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
      31             : ** included in the packaging of this file. Please review the following
      32             : ** information to ensure the GNU General Public License requirements will
      33             : ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
      34             : ** https://www.gnu.org/licenses/gpl-3.0.html.
      35             : **
      36             : ** $QT_END_LICENSE$
      37             : **
      38             : ****************************************************************************/
      39             : 
      40             : #ifndef QCOREAPPLICATION_H
      41             : #define QCOREAPPLICATION_H
      42             : 
      43             : #include <QtCore/qglobal.h>
      44             : #include <QtCore/qstring.h>
      45             : #ifndef QT_NO_QOBJECT
      46             : #include <QtCore/qobject.h>
      47             : #include <QtCore/qcoreevent.h>
      48             : #include <QtCore/qeventloop.h>
      49             : #else
      50             : #include <QtCore/qscopedpointer.h>
      51             : #endif
      52             : 
      53             : #ifndef QT_NO_QOBJECT
      54             : #if defined(Q_OS_WIN) && !defined(tagMSG)
      55             : typedef struct tagMSG MSG;
      56             : #endif
      57             : #endif
      58             : 
      59             : QT_BEGIN_NAMESPACE
      60             : 
      61             : 
      62             : class QCoreApplicationPrivate;
      63             : class QTextCodec;
      64             : class QTranslator;
      65             : class QPostEventList;
      66             : class QStringList;
      67             : class QAbstractEventDispatcher;
      68             : class QAbstractNativeEventFilter;
      69             : 
      70             : #define qApp QCoreApplication::instance()
      71             : 
      72             : class Q_CORE_EXPORT QCoreApplication
      73             : #ifndef QT_NO_QOBJECT
      74             :     : public QObject
      75             : #endif
      76             : {
      77             : #ifndef QT_NO_QOBJECT
      78             :     Q_OBJECT
      79             :     Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
      80             :     Q_PROPERTY(QString applicationVersion READ applicationVersion WRITE setApplicationVersion NOTIFY applicationVersionChanged)
      81             :     Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName NOTIFY organizationNameChanged)
      82             :     Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain NOTIFY organizationDomainChanged)
      83             :     Q_PROPERTY(bool quitLockEnabled READ isQuitLockEnabled WRITE setQuitLockEnabled)
      84             : #endif
      85             : 
      86             :     Q_DECLARE_PRIVATE(QCoreApplication)
      87             : public:
      88             :     enum { ApplicationFlags = QT_VERSION
      89             :     };
      90             : 
      91             :     QCoreApplication(int &argc, char **argv
      92             : #ifndef Q_QDOC
      93             :                      , int = ApplicationFlags
      94             : #endif
      95             :             );
      96             : 
      97             :     ~QCoreApplication();
      98             : 
      99             :     static QStringList arguments();
     100             : 
     101             :     static void setAttribute(Qt::ApplicationAttribute attribute, bool on = true);
     102             :     static bool testAttribute(Qt::ApplicationAttribute attribute);
     103             : 
     104             :     static void setOrganizationDomain(const QString &orgDomain);
     105             :     static QString organizationDomain();
     106             :     static void setOrganizationName(const QString &orgName);
     107             :     static QString organizationName();
     108             :     static void setApplicationName(const QString &application);
     109             :     static QString applicationName();
     110             :     static void setApplicationVersion(const QString &version);
     111             :     static QString applicationVersion();
     112             : 
     113             :     static void setSetuidAllowed(bool allow);
     114             :     static bool isSetuidAllowed();
     115             : 
     116          37 :     static QCoreApplication *instance() { return self; }
     117             : 
     118             : #ifndef QT_NO_QOBJECT
     119             :     static int exec();
     120             :     static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
     121             :     static void processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime);
     122             :     static void exit(int retcode=0);
     123             : 
     124             :     static bool sendEvent(QObject *receiver, QEvent *event);
     125             :     static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority);
     126             :     static void sendPostedEvents(QObject *receiver = Q_NULLPTR, int event_type = 0);
     127             :     static void removePostedEvents(QObject *receiver, int eventType = 0);
     128             : #if QT_DEPRECATED_SINCE(5, 3)
     129             :     QT_DEPRECATED static bool hasPendingEvents();
     130             : #endif
     131             :     static QAbstractEventDispatcher *eventDispatcher();
     132             :     static void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
     133             : 
     134             :     virtual bool notify(QObject *, QEvent *);
     135             : 
     136             :     static bool startingUp();
     137             :     static bool closingDown();
     138             : #endif
     139             : 
     140             :     static QString applicationDirPath();
     141             :     static QString applicationFilePath();
     142             :     static qint64 applicationPid();
     143             : 
     144             : #ifndef QT_NO_LIBRARY
     145             :     static void setLibraryPaths(const QStringList &);
     146             :     static QStringList libraryPaths();
     147             :     static void addLibraryPath(const QString &);
     148             :     static void removeLibraryPath(const QString &);
     149             : #endif // QT_NO_LIBRARY
     150             : 
     151             : #ifndef QT_NO_TRANSLATION
     152             :     static bool installTranslator(QTranslator * messageFile);
     153             :     static bool removeTranslator(QTranslator * messageFile);
     154             : #endif
     155             : 
     156             :     static QString translate(const char * context,
     157             :                              const char * key,
     158             :                              const char * disambiguation = Q_NULLPTR,
     159             :                              int n = -1);
     160             : #if QT_DEPRECATED_SINCE(5, 0)
     161             :     enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = UnicodeUTF8, CodecForTr = UnicodeUTF8 };
     162             :     QT_DEPRECATED static inline QString translate(const char * context, const char * key,
     163             :                              const char * disambiguation, Encoding, int n = -1)
     164             :         { return translate(context, key, disambiguation, n); }
     165             : #endif
     166             : 
     167             : #ifndef QT_NO_QOBJECT
     168             :     static void flush();
     169             : 
     170             :     void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
     171             :     void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
     172             : 
     173             :     static bool isQuitLockEnabled();
     174             :     static void setQuitLockEnabled(bool enabled);
     175             : 
     176             : public Q_SLOTS:
     177             :     static void quit();
     178             : 
     179             : Q_SIGNALS:
     180             :     void aboutToQuit(QPrivateSignal);
     181             : 
     182             :     void organizationNameChanged();
     183             :     void organizationDomainChanged();
     184             :     void applicationNameChanged();
     185             :     void applicationVersionChanged();
     186             : 
     187             : protected:
     188             :     bool event(QEvent *) Q_DECL_OVERRIDE;
     189             : 
     190             :     virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
     191             : #endif // QT_NO_QOBJECT
     192             : 
     193             : protected:
     194             :     QCoreApplication(QCoreApplicationPrivate &p);
     195             : 
     196             : #ifdef QT_NO_QOBJECT
     197             :     QScopedPointer<QCoreApplicationPrivate> d_ptr;
     198             : #endif
     199             : 
     200             : private:
     201             : #ifndef QT_NO_QOBJECT
     202             :     static bool sendSpontaneousEvent(QObject *receiver, QEvent *event);
     203             : #  if QT_DEPRECATED_SINCE(5,6)
     204             :     QT_DEPRECATED bool notifyInternal(QObject *receiver, QEvent *event); // ### Qt6 BIC: remove me
     205             : #  endif
     206             :     static bool notifyInternal2(QObject *receiver, QEvent *);
     207             : #endif
     208             : 
     209             :     static QCoreApplication *self;
     210             : 
     211             :     Q_DISABLE_COPY(QCoreApplication)
     212             : 
     213             :     friend class QApplication;
     214             :     friend class QApplicationPrivate;
     215             :     friend class QGuiApplication;
     216             :     friend class QGuiApplicationPrivate;
     217             :     friend class QWidget;
     218             :     friend class QWidgetWindow;
     219             :     friend class QWidgetPrivate;
     220             : #ifndef QT_NO_QOBJECT
     221             :     friend class QEventDispatcherUNIXPrivate;
     222             :     friend class QCocoaEventDispatcherPrivate;
     223             :     friend bool qt_sendSpontaneousEvent(QObject*, QEvent*);
     224             : #endif
     225             :     friend Q_CORE_EXPORT QString qAppName();
     226             :     friend class QClassFactory;
     227             : };
     228             : 
     229             : #ifndef QT_NO_QOBJECT
     230             : inline bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event)
     231             : {  if (event) event->spont = false; return notifyInternal2(receiver, event); }
     232             : 
     233             : inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event)
     234             : { if (event) event->spont = true; return notifyInternal2(receiver, event); }
     235             : #endif
     236             : 
     237             : #ifdef QT_NO_DEPRECATED
     238             : #  define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context)
     239             : #else
     240             : #  define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \
     241             :     QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \
     242             :         { return QCoreApplication::translate(#context, sourceText, disambiguation, n); }
     243             : #endif
     244             : 
     245             : #define Q_DECLARE_TR_FUNCTIONS(context) \
     246             : public: \
     247             :     static inline QString tr(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \
     248             :         { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
     249             :     QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \
     250             : private:
     251             : 
     252             : typedef void (*QtStartUpFunction)();
     253             : typedef void (*QtCleanUpFunction)();
     254             : 
     255             : Q_CORE_EXPORT void qAddPreRoutine(QtStartUpFunction);
     256             : Q_CORE_EXPORT void qAddPostRoutine(QtCleanUpFunction);
     257             : Q_CORE_EXPORT void qRemovePostRoutine(QtCleanUpFunction);
     258             : Q_CORE_EXPORT QString qAppName();                // get application name
     259             : 
     260             : #define Q_COREAPP_STARTUP_FUNCTION(AFUNC) \
     261             :     static void AFUNC ## _ctor_function() {  \
     262             :         qAddPreRoutine(AFUNC);        \
     263             :     }                                 \
     264             :     Q_CONSTRUCTOR_FUNCTION(AFUNC ## _ctor_function)
     265             : 
     266             : #ifndef QT_NO_QOBJECT
     267             : #if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG_STREAM)
     268             : Q_CORE_EXPORT QString decodeMSG(const MSG &);
     269             : Q_CORE_EXPORT QDebug operator<<(QDebug, const MSG &);
     270             : #endif
     271             : #endif
     272             : 
     273             : QT_END_NAMESPACE
     274             : 
     275             : #endif // QCOREAPPLICATION_H

Generated by: LCOV version 1.13