Make QApplication::type() set by QGuiApplication.

QApplication::type used to be static and set by the
QApplicationPrivate constructors.

In QCoreApplication we have the new application_type that should take its place.
QApplication::GuiServer is deprecated (since it doesn't have any functionallity
any more with QWS being removed).

This change prepares QStyle to be called from a QQuickCanvase based application
that does not inherit the QWidget version of QApplication.

Change-Id: Ifbe992e25f1e5821fa047b6eb915f75fa675ab97
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
This commit is contained in:
Frederik Gladhorn 2011-12-12 14:12:15 +01:00 committed by Qt by Nokia
parent 1b6b1358bf
commit 2e02aaf24c
5 changed files with 22 additions and 16 deletions

View File

@ -2587,6 +2587,14 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
\sa Q_OBJECT, QObject::tr(), QObject::trUtf8()
*/
/*!
\enum QCoreApplication::Type
\value Tty a console application
\value GuiClient a GUI application
\value GuiServer \e{Deprecated.} this value is only left for compatibility.
*/
QT_END_NAMESPACE
#include "moc_qcoreapplication.cpp"

View File

@ -78,6 +78,12 @@ public:
enum { ApplicationFlags = QT_VERSION
};
enum Type {
Tty,
GuiClient,
GuiServer // # deprecated
};
QCoreApplication(int &argc, char **argv, int = ApplicationFlags);
~QCoreApplication();

View File

@ -186,6 +186,7 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
inputPanel(0)
{
self = this;
application_type = QCoreApplication::GuiClient;
}
QWindow *QGuiApplication::focusWindow()

View File

@ -139,7 +139,6 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT void qt_call_post_routines();
QApplication::Type qt_appType=QApplication::Tty;
QApplicationPrivate *QApplicationPrivate::self = 0;
QInputContext *QApplicationPrivate::inputContext = 0;
@ -157,7 +156,6 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T
: QApplicationPrivateBase(argc, argv, flags)
{
application_type = type;
qt_appType = type;
#ifndef QT_NO_SESSIONMANAGER
is_session_restored = false;
@ -365,14 +363,6 @@ QApplicationPrivate::~QApplicationPrivate()
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
*/
/*!
\enum QApplication::Type
\value Tty a console application
\value GuiClient a GUI client application
\value GuiServer a GUI server application (for Qt for Embedded Linux)
*/
/*!
\enum QApplication::ColorSpec
@ -743,11 +733,11 @@ void QApplicationPrivate::construct(
{
initResources();
qt_is_gui_used = (qt_appType != QApplication::Tty);
qt_is_gui_used = (application_type != QApplication::Tty);
process_cmdline();
// Must be called before initialize()
qt_init(this, qt_appType
qt_init(this, application_type
#ifdef Q_WS_X11
, dpy, visual, cmap
#endif
@ -873,7 +863,7 @@ void QApplicationPrivate::initialize()
QWidgetPrivate::mapper = new QWidgetMapper;
QWidgetPrivate::allWidgets = new QWidgetSet;
if (qt_appType != QApplication::Tty)
if (application_type != QApplication::Tty)
(void) QApplication::style(); // trigger creation of application style
#ifndef QT_NO_STATEMACHINE
// trigger registering of QStateMachine's GUI types
@ -917,7 +907,9 @@ void QApplicationPrivate::initialize()
*/
QApplication::Type QApplication::type()
{
return qt_appType;
if (QApplicationPrivate::instance())
return (QCoreApplication::Type)QApplicationPrivate::instance()->application_type;
return Tty;
}
/*****************************************************************************
@ -1275,7 +1267,7 @@ QStyle *QApplication::style()
{
if (QApplicationPrivate::app_style)
return QApplicationPrivate::app_style;
if (!qt_is_gui_used) {
if (qApp->type() == QApplication::Tty) {
Q_ASSERT(!"No style available in non-gui applications!");
return 0;
}

View File

@ -98,7 +98,6 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
public:
enum Type { Tty, GuiClient, GuiServer };
#ifndef qdoc
QApplication(int &argc, char **argv, int = ApplicationFlags);