summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2011-12-12 14:12:15 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-12 17:28:24 +0100
commit2e02aaf24c7803b672cdf815f33f3ecd48d98822 (patch)
tree6854d3807c34e0752e245fcfb5bec96c21826665
parent1b6b1358bf2b3597747688332afc893ece2e0cfb (diff)
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>
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp8
-rw-r--r--src/corelib/kernel/qcoreapplication.h6
-rw-r--r--src/gui/kernel/qguiapplication.cpp1
-rw-r--r--src/widgets/kernel/qapplication.cpp22
-rw-r--r--src/widgets/kernel/qapplication.h1
5 files changed, 22 insertions, 16 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 7ff82b1bca..7523963485 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -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"
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 3d6aa170fd..0135d88045 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -78,6 +78,12 @@ public:
enum { ApplicationFlags = QT_VERSION
};
+ enum Type {
+ Tty,
+ GuiClient,
+ GuiServer // # deprecated
+ };
+
QCoreApplication(int &argc, char **argv, int = ApplicationFlags);
~QCoreApplication();
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 28ce2e599b..dc8e5edb56 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -186,6 +186,7 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
inputPanel(0)
{
self = this;
+ application_type = QCoreApplication::GuiClient;
}
QWindow *QGuiApplication::focusWindow()
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index c94c48e28b..4c4cb4061c 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -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;
@@ -366,14 +364,6 @@ QApplicationPrivate::~QApplicationPrivate()
*/
/*!
- \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
\value NormalColor the default color allocation policy
@@ -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;
}
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index 1792d2f05d..4883ecefac 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -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);