68 #include "private/qstylesheetstyle_p.h" |
68 #include "private/qstylesheetstyle_p.h" |
69 #include "private/qstyle_p.h" |
69 #include "private/qstyle_p.h" |
70 #include "qmessagebox.h" |
70 #include "qmessagebox.h" |
71 #include <QtGui/qgraphicsproxywidget.h> |
71 #include <QtGui/qgraphicsproxywidget.h> |
72 |
72 |
|
73 #ifdef QT_GRAPHICSSYSTEM_RUNTIME |
|
74 #include "private/qgraphicssystem_runtime_p.h" |
|
75 #endif |
|
76 |
73 #include "qinputcontext.h" |
77 #include "qinputcontext.h" |
74 #include "qkeymapper_p.h" |
78 #include "qkeymapper_p.h" |
75 |
79 |
76 #ifdef Q_WS_X11 |
80 #ifdef Q_WS_X11 |
77 #include <private/qt_x11_p.h> |
81 #include <private/qt_x11_p.h> |
78 #endif |
82 #endif |
79 |
83 |
80 #if defined(Q_WS_X11) || defined(Q_WS_S60) |
84 #if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN) |
81 #include "qinputcontextfactory.h" |
85 #include "qinputcontextfactory.h" |
82 #endif |
86 #endif |
83 |
87 |
84 #include "qguiplatformplugin_p.h" |
88 #include "qguiplatformplugin_p.h" |
85 |
89 |
140 |
144 |
141 } |
145 } |
142 |
146 |
143 QT_BEGIN_NAMESPACE |
147 QT_BEGIN_NAMESPACE |
144 |
148 |
145 Q_DECL_IMPORT extern void qt_call_post_routines(); |
149 Q_CORE_EXPORT void qt_call_post_routines(); |
146 |
150 |
147 int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 |
151 int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 |
148 |
152 |
149 QApplication::Type qt_appType=QApplication::Tty; |
153 QApplication::Type qt_appType=QApplication::Tty; |
150 QApplicationPrivate *QApplicationPrivate::self = 0; |
154 QApplicationPrivate *QApplicationPrivate::self = 0; |
440 QPalette *QApplicationPrivate::sys_pal = 0; // default system palette |
446 QPalette *QApplicationPrivate::sys_pal = 0; // default system palette |
441 QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer |
447 QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer |
442 |
448 |
443 QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system |
449 QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system |
444 QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization |
450 QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization |
|
451 bool QApplicationPrivate::runtime_graphics_system = false; |
445 |
452 |
446 Q_GLOBAL_STATIC(QMutex, applicationFontMutex) |
453 Q_GLOBAL_STATIC(QMutex, applicationFontMutex) |
447 QFont *QApplicationPrivate::app_font = 0; // default application font |
454 QFont *QApplicationPrivate::app_font = 0; // default application font |
448 QFont *QApplicationPrivate::sys_font = 0; // default system font |
455 QFont *QApplicationPrivate::sys_font = 0; // default system font |
449 QFont *QApplicationPrivate::set_font = 0; // default font set by programmer |
456 QFont *QApplicationPrivate::set_font = 0; // default font set by programmer |
664 \list |
671 \list |
665 \o -display \e display, sets the X display (default is $DISPLAY). |
672 \o -display \e display, sets the X display (default is $DISPLAY). |
666 \o -geometry \e geometry, sets the client geometry of the first window |
673 \o -geometry \e geometry, sets the client geometry of the first window |
667 that is shown. |
674 that is shown. |
668 \o -fn or \c -font \e font, defines the application font. The font |
675 \o -fn or \c -font \e font, defines the application font. The font |
669 should be specified using an X logical font description. |
676 should be specified using an X logical font description. Note that |
|
677 this option is ignored when Qt is built with fontconfig support enabled. |
670 \o -bg or \c -background \e color, sets the default background color |
678 \o -bg or \c -background \e color, sets the default background color |
671 and an application palette (light and dark shades are calculated). |
679 and an application palette (light and dark shades are calculated). |
672 \o -fg or \c -foreground \e color, sets the default foreground color. |
680 \o -fg or \c -foreground \e color, sets the default foreground color. |
673 \o -btn or \c -button \e color, sets the default button color. |
681 \o -btn or \c -button \e color, sets the default button color. |
674 \o -name \e name, sets the application name. |
682 \o -name \e name, sets the application name. |
772 { |
780 { |
773 initResources(); |
781 initResources(); |
774 |
782 |
775 qt_is_gui_used = (qt_appType != QApplication::Tty); |
783 qt_is_gui_used = (qt_appType != QApplication::Tty); |
776 process_cmdline(); |
784 process_cmdline(); |
|
785 // the environment variable has the lowest precedence of runtime graphicssystem switches |
|
786 if (graphics_system_name.isEmpty()) |
|
787 graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM")); |
777 // Must be called before initialize() |
788 // Must be called before initialize() |
778 qt_init(this, qt_appType |
789 qt_init(this, qt_appType |
779 #ifdef Q_WS_X11 |
790 #ifdef Q_WS_X11 |
780 , dpy, visual, cmap |
791 , dpy, visual, cmap |
781 #endif |
792 #endif |
889 } |
900 } |
890 |
901 |
891 #endif // Q_WS_X11 |
902 #endif // Q_WS_X11 |
892 |
903 |
893 extern void qInitDrawhelperAsm(); |
904 extern void qInitDrawhelperAsm(); |
|
905 extern void qInitImageConversions(); |
894 extern int qRegisterGuiVariant(); |
906 extern int qRegisterGuiVariant(); |
895 extern int qUnregisterGuiVariant(); |
907 extern int qUnregisterGuiVariant(); |
896 #ifndef QT_NO_STATEMACHINE |
908 #ifndef QT_NO_STATEMACHINE |
897 extern int qRegisterGuiStateMachine(); |
909 extern int qRegisterGuiStateMachine(); |
898 extern int qUnregisterGuiStateMachine(); |
910 extern int qUnregisterGuiStateMachine(); |
946 #endif //QT_AUTO_MAXIMIZE_THRESHOLD |
958 #endif //QT_AUTO_MAXIMIZE_THRESHOLD |
947 #endif //Q_WS_WINCE |
959 #endif //Q_WS_WINCE |
948 |
960 |
949 // Set up which span functions should be used in raster engine... |
961 // Set up which span functions should be used in raster engine... |
950 qInitDrawhelperAsm(); |
962 qInitDrawhelperAsm(); |
|
963 // and QImage conversion functions |
|
964 qInitImageConversions(); |
951 |
965 |
952 #ifndef QT_NO_WHEELEVENT |
966 #ifndef QT_NO_WHEELEVENT |
953 QApplicationPrivate::wheel_scroll_lines = 3; |
967 QApplicationPrivate::wheel_scroll_lines = 3; |
954 #endif |
968 #endif |
955 |
969 |
1552 |
1566 |
1553 Sets the default graphics backend to \a system, which will be used for |
1567 Sets the default graphics backend to \a system, which will be used for |
1554 on-screen widgets and QPixmaps. The available systems are \c{"native"}, |
1568 on-screen widgets and QPixmaps. The available systems are \c{"native"}, |
1555 \c{"raster"} and \c{"opengl"}. |
1569 \c{"raster"} and \c{"opengl"}. |
1556 |
1570 |
1557 This function call overrides both the application commandline |
1571 There are several ways to set the graphics backend, in order of decreasing |
1558 \c{-graphicssystem} switch and the configure \c{-graphicssystem} switch. |
1572 precedence: |
1559 |
1573 \list |
1560 \warning This function must be called before the QApplication constructor |
1574 \o the application commandline \c{-graphicssystem} switch |
|
1575 \o QApplication::setGraphicsSystem() |
|
1576 \o the QT_GRAPHICSSYSTEM environment variable |
|
1577 \o the Qt configure \c{-graphicssystem} switch |
|
1578 \endlist |
|
1579 If the highest precedence switch sets an invalid name, the error will be |
|
1580 ignored and the default backend will be used. |
|
1581 |
|
1582 \warning This function is only effective before the QApplication constructor |
1561 is called. |
1583 is called. |
1562 |
1584 |
1563 \note The \c{"opengl"} option is currently experimental. |
1585 \note The \c{"opengl"} option is currently experimental. |
1564 */ |
1586 */ |
1565 |
1587 |
1566 void QApplication::setGraphicsSystem(const QString &system) |
1588 void QApplication::setGraphicsSystem(const QString &system) |
1567 { |
1589 { |
1568 QApplicationPrivate::graphics_system_name = system; |
1590 #ifdef QT_GRAPHICSSYSTEM_RUNTIME |
|
1591 if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) { |
|
1592 QRuntimeGraphicsSystem *r = |
|
1593 static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system); |
|
1594 r->setGraphicsSystem(system); |
|
1595 } else |
|
1596 #endif |
|
1597 QApplicationPrivate::graphics_system_name = system; |
1569 } |
1598 } |
1570 |
1599 |
1571 /*! |
1600 /*! |
1572 Returns the color specification. |
1601 Returns the color specification. |
1573 |
1602 |
2216 */ |
2245 */ |
2217 void QApplication::closeAllWindows() |
2246 void QApplication::closeAllWindows() |
2218 { |
2247 { |
2219 bool did_close = true; |
2248 bool did_close = true; |
2220 QWidget *w; |
2249 QWidget *w; |
2221 while((w = activeModalWidget()) && did_close) { |
2250 while ((w = activeModalWidget()) && did_close) { |
2222 if(!w->isVisible()) |
2251 if (!w->isVisible() || w->data->is_closing) |
2223 break; |
2252 break; |
2224 did_close = w->close(); |
2253 did_close = w->close(); |
2225 } |
2254 } |
2226 QWidgetList list = QApplication::topLevelWidgets(); |
2255 QWidgetList list = QApplication::topLevelWidgets(); |
2227 for (int i = 0; did_close && i < list.size(); ++i) { |
2256 for (int i = 0; did_close && i < list.size(); ++i) { |
2228 w = list.at(i); |
2257 w = list.at(i); |
2229 if (w->isVisible() && w->windowType() != Qt::Desktop) { |
2258 if (w->isVisible() |
|
2259 && w->windowType() != Qt::Desktop |
|
2260 && !w->data->is_closing) { |
2230 did_close = w->close(); |
2261 did_close = w->close(); |
2231 list = QApplication::topLevelWidgets(); |
2262 list = QApplication::topLevelWidgets(); |
2232 i = -1; |
2263 i = -1; |
2233 } |
2264 } |
2234 } |
2265 } |
2741 { |
2772 { |
2742 #if defined(Q_WS_WIN) |
2773 #if defined(Q_WS_WIN) |
2743 qt_win_set_cursor(cursorWidget, true); |
2774 qt_win_set_cursor(cursorWidget, true); |
2744 #elif defined(Q_WS_X11) |
2775 #elif defined(Q_WS_X11) |
2745 qt_x11_enforce_cursor(cursorWidget, true); |
2776 qt_x11_enforce_cursor(cursorWidget, true); |
2746 #elif defined(Q_WS_S60) |
2777 #elif defined(Q_OS_SYMBIAN) |
2747 qt_symbian_set_cursor(cursorWidget, true); |
2778 qt_symbian_set_cursor(cursorWidget, true); |
2748 #endif |
2779 #endif |
2749 } |
2780 } |
2750 } |
2781 } |
2751 #endif |
2782 #endif |
3514 \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() |
3545 \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() |
3515 */ |
3546 */ |
3516 |
3547 |
3517 void QApplication::setLayoutDirection(Qt::LayoutDirection direction) |
3548 void QApplication::setLayoutDirection(Qt::LayoutDirection direction) |
3518 { |
3549 { |
3519 if (layout_direction == direction) |
3550 if (layout_direction == direction || direction == Qt::LayoutDirectionAuto) |
3520 return; |
3551 return; |
3521 |
3552 |
3522 layout_direction = direction; |
3553 layout_direction = direction; |
3523 |
3554 |
3524 QWidgetList list = topLevelWidgets(); |
3555 QWidgetList list = topLevelWidgets(); |
3690 QApplicationPrivate::modifier_buttons = ie->modifiers(); |
3721 QApplicationPrivate::modifier_buttons = ie->modifiers(); |
3691 } |
3722 } |
3692 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT |
3723 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT |
3693 } |
3724 } |
3694 |
3725 |
|
3726 #ifndef QT_NO_GESTURES |
3695 // walk through parents and check for gestures |
3727 // walk through parents and check for gestures |
3696 if (d->gestureManager) { |
3728 if (d->gestureManager) { |
3697 switch (e->type()) { |
3729 switch (e->type()) { |
3698 case QEvent::Paint: |
3730 case QEvent::Paint: |
3699 case QEvent::MetaCall: |
3731 case QEvent::MetaCall: |
4239 } |
4271 } |
4240 #endif |
4272 #endif |
4241 res = d->notify_helper(receiver, e); |
4273 res = d->notify_helper(receiver, e); |
4242 break; |
4274 break; |
4243 |
4275 |
|
4276 #ifndef QT_NO_GESTURES |
4244 case QEvent::NativeGesture: |
4277 case QEvent::NativeGesture: |
4245 { |
4278 { |
4246 // only propagate the first gesture event (after the GID_BEGIN) |
4279 // only propagate the first gesture event (after the GID_BEGIN) |
4247 QWidget *w = static_cast<QWidget *>(receiver); |
4280 QWidget *w = static_cast<QWidget *>(receiver); |
4248 while (w) { |
4281 while (w) { |
5258 Only one application object can be created. |
5292 Only one application object can be created. |
5259 |
5293 |
5260 \sa QCoreApplication::instance() |
5294 \sa QCoreApplication::instance() |
5261 */ |
5295 */ |
5262 |
5296 |
|
5297 #ifndef QT_NO_IM |
5263 // ************************************************************************ |
5298 // ************************************************************************ |
5264 // Input Method support |
5299 // Input Method support |
5265 // ************************************************************************ |
5300 // ************************************************************************ |
5266 |
5301 |
5267 /*! |
5302 /*! |
5268 This function replaces the QInputContext instance used by the application |
5303 This function replaces the QInputContext instance used by the application |
5269 with \a inputContext. |
5304 with \a inputContext. |
5270 |
5305 |
|
5306 Qt takes ownership of the given \a inputContext. |
|
5307 |
5271 \sa inputContext() |
5308 \sa inputContext() |
5272 */ |
5309 */ |
5273 void QApplication::setInputContext(QInputContext *inputContext) |
5310 void QApplication::setInputContext(QInputContext *inputContext) |
5274 { |
5311 { |
5275 Q_D(QApplication); |
5312 if (inputContext == QApplicationPrivate::inputContext) |
5276 Q_UNUSED(d);// only static members being used. |
5313 return; |
5277 if (!inputContext) { |
5314 if (!inputContext) { |
5278 qWarning("QApplication::setInputContext: called with 0 input context"); |
5315 qWarning("QApplication::setInputContext: called with 0 input context"); |
5279 return; |
5316 return; |
5280 } |
5317 } |
5281 delete d->inputContext; |
5318 delete QApplicationPrivate::inputContext; |
5282 d->inputContext = inputContext; |
5319 QApplicationPrivate::inputContext = inputContext; |
|
5320 QApplicationPrivate::inputContext->setParent(this); |
5283 } |
5321 } |
5284 |
5322 |
5285 /*! |
5323 /*! |
5286 Returns the QInputContext instance used by the application. |
5324 Returns the QInputContext instance used by the application. |
5287 |
5325 |
5747 const QList<QTouchEvent::TouchPoint> &touchPoints) |
5786 const QList<QTouchEvent::TouchPoint> &touchPoints) |
5748 { |
5787 { |
5749 QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); |
5788 QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); |
5750 } |
5789 } |
5751 |
5790 |
|
5791 #ifndef QT_NO_GESTURES |
5752 QGestureManager* QGestureManager::instance() |
5792 QGestureManager* QGestureManager::instance() |
5753 { |
5793 { |
5754 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); |
5794 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); |
5755 if (!qAppPriv->gestureManager) |
5795 if (!qAppPriv->gestureManager) |
5756 qAppPriv->gestureManager = new QGestureManager(qApp); |
5796 qAppPriv->gestureManager = new QGestureManager(qApp); |
5757 return qAppPriv->gestureManager; |
5797 return qAppPriv->gestureManager; |
5758 } |
5798 } |
|
5799 #endif // QT_NO_GESTURES |
5759 |
5800 |
5760 // These pixmaps approximate the images in the Windows User Interface Guidelines. |
5801 // These pixmaps approximate the images in the Windows User Interface Guidelines. |
5761 |
5802 |
5762 // XPM |
5803 // XPM |
5763 |
5804 |