From: J-P Nurmi Date: Thu, 22 Nov 2012 13:29:07 +0000 (+0100) Subject: Remove QApplication::type() and make QCoreApplication::Type internal X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=553e216d891177ee0c2cea70bbd7f21103fc7795;p=profile%2Fivi%2Fqtbase.git Remove QApplication::type() and make QCoreApplication::Type internal These Qt3 legacy application types do not match the application types available in Qt5. Thus, the decision was to kill the confusing and mostly useless type enum. Use for example qobject_cast instead to find out the application type. Task-number: QTBUG-28093 Change-Id: Ia8cf7c3ea98a3cea27f74760d62e519ea10bce9f Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index d64d46e..4160d9b 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -327,6 +327,11 @@ information about a particular change. - QPrintEngine - Removed the PPK_SuppressSystemPrintStatus key as no longer used. +- QCoreApplication::Type and QApplication::type() have been removed. These + Qt3 legacy application types did not match the application types + available in Qt5. Use for example qobject_cast instead to dynamically + find out the exact application type. + **************************************************************************** * General * **************************************************************************** diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 94b0566..83f444c 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -79,12 +79,6 @@ public: enum { ApplicationFlags = QT_VERSION }; - enum Type { - Tty, - GuiClient, - GuiServer // # deprecated - }; - QCoreApplication(int &argc, char **argv #ifndef Q_QDOC , int = ApplicationFlags diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 321f690..8d5eeff 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -69,6 +69,11 @@ class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QCoreApplication) public: + enum Type { + Tty, + Gui + }; + QCoreApplicationPrivate(int &aargc, char **aargv, uint flags); ~QCoreApplicationPrivate(); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 949c963..61c733b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -391,7 +391,7 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags lastTouchType(QEvent::TouchEnd) { self = this; - application_type = QCoreApplication::GuiClient; + application_type = QCoreApplicationPrivate::Gui; } /*! diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ae426fd..faf68cb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -155,10 +155,10 @@ bool QApplicationPrivate::autoSipEnabled = false; bool QApplicationPrivate::autoSipEnabled = true; #endif -QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags) +QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) : QApplicationPrivateBase(argc, argv, flags) { - application_type = type; + application_type = QApplicationPrivate::Gui; #ifndef QT_NO_SESSIONMANAGER is_session_restored = false; @@ -560,44 +560,7 @@ QApplication::QApplication(int &argc, char **argv) #else QApplication::QApplication(int &argc, char **argv, int _internal) #endif - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) -{ Q_D(QApplication); d->construct(); } - - -/*! - Constructs an application object with \a argc command line arguments in - \a argv. - - \warning The data referred to by \a argc and \a argv must stay valid for - the entire lifetime of the QApplication object. In addition, \a argc must - be greater than zero and \a argv must contain at least one valid character - string. - - The following example shows how to create an application that uses a - graphical interface when available. - - \obsolete - - \snippet code/src_gui_kernel_qapplication.cpp 0 -*/ - -QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal)) -{ Q_D(QApplication); d->construct();} - - - -/*! - Constructs an application object with \a argc command line arguments in - \a argv. - - \warning The data referred to by \a argc and \a argv must stay valid for - the entire lifetime of the QApplication object. In addition, \a argc must - be greater than zero and \a argv must contain at least one valid character - string. -*/ -QApplication::QApplication(int &argc, char **argv, Type type , int _internal) - : QGuiApplication(*new QApplicationPrivate(argc, argv, type, _internal)) + : QGuiApplication(*new QApplicationPrivate(argc, argv, _internal)) { Q_D(QApplication); d->construct(); } /*! @@ -607,7 +570,7 @@ void QApplicationPrivate::construct() { initResources(); - qt_is_gui_used = (application_type != QApplication::Tty); + qt_is_gui_used = (application_type != QApplicationPrivate::Tty); process_cmdline(); // Must be called before initialize() @@ -653,7 +616,7 @@ void QApplicationPrivate::initialize() QWidgetPrivate::mapper = new QWidgetMapper; QWidgetPrivate::allWidgets = new QWidgetSet; - if (application_type != QApplication::Tty) + if (application_type != QApplicationPrivate::Tty) (void) QApplication::style(); // trigger creation of application style #ifndef QT_NO_STATEMACHINE // trigger registering of QStateMachine's GUI types @@ -694,18 +657,6 @@ void QApplicationPrivate::initialize() QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt(); } -/*! - Returns the type of application (\l Tty, GuiClient, or - GuiServer). The type is set when constructing the QApplication - object. -*/ -QApplication::Type QApplication::type() -{ - if (QApplicationPrivate::instance()) - return (QCoreApplication::Type)QApplicationPrivate::instance()->application_type; - return Tty; -} - /***************************************************************************** Functions returning the active popup and modal widgets. *****************************************************************************/ @@ -1037,8 +988,8 @@ QStyle *QApplication::style() { if (QApplicationPrivate::app_style) return QApplicationPrivate::app_style; - if (qApp->type() == QApplication::Tty) { - Q_ASSERT(!"No style available in non-gui applications!"); + if (!qobject_cast(QCoreApplication::instance())) { + Q_ASSERT(!"No style available without QApplication!"); return 0; } diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 3c61ffe..86e9638 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -95,16 +95,13 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) public: - +#ifdef Q_QDOC + QApplication(int &argc, char **argv); +#else QApplication(int &argc, char **argv, int = ApplicationFlags); -#ifdef QT_DEPRECATED - QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); #endif - QApplication(int &argc, char **argv, Type, int = ApplicationFlags); virtual ~QApplication(); - static Type type(); - static QStyle *style(); static void setStyle(QStyle*); static QStyle *setStyle(const QString&); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 5b3493f..bba20bc 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -113,7 +113,7 @@ class Q_WIDGETS_EXPORT QApplicationPrivate : public QApplicationPrivateBase { Q_DECLARE_PUBLIC(QApplication) public: - QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags); + QApplicationPrivate(int &argc, char **argv, int flags); ~QApplicationPrivate(); virtual void notifyLayoutDirectionChange();