Qt 4.8
Classes | Functions | Variables
qapplication_qpa.cpp File Reference
#include "qapplication_p.h"
#include "qcolormap.h"
#include "qpixmapcache.h"
#include "qeventdispatcher_glib_qpa_p.h"
#include "qeventdispatcher_qpa_p.h"
#include "private/qcursor_p.h"
#include "private/qwidget_p.h"
#include "private/qevent_p.h"
#include "qgenericpluginfactory_qpa.h"
#include "qplatformintegrationfactory_qpa_p.h"
#include <qdesktopwidget.h>
#include <qinputcontext.h>
#include <QPlatformCursor>
#include <qdebug.h>
#include <QWindowSystemInterface>
#include "qwindowsysteminterface_qpa_p.h"
#include <QPlatformIntegration>
#include "qdesktopwidget_qpa_p.h"

Go to the source code of this file.

Classes

class  QDummyInputContext
 

Functions

static void cleanup_platform ()
 
static void init_platform (const QString &name, const QString &platformPluginPath)
 
static void init_plugins (const QList< QByteArray > pluginList)
 
void qt_cleanup ()
 
void qt_init (QApplicationPrivate *priv, int type)
 
static bool qt_try_modal (QWidget *widget, QEvent::Type type)
 

Variables

static bool app_do_modal = false
 
static QString appFont
 
static QString appName
 
static Qt::MouseButtons buttons = Qt::NoButton
 
static int mouse_double_click_distance = 5
 
static Qt::MouseButton mousePressButton = Qt::NoButton
 
static ulong mousePressTime
 
static int mousePressX
 
static int mousePressY
 
static int openPopupCount = 0
 
QWidgetqt_button_down = 0
 
QPointer< QWidgetqt_last_mouse_receiver = 0
 
int qt_last_x = 0
 
int qt_last_y = 0
 
QWidgetListqt_modal_stack
 

Function Documentation

◆ cleanup_platform()

static void cleanup_platform ( )
static

Definition at line 506 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

507 {
508  delete QApplicationPrivate::platform_integration;
509  QApplicationPrivate::platform_integration = 0;
510 }

◆ init_platform()

static void init_platform ( const QString name,
const QString platformPluginPath 
)
static

Definition at line 489 of file qapplication_qpa.cpp.

Referenced by qt_init().

490 {
491  QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
492  if (!QApplicationPrivate::platform_integration) {
493  QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
494  QString fatalMessage =
495  QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
496  foreach(QString key, keys) {
497  fatalMessage.append(key + QString::fromLatin1("\n"));
498  }
499  qFatal("%s", fatalMessage.toLocal8Bit().constData());
500 
501  }
502 
503 }
static QStringList keys(const QString &platformPluginPath=QString())
Returns the list of valid keys, i.e.
The QString class provides a Unicode character string.
Definition: qstring.h:83
QStringList keys
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QPlatformIntegration * create(const QString &key, const QString &platformPluginPath=QString())
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
Q_CORE_EXPORT void qFatal(const char *,...)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QString & append(QChar c)
Definition: qstring.cpp:1777
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int key

◆ init_plugins()

static void init_plugins ( const QList< QByteArray pluginList)
static

Definition at line 512 of file qapplication_qpa.cpp.

Referenced by qt_init().

513 {
514  for (int i = 0; i < pluginList.count(); ++i) {
515  QByteArray pluginSpec = pluginList.at(i);
516  qDebug() << "init_plugins" << i << pluginSpec;
517  int colonPos = pluginSpec.indexOf(':');
518  QObject *plugin;
519  if (colonPos < 0)
520  plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
521  else
522  plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
523  QLatin1String(pluginSpec.mid(colonPos+1)));
524  qDebug() << " created" << plugin;
525  }
526 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
Q_CORE_EXPORT void qDebug(const char *,...)
static QObject * create(const QString &, const QString &)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...

◆ qt_cleanup()

void qt_cleanup ( )

Definition at line 622 of file qapplication_qpa.cpp.

623 {
625 
627 #ifndef QT_NO_CURSOR
629 #endif
630  QFont::cleanup();
634 
635  QApplicationPrivate::active_window = 0; //### this should not be necessary
636 }
static QWidget * active_window
static void cleanup()
Internal function that cleans up the font system.
Definition: qfont_mac.cpp:93
static void cleanup_platform()
static void clear()
Removes all pixmaps from the cache.
static QInputContext * inputContext
static void cleanup()
Definition: qcursor.cpp:402
static void cleanup()

◆ qt_init()

void qt_init ( QApplicationPrivate priv,
int  type 
)

Definition at line 543 of file qapplication_qpa.cpp.

