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 <lars.knoll@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e4e8578c35
commit
553e216d89
5
dist/changes-5.0.0
vendored
5
dist/changes-5.0.0
vendored
@ -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 *
|
||||
****************************************************************************
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -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<QApplication *>(QCoreApplication::instance())) {
|
||||
Q_ASSERT(!"No style available without QApplication!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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&);
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user