From 9d173c92183c30144e8bd4f115b2cd93c3da0d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 20 Feb 2012 14:11:29 +0100 Subject: Updated QApplication / QGuiApplication to match Qt 5 reality. Removed obsolete Q_WS_X11/WIN/MAC stuff as well. Change-Id: I8b65a0348a8cb170f3f060023fc6d9d982949b7e Reviewed-by: Casper van Donderen Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qapplication.cpp | 627 +---------------------------- src/widgets/kernel/qapplication.h | 52 +-- src/widgets/kernel/qwidgetbackingstore.cpp | 2 - 3 files changed, 24 insertions(+), 657 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f7153a0f32..134b1809bb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -76,10 +76,6 @@ #include "private/qkeymapper_p.h" -#ifdef Q_WS_X11 -#include -#endif - #include #include @@ -87,10 +83,6 @@ #include -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -#include -#endif - #include "qapplication_p.h" #include "private/qevent_p.h" #include "qwidget_p.h" @@ -114,10 +106,6 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp #include "qdatetime.h" -#ifdef Q_WS_MAC -#include -#endif - //#define ALIEN_DEBUG static void initResources() @@ -156,24 +144,11 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T is_session_restored = false; #endif -#if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER) - directPainters = 0; -#endif - #ifndef QT_NO_GESTURES gestureManager = 0; gestureWidget = 0; #endif // QT_NO_GESTURES -#if defined(Q_WS_X11) || defined(Q_WS_WIN) - move_cursor = 0; - copy_cursor = 0; - link_cursor = 0; -#endif -#if defined(Q_WS_WIN) - ignore_cursor = 0; -#endif - if (!self) self = this; } @@ -191,16 +166,14 @@ QApplicationPrivate::~QApplicationPrivate() \inmodule QtWidgets - QApplication contains the main event loop, where all events from the window - system and other sources are processed and dispatched. It also handles the - application's initialization, finalization, and provides session - management. In addition, QApplication handles most of the system-wide and - application-wide settings. + QApplication specializes QGuiApplication with some functionality needed + for QWidget-based applications. It handles widget specific initialization, + finalization, and provides session management. For any GUI application using Qt, there is precisely \bold one QApplication object, no matter whether the application has 0, 1, 2 or more windows at - any given time. For non-GUI Qt applications, use QCoreApplication instead, - as it does not depend on the \l QtGui library. + any given time. For non-QWidget based Qt applications, use QGuiApplication instead, + as it does not depend on the \l QtWidgets library. The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer. @@ -241,9 +214,6 @@ QApplicationPrivate::~QApplicationPrivate() \o It manages the application's mouse cursor handling, see setOverrideCursor() - \o On the X window system, it provides functions to flush and sync - the communication stream, see flushX() and syncX(). - \o It provides support for sophisticated \l{Session Management} {session management}. This makes it possible for applications to terminate gracefully when the user logs out, to cancel a @@ -291,12 +261,7 @@ QApplicationPrivate::~QApplicationPrivate() sendPostedEvents(), removePostedEvents(), hasPendingEvents(), - notify(), - macEventFilter(), - qwsEventFilter(), - x11EventFilter(), - x11ProcessEvent(), - winEventFilter(). + notify(). \row \o GUI Styles @@ -306,8 +271,7 @@ QApplicationPrivate::~QApplicationPrivate() \row \o Color usage \o colorSpec(), - setColorSpec(), - qwsSetCustomColors(). + setColorSpec(). \row \o Text handling @@ -333,11 +297,6 @@ QApplicationPrivate::~QApplicationPrivate() setOverrideCursor(), restoreOverrideCursor(). - \row - \o X Window System synchronization - \o flushX(), - syncX(). - \row \o Session management \o isSessionRestored(), @@ -391,9 +350,6 @@ QApplicationPrivate::~QApplicationPrivate() */ void qt_init(QApplicationPrivate *priv, int type -#ifdef Q_WS_X11 - , Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0 -#endif ); void qt_cleanup(); @@ -560,19 +516,6 @@ void QApplicationPrivate::process_cmdline() \note \a argc and \a argv might be changed as Qt removes command line arguments that it recognizes. - Qt debugging options (not available if Qt was compiled without the QT_DEBUG - flag defined): - \list - \o -nograb, tells Qt that it must never grab the mouse or the - keyboard. - \o -dograb (only under X11), running under a debugger can cause an - implicit -nograb, use -dograb to override. - \o -sync (only under X11), switches to synchronous mode for - debugging. - \endlist - - See \l{Debugging Techniques} for a more detailed explanation. - All Qt programs automatically support the following command line options: \list \o -style= \e style, sets the application GUI style. Possible values @@ -598,45 +541,6 @@ void QApplicationPrivate::process_cmdline() and will make the application wait until a debugger connects to it. \endlist - The X11 version of Qt supports some traditional X11 command line options: - \list - \o -display \e display, sets the X display (default is $DISPLAY). - \o -geometry \e geometry, sets the client geometry of the first window - that is shown. - \o -fn or \c -font \e font, defines the application font. The font - should be specified using an X logical font description. Note that - this option is ignored when Qt is built with fontconfig support enabled. - \o -bg or \c -background \e color, sets the default background color - and an application palette (light and dark shades are calculated). - \o -fg or \c -foreground \e color, sets the default foreground color. - \o -btn or \c -button \e color, sets the default button color. - \o -name \e name, sets the application name. - \o -title \e title, sets the application title. - \o -visual \c TrueColor, forces the application to use a TrueColor - visual on an 8-bit display. - \o -ncols \e count, limits the number of colors allocated in the color - cube on an 8-bit display, if the application is using the - QApplication::ManyColor color specification. If \e count is 216 - then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, - and 6 of blue); for other values, a cube approximately proportional - to a 2x3x1 cube is used. - \o -cmap, causes the application to install a private color map on an - 8-bit display. - \o -im, sets the input method server (equivalent to setting the - XMODIFIERS environment variable) - \o -inputstyle, defines how the input is inserted into the given - widget, e.g., \c onTheSpot makes the input appear directly in the - widget, while \c overTheSpot makes the input appear in a box - floating over the widget and is not inserted until the editing is - done. - \endlist - - \section1 X11 Notes - - If QApplication fails to open the X11 display, it will terminate - the process. This behavior is consistent with most X11 - applications. - \sa arguments() */ @@ -651,26 +555,18 @@ QApplication::QApplication(int &argc, char **argv, int _internal) /*! Constructs an application object with \a argc command line arguments in - \a argv. If \a GUIenabled is true, a GUI application is constructed, - otherwise a non-GUI (console) application is created. + \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. - Set \a GUIenabled to false for programs without a graphical user interface - that should be able to run without a window system. - - On X11, the window system is initialized if \a GUIenabled is true. If - \a GUIenabled is false, the application does not connect to the X server. - On Windows and Mac OS, currently the window system is always initialized, - regardless of the value of GUIenabled. This may change in future versions - of Qt. - The following example shows how to create an application that uses a graphical interface when available. + \obsolete + \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0 */ @@ -692,10 +588,6 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern 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. - - With Qt for Embedded Linux, passing QApplication::GuiServer for \a type - makes this application the server (equivalent to running with the - \c -qws option). */ QApplication::QApplication(int &argc, char **argv, Type type) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, 0x040000)) @@ -705,22 +597,10 @@ QApplication::QApplication(int &argc, char **argv, Type type , int _internal) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, _internal)) { Q_D(QApplication); d->construct(); } -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data) -{ - const char *name = static_cast(data); - return strstr(info->dlpi_name, name) != 0; -} -#endif - /*! \internal */ -void QApplicationPrivate::construct( -#ifdef Q_WS_X11 - Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap -#endif - ) +void QApplicationPrivate::construct() { initResources(); @@ -728,11 +608,7 @@ void QApplicationPrivate::construct( process_cmdline(); // Must be called before initialize() - qt_init(this, application_type -#ifdef Q_WS_X11 - , dpy, visual, cmap -#endif - ); + qt_init(this, application_type); initialize(); eventDispatcher->startingUp(); @@ -759,82 +635,6 @@ void QApplicationPrivate::construct( #endif } -#if defined(Q_WS_X11) -// ### a string literal is a cont char* -// ### using it as a char* is wrong and could lead to segfaults -// ### if aargv is modified someday -// ########## make it work with argc == argv == 0 -static int aargc = 1; -static char *aargv[] = { (char*)"unknown", 0 }; - -/*! - \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) - - Creates an application, given an already open display \a display. If - \a visual and \a colormap are non-zero, the application will use those - values as the default Visual and Colormap contexts. - - \warning Qt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This function is only available on X11. -*/ -QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) - : QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); -} - -QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); - QApplicationPrivate::app_compile_version = _internal; -} - -/*! - \fn QApplication::QApplication(Display *display, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) - - Creates an application, given an already open \a display and using \a argc - command line arguments in \a argv. If \a visual and \a colormap are - non-zero, the application will use those values as the default Visual - and Colormap contexts. - - \warning Qt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This function is only available on X11. -*/ -QApplication::QApplication(Display *dpy, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); -} - -QApplication::QApplication(Display *dpy, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); - QApplicationPrivate::app_compile_version = _internal; -} - -#endif // Q_WS_X11 - #ifndef QT_NO_STATEMACHINE void qRegisterGuiStateMachine(); void qUnregisterGuiStateMachine(); @@ -981,15 +781,6 @@ QApplication::~QApplication() delete qt_desktopWidget; qt_desktopWidget = 0; -#if defined(Q_WS_X11) || defined(Q_WS_WIN) - delete d->move_cursor; d->move_cursor = 0; - delete d->copy_cursor; d->copy_cursor = 0; - delete d->link_cursor; d->link_cursor = 0; -#endif -#if defined(Q_WS_WIN) - delete d->ignore_cursor; d->ignore_cursor = 0; -#endif - delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; delete QApplicationPrivate::sys_pal; @@ -1731,14 +1522,6 @@ QFont QApplication::font(const QWidget *widget) { FontHash *hash = app_fonts(); -#ifdef Q_WS_MAC - // short circuit for small and mini controls - if (widget->testAttribute(Qt::WA_MacSmallSize)) { - return hash->value("QSmallFont"); - } else if (widget->testAttribute(Qt::WA_MacMiniSize)) { - return hash->value("QMiniFont"); - } -#endif if (widget && hash && hash->size()) { QHash::ConstIterator it = hash->constFind(widget->metaObject()->className()); @@ -1877,11 +1660,6 @@ void QApplication::setWindowIcon(const QIcon &icon) QApplicationPrivate::app_icon = new QIcon(); *QApplicationPrivate::app_icon = icon; if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { -#ifdef Q_WS_MAC - void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp - QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128)); - qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size)); -#endif QEvent e(QEvent::ApplicationWindowIconChange); QWidgetList all = QApplication::allWidgets(); for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { @@ -2094,13 +1872,7 @@ void QApplication::closeAllWindows() void QApplication::aboutQt() { #ifndef QT_NO_MESSAGEBOX - QMessageBox::aboutQt( -#ifdef Q_WS_MAC - 0 -#else - activeWindow() -#endif // Q_WS_MAC - ); + QMessageBox::aboutQt(activeWindow()); #endif // QT_NO_MESSAGEBOX } @@ -2184,9 +1956,6 @@ bool QApplication::event(QEvent *e) } if(e->type() == QEvent::LanguageChange) { -#ifdef Q_WS_MAC - qt_mac_post_retranslateAppMenu(); -#endif QWidgetList list = topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); @@ -2198,13 +1967,14 @@ bool QApplication::event(QEvent *e) return QGuiApplication::event(e); } -#if !defined(Q_WS_X11) - -// The doc and X implementation of this function is in qapplication_x11.cpp - -void QApplication::syncX() {} // do nothing - -#endif +/*! + Was used to synchronize with the X server in 4.x, here for source compatibility. + \internal + \obsolete +*/ +void QApplication::syncX() +{ +} void QApplicationPrivate::notifyLayoutDirectionChange() { @@ -2298,13 +2068,6 @@ void QApplication::setActiveWindow(QWidget* act) sendSpontaneousEvent(w, &activationChange); } -#ifdef Q_WS_MAC - // In case the user clicked on a child window, we need to - // reestablish the stacking order of the window so - // it pops in front of other child windows in cocoa: - qt_cocoaStackChildWindowOnTopOfOtherChildren(window); -#endif - for(int i = 0; i < toBeDeactivated.size(); ++i) { QWidget *w = toBeDeactivated.at(i); sendSpontaneousEvent(w, &windowDeactivate); @@ -2455,10 +2218,6 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { for (int i = 0; i < leaveList.size(); ++i) { w = leaveList.at(i); if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) - if (leaveAfterRelease == w) - leaveAfterRelease = 0; -#endif QApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { @@ -2511,9 +2270,6 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { if (!parentOfLeavingCursor->window()->graphicsProxyWidget()) #endif { -#if defined(Q_WS_X11) - qt_x11_enforce_cursor(parentOfLeavingCursor,true); -#endif if (enter == QApplication::desktop()) { qt_qpa_set_cursor(enter, true); } else { @@ -2535,13 +2291,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { } else #endif { -#if defined(Q_WS_WIN) - qt_win_set_cursor(cursorWidget, true); -#elif defined(Q_WS_X11) - qt_x11_enforce_cursor(cursorWidget, true); -#else qt_qpa_set_cursor(cursorWidget, true); -#endif } } #endif @@ -2575,12 +2325,6 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) return false; w = w->parentWidget(); } -#ifdef Q_WS_WIN - if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid) - && (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid) - && IsChild(modalWidget->data->winid, widget->data->winid)) - return false; -#endif } Qt::WindowModality windowModality = modalWidget->windowModality(); @@ -2708,12 +2452,6 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) if (QApplication::activePopupWidget()) return true; -#if defined(Q_WS_MAC) - top = QApplicationPrivate::tryModalHelper_sys(top); - if (rettop) - *rettop = top; -#endif - return !isBlockedByModal(widget->window()); } @@ -3726,16 +3464,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) case QEvent::DragEnter: { QWidget* w = static_cast(receiver); QDragEnterEvent *dragEvent = static_cast(e); -#ifdef Q_WS_MAC - // HIView has a slight difference in how it delivers events to children and parents - // It will not give a leave to a child's parent when it enters a child. - QWidget *currentTarget = QDragManager::self()->currentTarget(); - if (currentTarget) { - // Assume currentTarget did not get a leave - QDragLeaveEvent event; - QApplication::sendEvent(currentTarget, &event); - } -#endif #ifndef QT_NO_GRAPHICSVIEW // QGraphicsProxyWidget handles its own propagation, // and we must not change QDragManagers currentTarget. @@ -3774,20 +3502,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) w = qobject_cast(QDragManager::self()->currentTarget()); if (!w) { -#ifdef Q_WS_MAC - // HIView has a slight difference in how it delivers events to children and parents - // It will not give an enter to a child's parent when it leaves the child. - if (e->type() == QEvent::DragLeave) - break; - // Assume that w did not get an enter. - QDropEvent *dropEvent = static_cast(e); - QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(), - dropEvent->mimeData(), dropEvent->mouseButtons(), - dropEvent->keyboardModifiers()); - QApplication::sendEvent(receiver, &dragEnterEvent); - w = QDragManager::self()->currentTarget(); - if (!w) -#endif break; } if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) { @@ -3951,24 +3665,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; } #endif // QT_NO_GESTURES -#ifdef Q_WS_MAC - case QEvent::Enter: - if (receiver->isWidgetType()) { - QWidget *w = static_cast(receiver); - if (w->testAttribute(Qt::WA_AcceptTouchEvents)) - qt_widget_private(w)->registerTouchWindow(true); - } - res = d->notify_helper(receiver, e); - break; - case QEvent::Leave: - if (receiver->isWidgetType()) { - QWidget *w = static_cast(receiver); - if (w->testAttribute(Qt::WA_AcceptTouchEvents)) - qt_widget_private(w)->registerTouchWindow(false); - } - res = d->notify_helper(receiver, e); - break; -#endif default: res = d->notify_helper(receiver, e); break; @@ -4304,168 +4000,6 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) \sa isPhase2() */ -/***************************************************************************** - Stubbed session management support - *****************************************************************************/ -#ifndef QT_NO_SESSIONMANAGER -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS) - -#if defined(Q_OS_WINCE) -HRESULT qt_CoCreateGuid(GUID* guid) -{ - // We will use the following information to create the GUID - // 1. absolute path to application - wchar_t tempFilename[MAX_PATH]; - if (!GetModuleFileName(0, tempFilename, MAX_PATH)) - return S_FALSE; - unsigned int hash = qHash(QString::fromWCharArray(tempFilename)); - guid->Data1 = hash; - // 2. creation time of file - QFileInfo info(QString::fromWCharArray(tempFilename)); - guid->Data2 = qHash(info.created().toTime_t()); - // 3. current system time - guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t()); - return S_OK; -} -#if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID) -#define CoCreateGuid qt_CoCreateGuid -#endif - -#endif - -class QSessionManagerPrivate : public QObjectPrivate -{ -public: - QStringList restartCommand; - QStringList discardCommand; - QString sessionId; - QString sessionKey; - QSessionManager::RestartHint restartHint; -}; - -QSessionManager* qt_session_manager_self = 0; -QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key) - : QObject(*new QSessionManagerPrivate, app) -{ - Q_D(QSessionManager); - setObjectName(QLatin1String("qt_sessionmanager")); - qt_session_manager_self = this; -#if defined(Q_WS_WIN) - wchar_t guidstr[40]; - GUID guid; - CoCreateGuid(&guid); - StringFromGUID2(guid, guidstr, 40); - id = QString::fromWCharArray(guidstr); - CoCreateGuid(&guid); - StringFromGUID2(guid, guidstr, 40); - key = QString::fromWCharArray(guidstr); -#endif - d->sessionId = id; - d->sessionKey = key; - d->restartHint = RestartIfRunning; -} - -QSessionManager::~QSessionManager() -{ - qt_session_manager_self = 0; -} - -QString QSessionManager::sessionId() const -{ - Q_D(const QSessionManager); - return d->sessionId; -} - -QString QSessionManager::sessionKey() const -{ - Q_D(const QSessionManager); - return d->sessionKey; -} - - -#if defined(Q_WS_X11) || defined(Q_WS_MAC) -void* QSessionManager::handle() const -{ - return 0; -} -#endif - -#if !defined(Q_WS_WIN) -bool QSessionManager::allowsInteraction() -{ - return true; -} - -bool QSessionManager::allowsErrorInteraction() -{ - return true; -} -void QSessionManager::release() -{ -} - -void QSessionManager::cancel() -{ -} -#endif - - -void QSessionManager::setRestartHint(QSessionManager::RestartHint hint) -{ - Q_D(QSessionManager); - d->restartHint = hint; -} - -QSessionManager::RestartHint QSessionManager::restartHint() const -{ - Q_D(const QSessionManager); - return d->restartHint; -} - -void QSessionManager::setRestartCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->restartCommand = command; -} - -QStringList QSessionManager::restartCommand() const -{ - Q_D(const QSessionManager); - return d->restartCommand; -} - -void QSessionManager::setDiscardCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->discardCommand = command; -} - -QStringList QSessionManager::discardCommand() const -{ - Q_D(const QSessionManager); - return d->discardCommand; -} - -void QSessionManager::setManagerProperty(const QString&, const QString&) -{ -} - -void QSessionManager::setManagerProperty(const QString&, const QStringList&) -{ -} - -bool QSessionManager::isPhase2() const -{ - return false; -} - -void QSessionManager::requestPhase2() -{ -} - -#endif -#endif // QT_NO_SESSIONMANAGER - /*! \typedef QApplication::ColorMode \compat @@ -4895,120 +4429,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) return true; } -/*! \fn QDecoration &QApplication::qwsDecoration() - Return the QWSDecoration used for decorating windows. - - \warning This method is non-portable. It is only available in - Qt for Embedded Linux. - - \sa QDecoration -*/ - -/*! - \fn void QApplication::qwsSetDecoration(QDecoration *decoration) - - Sets the QDecoration derived class to use for decorating the - windows used by Qt for Embedded Linux to the \a decoration - specified. - - This method is non-portable. It is only available in Qt for Embedded Linux. - - \sa QDecoration -*/ - -/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration) - \overload - - Requests a QDecoration object for \a decoration from the - QDecorationFactory. - - The string must be one of the QDecorationFactory::keys(). Keys are case - insensitive. - - A later call to the QApplication constructor will override the requested - style when a "-style" option is passed in as a commandline parameter. - - Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object - returned is set as the application's GUI style. -*/ - -/*! - \fn bool QApplication::qwsEventFilter(QWSEvent *event) - - This virtual function is only implemented under Qt for Embedded Linux. - - If you create an application that inherits QApplication and - reimplement this function, you get direct access to all QWS (Q - Window System) events that the are received from the QWS master - process. The events are passed in the \a event parameter. - - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. -*/ - -/*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors) - Set Qt for Embedded Linux custom color table. - - Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. - The remaining 40 colors may be used by setting a custom color - table in the QWS master process before any clients connect. - - \a colorTable is an array of up to 40 custom colors. \a start is - the starting index (0-39) and \a numColors is the number of colors - to be set (1-40). - - This method is non-portable. It is available \e only in - Qt for Embedded Linux. - - \note The custom colors will not be used by the default screen - driver. To make use of the new colors, implement a custom screen - driver, or use QDirectPainter. -*/ - -/*! \fn int QApplication::qwsProcessEvent(QWSEvent* event) - \internal -*/ - -/*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) - \internal -*/ - -/*! \fn int QApplication::x11ProcessEvent(XEvent* event) - This function does the core processing of individual X - \a{event}s, normally by dispatching Qt events to the right - destination. - - It returns 1 if the event was consumed by special handling, 0 if - the \a event was consumed by normal handling, and -1 if the \a - event was for an unrecognized widget. - - \sa x11EventFilter() -*/ - -/*! - \fn bool QApplication::x11EventFilter(XEvent *event) - - \warning This virtual function is only implemented under X11. - - If you create an application that inherits QApplication and - reimplement this function, you get direct access to all X events - that the are received from the X server. The events are passed in - the \a event parameter. - - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. - - It is only the directly addressed messages that are filtered. - You must install an event filter directly on the event - dispatcher, which is returned by - QAbstractEventDispatcher::instance(), to handle system wide - messages. - - \sa x11ProcessEvent() -*/ - /*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus) \internal \since 4.1 @@ -5021,11 +4441,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) \internal */ -/*! \fn void QApplication::syncX() - Synchronizes with the X server in the X11 implementation. - This normally takes some time. Does nothing on other platforms. -*/ - void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent) { for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 503b36aec6..060765969f 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -98,12 +98,8 @@ public: #ifndef qdoc QApplication(int &argc, char **argv, int = ApplicationFlags); - QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); + QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); QApplication(int &argc, char **argv, Type, int = ApplicationFlags); -#if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags); -#endif #endif virtual ~QApplication(); @@ -150,7 +146,7 @@ public: static QWidget *topLevelAt(const QPoint &p); static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } - static void syncX(); + QT_DEPRECATED static void syncX(); static void beep(); static void alert(QWidget *widget, int duration = 0); @@ -182,31 +178,8 @@ public: static bool isEffectEnabled(Qt::UIEffect); static void setEffectEnabled(Qt::UIEffect, bool enable = true); -#if defined(Q_WS_MAC) - virtual bool macEventFilter(EventHandlerCallRef, EventRef); -#endif -#if defined(Q_WS_X11) - virtual bool x11EventFilter(XEvent *); - virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only); - int x11ProcessEvent(XEvent*); -#endif -#if defined(Q_WS_QWS) - virtual bool qwsEventFilter(QWSEvent *); - int qwsProcessEvent(QWSEvent*); - void qwsSetCustomColors(QRgb *colortable, int start, int numColors); -#ifndef QT_NO_QWS_MANAGER - static QDecoration &qwsDecoration(); - static void qwsSetDecoration(QDecoration *); - static QDecoration *qwsSetDecoration(const QString &decoration); -#endif -#endif - static QPlatformNativeInterface *platformNativeInterface(); -#if defined(Q_WS_WIN) - void winFocus(QWidget *, bool); - static void winMouseButtonUp(); -#endif #ifndef QT_NO_SESSIONMANAGER // session management bool isSessionRestored() const; @@ -252,21 +225,14 @@ public Q_SLOTS: static void aboutQt(); protected: -#if defined(Q_WS_QWS) - void setArgs(int, char **); -#endif bool event(QEvent *); bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); #if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) QApplication(int &argc, char **argv); - QApplication(int &argc, char **argv, bool GUIenabled); + QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled); QApplication(int &argc, char **argv, Type); -#if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); -#endif #endif private: @@ -291,21 +257,9 @@ private: #endif friend class QAction; -#if defined(Q_WS_QWS) - friend class QWSDirectPainterSurface; - friend class QDirectPainter; - friend class QDirectPainterPrivate; -#endif #ifndef QT_NO_GESTURES friend class QGestureManager; #endif - -#if defined(Q_WS_MAC) || defined(Q_WS_X11) - Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut()) -#endif -#if defined(QT_RX71_MULTITOUCH) - Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) -#endif }; QT_END_NAMESPACE diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 978e989a00..b331356e66 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -220,8 +220,6 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa if (pe) pe->setSystemClip(QRegion()); - QApplication::syncX(); - #if defined(Q_OS_UNIX) ::usleep(1000 * msec); #endif -- cgit v1.2.3 From 541949aed23ea14a71a7d4391bac244b623add0a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 15:36:01 +0100 Subject: Add further theme hints to QPlatformTheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add hints for QDialog/QDialogButtonBox. - Add hint for available popup-menu area. - Add keyboard scheme hint replacing QGuiApplicationPrivate::currentKeyPlatform() Reviewed-by: Samuel Rødal Reviewed-by: Morten Johan Sørvig Task-number: QTBUG-24204 Task-number: QTBUG-24315 Change-Id: I6653786b0dcb49a6fc264d3b9891dbfee502bd3e Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qicon.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index e579fac4f4..eebd57f97e 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -60,11 +60,6 @@ #include #endif -#ifdef Q_WS_X11 -#include "private/qt_x11_p.h" -#include "private/qkde_p.h" -#endif - #include "private/qhexstring_p.h" #ifndef QT_NO_ICON -- cgit v1.2.3 From f783ec5347ac9962d011b2ff470082e083216367 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 22:18:26 +0100 Subject: Remove use of Q_BROKEN_DEBUG_STREAM. No supported compiler defines it, and it was not used consistently so it didn't work anyway. Change-Id: Icc9e911e22daaedaee3d9316c15d19be26cd2e72 Reviewed-by: Thiago Macieira --- src/widgets/kernel/qwidgetsvariant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index 72080d9e6b..cf85cbf063 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -127,7 +127,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type type, void *resul return false; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast(&v.data_ptr()); @@ -157,7 +157,7 @@ static const QVariant::Handler widgets_handler = { compare, convert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) streamDebug #else 0 -- cgit v1.2.3 From a6e20e4874d3f46f311625e471f1b7fbc64964b2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 14:45:07 +0100 Subject: Handle theme change in QApplication/QGuiApplication. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-initialize palette and fonts. Change-Id: Ib312747886a31e8370f8d99536d52cbcf8afe8a4 Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qapplication.cpp | 33 ++++++++++++++++++++++++++------- src/widgets/kernel/qapplication_p.h | 4 +++- 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 134b1809bb..650d4af38b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -128,6 +128,21 @@ Q_CORE_EXPORT void qt_call_post_routines(); QApplicationPrivate *QApplicationPrivate::self = 0; +static void initSystemPalette() +{ + if (!QApplicationPrivate::sys_pal) + if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) + QApplicationPrivate::setSystemPalette(*themePalette); + if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style) + QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); +} + +static void clearSystemPalette() +{ + delete QApplicationPrivate::sys_pal; + QApplicationPrivate::sys_pal = 0; +} + #ifdef Q_OS_WINCE int QApplicationPrivate::autoMaximizeThreshold = -1; bool QApplicationPrivate::autoSipEnabled = false; @@ -365,6 +380,7 @@ QString QApplicationPrivate::styleSheet; // default application styles QPointer QApplicationPrivate::leaveAfterRelease = 0; int QApplicationPrivate::app_cspec = QApplication::NormalColor; + QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer @@ -783,8 +799,7 @@ QApplication::~QApplication() delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; - delete QApplicationPrivate::sys_pal; - QApplicationPrivate::sys_pal = 0; + clearSystemPalette(); delete QApplicationPrivate::set_pal; QApplicationPrivate::set_pal = 0; app_palettes()->clear(); @@ -1084,11 +1099,8 @@ QStyle *QApplication::style() // take ownership of the style QApplicationPrivate::app_style->setParent(qApp); - if (!QApplicationPrivate::sys_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QApplicationPrivate::setSystemPalette(*themePalette); - if (!QApplicationPrivate::sys_pal) - QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); + initSystemPalette(); + if (QApplicationPrivate::set_pal) // repolish set palette with the new style QApplication::setPalette(*QApplicationPrivate::set_pal); @@ -4631,6 +4643,13 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times } } +void QApplicationPrivate::notifyThemeChanged() +{ + QGuiApplicationPrivate::notifyThemeChanged(); + clearSystemPalette(); + initSystemPalette(); +} + #ifndef QT_NO_GESTURES QGestureManager* QGestureManager::instance() { diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index e728868182..7a880986bf 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -260,7 +260,9 @@ public: static QPalette *sys_pal; static QPalette *set_pal; -private: +protected: + void notifyThemeChanged(); + public: static QFont *sys_font; static QFont *set_font; -- cgit v1.2.3 From 5a2efb490bc3549ef42420a0dafcf22072785e0d Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Mon, 9 Jan 2012 11:25:40 +0100 Subject: QWheelEvent high-resolution delta support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support pixel-based deltas as well as sending dx and dy values in the same event. Keep source and behavior compatibility with Qt 4. New API: QPoint pixelDelta() const QPoint angleDelta() const Deprecate delta() and orientation(). Both pixel-based deltas and combined updates are necessary for smooth trackpad-based scrolling on OS X. Qt 4 compatible behavior is achieved by sending an extra wheel event in cases where the initial event has a combined dx and dy update. This extra event sends dx in delta() and orientation(), with pixelDelta() and angleDelta() set to null. Modify the Cocoa implementation to provide pixel deltas. It is expected that not all platforms can provide these. Angle deltas will always be available. Change-Id: I20c10f0df338ddcd6a3f7a4d40949ed5ae3b4795 Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qapplication.cpp | 4 ++-- src/widgets/kernel/qwidgetwindow_qpa.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 650d4af38b..c350223278 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3357,8 +3357,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } while (w) { - QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(), - wheel->modifiers(), wheel->orientation()); + QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), + wheel->modifiers()); we.spont = wheel->spontaneous(); res = d->notify_helper(w, w == receiver ? wheel : &we); eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted(); diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index c04d8a9dc3..4d5e9d5774 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -364,7 +364,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) QPoint mapped = widget->mapFrom(m_widget, event->pos()); - QWheelEvent translated(mapped, event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation()); + QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->pixelDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(widget, &translated); } -- cgit v1.2.3 From 51f2a0c3318549a6f9388e3d4920eb23a60f8b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 10 Feb 2012 12:21:25 +0100 Subject: Cleanup usage of QVariant::Type. QVariant::Type is marked as obsolete. It is not possible to get rid of it completely, in a source compatible way, but at least we can remove it safely from a method arguments list. Change-Id: I26b58099bfa6d32f3a583a8ae0047f0bb36bcd0d Reviewed-by: Thiago Macieira --- src/widgets/kernel/qwidgetsvariant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index cf85cbf063..81847681e4 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -117,7 +117,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return false; } -static bool convert(const QVariant::Private *d, QVariant::Type type, void *result, bool *ok) +static bool convert(const QVariant::Private *d, int type, void *result, bool *ok) { Q_UNUSED(d); Q_UNUSED(type); @@ -141,7 +141,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) dbg.nospace() << *v_cast(d); break; default: - dbg.nospace() << "QVariant::Type(" << d->type << ")"; + dbg.nospace() << "QMetaType::Type(" << d->type << ")"; } } #endif -- cgit v1.2.3 From bc6ad75d18a029da363afc4f6007aefc7962a8ad Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 26 Feb 2012 10:56:49 +0100 Subject: Remove use of deprecated conversion from QKeySequence Note: UNICODE_ACCEL is Qt3 compatibility and is equal to 0 Change-Id: I808a66772abceb3822d515d69386728264eb1b40 Reviewed-by: Lars Knoll --- src/widgets/kernel/qaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index d3d63a8c7b..f450d13a39 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -1119,7 +1119,7 @@ QAction::event(QEvent *e) "QAction::event", "Received shortcut event from incorrect shortcut"); if (se->isAmbiguous()) - qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", QString(se->key()).toLatin1().constData()); + qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); else activate(Trigger); return true; -- cgit v1.2.3