544 {
545  Q_UNUSED(type);
546 
548  char *p;
549  char **argv = priv->argv;
550  int argc = priv->argc;
551 
552  if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
553  p = strrchr(argv[0], '/');
554  appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
555  }
556 
557  QList<QByteArray> pluginList;
558  QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
559  QByteArray platformName;
560 #ifdef QT_QPA_DEFAULT_PLATFORM_NAME
561  platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
562 #endif
563  QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
564  if (!platformNameEnv.isEmpty()) {
565  platformName = platformNameEnv;
566  }
567 
568  // Get command line params
569 
570  int j = argc ? 1 : 0;
571  for (int i=1; i<argc; i++) {
572  if (argv[i] && *argv[i] != '-') {
573  argv[j++] = argv[i];
574  continue;
575  }
576  QByteArray arg = argv[i];
577  if (arg == "-fn" || arg == "-font") {
578  if (++i < argc)
579  appFont = QString::fromLocal8Bit(argv[i]);
580  } else if (arg == "-platformpluginpath") {
581  if (++i < argc)
582  platformPluginPath = QLatin1String(argv[i]);
583  } else if (arg == "-platform") {
584  if (++i < argc)
585  platformName = argv[i];
586  } else if (arg == "-plugin") {
587  if (++i < argc)
588  pluginList << argv[i];
589  } else {
590  argv[j++] = argv[i];
591  }
592  }
593 
594  if (j < priv->argc) {
595  priv->argv[j] = 0;
596  priv->argc = j;
597  }
598 
599 #if 0
600  QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
601  if (!pluginEnv.isEmpty()) {
602  pluginList.append(pluginEnv.split(';'));
603  }
604 #endif
605 
606  init_platform(QLatin1String(platformName), platformPluginPath);
607  init_plugins(pluginList);
608 
611 #ifndef QT_NO_CURSOR
612 // QCursorData::initialize();
613 #endif
614 
615  qApp->setObjectName(appName);
616 
617 #ifndef QT_NO_QWS_INPUTMETHODS
618  qApp->setInputContext(new QDummyInputContext(qApp));
619 #endif
620 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static void init_plugins(const QList< QByteArray > pluginList)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static void initialize()
Internal function that initializes the font system.
Definition: qfont_mac.cpp:131
#define qApp
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
static void init_platform(const QString &name, const QString &platformPluginPath)
static QString appFont
static void initialize()
static QString appName
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qt_try_modal()

static bool qt_try_modal ( QWidget widget,
QEvent::Type  type 
)
static

Definition at line 187 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

188 {
189  QWidget * top = 0;
190 
191  if (QApplicationPrivate::tryModalHelper(widget, &top))
192  return true;
193 
194  bool block_event = false;
195  bool paint_event = false;
196 
197  switch (type) {
198 #if 0
199  case QEvent::Focus:
200  if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
201  break;
202  // drop through
203 #endif
204  case QEvent::MouseButtonPress: // disallow mouse/key events
206  case QEvent::MouseMove:
207  case QEvent::KeyPress:
208  case QEvent::KeyRelease:
210  block_event = true;
211  break;
212  default:
213  break;
214  }
215 
216  if ((block_event || paint_event) && top->parentWidget() == 0)
217  top->raise();
218 
219  return !block_event;
220 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int type
Definition: qmetatype.cpp:239
EventRef event
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)

Variable Documentation

◆ app_do_modal

bool app_do_modal = false
static

Definition at line 80 of file qapplication_qpa.cpp.

Referenced by qt_cleanup(), and qt_try_modal().

◆ appFont

QString appFont
static

Definition at line 76 of file qapplication_qpa.cpp.

◆ appName

QString appName
static

◆ buttons

Qt::MouseButtons buttons = Qt::NoButton
static

◆ mouse_double_click_distance

int mouse_double_click_distance = 5
static

Definition at line 92 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ mousePressButton

Qt::MouseButton mousePressButton = Qt::NoButton
static

Definition at line 89 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ mousePressTime

ulong mousePressTime
static

Definition at line 88 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ mousePressX

int mousePressX
static

Definition at line 90 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ mousePressY

int mousePressY
static

Definition at line 91 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ openPopupCount

int openPopupCount = 0
static

Definition at line 298 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ qt_button_down

QWidget* qt_button_down = 0

Definition at line 78 of file qapplication_qpa.cpp.

◆ qt_last_mouse_receiver

QPointer<QWidget> qt_last_mouse_receiver = 0

Definition at line 85 of file qapplication_qpa.cpp.

◆ qt_last_x

int qt_last_x = 0

Definition at line 83 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ qt_last_y

int qt_last_y = 0

Definition at line 84 of file qapplication_qpa.cpp.

Referenced by qt_cleanup().

◆ qt_modal_stack

QWidgetList* qt_modal_stack

Definition at line 564 of file qapplication.cpp.

Referenced by qt_try_modal().