2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2013-01-02 11:13:29 +00:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-09-19 12:28:29 +00:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2013-03-17 18:26:18 +00:00
|
|
|
** This file is part of the QtWidgets module of the Qt Toolkit.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-19 12:28:29 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2012-09-19 12:28:29 +00:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-04-27 10:05:43 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2011-05-24 09:34:08 +00:00
|
|
|
** GNU General Public License Usage
|
2012-09-19 12:28:29 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2012-01-24 06:17:24 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "qplatformdefs.h"
|
|
|
|
#include "qabstracteventdispatcher.h"
|
|
|
|
#include "qapplication.h"
|
|
|
|
#include "qclipboard.h"
|
|
|
|
#include "qcursor.h"
|
|
|
|
#include "qdesktopwidget.h"
|
|
|
|
#include "qdir.h"
|
|
|
|
#include "qevent.h"
|
|
|
|
#include "qfile.h"
|
|
|
|
#include "qfileinfo.h"
|
|
|
|
#include "qgraphicsscene.h"
|
|
|
|
#include "qhash.h"
|
|
|
|
#include "qset.h"
|
|
|
|
#include "qlayout.h"
|
|
|
|
#include "qstyle.h"
|
2012-06-20 20:55:57 +00:00
|
|
|
#include "qstyleoption.h"
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "qstylefactory.h"
|
|
|
|
#include "qtextcodec.h"
|
|
|
|
#include "qtranslator.h"
|
|
|
|
#include "qvariant.h"
|
|
|
|
#include "qwidget.h"
|
2011-05-04 10:50:14 +00:00
|
|
|
#include "private/qdnd_p.h"
|
2012-02-10 16:17:36 +00:00
|
|
|
#include "private/qguiapplication_p.h"
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "qcolormap.h"
|
|
|
|
#include "qdebug.h"
|
|
|
|
#include "private/qstylesheetstyle_p.h"
|
|
|
|
#include "private/qstyle_p.h"
|
|
|
|
#include "qmessagebox.h"
|
2012-02-11 00:33:55 +00:00
|
|
|
#include "qwidgetwindow_qpa_p.h"
|
2011-05-07 13:05:43 +00:00
|
|
|
#include <QtWidgets/qgraphicsproxywidget.h>
|
2011-08-31 08:47:09 +00:00
|
|
|
#include <QtGui/qstylehints.h>
|
2012-01-24 15:44:38 +00:00
|
|
|
#include <QtGui/qinputmethod.h>
|
Expose QPA API under qpa/*
The main reasons for doing this are:
1. _qpa.h end up in the master QtGui include file. QtGui is meant for
userland applications. qpa code is neither binary nor source compatible.
Inadvertant use of QPA api makes the user code binary-incompatible.
2. syncqt creates forwarding headers for non-private header files. This
gives people the impression that this is public API.
As discussed on the mailing list, even though QPA api is internal and subject
to change, it needs to treated differently from private headers since they
will be used by in-qtbase and out-of-qtbase plugins.
This commit does the following:
1. The _qpa in QPA header files is dropped.
2. syncqt now treats any file with qplatform prefix as a special file and
moves it to qpa/ directory. The recommended way of using QPA API in plugins
is: #include <qpa/qplatformfoo.h>. This allows the user include QPA API
from multiple modules (for example, qplatformfoo might be in QtPrintSupport)
3. The user needs to explicitly add QT += <module>-private to get access to
the qpa api.
4. Creates compat headers for the olden style qplatformfoo_qpa.h and QPlatformFoo
includes.
This commit does not change the cpp filenames. This requires a more careful
merging of existing non qpa cpp files and existing cpp files on a case by
case basis. This can be done at anytime.
The following files are not renamed as part of this changed but will be fixed
as part of a future change:
src/gui/kernel/qgenericpluginfactory_qpa.h
src/gui/kernel/qgenericplugin_qpa.h
src/gui/kernel/qwindowsysteminterface_qpa.h
files were renamed using
for x in `find . -name "qplatform*_qpa.h"`; do git mv $x "${x/_qpa.h/.h}"; done
for x in `find . -name "qplatform*_qpa_p.h"`; do git mv $x "${x/_qpa_p.h/_p.h}"; done
includes were renamed using script
for file in `find . -name "*.h" -or -name "*.cpp" -or -name "*.mm"`; do
sed -i -e 's,.*#.*include.*<\(Qt.*/\)\?\(QPlatform.*\)>,#include <qpa/\L\2.h>,g' \
-e 's,.*#.*include.*"\(Qt.*/\)\?\(QPlatform.*\)",#include <qpa/\L\2.h>,g' \
-e 's,.*#.*include.* "\(qplatform.*\)_qpa.h",#include <qpa/\L\1.h>,g' \
-e 's,.*#.*include.*"\(qplatform.*\)_qpa_p.h",#include <qpa/\L\1_p.h>,g' \
-e 's,.*#.*include.*<\(Qt.*/\|Qt.*/private/\|private/\)\?\(qplatform.*\)_qpa\(.*\)>,#include <qpa/\2\3>,g' \
-e 's,.*#.*include.*"\(Qt.*/\|Qt.*/private/\|private/\)\?\(qplatform.*\)_qpa\(.*\)",#include <qpa/\2\3>,g' \
$file
done
Change-Id: I04a350314a45746e3911f54b3b21ad03315afb67
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
2012-04-26 23:33:35 +00:00
|
|
|
#include <qpa/qplatformtheme.h>
|
2013-04-23 14:03:36 +00:00
|
|
|
#ifndef QT_NO_WHATSTHIS
|
|
|
|
#include <QtWidgets/QWhatsThis>
|
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2011-05-04 10:50:14 +00:00
|
|
|
#include "private/qkeymapper_p.h"
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include <qthread.h>
|
|
|
|
#include <private/qthread_p.h>
|
|
|
|
|
|
|
|
#include <private/qfont_p.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "qapplication_p.h"
|
2011-05-04 10:50:14 +00:00
|
|
|
#include "private/qevent_p.h"
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "qwidget_p.h"
|
|
|
|
|
|
|
|
#include "qgesture.h"
|
|
|
|
#include "private/qgesturemanager_p.h"
|
Expose QPA API under qpa/*
The main reasons for doing this are:
1. _qpa.h end up in the master QtGui include file. QtGui is meant for
userland applications. qpa code is neither binary nor source compatible.
Inadvertant use of QPA api makes the user code binary-incompatible.
2. syncqt creates forwarding headers for non-private header files. This
gives people the impression that this is public API.
As discussed on the mailing list, even though QPA api is internal and subject
to change, it needs to treated differently from private headers since they
will be used by in-qtbase and out-of-qtbase plugins.
This commit does the following:
1. The _qpa in QPA header files is dropped.
2. syncqt now treats any file with qplatform prefix as a special file and
moves it to qpa/ directory. The recommended way of using QPA API in plugins
is: #include <qpa/qplatformfoo.h>. This allows the user include QPA API
from multiple modules (for example, qplatformfoo might be in QtPrintSupport)
3. The user needs to explicitly add QT += <module>-private to get access to
the qpa api.
4. Creates compat headers for the olden style qplatformfoo_qpa.h and QPlatformFoo
includes.
This commit does not change the cpp filenames. This requires a more careful
merging of existing non qpa cpp files and existing cpp files on a case by
case basis. This can be done at anytime.
The following files are not renamed as part of this changed but will be fixed
as part of a future change:
src/gui/kernel/qgenericpluginfactory_qpa.h
src/gui/kernel/qgenericplugin_qpa.h
src/gui/kernel/qwindowsysteminterface_qpa.h
files were renamed using
for x in `find . -name "qplatform*_qpa.h"`; do git mv $x "${x/_qpa.h/.h}"; done
for x in `find . -name "qplatform*_qpa_p.h"`; do git mv $x "${x/_qpa_p.h/_p.h}"; done
includes were renamed using script
for file in `find . -name "*.h" -or -name "*.cpp" -or -name "*.mm"`; do
sed -i -e 's,.*#.*include.*<\(Qt.*/\)\?\(QPlatform.*\)>,#include <qpa/\L\2.h>,g' \
-e 's,.*#.*include.*"\(Qt.*/\)\?\(QPlatform.*\)",#include <qpa/\L\2.h>,g' \
-e 's,.*#.*include.* "\(qplatform.*\)_qpa.h",#include <qpa/\L\1.h>,g' \
-e 's,.*#.*include.*"\(qplatform.*\)_qpa_p.h",#include <qpa/\L\1_p.h>,g' \
-e 's,.*#.*include.*<\(Qt.*/\|Qt.*/private/\|private/\)\?\(qplatform.*\)_qpa\(.*\)>,#include <qpa/\2\3>,g' \
-e 's,.*#.*include.*"\(Qt.*/\|Qt.*/private/\|private/\)\?\(qplatform.*\)_qpa\(.*\)",#include <qpa/\2\3>,g' \
$file
done
Change-Id: I04a350314a45746e3911f54b3b21ad03315afb67
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
2012-04-26 23:33:35 +00:00
|
|
|
#include <qpa/qplatformfontdatabase.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#ifndef QT_NO_LIBRARY
|
|
|
|
#include "qlibrary.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "qdatetime.h"
|
2012-09-05 13:07:42 +00:00
|
|
|
|
|
|
|
#ifdef Q_OS_WINCE
|
2011-04-27 10:05:43 +00:00
|
|
|
extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
|
|
|
|
extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
|
|
|
|
extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
|
|
|
|
#endif
|
|
|
|
|
2012-08-17 11:19:36 +00:00
|
|
|
#include <qpa/qplatformwindow.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
//#define ALIEN_DEBUG
|
|
|
|
|
|
|
|
static void initResources()
|
|
|
|
{
|
2012-02-07 13:23:50 +00:00
|
|
|
#if defined(Q_OS_WINCE)
|
2011-04-27 10:05:43 +00:00
|
|
|
Q_INIT_RESOURCE(qstyle_wince);
|
|
|
|
#else
|
|
|
|
Q_INIT_RESOURCE(qstyle);
|
|
|
|
#endif
|
|
|
|
Q_INIT_RESOURCE(qmessagebox);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
Q_CORE_EXPORT void qt_call_post_routines();
|
|
|
|
|
|
|
|
QApplicationPrivate *QApplicationPrivate::self = 0;
|
|
|
|
|
2012-02-21 13:45:07 +00:00
|
|
|
static void initSystemPalette()
|
|
|
|
{
|
2012-03-17 18:46:33 +00:00
|
|
|
if (!QApplicationPrivate::sys_pal) {
|
|
|
|
QPalette defaultPlatte;
|
|
|
|
if (QApplicationPrivate::app_style)
|
|
|
|
defaultPlatte = QApplicationPrivate::app_style->standardPalette();
|
2012-02-24 08:17:00 +00:00
|
|
|
if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) {
|
2012-03-17 18:46:33 +00:00
|
|
|
QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte));
|
2012-02-24 08:17:00 +00:00
|
|
|
QApplicationPrivate::initializeWidgetPaletteHash();
|
2012-03-17 18:46:33 +00:00
|
|
|
} else {
|
|
|
|
QApplicationPrivate::setSystemPalette(defaultPlatte);
|
2012-02-24 08:17:00 +00:00
|
|
|
}
|
2012-03-17 18:46:33 +00:00
|
|
|
}
|
2012-02-21 13:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clearSystemPalette()
|
|
|
|
{
|
|
|
|
delete QApplicationPrivate::sys_pal;
|
|
|
|
QApplicationPrivate::sys_pal = 0;
|
|
|
|
}
|
|
|
|
|
2012-02-07 13:23:50 +00:00
|
|
|
#ifdef Q_OS_WINCE
|
2011-04-27 10:05:43 +00:00
|
|
|
int QApplicationPrivate::autoMaximizeThreshold = -1;
|
|
|
|
bool QApplicationPrivate::autoSipEnabled = false;
|
|
|
|
#else
|
|
|
|
bool QApplicationPrivate::autoSipEnabled = true;
|
|
|
|
#endif
|
|
|
|
|
2012-11-22 13:29:07 +00:00
|
|
|
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags)
|
2011-04-27 15:36:02 +00:00
|
|
|
: QApplicationPrivateBase(argc, argv, flags)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2012-11-22 13:29:07 +00:00
|
|
|
application_type = QApplicationPrivate::Gui;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef QT_NO_GESTURES
|
|
|
|
gestureManager = 0;
|
|
|
|
gestureWidget = 0;
|
|
|
|
#endif // QT_NO_GESTURES
|
|
|
|
|
|
|
|
if (!self)
|
|
|
|
self = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QApplicationPrivate::~QApplicationPrivate()
|
|
|
|
{
|
|
|
|
if (self == this)
|
|
|
|
self = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class QApplication
|
|
|
|
\brief The QApplication class manages the GUI application's control
|
|
|
|
flow and main settings.
|
|
|
|
|
2011-09-20 21:22:36 +00:00
|
|
|
\inmodule QtWidgets
|
|
|
|
|
2012-02-20 13:11:29 +00:00
|
|
|
QApplication specializes QGuiApplication with some functionality needed
|
|
|
|
for QWidget-based applications. It handles widget specific initialization,
|
2012-11-23 14:29:03 +00:00
|
|
|
finalization.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
For any GUI application using Qt, there is precisely \b one QApplication
|
2011-04-27 10:05:43 +00:00
|
|
|
object, no matter whether the application has 0, 1, 2 or more windows at
|
2012-02-20 13:11:29 +00:00
|
|
|
any given time. For non-QWidget based Qt applications, use QGuiApplication instead,
|
|
|
|
as it does not depend on the \l QtWidgets library.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-12-10 13:09:55 +00:00
|
|
|
Some GUI applications provide a special batch mode ie. provide command line
|
|
|
|
arguments for executing tasks without manual intervention. In such non-GUI
|
|
|
|
mode, it is often sufficient to instantiate a plain QCoreApplication to
|
|
|
|
avoid unnecessarily initializing resources needed for a graphical user
|
|
|
|
interface. The following example shows how to dynamically create an
|
|
|
|
appropriate type of application instance:
|
|
|
|
|
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 0
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
The QApplication object is accessible through the instance() function that
|
|
|
|
returns a pointer equivalent to the global qApp pointer.
|
|
|
|
|
|
|
|
QApplication's main areas of responsibility are:
|
|
|
|
\list
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It initializes the application with the user's desktop settings
|
2011-04-27 10:05:43 +00:00
|
|
|
such as palette(), font() and doubleClickInterval(). It keeps
|
|
|
|
track of these properties in case the user changes the desktop
|
|
|
|
globally, for example through some kind of control panel.
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It performs event handling, meaning that it receives events
|
2011-04-27 10:05:43 +00:00
|
|
|
from the underlying window system and dispatches them to the
|
|
|
|
relevant widgets. By using sendEvent() and postEvent() you can
|
|
|
|
send your own events to widgets.
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It parses common command line arguments and sets its internal
|
2011-04-27 10:05:43 +00:00
|
|
|
state accordingly. See the \l{QApplication::QApplication()}
|
|
|
|
{constructor documentation} below for more details.
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It defines the application's look and feel, which is
|
2011-04-27 10:05:43 +00:00
|
|
|
encapsulated in a QStyle object. This can be changed at runtime
|
|
|
|
with setStyle().
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It specifies how the application is to allocate colors. See
|
2011-04-27 10:05:43 +00:00
|
|
|
setColorSpec() for details.
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It provides localization of strings that are visible to the
|
2011-04-27 10:05:43 +00:00
|
|
|
user via translate().
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It provides some magical objects like the desktop() and the
|
2011-04-27 10:05:43 +00:00
|
|
|
clipboard().
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It knows about the application's windows. You can ask which
|
2011-04-27 10:05:43 +00:00
|
|
|
widget is at a certain position using widgetAt(), get a list of
|
|
|
|
topLevelWidgets() and closeAllWindows(), etc.
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\li It manages the application's mouse cursor handling, see
|
2011-04-27 10:05:43 +00:00
|
|
|
setOverrideCursor()
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
Since the QApplication object does so much initialization, it \e{must} be
|
|
|
|
created before any other objects related to the user interface are created.
|
|
|
|
QApplication also deals with common command line arguments. Hence, it is
|
|
|
|
usually a good idea to create it \e before any interpretation or
|
|
|
|
modification of \c argv is done in the application itself.
|
|
|
|
|
|
|
|
\table
|
|
|
|
\header
|
2012-03-01 14:28:31 +00:00
|
|
|
\li{2,1} Groups of functions
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li System settings
|
|
|
|
\li desktopSettingsAware(),
|
2011-04-27 10:05:43 +00:00
|
|
|
setDesktopSettingsAware(),
|
|
|
|
cursorFlashTime(),
|
|
|
|
setCursorFlashTime(),
|
|
|
|
doubleClickInterval(),
|
|
|
|
setDoubleClickInterval(),
|
|
|
|
setKeyboardInputInterval(),
|
|
|
|
wheelScrollLines(),
|
|
|
|
setWheelScrollLines(),
|
|
|
|
palette(),
|
|
|
|
setPalette(),
|
|
|
|
font(),
|
|
|
|
setFont(),
|
|
|
|
fontMetrics().
|
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li Event handling
|
|
|
|
\li exec(),
|
2011-04-27 10:05:43 +00:00
|
|
|
processEvents(),
|
|
|
|
exit(),
|
|
|
|
quit().
|
|
|
|
sendEvent(),
|
|
|
|
postEvent(),
|
|
|
|
sendPostedEvents(),
|
|
|
|
removePostedEvents(),
|
|
|
|
hasPendingEvents(),
|
2012-02-20 13:11:29 +00:00
|
|
|
notify().
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li GUI Styles
|
|
|
|
\li style(),
|
2011-04-27 10:05:43 +00:00
|
|
|
setStyle().
|
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li Color usage
|
|
|
|
\li colorSpec(),
|
2012-02-20 13:11:29 +00:00
|
|
|
setColorSpec().
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li Text handling
|
|
|
|
\li installTranslator(),
|
2011-04-27 10:05:43 +00:00
|
|
|
removeTranslator()
|
|
|
|
translate().
|
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li Widgets
|
|
|
|
\li allWidgets(),
|
2011-04-27 10:05:43 +00:00
|
|
|
topLevelWidgets(),
|
|
|
|
desktop(),
|
|
|
|
activePopupWidget(),
|
|
|
|
activeModalWidget(),
|
|
|
|
clipboard(),
|
|
|
|
focusWidget(),
|
|
|
|
activeWindow(),
|
|
|
|
widgetAt().
|
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li Advanced cursor handling
|
|
|
|
\li overrideCursor(),
|
2011-04-27 10:05:43 +00:00
|
|
|
setOverrideCursor(),
|
|
|
|
restoreOverrideCursor().
|
|
|
|
|
|
|
|
\row
|
2012-03-01 14:28:31 +00:00
|
|
|
\li Miscellaneous
|
|
|
|
\li closeAllWindows(),
|
2011-04-27 10:05:43 +00:00
|
|
|
startingUp(),
|
|
|
|
closingDown(),
|
|
|
|
type().
|
|
|
|
\endtable
|
|
|
|
|
|
|
|
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QApplication::ColorSpec
|
|
|
|
|
|
|
|
\value NormalColor the default color allocation policy
|
|
|
|
\value CustomColor the same as NormalColor for X11; allocates colors
|
|
|
|
to a palette on demand under Windows
|
|
|
|
\value ManyColor the right choice for applications that use thousands of
|
|
|
|
colors
|
|
|
|
|
|
|
|
See setColorSpec() for full details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QWidget *QApplication::topLevelAt(const QPoint &point)
|
|
|
|
|
|
|
|
Returns the top-level widget at the given \a point; returns 0 if
|
|
|
|
there is no such widget.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QWidget *QApplication::topLevelAt(int x, int y)
|
|
|
|
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Returns the top-level widget at the point (\a{x}, \a{y}); returns
|
|
|
|
0 if there is no such widget.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
The qt_init() and qt_cleanup() functions are implemented in the
|
|
|
|
qapplication_xyz.cpp file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void qt_init(QApplicationPrivate *priv, int type
|
|
|
|
);
|
|
|
|
void qt_cleanup();
|
|
|
|
|
|
|
|
QStyle *QApplicationPrivate::app_style = 0; // default application style
|
|
|
|
QString QApplicationPrivate::styleOverride; // style override
|
|
|
|
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
QString QApplicationPrivate::styleSheet; // default application stylesheet
|
|
|
|
#endif
|
|
|
|
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0;
|
|
|
|
|
|
|
|
int QApplicationPrivate::app_cspec = QApplication::NormalColor;
|
2012-02-21 13:45:07 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
|
|
|
|
QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
|
|
|
|
|
|
|
|
QFont *QApplicationPrivate::sys_font = 0; // default system font
|
|
|
|
QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
|
|
|
|
|
|
|
|
QWidget *QApplicationPrivate::main_widget = 0; // main application widget
|
|
|
|
QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus
|
|
|
|
QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show()
|
|
|
|
QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus
|
|
|
|
#ifndef QT_NO_WHEELEVENT
|
|
|
|
int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
|
|
|
|
#endif
|
|
|
|
bool qt_in_tab_key_event = false;
|
|
|
|
int qt_antialiasing_threshold = -1;
|
|
|
|
QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
|
2012-05-08 11:02:44 +00:00
|
|
|
int QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect;
|
2011-04-27 10:05:43 +00:00
|
|
|
bool QApplicationPrivate::widgetCount = false;
|
|
|
|
bool QApplicationPrivate::load_testability = false;
|
|
|
|
#ifdef QT_KEYPAD_NAVIGATION
|
|
|
|
Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
|
|
|
|
QWidget *QApplicationPrivate::oldEditFocus = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool qt_tabletChokeMouse = false;
|
|
|
|
|
|
|
|
inline bool QApplicationPrivate::isAlien(QWidget *widget)
|
|
|
|
{
|
2011-06-20 11:29:26 +00:00
|
|
|
return widget && !widget->isWindow();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-10-09 09:27:01 +00:00
|
|
|
bool Q_WIDGETS_EXPORT qt_tab_all_widgets()
|
|
|
|
{
|
|
|
|
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
|
|
|
|
return theme->themeHint(QPlatformTheme::TabAllWidgets).toBool();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
// ######## move to QApplicationPrivate
|
|
|
|
// Default application palettes and fonts (per widget type)
|
|
|
|
Q_GLOBAL_STATIC(PaletteHash, app_palettes)
|
|
|
|
PaletteHash *qt_app_palettes_hash()
|
|
|
|
{
|
|
|
|
return app_palettes();
|
|
|
|
}
|
|
|
|
|
2011-09-15 20:28:07 +00:00
|
|
|
Q_GLOBAL_STATIC(FontHash, app_fonts)
|
2011-04-27 10:05:43 +00:00
|
|
|
FontHash *qt_app_fonts_hash()
|
|
|
|
{
|
|
|
|
return app_fonts();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus
|
|
|
|
|
|
|
|
QDesktopWidget *qt_desktopWidget = 0; // root window widgets
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
*/
|
|
|
|
void QApplicationPrivate::process_cmdline()
|
|
|
|
{
|
|
|
|
// process platform-indep command line
|
|
|
|
if (!qt_is_gui_used || !argc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = 1;
|
|
|
|
for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
|
|
|
|
if (argv[i] && *argv[i] != '-') {
|
|
|
|
argv[j++] = argv[i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
QByteArray arg = argv[i];
|
2014-01-31 08:49:58 +00:00
|
|
|
if (arg.startsWith("--"))
|
|
|
|
arg.remove(0, 1);
|
2011-04-27 10:05:43 +00:00
|
|
|
QString s;
|
|
|
|
if (arg == "-qdevel" || arg == "-qdebug") {
|
|
|
|
// obsolete argument
|
|
|
|
} else if (arg.indexOf("-style=", 0) != -1) {
|
|
|
|
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
|
|
|
|
} else if (arg == "-style" && i < argc-1) {
|
|
|
|
s = QString::fromLocal8Bit(argv[++i]).toLower();
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
} else if (arg == "-stylesheet" && i < argc -1) {
|
|
|
|
styleSheet = QLatin1String("file:///");
|
|
|
|
styleSheet.append(QString::fromLocal8Bit(argv[++i]));
|
|
|
|
} else if (arg.indexOf("-stylesheet=") != -1) {
|
|
|
|
styleSheet = QLatin1String("file:///");
|
|
|
|
styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12)));
|
|
|
|
#endif
|
|
|
|
} else if (qstrcmp(arg, "-widgetcount") == 0) {
|
|
|
|
widgetCount = true;
|
|
|
|
} else if (qstrcmp(arg, "-testability") == 0) {
|
|
|
|
load_testability = true;
|
|
|
|
} else {
|
|
|
|
argv[j++] = argv[i];
|
|
|
|
}
|
|
|
|
if (!s.isEmpty()) {
|
|
|
|
if (app_style) {
|
|
|
|
delete app_style;
|
|
|
|
app_style = 0;
|
|
|
|
}
|
|
|
|
styleOverride = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(j < argc) {
|
|
|
|
argv[j] = 0;
|
|
|
|
argc = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Initializes the window system and 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 global \c qApp pointer refers to this application object. Only one
|
|
|
|
application object should be created.
|
|
|
|
|
|
|
|
This application object must be constructed before any \l{QPaintDevice}
|
|
|
|
{paint devices} (including widgets, pixmaps, bitmaps etc.).
|
|
|
|
|
|
|
|
\note \a argc and \a argv might be changed as Qt removes command line
|
|
|
|
arguments that it recognizes.
|
|
|
|
|
|
|
|
All Qt programs automatically support the following command line options:
|
|
|
|
\list
|
2012-03-01 14:28:31 +00:00
|
|
|
\li -style= \e style, sets the application GUI style. Possible values
|
2012-09-18 11:55:45 +00:00
|
|
|
depend on your system configuration. If you compiled Qt with
|
2011-04-27 10:05:43 +00:00
|
|
|
additional styles or have additional styles as plugins these will
|
2012-11-30 16:43:45 +00:00
|
|
|
be available to the \c -style command line option. You can also
|
|
|
|
set the style for all Qt applications by setting the
|
|
|
|
\c QT_STYLE_OVERRIDE environment variable.
|
2012-03-01 14:28:31 +00:00
|
|
|
\li -style \e style, is the same as listed above.
|
|
|
|
\li -stylesheet= \e stylesheet, sets the application \l styleSheet. The
|
2011-04-27 10:05:43 +00:00
|
|
|
value must be a path to a file that contains the Style Sheet.
|
|
|
|
\note Relative URLs in the Style Sheet file are relative to the
|
|
|
|
Style Sheet file's path.
|
2012-03-01 14:28:31 +00:00
|
|
|
\li -stylesheet \e stylesheet, is the same as listed above.
|
|
|
|
\li -widgetcount, prints debug message at the end about number of
|
2011-04-27 10:05:43 +00:00
|
|
|
widgets left undestroyed and maximum number of widgets existed at
|
|
|
|
the same time
|
2012-03-01 14:28:31 +00:00
|
|
|
\li -reverse, sets the application's layout direction to
|
2011-04-27 10:05:43 +00:00
|
|
|
Qt::RightToLeft
|
2012-03-01 14:28:31 +00:00
|
|
|
\li -qmljsdebugger=, activates the QML/JS debugger with a specified port.
|
2011-04-27 10:05:43 +00:00
|
|
|
The value must be of format port:1234[,block], where block is optional
|
|
|
|
and will make the application wait until a debugger connects to it.
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
\sa arguments()
|
|
|
|
*/
|
|
|
|
|
2012-08-15 11:32:02 +00:00
|
|
|
#ifdef Q_QDOC
|
|
|
|
QApplication::QApplication(int &argc, char **argv)
|
|
|
|
#else
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplication::QApplication(int &argc, char **argv, int _internal)
|
2012-08-15 11:32:02 +00:00
|
|
|
#endif
|
2012-11-22 13:29:07 +00:00
|
|
|
: QGuiApplication(*new QApplicationPrivate(argc, argv, _internal))
|
2011-04-27 10:05:43 +00:00
|
|
|
{ Q_D(QApplication); d->construct(); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
*/
|
2012-02-20 13:11:29 +00:00
|
|
|
void QApplicationPrivate::construct()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
initResources();
|
|
|
|
|
2012-11-22 13:29:07 +00:00
|
|
|
qt_is_gui_used = (application_type != QApplicationPrivate::Tty);
|
2011-04-27 10:05:43 +00:00
|
|
|
process_cmdline();
|
|
|
|
|
|
|
|
// Must be called before initialize()
|
2012-02-20 13:11:29 +00:00
|
|
|
qt_init(this, application_type);
|
2011-04-27 10:05:43 +00:00
|
|
|
initialize();
|
|
|
|
eventDispatcher->startingUp();
|
|
|
|
|
|
|
|
#ifdef QT_EVAL
|
2013-07-04 13:44:53 +00:00
|
|
|
extern void qt_gui_eval_init(QCoreApplicationPrivate::Type);
|
2011-04-27 10:05:43 +00:00
|
|
|
qt_gui_eval_init(application_type);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef QT_NO_LIBRARY
|
|
|
|
if(load_testability) {
|
|
|
|
QLibrary testLib(QLatin1String("qttestability"));
|
|
|
|
if (testLib.load()) {
|
|
|
|
typedef void (*TasInitialize)(void);
|
|
|
|
TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
|
|
|
|
if (initFunction) {
|
|
|
|
initFunction();
|
|
|
|
} else {
|
|
|
|
qCritical("Library qttestability resolve failed!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qCritical("Library qttestability load failed!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_STATEMACHINE
|
2011-11-28 14:40:35 +00:00
|
|
|
void qRegisterGuiStateMachine();
|
|
|
|
void qUnregisterGuiStateMachine();
|
2011-04-27 10:05:43 +00:00
|
|
|
#endif
|
2013-01-08 12:07:16 +00:00
|
|
|
extern void qRegisterWidgetsVariant();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QApplicationPrivate::initialize()
|
|
|
|
|
|
|
|
Initializes the QApplication object, called from the constructors.
|
|
|
|
*/
|
|
|
|
void QApplicationPrivate::initialize()
|
|
|
|
{
|
2013-03-13 09:34:18 +00:00
|
|
|
is_app_running = false; // Starting up.
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QWidgetPrivate::mapper = new QWidgetMapper;
|
|
|
|
QWidgetPrivate::allWidgets = new QWidgetSet;
|
|
|
|
|
2013-01-08 12:07:16 +00:00
|
|
|
// needed for a static build.
|
|
|
|
qRegisterWidgetsVariant();
|
|
|
|
|
2012-11-22 13:29:07 +00:00
|
|
|
if (application_type != QApplicationPrivate::Tty)
|
2011-04-27 10:05:43 +00:00
|
|
|
(void) QApplication::style(); // trigger creation of application style
|
|
|
|
#ifndef QT_NO_STATEMACHINE
|
|
|
|
// trigger registering of QStateMachine's GUI types
|
|
|
|
qRegisterGuiStateMachine();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0)
|
2013-03-07 15:41:39 +00:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_NativeWindows);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-02-07 13:23:50 +00:00
|
|
|
#ifdef Q_OS_WINCE
|
2011-04-27 10:05:43 +00:00
|
|
|
#ifdef QT_AUTO_MAXIMIZE_THRESHOLD
|
|
|
|
autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
|
|
|
|
#else
|
|
|
|
if (qt_wince_is_mobile())
|
|
|
|
autoMaximizeThreshold = 50;
|
|
|
|
else
|
|
|
|
autoMaximizeThreshold = -1;
|
|
|
|
#endif //QT_AUTO_MAXIMIZE_THRESHOLD
|
2012-02-07 13:23:50 +00:00
|
|
|
#endif //Q_OS_WINCE
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef QT_NO_WHEELEVENT
|
|
|
|
QApplicationPrivate::wheel_scroll_lines = 3;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (qt_is_gui_used)
|
|
|
|
initializeMultitouch();
|
2012-05-08 11:02:44 +00:00
|
|
|
|
|
|
|
if (QApplication::desktopSettingsAware())
|
|
|
|
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
|
|
|
|
QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt();
|
2013-03-13 09:34:18 +00:00
|
|
|
|
|
|
|
is_app_running = true; // no longer starting up
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
Functions returning the active popup and modal widgets.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the active popup widget.
|
|
|
|
|
|
|
|
A popup widget is a special top-level widget that sets the \c
|
|
|
|
Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application
|
|
|
|
opens a popup widget, all events are sent to the popup. Normal widgets and
|
|
|
|
modal widgets cannot be accessed before the popup widget is closed.
|
|
|
|
|
|
|
|
Only other popup widgets may be opened when a popup widget is shown. The
|
|
|
|
popup widgets are organized in a stack. This function returns the active
|
|
|
|
popup widget at the top of the stack.
|
|
|
|
|
|
|
|
\sa activeModalWidget(), topLevelWidgets()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QWidget *QApplication::activePopupWidget()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ?
|
|
|
|
QApplicationPrivate::popupWidgets->last() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the active modal widget.
|
|
|
|
|
|
|
|
A modal widget is a special top-level widget which is a subclass of QDialog
|
|
|
|
that specifies the modal parameter of the constructor as true. A modal
|
|
|
|
widget must be closed before the user can continue with other parts of the
|
|
|
|
program.
|
|
|
|
|
|
|
|
Modal widgets are organized in a stack. This function returns the active
|
|
|
|
modal widget at the top of the stack.
|
|
|
|
|
|
|
|
\sa activePopupWidget(), topLevelWidgets()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QWidget *QApplication::activeModalWidget()
|
|
|
|
{
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow());
|
|
|
|
return widgetWindow ? widgetWindow->widget() : 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Cleans up any window system resources that were allocated by this
|
|
|
|
application. Sets the global variable \c qApp to 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
QApplication::~QApplication()
|
|
|
|
{
|
|
|
|
Q_D(QApplication);
|
|
|
|
|
|
|
|
//### this should probable be done even later
|
|
|
|
qt_call_post_routines();
|
|
|
|
|
|
|
|
// kill timers before closing down the dispatcher
|
|
|
|
d->toolTipWakeUp.stop();
|
|
|
|
d->toolTipFallAsleep.stop();
|
|
|
|
|
|
|
|
QApplicationPrivate::is_app_closing = true;
|
|
|
|
QApplicationPrivate::is_app_running = false;
|
|
|
|
|
|
|
|
delete QWidgetPrivate::mapper;
|
|
|
|
QWidgetPrivate::mapper = 0;
|
|
|
|
|
|
|
|
// delete all widgets
|
|
|
|
if (QWidgetPrivate::allWidgets) {
|
|
|
|
QWidgetSet *mySet = QWidgetPrivate::allWidgets;
|
|
|
|
QWidgetPrivate::allWidgets = 0;
|
|
|
|
for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QWidget *w = *it;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (!w->parent()) // window
|
|
|
|
w->destroy(true, true);
|
|
|
|
}
|
|
|
|
delete mySet;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete qt_desktopWidget;
|
|
|
|
qt_desktopWidget = 0;
|
|
|
|
|
|
|
|
delete QApplicationPrivate::app_pal;
|
|
|
|
QApplicationPrivate::app_pal = 0;
|
2012-02-21 13:45:07 +00:00
|
|
|
clearSystemPalette();
|
2011-04-27 10:05:43 +00:00
|
|
|
delete QApplicationPrivate::set_pal;
|
|
|
|
QApplicationPrivate::set_pal = 0;
|
|
|
|
app_palettes()->clear();
|
|
|
|
|
|
|
|
delete QApplicationPrivate::sys_font;
|
|
|
|
QApplicationPrivate::sys_font = 0;
|
|
|
|
delete QApplicationPrivate::set_font;
|
|
|
|
QApplicationPrivate::set_font = 0;
|
|
|
|
app_fonts()->clear();
|
|
|
|
|
|
|
|
delete QApplicationPrivate::app_style;
|
|
|
|
QApplicationPrivate::app_style = 0;
|
|
|
|
|
|
|
|
#ifndef QT_NO_DRAGANDDROP
|
|
|
|
if (qt_is_gui_used)
|
|
|
|
delete QDragManager::self();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
d->cleanupMultitouch();
|
|
|
|
|
|
|
|
qt_cleanup();
|
|
|
|
|
|
|
|
if (QApplicationPrivate::widgetCount)
|
|
|
|
qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
|
|
|
|
|
|
|
|
QApplicationPrivate::obey_desktop_settings = true;
|
|
|
|
|
|
|
|
QApplicationPrivate::app_strut = QSize(0, 0);
|
2012-05-08 11:02:44 +00:00
|
|
|
QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect;
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplicationPrivate::widgetCount = false;
|
|
|
|
|
|
|
|
#ifndef QT_NO_STATEMACHINE
|
|
|
|
// trigger unregistering of QStateMachine's GUI types
|
|
|
|
qUnregisterGuiStateMachine();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QWidget *QApplication::widgetAt(const QPoint &point)
|
|
|
|
|
|
|
|
Returns the widget at global screen position \a point, or 0 if there is no
|
|
|
|
Qt widget there.
|
|
|
|
|
|
|
|
This function can be slow.
|
|
|
|
|
|
|
|
\sa QCursor::pos(), QWidget::grabMouse(), QWidget::grabKeyboard()
|
|
|
|
*/
|
|
|
|
QWidget *QApplication::widgetAt(const QPoint &p)
|
|
|
|
{
|
|
|
|
QWidget *window = QApplication::topLevelAt(p);
|
|
|
|
if (!window)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QWidget *child = 0;
|
|
|
|
|
|
|
|
if (!window->testAttribute(Qt::WA_TransparentForMouseEvents))
|
|
|
|
child = window->childAt(window->mapFromGlobal(p));
|
|
|
|
|
|
|
|
if (child)
|
|
|
|
return child;
|
|
|
|
|
|
|
|
if (window->testAttribute(Qt::WA_TransparentForMouseEvents)) {
|
|
|
|
//shoot a hole in the widget and try once again,
|
|
|
|
//suboptimal on Qt for Embedded Linux where we do
|
|
|
|
//know the stacking order of the toplevels.
|
|
|
|
int x = p.x();
|
|
|
|
int y = p.y();
|
|
|
|
QRegion oldmask = window->mask();
|
|
|
|
QPoint wpoint = window->mapFromGlobal(QPoint(x, y));
|
|
|
|
QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
|
|
|
|
- QRegion(wpoint.x(), wpoint.y(), 1, 1);
|
|
|
|
window->setMask(newmask);
|
|
|
|
QWidget *recurse = 0;
|
|
|
|
if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
|
|
|
|
recurse = widgetAt(x, y);
|
|
|
|
if (oldmask.isEmpty())
|
|
|
|
window->clearMask();
|
|
|
|
else
|
|
|
|
window->setMask(oldmask);
|
|
|
|
return recurse;
|
|
|
|
}
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QWidget *QApplication::widgetAt(int x, int y)
|
|
|
|
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Returns the widget at global screen position (\a x, \a y), or 0 if there is
|
|
|
|
no Qt widget there.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
*/
|
|
|
|
bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
|
|
|
|
{
|
|
|
|
if ((event->type() == QEvent::UpdateRequest
|
|
|
|
|| event->type() == QEvent::LayoutRequest
|
|
|
|
|| event->type() == QEvent::Resize
|
|
|
|
|| event->type() == QEvent::Move
|
|
|
|
|| event->type() == QEvent::LanguageChange
|
|
|
|
|| event->type() == QEvent::InputMethod)) {
|
2011-06-24 15:26:20 +00:00
|
|
|
for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
|
|
|
|
const QPostEvent &cur = *it;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
|
|
|
|
continue;
|
|
|
|
if (cur.event->type() == QEvent::LayoutRequest
|
|
|
|
|| cur.event->type() == QEvent::UpdateRequest) {
|
|
|
|
;
|
|
|
|
} else if (cur.event->type() == QEvent::Resize) {
|
|
|
|
((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s;
|
|
|
|
} else if (cur.event->type() == QEvent::Move) {
|
|
|
|
((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p;
|
|
|
|
} else if (cur.event->type() == QEvent::LanguageChange) {
|
|
|
|
;
|
|
|
|
} else if ( cur.event->type() == QEvent::InputMethod ) {
|
|
|
|
*(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
delete event;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-11-21 13:10:37 +00:00
|
|
|
return QGuiApplication::compressEvent(event, receiver, postedEvents);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::styleSheet
|
|
|
|
\brief the application style sheet
|
|
|
|
\since 4.2
|
|
|
|
|
|
|
|
By default, this property returns an empty string unless the user specifies
|
|
|
|
the \c{-stylesheet} option on the command line when running the application.
|
|
|
|
|
|
|
|
\sa QWidget::setStyle(), {Qt Style Sheets}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::autoMaximizeThreshold
|
|
|
|
\since 4.4
|
|
|
|
\brief defines a threshold for auto maximizing widgets
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\b{The auto maximize threshold is only available as part of Qt for
|
2011-04-27 10:05:43 +00:00
|
|
|
Windows CE.}
|
|
|
|
|
|
|
|
This property defines a threshold for the size of a window as a percentage
|
|
|
|
of the screen size. If the minimum size hint of a window exceeds the
|
|
|
|
threshold, calling show() will cause the window to be maximized
|
|
|
|
automatically.
|
|
|
|
|
|
|
|
Setting the threshold to 100 or greater means that the widget will always
|
|
|
|
be maximized. Alternatively, setting the threshold to 50 means that the
|
|
|
|
widget will be maximized only if the vertical minimum size hint is at least
|
|
|
|
50% of the vertical screen size.
|
|
|
|
|
|
|
|
Setting the threshold to -1 disables the feature.
|
|
|
|
|
|
|
|
On Windows CE the default is -1 (i.e., it is disabled).
|
|
|
|
On Windows Mobile the default is 40.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::autoSipEnabled
|
|
|
|
\since 4.5
|
|
|
|
\brief toggles automatic SIP (software input panel) visibility
|
|
|
|
|
|
|
|
Set this property to \c true to automatically display the SIP when entering
|
|
|
|
widgets that accept keyboard input. This property only affects widgets with
|
|
|
|
the WA_InputMethodEnabled attribute set, and is typically used to launch
|
|
|
|
a virtual keyboard on devices which have very few or no keys.
|
|
|
|
|
2012-03-01 14:28:31 +00:00
|
|
|
\b{ The property only has an effect on platforms which use software input
|
2012-01-23 18:37:27 +00:00
|
|
|
panels, such as Windows CE.}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
The default is platform dependent.
|
|
|
|
*/
|
|
|
|
|
2012-02-07 13:23:50 +00:00
|
|
|
#ifdef Q_OS_WINCE
|
2011-04-27 10:05:43 +00:00
|
|
|
void QApplication::setAutoMaximizeThreshold(const int threshold)
|
|
|
|
{
|
|
|
|
QApplicationPrivate::autoMaximizeThreshold = threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
int QApplication::autoMaximizeThreshold() const
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::autoMaximizeThreshold;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void QApplication::setAutoSipEnabled(const bool enabled)
|
|
|
|
{
|
|
|
|
QApplicationPrivate::autoSipEnabled = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QApplication::autoSipEnabled() const
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::autoSipEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
|
|
|
|
QString QApplication::styleSheet() const
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::styleSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplication::setStyleSheet(const QString& styleSheet)
|
|
|
|
{
|
|
|
|
QApplicationPrivate::styleSheet = styleSheet;
|
|
|
|
QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplicationPrivate::app_style);
|
|
|
|
if (styleSheet.isEmpty()) { // application style sheet removed
|
|
|
|
if (!proxy)
|
|
|
|
return; // there was no stylesheet before
|
|
|
|
setStyle(proxy->base);
|
|
|
|
} else if (proxy) { // style sheet update, just repolish
|
|
|
|
proxy->repolish(qApp);
|
|
|
|
} else { // stylesheet set the first time
|
|
|
|
QStyleSheetStyle *newProxy = new QStyleSheetStyle(QApplicationPrivate::app_style);
|
|
|
|
QApplicationPrivate::app_style->setParent(newProxy);
|
|
|
|
setStyle(newProxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // QT_NO_STYLE_STYLESHEET
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the application's style object.
|
|
|
|
|
|
|
|
\sa setStyle(), QStyle
|
|
|
|
*/
|
|
|
|
QStyle *QApplication::style()
|
|
|
|
{
|
|
|
|
if (QApplicationPrivate::app_style)
|
|
|
|
return QApplicationPrivate::app_style;
|
2012-11-22 13:29:07 +00:00
|
|
|
if (!qobject_cast<QApplication *>(QCoreApplication::instance())) {
|
|
|
|
Q_ASSERT(!"No style available without QApplication!");
|
2011-04-27 10:05:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!QApplicationPrivate::app_style) {
|
|
|
|
// Compile-time search for default style
|
|
|
|
//
|
|
|
|
QString style;
|
|
|
|
QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
|
|
|
|
if (!QApplicationPrivate::styleOverride.isEmpty()) {
|
|
|
|
style = QApplicationPrivate::styleOverride;
|
|
|
|
} else if (!envStyle.isEmpty()) {
|
|
|
|
style = envStyle;
|
|
|
|
} else {
|
|
|
|
style = QApplicationPrivate::desktopStyleKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
QStyle *&app_style = QApplicationPrivate::app_style;
|
|
|
|
app_style = QStyleFactory::create(style);
|
|
|
|
if (!app_style) {
|
|
|
|
QStringList styles = QStyleFactory::keys();
|
|
|
|
for (int i = 0; i < styles.size(); ++i) {
|
|
|
|
if ((app_style = QStyleFactory::create(styles.at(i))))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!app_style) {
|
|
|
|
Q_ASSERT(!"No styles available!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// take ownership of the style
|
|
|
|
QApplicationPrivate::app_style->setParent(qApp);
|
|
|
|
|
2012-02-21 13:45:07 +00:00
|
|
|
initSystemPalette();
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
if (QApplicationPrivate::set_pal) // repolish set palette with the new style
|
|
|
|
QApplication::setPalette(*QApplicationPrivate::set_pal);
|
|
|
|
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
if (!QApplicationPrivate::styleSheet.isEmpty()) {
|
|
|
|
qApp->setStyleSheet(QApplicationPrivate::styleSheet);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
QApplicationPrivate::app_style->polish(qApp);
|
|
|
|
|
|
|
|
return QApplicationPrivate::app_style;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the application's GUI style to \a style. Ownership of the style object
|
|
|
|
is transferred to QApplication, so QApplication will delete the style
|
|
|
|
object on application exit or when a new style is set and the old style is
|
|
|
|
still the parent of the application object.
|
|
|
|
|
|
|
|
Example usage:
|
2012-05-07 16:49:48 +00:00
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 1
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
When switching application styles, the color palette is set back to the
|
|
|
|
initial colors or the system defaults. This is necessary since certain
|
|
|
|
styles have to adapt the color palette to be fully style-guide compliant.
|
|
|
|
|
2012-08-21 16:36:26 +00:00
|
|
|
Setting the style before a palette has been set, i.e., before creating
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplication, will cause the application to use QStyle::standardPalette()
|
|
|
|
for the palette.
|
|
|
|
|
|
|
|
\warning Qt style sheets are currently not supported for custom QStyle
|
|
|
|
subclasses. We plan to address this in some future release.
|
|
|
|
|
|
|
|
\sa style(), QStyle, setPalette(), desktopSettingsAware()
|
|
|
|
*/
|
|
|
|
void QApplication::setStyle(QStyle *style)
|
|
|
|
{
|
|
|
|
if (!style || style == QApplicationPrivate::app_style)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QWidgetList all = allWidgets();
|
|
|
|
|
|
|
|
// clean up the old style
|
|
|
|
if (QApplicationPrivate::app_style) {
|
|
|
|
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
|
|
|
|
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QWidget *w = *it;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (!(w->windowType() == Qt::Desktop) && // except desktop
|
|
|
|
w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
|
|
|
|
QApplicationPrivate::app_style->unpolish(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QApplicationPrivate::app_style->unpolish(qApp);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStyle *old = QApplicationPrivate::app_style; // save
|
|
|
|
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) {
|
|
|
|
// we have a stylesheet already and a new style is being set
|
|
|
|
QStyleSheetStyle *newProxy = new QStyleSheetStyle(style);
|
|
|
|
style->setParent(newProxy);
|
|
|
|
QApplicationPrivate::app_style = newProxy;
|
|
|
|
} else
|
|
|
|
#endif // QT_NO_STYLE_STYLESHEET
|
|
|
|
QApplicationPrivate::app_style = style;
|
|
|
|
QApplicationPrivate::app_style->setParent(qApp); // take ownership
|
|
|
|
|
|
|
|
// take care of possible palette requirements of certain gui
|
|
|
|
// styles. Do it before polishing the application since the style
|
|
|
|
// might call QApplication::setPalette() itself
|
|
|
|
if (QApplicationPrivate::set_pal) {
|
|
|
|
QApplication::setPalette(*QApplicationPrivate::set_pal);
|
|
|
|
} else if (QApplicationPrivate::sys_pal) {
|
2013-09-01 09:03:57 +00:00
|
|
|
clearSystemPalette();
|
|
|
|
initSystemPalette();
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplicationPrivate::initializeWidgetPaletteHash();
|
2013-09-01 09:03:57 +00:00
|
|
|
QApplicationPrivate::initializeWidgetFontHash();
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false);
|
|
|
|
} else if (!QApplicationPrivate::sys_pal) {
|
|
|
|
// Initialize the sys_pal if it hasn't happened yet...
|
|
|
|
QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
|
|
|
|
}
|
|
|
|
|
|
|
|
// initialize the application with the new style
|
|
|
|
QApplicationPrivate::app_style->polish(qApp);
|
|
|
|
|
|
|
|
// re-polish existing widgets if necessary
|
|
|
|
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
|
|
|
|
for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QWidget *w = *it1;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
|
|
|
|
if (w->style() == QApplicationPrivate::app_style)
|
|
|
|
QApplicationPrivate::app_style->polish(w); // repolish
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
else
|
|
|
|
w->setStyleSheet(w->styleSheet()); // touch
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QWidget *w = *it2;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
|
|
|
|
QEvent e(QEvent::StyleChange);
|
|
|
|
QApplication::sendEvent(w, &e);
|
|
|
|
w->update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_STYLE_STYLESHEET
|
|
|
|
if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) {
|
|
|
|
oldProxy->deref();
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if (old && old->parent() == qApp) {
|
|
|
|
delete old;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QApplicationPrivate::focus_widget) {
|
|
|
|
QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason);
|
|
|
|
QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in);
|
|
|
|
QApplicationPrivate::focus_widget->update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Requests a QStyle object for \a style from the QStyleFactory.
|
|
|
|
|
|
|
|
The string must be one of the QStyleFactory::keys(), typically one of
|
2012-10-18 13:22:15 +00:00
|
|
|
"windows", "fusion", "windowsxp", or "macintosh". Style
|
2011-04-27 10:05:43 +00:00
|
|
|
names are case insensitive.
|
|
|
|
|
|
|
|
Returns 0 if an unknown \a style is passed, otherwise the QStyle object
|
|
|
|
returned is set as the application's GUI style.
|
|
|
|
|
|
|
|
\warning To ensure that the application's style is set correctly, it is
|
|
|
|
best to call this function before the QApplication constructor, if
|
|
|
|
possible.
|
|
|
|
*/
|
|
|
|
QStyle* QApplication::setStyle(const QString& style)
|
|
|
|
{
|
|
|
|
QStyle *s = QStyleFactory::create(style);
|
|
|
|
if (!s)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
setStyle(s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the color specification.
|
|
|
|
|
|
|
|
\sa QApplication::setColorSpec()
|
|
|
|
*/
|
|
|
|
|
|
|
|
int QApplication::colorSpec()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::app_cspec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the color specification for the application to \a spec.
|
|
|
|
|
|
|
|
The color specification controls how the application allocates colors when
|
|
|
|
run on a display with a limited amount of colors, e.g. 8 bit / 256 color
|
|
|
|
displays.
|
|
|
|
|
|
|
|
The color specification must be set before you create the QApplication
|
|
|
|
object.
|
|
|
|
|
|
|
|
The options are:
|
|
|
|
\list
|
2012-03-01 14:28:31 +00:00
|
|
|
\li QApplication::NormalColor. This is the default color allocation
|
2011-04-27 10:05:43 +00:00
|
|
|
strategy. Use this option if your application uses buttons, menus,
|
|
|
|
texts and pixmaps with few colors. With this option, the
|
|
|
|
application uses system global colors. This works fine for most
|
|
|
|
applications under X11, but on the Windows platform, it may cause
|
|
|
|
dithering of non-standard colors.
|
2012-03-01 14:28:31 +00:00
|
|
|
\li QApplication::CustomColor. Use this option if your application
|
2011-04-27 10:05:43 +00:00
|
|
|
needs a small number of custom colors. On X11, this option is the
|
|
|
|
same as NormalColor. On Windows, Qt creates a Windows palette, and
|
|
|
|
allocates colors to it on demand.
|
2012-03-01 14:28:31 +00:00
|
|
|
\li QApplication::ManyColor. Use this option if your application is
|
2011-04-27 10:05:43 +00:00
|
|
|
very color hungry, e.g., it requires thousands of colors. \br
|
|
|
|
Under X11 the effect is:
|
|
|
|
\list
|
2012-03-01 14:28:31 +00:00
|
|
|
\li For 256-color displays which have at best a 256 color true
|
2011-04-27 10:05:43 +00:00
|
|
|
color visual, the default visual is used, and colors are
|
|
|
|
allocated from a color cube. The color cube is the 6x6x6
|
|
|
|
(216 color) "Web palette" (the red, green, and blue
|
|
|
|
components always have one of the following values: 0x00,
|
|
|
|
0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors
|
|
|
|
can be changed by the \e -ncols option. The user can force
|
|
|
|
the application to use the true color visual with the
|
|
|
|
\l{QApplication::QApplication()}{-visual} option.
|
2012-03-01 14:28:31 +00:00
|
|
|
\li For 256-color displays which have a true color visual with
|
2011-04-27 10:05:43 +00:00
|
|
|
more than 256 colors, use that visual. Silicon Graphics X
|
|
|
|
servers this feature, for example. They provide an 8 bit
|
|
|
|
visual by default but can deliver true color when asked.
|
|
|
|
\endlist
|
|
|
|
On Windows, Qt creates a Windows palette, and fills it with a color
|
|
|
|
cube.
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
Be aware that the CustomColor and ManyColor choices may lead to colormap
|
|
|
|
flashing: The foreground application gets (most) of the available colors,
|
|
|
|
while the background windows will look less attractive.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2012-05-07 16:49:48 +00:00
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 2
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\sa colorSpec()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QApplication::setColorSpec(int spec)
|
|
|
|
{
|
|
|
|
if (qApp)
|
|
|
|
qWarning("QApplication::setColorSpec: This function must be "
|
|
|
|
"called before the QApplication object is created");
|
|
|
|
QApplicationPrivate::app_cspec = spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::globalStrut
|
|
|
|
\brief the minimum size that any GUI element that the user can interact
|
|
|
|
with should have
|
|
|
|
|
|
|
|
For example, no button should be resized to be smaller than the global
|
|
|
|
strut size. The strut size should be considered when reimplementing GUI
|
|
|
|
controls that may be used on touch-screens or similar I/O devices.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2012-05-07 16:49:48 +00:00
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 3
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
By default, this property contains a QSize object with zero width and height.
|
|
|
|
*/
|
|
|
|
QSize QApplication::globalStrut()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::app_strut;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplication::setGlobalStrut(const QSize& strut)
|
|
|
|
{
|
|
|
|
QApplicationPrivate::app_strut = strut;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QPalette QApplication::palette(const QWidget* widget)
|
|
|
|
\overload
|
|
|
|
|
|
|
|
If a \a widget is passed, the default palette for the widget's class is
|
|
|
|
returned. This may or may not be the application palette. In most cases
|
|
|
|
there is no special palette for certain types of widgets, but one notable
|
|
|
|
exception is the popup menu under Windows, if the user has defined a
|
|
|
|
special background color for menus in the display settings.
|
|
|
|
|
|
|
|
\sa setPalette(), QWidget::palette()
|
|
|
|
*/
|
|
|
|
QPalette QApplication::palette(const QWidget* w)
|
|
|
|
{
|
|
|
|
PaletteHash *hash = app_palettes();
|
|
|
|
if (w && hash && hash->size()) {
|
|
|
|
QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className());
|
|
|
|
if (it != hash->constEnd())
|
|
|
|
return *it;
|
|
|
|
for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
|
|
|
|
if (w->inherits(it.key()))
|
|
|
|
return it.value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return palette();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Returns the palette for widgets of the given \a className.
|
|
|
|
|
|
|
|
\sa setPalette(), QWidget::palette()
|
|
|
|
*/
|
|
|
|
QPalette QApplication::palette(const char *className)
|
|
|
|
{
|
|
|
|
if (!QApplicationPrivate::app_pal)
|
|
|
|
palette();
|
|
|
|
PaletteHash *hash = app_palettes();
|
|
|
|
if (className && hash && hash->size()) {
|
|
|
|
QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className);
|
|
|
|
if (it != hash->constEnd())
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
return *QApplicationPrivate::app_pal;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash)
|
|
|
|
{
|
|
|
|
QPalette pal = palette;
|
|
|
|
|
|
|
|
if (QApplicationPrivate::app_style)
|
|
|
|
QApplicationPrivate::app_style->polish(pal); // NB: non-const reference
|
|
|
|
|
|
|
|
bool all = false;
|
|
|
|
PaletteHash *hash = app_palettes();
|
|
|
|
if (!className) {
|
|
|
|
if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal))
|
|
|
|
return;
|
|
|
|
if (!QApplicationPrivate::app_pal)
|
|
|
|
QApplicationPrivate::app_pal = new QPalette(pal);
|
|
|
|
else
|
|
|
|
*QApplicationPrivate::app_pal = pal;
|
|
|
|
if (hash && hash->size()) {
|
|
|
|
all = true;
|
|
|
|
if (clearWidgetPaletteHash)
|
|
|
|
hash->clear();
|
|
|
|
}
|
|
|
|
} else if (hash) {
|
|
|
|
hash->insert(className, pal);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
|
|
|
|
// Send ApplicationPaletteChange to qApp itself, and to the widgets.
|
|
|
|
QEvent e(QEvent::ApplicationPaletteChange);
|
|
|
|
QApplication::sendEvent(QApplication::instance(), &e);
|
|
|
|
|
|
|
|
QWidgetList wids = QApplication::allWidgets();
|
|
|
|
for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QWidget *w = *it;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
|
|
|
|
QApplication::sendEvent(w, &e);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send to all scenes as well.
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
|
|
|
|
for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
|
|
|
|
it != scenes.constEnd(); ++it) {
|
|
|
|
QApplication::sendEvent(*it, &e);
|
|
|
|
}
|
|
|
|
#endif //QT_NO_GRAPHICSVIEW
|
|
|
|
}
|
|
|
|
if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) {
|
|
|
|
if (!QApplicationPrivate::set_pal)
|
|
|
|
QApplicationPrivate::set_pal = new QPalette(palette);
|
|
|
|
else
|
|
|
|
*QApplicationPrivate::set_pal = palette;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Changes the default application palette to \a palette.
|
|
|
|
|
|
|
|
If \a className is passed, the change applies only to widgets that inherit
|
|
|
|
\a className (as reported by QObject::inherits()). If \a className is left
|
|
|
|
0, the change affects all widgets, thus overriding any previously set class
|
|
|
|
specific palettes.
|
|
|
|
|
|
|
|
The palette may be changed according to the current GUI style in
|
|
|
|
QStyle::polish().
|
|
|
|
|
|
|
|
\warning Do not use this function in conjunction with \l{Qt Style Sheets}.
|
|
|
|
When using style sheets, the palette of a widget can be customized using
|
|
|
|
the "color", "background-color", "selection-color",
|
|
|
|
"selection-background-color" and "alternate-background-color".
|
|
|
|
|
|
|
|
\note Some styles do not use the palette for all drawing, for instance, if
|
|
|
|
they make use of native theme engines. This is the case for the Windows XP,
|
|
|
|
Windows Vista, and Mac OS X styles.
|
|
|
|
|
|
|
|
\sa QWidget::setPalette(), palette(), QStyle::polish()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QApplication::setPalette(const QPalette &palette, const char* className)
|
|
|
|
{
|
|
|
|
QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QApplicationPrivate::setSystemPalette(const QPalette &pal)
|
|
|
|
{
|
|
|
|
QPalette adjusted;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// adjust the system palette to avoid dithering
|
|
|
|
QColormap cmap = QColormap::instance();
|
|
|
|
if (cmap.depths() > 4 && cmap.depths() < 24) {
|
|
|
|
for (int g = 0; g < QPalette::NColorGroups; g++)
|
|
|
|
for (int i = 0; i < QPalette::NColorRoles; i++) {
|
|
|
|
QColor color = pal.color((QPalette::ColorGroup)g, (QPalette::ColorRole)i);
|
|
|
|
color = cmap.colorAt(cmap.pixel(color));
|
|
|
|
adjusted.setColor((QPalette::ColorGroup)g, (QPalette::ColorRole) i, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
adjusted = pal;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!sys_pal)
|
|
|
|
sys_pal = new QPalette(adjusted);
|
|
|
|
else
|
|
|
|
*sys_pal = adjusted;
|
|
|
|
|
|
|
|
|
|
|
|
if (!QApplicationPrivate::set_pal)
|
|
|
|
QApplication::setPalette(*sys_pal);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the default application font.
|
|
|
|
|
|
|
|
\sa fontMetrics(), QWidget::font()
|
|
|
|
*/
|
|
|
|
QFont QApplication::font()
|
|
|
|
{
|
2011-04-27 15:29:10 +00:00
|
|
|
return QGuiApplication::font();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Returns the default font for the \a widget.
|
|
|
|
|
|
|
|
\sa fontMetrics(), QWidget::setFont()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QFont QApplication::font(const QWidget *widget)
|
|
|
|
{
|
|
|
|
FontHash *hash = app_fonts();
|
|
|
|
|
|
|
|
if (widget && hash && hash->size()) {
|
2012-11-19 13:57:11 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
// short circuit for small and mini controls
|
|
|
|
if (widget->testAttribute(Qt::WA_MacSmallSize)) {
|
|
|
|
return hash->value(QByteArrayLiteral("QSmallFont"));
|
|
|
|
} else if (widget->testAttribute(Qt::WA_MacMiniSize)) {
|
|
|
|
return hash->value(QByteArrayLiteral("QMiniFont"));
|
|
|
|
}
|
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
QHash<QByteArray, QFont>::ConstIterator it =
|
|
|
|
hash->constFind(widget->metaObject()->className());
|
|
|
|
if (it != hash->constEnd())
|
|
|
|
return it.value();
|
|
|
|
for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
|
|
|
|
if (widget->inherits(it.key()))
|
|
|
|
return it.value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return font();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Returns the font for widgets of the given \a className.
|
|
|
|
|
|
|
|
\sa setFont(), QWidget::font()
|
|
|
|
*/
|
|
|
|
QFont QApplication::font(const char *className)
|
|
|
|
{
|
|
|
|
FontHash *hash = app_fonts();
|
|
|
|
if (className && hash && hash->size()) {
|
|
|
|
QHash<QByteArray, QFont>::ConstIterator it = hash->constFind(className);
|
|
|
|
if (it != hash->constEnd())
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
return font();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Changes the default application font to \a font. If \a className is passed,
|
|
|
|
the change applies only to classes that inherit \a className (as reported
|
|
|
|
by QObject::inherits()).
|
|
|
|
|
|
|
|
On application start-up, the default font depends on the window system. It
|
|
|
|
can vary depending on both the window system version and the locale. This
|
|
|
|
function lets you override the default font; but overriding may be a bad
|
|
|
|
idea because, for example, some locales need extra large fonts to support
|
|
|
|
their special characters.
|
|
|
|
|
|
|
|
\warning Do not use this function in conjunction with \l{Qt Style Sheets}.
|
|
|
|
The font of an application can be customized using the "font" style sheet
|
|
|
|
property. To set a bold font for all QPushButtons, set the application
|
|
|
|
styleSheet() as "QPushButton { font: bold }"
|
|
|
|
|
|
|
|
\sa font(), fontMetrics(), QWidget::setFont()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QApplication::setFont(const QFont &font, const char *className)
|
|
|
|
{
|
|
|
|
bool all = false;
|
|
|
|
FontHash *hash = app_fonts();
|
|
|
|
if (!className) {
|
2011-04-27 15:29:10 +00:00
|
|
|
QGuiApplication::setFont(font);
|
2011-04-27 10:05:43 +00:00
|
|
|
if (hash && hash->size()) {
|
|
|
|
all = true;
|
|
|
|
hash->clear();
|
|
|
|
}
|
|
|
|
} else if (hash) {
|
|
|
|
hash->insert(className, font);
|
|
|
|
}
|
|
|
|
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
|
|
|
|
// Send ApplicationFontChange to qApp itself, and to the widgets.
|
|
|
|
QEvent e(QEvent::ApplicationFontChange);
|
|
|
|
QApplication::sendEvent(QApplication::instance(), &e);
|
|
|
|
|
|
|
|
QWidgetList wids = QApplication::allWidgets();
|
|
|
|
for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QWidget *w = *it;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
|
|
|
|
sendEvent(w, &e);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
// Send to all scenes as well.
|
|
|
|
QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
|
|
|
|
for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
|
|
|
|
it != scenes.constEnd(); ++it) {
|
|
|
|
QApplication::sendEvent(*it, &e);
|
|
|
|
}
|
|
|
|
#endif //QT_NO_GRAPHICSVIEW
|
|
|
|
}
|
|
|
|
if (!className && (!QApplicationPrivate::sys_font || !font.isCopyOf(*QApplicationPrivate::sys_font))) {
|
|
|
|
if (!QApplicationPrivate::set_font)
|
|
|
|
QApplicationPrivate::set_font = new QFont(font);
|
|
|
|
else
|
|
|
|
*QApplicationPrivate::set_font = font;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
*/
|
|
|
|
void QApplicationPrivate::setSystemFont(const QFont &font)
|
|
|
|
{
|
|
|
|
if (!sys_font)
|
|
|
|
sys_font = new QFont(font);
|
|
|
|
else
|
|
|
|
*sys_font = font;
|
|
|
|
|
|
|
|
if (!QApplicationPrivate::set_font)
|
|
|
|
QApplication::setFont(*sys_font);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
*/
|
|
|
|
QString QApplicationPrivate::desktopStyleKey()
|
|
|
|
{
|
2012-02-10 16:17:36 +00:00
|
|
|
// The platform theme might return a style that is not available, find
|
|
|
|
// first valid one.
|
|
|
|
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
|
|
|
|
const QStringList availableKeys = QStyleFactory::keys();
|
|
|
|
foreach (const QString &style, theme->themeHint(QPlatformTheme::StyleNames).toStringList())
|
|
|
|
if (availableKeys.contains(style, Qt::CaseInsensitive))
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
return QString();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2014-02-01 13:17:51 +00:00
|
|
|
#if QT_VERSION < 0x060000 // remove these forwarders in Qt 6
|
2011-04-27 10:05:43 +00:00
|
|
|
/*!
|
|
|
|
\property QApplication::windowIcon
|
|
|
|
\brief the default window icon
|
|
|
|
|
|
|
|
\sa QWidget::setWindowIcon(), {Setting the Application Icon}
|
|
|
|
*/
|
|
|
|
QIcon QApplication::windowIcon()
|
|
|
|
{
|
2014-02-01 13:17:51 +00:00
|
|
|
return QGuiApplication::windowIcon();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QApplication::setWindowIcon(const QIcon &icon)
|
|
|
|
{
|
2014-02-01 13:17:51 +00:00
|
|
|
QGuiApplication::setWindowIcon(icon);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void QApplicationPrivate::notifyWindowIconChanged()
|
|
|
|
{
|
|
|
|
QEvent ev(QEvent::ApplicationWindowIconChange);
|
|
|
|
const QWidgetList list = QApplication::topLevelWidgets();
|
|
|
|
QWindowList windowList = QGuiApplication::topLevelWindows();
|
|
|
|
|
|
|
|
// send to all top-level QWidgets
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
|
|
|
windowList.removeOne(w->windowHandle());
|
|
|
|
QCoreApplication::sendEvent(w, &ev);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2014-02-01 13:17:51 +00:00
|
|
|
|
|
|
|
// in case there are any plain QWindows in this QApplication-using
|
|
|
|
// application, also send the notification to them
|
|
|
|
for (int i = 0; i < windowList.size(); ++i)
|
|
|
|
QCoreApplication::sendEvent(windowList.at(i), &ev);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns a list of the top-level widgets (windows) in the application.
|
|
|
|
|
|
|
|
\note Some of the top-level widgets may be hidden, for example a tooltip if
|
|
|
|
no tooltip is currently shown.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2012-05-07 16:49:48 +00:00
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 4
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\sa allWidgets(), QWidget::isWindow(), QWidget::isHidden()
|
|
|
|
*/
|
|
|
|
QWidgetList QApplication::topLevelWidgets()
|
|
|
|
{
|
|
|
|
QWidgetList list;
|
|
|
|
QWidgetList all = allWidgets();
|
|
|
|
|
|
|
|
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
|
|
|
|
QWidget *w = *it;
|
|
|
|
if (w->isWindow() && w->windowType() != Qt::Desktop)
|
|
|
|
list.append(w);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns a list of all the widgets in the application.
|
|
|
|
|
|
|
|
The list is empty (QList::isEmpty()) if there are no widgets.
|
|
|
|
|
|
|
|
\note Some of the widgets may be hidden.
|
|
|
|
|
|
|
|
Example:
|
2012-05-07 16:49:48 +00:00
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 5
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\sa topLevelWidgets(), QWidget::isVisible()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QWidgetList QApplication::allWidgets()
|
|
|
|
{
|
|
|
|
if (QWidgetPrivate::allWidgets)
|
|
|
|
return QWidgetPrivate::allWidgets->toList();
|
|
|
|
return QWidgetList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the application widget that has the keyboard input focus, or 0 if
|
|
|
|
no widget in this application has the focus.
|
|
|
|
|
|
|
|
\sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QWidget *QApplication::focusWidget()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::focus_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
|
|
|
|
{
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
if (focus && focus->window()->graphicsProxyWidget())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
hidden_focus_widget = 0;
|
|
|
|
|
|
|
|
if (focus != focus_widget) {
|
|
|
|
if (focus && focus->isHidden()) {
|
|
|
|
hidden_focus_widget = focus;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason)
|
|
|
|
&& qt_in_tab_key_event)
|
|
|
|
focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
|
|
|
|
else if (focus && reason == Qt::ShortcutFocusReason) {
|
|
|
|
focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
|
|
|
|
}
|
|
|
|
QWidget *prev = focus_widget;
|
|
|
|
focus_widget = focus;
|
|
|
|
|
|
|
|
if(focus_widget)
|
|
|
|
focus_widget->d_func()->setFocus_sys();
|
|
|
|
|
|
|
|
if (reason != Qt::NoFocusReason) {
|
|
|
|
|
|
|
|
//send events
|
|
|
|
if (prev) {
|
|
|
|
#ifdef QT_KEYPAD_NAVIGATION
|
|
|
|
if (QApplication::keypadNavigationEnabled()) {
|
2011-10-20 14:36:05 +00:00
|
|
|
if (prev->hasEditFocus() && reason != Qt::PopupFocusReason)
|
2011-04-27 10:05:43 +00:00
|
|
|
prev->setEditFocus(false);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
QFocusEvent out(QEvent::FocusOut, reason);
|
|
|
|
QPointer<QWidget> that = prev;
|
|
|
|
QApplication::sendEvent(prev, &out);
|
|
|
|
if (that)
|
|
|
|
QApplication::sendEvent(that->style(), &out);
|
|
|
|
}
|
|
|
|
if(focus && QApplicationPrivate::focus_widget == focus) {
|
|
|
|
QFocusEvent in(QEvent::FocusIn, reason);
|
|
|
|
QPointer<QWidget> that = focus;
|
|
|
|
QApplication::sendEvent(focus, &in);
|
|
|
|
if (that)
|
|
|
|
QApplication::sendEvent(that->style(), &in);
|
|
|
|
}
|
|
|
|
emit qApp->focusChanged(prev, focus_widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the application top-level window that has the keyboard input focus,
|
|
|
|
or 0 if no application window has the focus. There might be an
|
|
|
|
activeWindow() even if there is no focusWidget(), for example if no widget
|
|
|
|
in that window accepts key events.
|
|
|
|
|
|
|
|
\sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QWidget *QApplication::activeWindow()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::active_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns display (screen) font metrics for the application font.
|
|
|
|
|
|
|
|
\sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics()
|
|
|
|
*/
|
|
|
|
|
|
|
|
QFontMetrics QApplication::fontMetrics()
|
|
|
|
{
|
|
|
|
return desktop()->fontMetrics();
|
|
|
|
}
|
|
|
|
|
2014-02-11 12:00:59 +00:00
|
|
|
bool QApplicationPrivate::tryCloseAllWidgetWindows(QWindowList *processedWindows)
|
|
|
|
{
|
|
|
|
Q_ASSERT(processedWindows);
|
|
|
|
while (QWidget *w = QApplication::activeModalWidget()) {
|
|
|
|
if (!w->isVisible() || w->data->is_closing)
|
|
|
|
break;
|
|
|
|
QWindow *window = w->windowHandle();
|
|
|
|
if (!w->close()) // Qt::WA_DeleteOnClose may cause deletion.
|
|
|
|
return false;
|
|
|
|
if (window)
|
|
|
|
processedWindows->append(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidgetList list = QApplication::topLevelWidgets();
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
2014-01-28 13:53:49 +00:00
|
|
|
if (w->isVisible() && w->windowType() != Qt::Desktop &&
|
|
|
|
!w->testAttribute(Qt::WA_DontShowOnScreen) && !w->data->is_closing) {
|
2014-02-11 12:00:59 +00:00
|
|
|
QWindow *window = w->windowHandle();
|
|
|
|
if (!w->close()) // Qt::WA_DeleteOnClose may cause deletion.
|
|
|
|
return false;
|
|
|
|
if (window)
|
|
|
|
processedWindows->append(window);
|
|
|
|
list = QApplication::topLevelWidgets();
|
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QApplicationPrivate::tryCloseAllWindows()
|
|
|
|
{
|
|
|
|
QWindowList processedWindows;
|
|
|
|
return QApplicationPrivate::tryCloseAllWidgetWindows(&processedWindows)
|
|
|
|
&& QGuiApplicationPrivate::tryCloseRemainingWindows(processedWindows);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Closes all top-level windows.
|
|
|
|
|
|
|
|
This function is particularly useful for applications with many top-level
|
2012-05-07 16:49:48 +00:00
|
|
|
windows. It could, for example, be connected to a \uicontrol{Exit} entry in the
|
|
|
|
\uicontrol{File} menu:
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-05-07 16:49:48 +00:00
|
|
|
\snippet mainwindows/mdi/mainwindow.cpp 0
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
The windows are closed in random order, until one window does not accept
|
|
|
|
the close event. The application quits when the last window was
|
|
|
|
successfully closed; this can be turned off by setting
|
|
|
|
\l quitOnLastWindowClosed to false.
|
|
|
|
|
|
|
|
\sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(),
|
|
|
|
QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(),
|
|
|
|
QWidget::isWindow()
|
|
|
|
*/
|
|
|
|
void QApplication::closeAllWindows()
|
|
|
|
{
|
2014-02-11 12:00:59 +00:00
|
|
|
QWindowList processedWindows;
|
|
|
|
QApplicationPrivate::tryCloseAllWidgetWindows(&processedWindows);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Displays a simple message box about Qt. The message includes the version
|
|
|
|
number of Qt being used by the application.
|
|
|
|
|
2012-05-07 16:49:48 +00:00
|
|
|
This is useful for inclusion in the \uicontrol Help menu of an application, as
|
2011-04-27 10:05:43 +00:00
|
|
|
shown in the \l{mainwindows/menus}{Menus} example.
|
|
|
|
|
|
|
|
This function is a convenience slot for QMessageBox::aboutQt().
|
|
|
|
*/
|
|
|
|
void QApplication::aboutQt()
|
|
|
|
{
|
|
|
|
#ifndef QT_NO_MESSAGEBOX
|
2012-02-20 13:11:29 +00:00
|
|
|
QMessageBox::aboutQt(activeWindow());
|
2011-04-27 10:05:43 +00:00
|
|
|
#endif // QT_NO_MESSAGEBOX
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\since 4.1
|
|
|
|
\fn void QApplication::focusChanged(QWidget *old, QWidget *now)
|
|
|
|
|
|
|
|
This signal is emitted when the widget that has keyboard focus changed from
|
|
|
|
\a old to \a now, i.e., because the user pressed the tab-key, clicked into
|
|
|
|
a widget or changed the active window. Both \a old and \a now can be the
|
|
|
|
null-pointer.
|
|
|
|
|
|
|
|
The signal is emitted after both widget have been notified about the change
|
|
|
|
through QFocusEvent.
|
|
|
|
|
|
|
|
\sa QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!\reimp
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool QApplication::event(QEvent *e)
|
|
|
|
{
|
|
|
|
Q_D(QApplication);
|
|
|
|
if(e->type() == QEvent::Close) {
|
|
|
|
QCloseEvent *ce = static_cast<QCloseEvent*>(e);
|
|
|
|
ce->accept();
|
|
|
|
closeAllWindows();
|
|
|
|
|
|
|
|
QWidgetList list = topLevelWidgets();
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
|
|
|
if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
|
|
|
|
(!(w->windowType() == Qt::Dialog) || !w->parentWidget())) {
|
|
|
|
ce->ignore();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ce->isAccepted()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#ifndef Q_OS_WIN
|
|
|
|
} else if (e->type() == QEvent::LocaleChange) {
|
|
|
|
// on Windows the event propagation is taken care by the
|
|
|
|
// WM_SETTINGCHANGE event handler.
|
|
|
|
QWidgetList list = topLevelWidgets();
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
|
|
|
if (!(w->windowType() == Qt::Desktop)) {
|
|
|
|
if (!w->testAttribute(Qt::WA_SetLocale))
|
|
|
|
w->d_func()->setLocale_helper(QLocale(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else if (e->type() == QEvent::Timer) {
|
|
|
|
QTimerEvent *te = static_cast<QTimerEvent*>(e);
|
|
|
|
Q_ASSERT(te != 0);
|
|
|
|
if (te->timerId() == d->toolTipWakeUp.timerId()) {
|
|
|
|
d->toolTipWakeUp.stop();
|
|
|
|
if (d->toolTipWidget) {
|
|
|
|
QWidget *w = d->toolTipWidget->window();
|
|
|
|
// show tooltip if WA_AlwaysShowToolTips is set, or if
|
|
|
|
// any ancestor of d->toolTipWidget is the active
|
|
|
|
// window
|
|
|
|
bool showToolTip = w->testAttribute(Qt::WA_AlwaysShowToolTips);
|
|
|
|
while (w && !showToolTip) {
|
|
|
|
showToolTip = w->isActiveWindow();
|
|
|
|
w = w->parentWidget();
|
|
|
|
w = w ? w->window() : 0;
|
|
|
|
}
|
|
|
|
if (showToolTip) {
|
|
|
|
QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
|
|
|
|
QApplication::sendEvent(d->toolTipWidget, &e);
|
2013-07-01 05:10:48 +00:00
|
|
|
if (e.isAccepted()) {
|
|
|
|
QStyle *s = d->toolTipWidget->style();
|
|
|
|
int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, 0, d->toolTipWidget, 0);
|
|
|
|
d->toolTipFallAsleep.start(sleepDelay, this);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
|
|
|
|
d->toolTipFallAsleep.stop();
|
|
|
|
}
|
2013-04-23 14:03:36 +00:00
|
|
|
#ifndef QT_NO_WHATSTHIS
|
|
|
|
} else if (e->type() == QEvent::EnterWhatsThisMode) {
|
|
|
|
QWhatsThis::enterWhatsThisMode();
|
|
|
|
return true;
|
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-05-03 19:06:20 +00:00
|
|
|
|
|
|
|
if(e->type() == QEvent::LanguageChange) {
|
|
|
|
QWidgetList list = topLevelWidgets();
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
|
|
|
if (!(w->windowType() == Qt::Desktop))
|
|
|
|
postEvent(w, new QEvent(QEvent::LanguageChange));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-21 13:10:37 +00:00
|
|
|
return QGuiApplication::event(e);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-09-28 21:06:00 +00:00
|
|
|
|
2012-02-20 13:11:29 +00:00
|
|
|
/*!
|
2012-04-30 12:26:41 +00:00
|
|
|
\fn void QApplication::syncX()
|
2012-02-20 13:11:29 +00:00
|
|
|
Was used to synchronize with the X server in 4.x, here for source compatibility.
|
|
|
|
\internal
|
|
|
|
\obsolete
|
|
|
|
*/
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2013-12-13 11:36:45 +00:00
|
|
|
// ### FIXME: topLevelWindows does not contain QWidgets without a parent
|
|
|
|
// until create_sys is called. So we have to override the
|
|
|
|
// QGuiApplication::notifyLayoutDirectionChange
|
|
|
|
// to do the right thing.
|
2011-05-03 19:06:20 +00:00
|
|
|
void QApplicationPrivate::notifyLayoutDirectionChange()
|
|
|
|
{
|
2013-12-13 11:36:45 +00:00
|
|
|
const QWidgetList list = QApplication::topLevelWidgets();
|
|
|
|
QWindowList windowList = QGuiApplication::topLevelWindows();
|
|
|
|
|
|
|
|
// send to all top-level QWidgets
|
2011-05-03 19:06:20 +00:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
2013-12-13 11:36:45 +00:00
|
|
|
windowList.removeAll(w->windowHandle());
|
2011-05-03 19:06:20 +00:00
|
|
|
QEvent ev(QEvent::ApplicationLayoutDirectionChange);
|
2012-04-03 07:37:13 +00:00
|
|
|
QCoreApplication::sendEvent(w, &ev);
|
2011-05-03 19:06:20 +00:00
|
|
|
}
|
2013-12-13 11:36:45 +00:00
|
|
|
|
|
|
|
// in case there are any plain QWindows in this QApplication-using
|
|
|
|
// application, also send the notification to them
|
|
|
|
for (int i = 0; i < windowList.size(); ++i) {
|
|
|
|
QEvent ev(QEvent::ApplicationLayoutDirectionChange);
|
|
|
|
QCoreApplication::sendEvent(windowList.at(i), &ev);
|
|
|
|
}
|
2011-05-03 19:06:20 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
/*!
|
|
|
|
\fn void QApplication::setActiveWindow(QWidget* active)
|
|
|
|
|
|
|
|
Sets the active window to the \a active widget in response to a system
|
|
|
|
event. The function is called from the platform specific event handlers.
|
|
|
|
|
|
|
|
\warning This function does \e not set the keyboard focus to the active
|
|
|
|
widget. Call QWidget::activateWindow() instead.
|
|
|
|
|
|
|
|
It sets the activeWindow() and focusWidget() attributes and sends proper
|
|
|
|
\l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate}
|
|
|
|
{WindowDeactivate} and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut}
|
|
|
|
{FocusOut} events to all appropriate widgets. The window will then be
|
|
|
|
painted in active state (e.g. cursors in line edits will blink), and it
|
|
|
|
will have tool tips enabled.
|
|
|
|
|
|
|
|
\sa activeWindow(), QWidget::activateWindow()
|
|
|
|
*/
|
|
|
|
void QApplication::setActiveWindow(QWidget* act)
|
|
|
|
{
|
|
|
|
QWidget* window = act?act->window():0;
|
|
|
|
|
|
|
|
if (QApplicationPrivate::active_window == window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
if (window && window->graphicsProxyWidget()) {
|
|
|
|
// Activate the proxy's view->viewport() ?
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QWidgetList toBeActivated;
|
|
|
|
QWidgetList toBeDeactivated;
|
|
|
|
|
|
|
|
if (QApplicationPrivate::active_window) {
|
|
|
|
if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
|
|
|
|
QWidgetList list = topLevelWidgets();
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
|
|
|
if (w->isVisible() && w->isActiveWindow())
|
|
|
|
toBeDeactivated.append(w);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
toBeDeactivated.append(QApplicationPrivate::active_window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-01 14:54:50 +00:00
|
|
|
if (QApplicationPrivate::focus_widget) {
|
|
|
|
if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
|
2012-02-28 11:35:17 +00:00
|
|
|
qApp->inputMethod()->commit();
|
2012-03-01 14:54:50 +00:00
|
|
|
|
|
|
|
QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason);
|
|
|
|
QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplicationPrivate::active_window = window;
|
|
|
|
|
|
|
|
if (QApplicationPrivate::active_window) {
|
|
|
|
if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
|
|
|
|
QWidgetList list = topLevelWidgets();
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
|
|
|
if (w->isVisible() && w->isActiveWindow())
|
|
|
|
toBeActivated.append(w);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
toBeActivated.append(QApplicationPrivate::active_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// first the activation/deactivation events
|
|
|
|
QEvent activationChange(QEvent::ActivationChange);
|
|
|
|
QEvent windowActivate(QEvent::WindowActivate);
|
|
|
|
QEvent windowDeactivate(QEvent::WindowDeactivate);
|
|
|
|
|
|
|
|
for (int i = 0; i < toBeActivated.size(); ++i) {
|
|
|
|
QWidget *w = toBeActivated.at(i);
|
|
|
|
sendSpontaneousEvent(w, &windowActivate);
|
|
|
|
sendSpontaneousEvent(w, &activationChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < toBeDeactivated.size(); ++i) {
|
|
|
|
QWidget *w = toBeDeactivated.at(i);
|
|
|
|
sendSpontaneousEvent(w, &windowDeactivate);
|
|
|
|
sendSpontaneousEvent(w, &activationChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
|
|
|
|
// then focus events
|
|
|
|
if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) {
|
|
|
|
QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
|
|
|
|
} else if (QApplicationPrivate::active_window) {
|
|
|
|
QWidget *w = QApplicationPrivate::active_window->focusWidget();
|
|
|
|
if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
|
|
|
|
w->setFocus(Qt::ActiveWindowFocusReason);
|
|
|
|
else {
|
|
|
|
w = QApplicationPrivate::focusNextPrevChild_helper(QApplicationPrivate::active_window, true);
|
|
|
|
if (w) {
|
|
|
|
w->setFocus(Qt::ActiveWindowFocusReason);
|
|
|
|
} else {
|
|
|
|
// If the focus widget is not in the activate_window, clear the focus
|
|
|
|
w = QApplicationPrivate::focus_widget;
|
|
|
|
if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
|
|
|
|
QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
|
|
|
|
else if (!QApplicationPrivate::active_window->isAncestorOf(w))
|
|
|
|
QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!internal
|
|
|
|
* Helper function that returns the new focus widget, but does not set the focus reason.
|
|
|
|
* Returns 0 if a new focus widget could not be found.
|
|
|
|
* Shared with QGraphicsProxyWidgetPrivate::findFocusChild()
|
|
|
|
*/
|
2012-12-12 16:18:28 +00:00
|
|
|
QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next,
|
|
|
|
bool *wrappingOccurred)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2012-10-09 09:27:01 +00:00
|
|
|
uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QWidget *f = toplevel->focusWidget();
|
|
|
|
if (!f)
|
|
|
|
f = toplevel;
|
|
|
|
|
|
|
|
QWidget *w = f;
|
|
|
|
QWidget *test = f->d_func()->focus_next;
|
2012-12-12 16:18:28 +00:00
|
|
|
bool seenWindow = false;
|
|
|
|
bool focusWidgetAfterWindow = false;
|
2011-04-27 10:05:43 +00:00
|
|
|
while (test && test != f) {
|
2012-12-12 16:18:28 +00:00
|
|
|
if (test->isWindow())
|
|
|
|
seenWindow = true;
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
if ((test->focusPolicy() & focus_flag) == focus_flag
|
|
|
|
&& !(test->d_func()->extra && test->d_func()->extra->focus_proxy)
|
|
|
|
&& test->isVisibleTo(toplevel) && test->isEnabled()
|
|
|
|
&& !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test))
|
|
|
|
&& (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) {
|
|
|
|
w = test;
|
2012-12-12 16:18:28 +00:00
|
|
|
if (seenWindow)
|
|
|
|
focusWidgetAfterWindow = true;
|
2011-04-27 10:05:43 +00:00
|
|
|
if (next)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
test = test->d_func()->focus_next;
|
|
|
|
}
|
2012-12-12 16:18:28 +00:00
|
|
|
|
|
|
|
if (wrappingOccurred != 0)
|
|
|
|
*wrappingOccurred = next ? focusWidgetAfterWindow : !focusWidgetAfterWindow;
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
if (w == f) {
|
|
|
|
if (qt_in_tab_key_event) {
|
|
|
|
w->window()->setAttribute(Qt::WA_KeyboardFocusChange);
|
|
|
|
w->update();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2012-11-07 15:23:32 +00:00
|
|
|
\fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
|
2011-04-27 10:05:43 +00:00
|
|
|
\internal
|
|
|
|
|
|
|
|
Creates the proper Enter/Leave event when widget \a enter is entered and
|
|
|
|
widget \a leave is left.
|
|
|
|
*/
|
2012-11-07 15:23:32 +00:00
|
|
|
void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
|
|
|
|
{
|
|
|
|
const QPoint globalPos = globalPosF.toPoint();
|
2011-04-27 10:05:43 +00:00
|
|
|
#if 0
|
|
|
|
if (leave) {
|
|
|
|
QEvent e(QEvent::Leave);
|
|
|
|
QApplication::sendEvent(leave, & e);
|
|
|
|
}
|
|
|
|
if (enter) {
|
2012-11-07 15:23:32 +00:00
|
|
|
const QPoint windowPos = enter->window()->mapFromGlobal(globalPos);
|
|
|
|
QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos);
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplication::sendEvent(enter, & e);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QWidget* w ;
|
|
|
|
if ((!enter && !leave) || (enter == leave))
|
|
|
|
return;
|
|
|
|
#ifdef ALIEN_DEBUG
|
|
|
|
qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave;
|
|
|
|
#endif
|
|
|
|
QWidgetList leaveList;
|
|
|
|
QWidgetList enterList;
|
|
|
|
|
|
|
|
bool sameWindow = leave && enter && leave->window() == enter->window();
|
|
|
|
if (leave && !sameWindow) {
|
|
|
|
w = leave;
|
|
|
|
do {
|
|
|
|
leaveList.append(w);
|
|
|
|
} while (!w->isWindow() && (w = w->parentWidget()));
|
|
|
|
}
|
|
|
|
if (enter && !sameWindow) {
|
|
|
|
w = enter;
|
|
|
|
do {
|
|
|
|
enterList.prepend(w);
|
|
|
|
} while (!w->isWindow() && (w = w->parentWidget()));
|
|
|
|
}
|
|
|
|
if (sameWindow) {
|
|
|
|
int enterDepth = 0;
|
|
|
|
int leaveDepth = 0;
|
|
|
|
w = enter;
|
|
|
|
while (!w->isWindow() && (w = w->parentWidget()))
|
|
|
|
enterDepth++;
|
|
|
|
w = leave;
|
|
|
|
while (!w->isWindow() && (w = w->parentWidget()))
|
|
|
|
leaveDepth++;
|
|
|
|
QWidget* wenter = enter;
|
|
|
|
QWidget* wleave = leave;
|
|
|
|
while (enterDepth > leaveDepth) {
|
|
|
|
wenter = wenter->parentWidget();
|
|
|
|
enterDepth--;
|
|
|
|
}
|
|
|
|
while (leaveDepth > enterDepth) {
|
|
|
|
wleave = wleave->parentWidget();
|
|
|
|
leaveDepth--;
|
|
|
|
}
|
|
|
|
while (!wenter->isWindow() && wenter != wleave) {
|
|
|
|
wenter = wenter->parentWidget();
|
|
|
|
wleave = wleave->parentWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
w = leave;
|
|
|
|
while (w != wleave) {
|
|
|
|
leaveList.append(w);
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
w = enter;
|
|
|
|
while (w != wenter) {
|
|
|
|
enterList.prepend(w);
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QEvent leaveEvent(QEvent::Leave);
|
|
|
|
for (int i = 0; i < leaveList.size(); ++i) {
|
|
|
|
w = leaveList.at(i);
|
|
|
|
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
|
|
|
|
QApplication::sendEvent(w, &leaveEvent);
|
|
|
|
if (w->testAttribute(Qt::WA_Hover) &&
|
|
|
|
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
|
|
|
|
Q_ASSERT(instance());
|
2011-06-29 08:16:34 +00:00
|
|
|
QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos),
|
|
|
|
QApplication::keyboardModifiers());
|
2011-04-27 10:05:43 +00:00
|
|
|
qApp->d_func()->notify_helper(w, &he);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-07 15:23:32 +00:00
|
|
|
if (!enterList.isEmpty()) {
|
|
|
|
const QPoint windowPos = enterList.front()->window()->mapFromGlobal(globalPos);
|
|
|
|
for (int i = 0; i < enterList.size(); ++i) {
|
|
|
|
w = enterList.at(i);
|
|
|
|
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
|
|
|
|
const QPointF localPos = w->mapFromGlobal(globalPos);
|
|
|
|
QEnterEvent enterEvent(localPos, windowPos, globalPosF);
|
|
|
|
QApplication::sendEvent(w, &enterEvent);
|
|
|
|
if (w->testAttribute(Qt::WA_Hover) &&
|
|
|
|
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
|
|
|
|
QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1),
|
|
|
|
QApplication::keyboardModifiers());
|
|
|
|
qApp->d_func()->notify_helper(w, &he);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
// Update cursor for alien/graphics widgets.
|
|
|
|
|
|
|
|
const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
|
2011-10-20 14:36:05 +00:00
|
|
|
// Whenever we leave an alien widget on X11/QPA, we need to reset its nativeParentWidget()'s cursor.
|
2011-04-27 10:05:43 +00:00
|
|
|
// This is not required on Windows as the cursor is reset on every single mouse move.
|
|
|
|
QWidget *parentOfLeavingCursor = 0;
|
|
|
|
for (int i = 0; i < leaveList.size(); ++i) {
|
|
|
|
w = leaveList.at(i);
|
|
|
|
if (!isAlien(w))
|
|
|
|
break;
|
|
|
|
if (w->testAttribute(Qt::WA_SetCursor)) {
|
|
|
|
QWidget *parent = w->parentWidget();
|
|
|
|
while (parent && parent->d_func()->data.in_destructor)
|
|
|
|
parent = parent->parentWidget();
|
|
|
|
parentOfLeavingCursor = parent;
|
|
|
|
//continue looping, we need to find the downest alien widget with a cursor.
|
|
|
|
// (downest on the screen)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//check that we will not call qt_x11_enforce_cursor twice with the same native widget
|
|
|
|
if (parentOfLeavingCursor && (!enterOnAlien
|
|
|
|
|| parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) {
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
if (!parentOfLeavingCursor->window()->graphicsProxyWidget())
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (enter == QApplication::desktop()) {
|
|
|
|
qt_qpa_set_cursor(enter, true);
|
|
|
|
} else {
|
|
|
|
qt_qpa_set_cursor(parentOfLeavingCursor, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (enterOnAlien) {
|
|
|
|
QWidget *cursorWidget = enter;
|
|
|
|
while (!cursorWidget->isWindow() && !cursorWidget->isEnabled())
|
|
|
|
cursorWidget = cursorWidget->parentWidget();
|
|
|
|
|
|
|
|
if (!cursorWidget)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
if (cursorWidget->window()->graphicsProxyWidget()) {
|
|
|
|
QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor());
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
qt_qpa_set_cursor(cursorWidget, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* exported for the benefit of testing tools */
|
2011-06-08 07:51:07 +00:00
|
|
|
Q_WIDGETS_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
return QApplicationPrivate::tryModalHelper(widget, rettop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! \internal
|
2013-10-02 14:51:05 +00:00
|
|
|
Returns \c true if \a widget is blocked by a modal window.
|
2011-04-27 10:05:43 +00:00
|
|
|
*/
|
|
|
|
bool QApplicationPrivate::isBlockedByModal(QWidget *widget)
|
|
|
|
{
|
|
|
|
widget = widget->window();
|
2013-01-14 11:11:45 +00:00
|
|
|
QWindow *window = widget->windowHandle();
|
|
|
|
return window && self->isWindowBlocked(window);
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const
|
|
|
|
{
|
|
|
|
QWindow *unused = 0;
|
2013-01-14 11:11:45 +00:00
|
|
|
if (!window) {
|
|
|
|
qWarning().nospace() << "window == 0 passed.";
|
|
|
|
return false;
|
|
|
|
}
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
if (!blockingWindow)
|
|
|
|
blockingWindow = &unused;
|
|
|
|
|
|
|
|
if (modalWindowList.isEmpty()) {
|
|
|
|
*blockingWindow = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
return false;
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
}
|
|
|
|
QWidget *popupWidget = QApplication::activePopupWidget();
|
|
|
|
QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : 0;
|
|
|
|
if (popupWindow == window) {
|
|
|
|
*blockingWindow = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
return false;
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
for (int i = 0; i < modalWindowList.count(); ++i) {
|
|
|
|
QWindow *modalWindow = modalWindowList.at(i);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
{
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
// check if the modal window is our window or a (transient) parent of our window
|
|
|
|
QWindow *w = window;
|
2011-04-27 10:05:43 +00:00
|
|
|
while (w) {
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
if (w == modalWindow) {
|
|
|
|
*blockingWindow = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
return false;
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
}
|
|
|
|
QWindow *p = w->parent();
|
|
|
|
if (!p)
|
|
|
|
p = w->transientParent();
|
|
|
|
w = p;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2012-08-17 11:19:36 +00:00
|
|
|
|
|
|
|
// Embedded in-process windows are not visible in normal parent-child chain,
|
|
|
|
// so check the native parent chain, too.
|
|
|
|
const QPlatformWindow *platWin = window->handle();
|
|
|
|
const QPlatformWindow *modalPlatWin = modalWindow->handle();
|
|
|
|
if (platWin && modalPlatWin && platWin->isEmbedded(modalPlatWin))
|
|
|
|
return false;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
Rename all QWindow properties that have "window" in them
windowTitle, windowModality, windowIcon and so on are named that way
to be similar to the ones in QWidget. However QQuickWindow inherits
all of the declared properties, and we would like to have shorter
property names in QML. If you are working with a Window then it's
obvious the title property is the window title. Unfortunately,
there must be patches in many other modules which depend on this one.
In order to avoid the need to merge them all at the same time,
there is also patch https://codereview.qt-project.org/#change,39001
which temporarily adds backwards-compatible accessors, which can be
removed after the other modules are able to build without them.
We should not rename windowState to state, because in QML, state
usually drives the state machine for animation transitions etc.
(although QWindow is not an Item, a user might get confused about it).
Related patches are
https://codereview.qt-project.org/#change,39001
https://codereview.qt-project.org/#change,37764
https://codereview.qt-project.org/#change,37765
https://codereview.qt-project.org/#change,37766
https://codereview.qt-project.org/#change,37762
Change-Id: Ie4424ec15fbdef6b29b137f90a2ae33f173edd21
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2012-10-22 10:47:34 +00:00
|
|
|
Qt::WindowModality windowModality = modalWindow->modality();
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
QWidgetWindow *modalWidgetWindow = qobject_cast<QWidgetWindow *>(modalWindow);
|
2011-04-27 10:05:43 +00:00
|
|
|
if (windowModality == Qt::NonModal) {
|
|
|
|
// determine the modality type if it hasn't been set on the
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
// modalWindow's widget, this normally happens when waiting for a
|
|
|
|
// native dialog. use WindowModal if we are the child of a group
|
|
|
|
// leader; otherwise use ApplicationModal.
|
|
|
|
QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
while (m && !m->testAttribute(Qt::WA_GroupLeader)) {
|
|
|
|
m = m->parentWidget();
|
|
|
|
if (m)
|
|
|
|
m = m->window();
|
|
|
|
}
|
|
|
|
windowModality = (m && m->testAttribute(Qt::WA_GroupLeader))
|
|
|
|
? Qt::WindowModal
|
|
|
|
: Qt::ApplicationModal;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (windowModality) {
|
|
|
|
case Qt::ApplicationModal:
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
{
|
|
|
|
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(window);
|
|
|
|
QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : 0;
|
|
|
|
while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader))
|
|
|
|
groupLeaderForWidget = groupLeaderForWidget->parentWidget();
|
|
|
|
|
|
|
|
if (groupLeaderForWidget) {
|
|
|
|
// if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children
|
|
|
|
QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0;
|
|
|
|
while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader))
|
|
|
|
m = m->parentWidget();
|
|
|
|
if (m == groupLeaderForWidget) {
|
|
|
|
*blockingWindow = m->windowHandle();
|
2011-04-27 10:05:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
} else if (modalWindow != window) {
|
|
|
|
*blockingWindow = modalWindow;
|
|
|
|
return true;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
case Qt::WindowModal:
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
{
|
|
|
|
QWindow *w = window;
|
|
|
|
do {
|
|
|
|
QWindow *m = modalWindow;
|
2011-04-27 10:05:43 +00:00
|
|
|
do {
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
if (m == w) {
|
|
|
|
*blockingWindow = m;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
QWindow *p = m->parent();
|
|
|
|
if (!p)
|
|
|
|
p = m->transientParent();
|
|
|
|
m = p;
|
|
|
|
} while (m);
|
|
|
|
QWindow *p = w->parent();
|
|
|
|
if (!p)
|
|
|
|
p = w->transientParent();
|
|
|
|
w = p;
|
|
|
|
} while (w);
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
default:
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
Q_ASSERT_X(false, "QApplication", "internal error, a modal window cannot be modeless");
|
2011-04-27 10:05:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Implement window modality in QtGui
QWindow already has windowModality() and setWindowModality() as part of
its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform
plugins can use this already to setup modality hints on windows that
they create, but it's not enough to implement modality fully.
QGuiApplication gets a modalWindow() static method, which is similar to
QApplication::activeModalWidget() in that it returns the last modal
window to be shown.
The modal window "stack" moves from QApplicationPrivate to
QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in
QApplicationPrivate are removed and replaced by
QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which
are called by QWindow::setVisible() just before calling
QPlatformWindow::setVisible().
The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a
window is blocked by a modal window (and tell which modal window for any
interested callers). The default implementation works on the QWindow
level. QApplicationPrivate reimplements isWindowBlocked() and adds popup
and WA_GroupLeader support.
QGuiApplication uses the state set from isWindowBlocked() to block
user-input events: mouse press, mouse move, mouse release, wheel, key
presses, key releases, enter/leave events, close events, and touch
begin, update, and end events.
Note also that the modality helper functions in QtWidgets and
QApplicationPrivate are left in place and working as they always have.
The behavior of QWidget in the presence of modal windows/dialogs should
not change.
Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
2012-03-28 13:26:17 +00:00
|
|
|
*blockingWindow = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!\internal
|
|
|
|
|
2013-10-02 14:51:05 +00:00
|
|
|
Called from qapplication_\e{platform}.cpp, returns \c true
|
2011-04-27 10:05:43 +00:00
|
|
|
if the widget should accept the event.
|
|
|
|
*/
|
|
|
|
bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop)
|
|
|
|
{
|
|
|
|
QWidget *top = QApplication::activeModalWidget();
|
|
|
|
if (rettop)
|
|
|
|
*rettop = top;
|
|
|
|
|
|
|
|
// the active popup widget always gets the input event
|
|
|
|
if (QApplication::activePopupWidget())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return !isBlockedByModal(widget->window());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
\internal
|
|
|
|
*/
|
2011-11-28 14:04:37 +00:00
|
|
|
QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint &windowPos,
|
2011-09-29 12:24:59 +00:00
|
|
|
QPoint *pos, QEvent::Type type,
|
2011-04-27 10:05:43 +00:00
|
|
|
Qt::MouseButtons buttons, QWidget *buttonDown,
|
|
|
|
QWidget *alienWidget)
|
|
|
|
{
|
|
|
|
Q_ASSERT(candidate);
|
|
|
|
|
|
|
|
QWidget *mouseGrabber = QWidget::mouseGrabber();
|
|
|
|
if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
|
|
|
|
&& !buttonDown && !mouseGrabber) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alienWidget && alienWidget->internalWinId())
|
|
|
|
alienWidget = 0;
|
|
|
|
|
|
|
|
QWidget *receiver = candidate;
|
|
|
|
|
|
|
|
if (!mouseGrabber)
|
|
|
|
mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget;
|
|
|
|
|
|
|
|
if (mouseGrabber && mouseGrabber != candidate) {
|
|
|
|
receiver = mouseGrabber;
|
2012-06-01 04:26:53 +00:00
|
|
|
*pos = receiver->mapFromGlobal(candidate->mapToGlobal(windowPos));
|
2011-04-27 10:05:43 +00:00
|
|
|
#ifdef ALIEN_DEBUG
|
|
|
|
qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return receiver;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
\internal
|
|
|
|
*/
|
|
|
|
bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
|
|
|
|
QWidget *alienWidget, QWidget *nativeWidget,
|
|
|
|
QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
|
|
|
|
bool spontaneous)
|
|
|
|
{
|
|
|
|
Q_ASSERT(receiver);
|
|
|
|
Q_ASSERT(event);
|
|
|
|
Q_ASSERT(nativeWidget);
|
|
|
|
Q_ASSERT(buttonDown);
|
|
|
|
|
|
|
|
if (alienWidget && !isAlien(alienWidget))
|
|
|
|
alienWidget = 0;
|
|
|
|
|
|
|
|
QPointer<QWidget> receiverGuard = receiver;
|
|
|
|
QPointer<QWidget> nativeGuard = nativeWidget;
|
|
|
|
QPointer<QWidget> alienGuard = alienWidget;
|
|
|
|
QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget();
|
|
|
|
|
|
|
|
const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen);
|
|
|
|
|
2012-06-18 13:53:30 +00:00
|
|
|
bool widgetUnderMouse = QRectF(receiver->rect()).contains(event->localPos());
|
|
|
|
|
2012-10-30 13:54:43 +00:00
|
|
|
// Clear the obsolete leaveAfterRelease value, if mouse button has been released but
|
|
|
|
// leaveAfterRelease has not been updated.
|
|
|
|
// This happens e.g. when modal dialog or popup is shown as a response to button click.
|
|
|
|
if (leaveAfterRelease && !*buttonDown && !event->buttons())
|
|
|
|
leaveAfterRelease = 0;
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
if (*buttonDown) {
|
|
|
|
if (!graphicsWidget) {
|
|
|
|
// Register the widget that shall receive a leave event
|
|
|
|
// after the last button is released.
|
|
|
|
if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
|
|
|
|
leaveAfterRelease = *buttonDown;
|
|
|
|
if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
|
|
|
|
*buttonDown = 0;
|
|
|
|
}
|
2012-06-18 13:53:30 +00:00
|
|
|
} else if (lastMouseReceiver && widgetUnderMouse) {
|
2011-04-27 10:05:43 +00:00
|
|
|
// Dispatch enter/leave if we move:
|
|
|
|
// 1) from an alien widget to another alien widget or
|
|
|
|
// from a native widget to an alien widget (first OR case)
|
|
|
|
// 2) from an alien widget to a native widget (second OR case)
|
|
|
|
if ((alienWidget && alienWidget != lastMouseReceiver)
|
|
|
|
|| (isAlien(lastMouseReceiver) && !alienWidget)) {
|
|
|
|
if (activePopupWidget) {
|
|
|
|
if (!QWidget::mouseGrabber())
|
2012-11-07 15:23:32 +00:00
|
|
|
dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->screenPos());
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
2012-11-07 15:23:32 +00:00
|
|
|
dispatchEnterLeave(receiver, lastMouseReceiver, event->screenPos());
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ALIEN_DEBUG
|
|
|
|
qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver
|
|
|
|
<< "pos:" << event->pos() << "alien" << alienWidget << "button down"
|
|
|
|
<< *buttonDown << "last" << lastMouseReceiver << "leave after release"
|
|
|
|
<< leaveAfterRelease;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// We need this quard in case someone opens a modal dialog / popup. If that's the case
|
|
|
|
// leaveAfterRelease is set to null, but we shall not update lastMouseReceiver.
|
|
|
|
const bool wasLeaveAfterRelease = leaveAfterRelease != 0;
|
|
|
|
bool result;
|
|
|
|
if (spontaneous)
|
|
|
|
result = QApplication::sendSpontaneousEvent(receiver, event);
|
|
|
|
else
|
|
|
|
result = QApplication::sendEvent(receiver, event);
|
|
|
|
|
|
|
|
if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease
|
|
|
|
&& !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) {
|
|
|
|
// Dispatch enter/leave if:
|
|
|
|
// 1) the mouse grabber is an alien widget
|
|
|
|
// 2) the button is released on an alien widget
|
|
|
|
QWidget *enter = 0;
|
|
|
|
if (nativeGuard)
|
|
|
|
enter = alienGuard ? alienWidget : nativeWidget;
|
|
|
|
else // The receiver is typically deleted on mouse release with drag'n'drop.
|
|
|
|
enter = QApplication::widgetAt(event->globalPos());
|
2012-11-07 15:23:32 +00:00
|
|
|
dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos());
|
2011-04-27 10:05:43 +00:00
|
|
|
leaveAfterRelease = 0;
|
|
|
|
lastMouseReceiver = enter;
|
|
|
|
} else if (!wasLeaveAfterRelease) {
|
|
|
|
if (activePopupWidget) {
|
|
|
|
if (!QWidget::mouseGrabber())
|
|
|
|
lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0);
|
|
|
|
} else {
|
|
|
|
lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function should only be called when the widget changes visibility, i.e.
|
|
|
|
when the \a widget is shown, hidden or deleted. This function does nothing
|
|
|
|
if the widget is a top-level or native, i.e. not an alien widget. In that
|
|
|
|
case enter/leave events are genereated by the underlying windowing system.
|
|
|
|
*/
|
|
|
|
extern QPointer<QWidget> qt_last_mouse_receiver;
|
|
|
|
extern QWidget *qt_button_down;
|
|
|
|
void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
|
|
|
|
{
|
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
if (!widget || widget->isWindow())
|
|
|
|
return;
|
|
|
|
const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor;
|
|
|
|
if (!widgetInShow && widget != qt_last_mouse_receiver)
|
|
|
|
return; // Widget was not under the cursor when it was hidden/deleted.
|
|
|
|
|
|
|
|
if (widgetInShow && widget->parentWidget()->data->in_show)
|
|
|
|
return; // Ingore recursive show.
|
|
|
|
|
|
|
|
QWidget *mouseGrabber = QWidget::mouseGrabber();
|
|
|
|
if (mouseGrabber && mouseGrabber != widget)
|
|
|
|
return; // Someone else has the grab; enter/leave should not occur.
|
|
|
|
|
|
|
|
QWidget *tlw = widget->window();
|
|
|
|
if (tlw->data->in_destructor || tlw->data->is_closing)
|
|
|
|
return; // Closing down the business.
|
|
|
|
|
|
|
|
if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw))
|
|
|
|
return; // Mouse cursor not inside the widget's top-level.
|
|
|
|
|
|
|
|
const QPoint globalPos(QCursor::pos());
|
2011-09-01 09:13:35 +00:00
|
|
|
QPoint windowPos = tlw->mapFromGlobal(globalPos);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// Find the current widget under the mouse. If this function was called from
|
|
|
|
// the widget's destructor, we have to make sure childAt() doesn't take into
|
|
|
|
// account widgets that are about to be destructed.
|
2011-09-01 09:13:35 +00:00
|
|
|
QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(windowPos, widget->data->in_destructor);
|
2011-04-27 10:05:43 +00:00
|
|
|
if (!widgetUnderCursor)
|
|
|
|
widgetUnderCursor = tlw;
|
2011-09-01 09:13:35 +00:00
|
|
|
QPoint pos = widgetUnderCursor->mapFrom(tlw, windowPos);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor))
|
|
|
|
return; // Mouse cursor not inside the widget or any of its children.
|
|
|
|
|
|
|
|
if (widget->data->in_destructor && qt_button_down == widget)
|
|
|
|
qt_button_down = 0;
|
|
|
|
|
|
|
|
// Send enter/leave events followed by a mouse move on the entered widget.
|
2011-09-01 09:13:35 +00:00
|
|
|
QMouseEvent e(QEvent::MouseMove, pos, windowPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
2011-04-27 10:05:43 +00:00
|
|
|
sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver);
|
|
|
|
#endif // QT_NO_CURSOR
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the desktop widget (also called the root window).
|
|
|
|
|
|
|
|
The desktop may be composed of multiple screens, so it would be incorrect,
|
|
|
|
for example, to attempt to \e center some widget in the desktop's geometry.
|
|
|
|
QDesktopWidget has various functions for obtaining useful geometries upon
|
|
|
|
the desktop, such as QDesktopWidget::screenGeometry() and
|
|
|
|
QDesktopWidget::availableGeometry().
|
|
|
|
|
|
|
|
On X11, it is also possible to draw on the desktop.
|
|
|
|
*/
|
|
|
|
QDesktopWidget *QApplication::desktop()
|
|
|
|
{
|
|
|
|
if (!qt_desktopWidget || // not created yet
|
|
|
|
!(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
|
|
|
|
qt_desktopWidget = new QDesktopWidget();
|
|
|
|
}
|
|
|
|
return qt_desktopWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Sets the time after which a drag should start to \a ms ms.
|
|
|
|
|
|
|
|
\sa startDragTime()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QApplication::setStartDragTime(int ms)
|
|
|
|
{
|
2013-10-15 12:12:34 +00:00
|
|
|
QGuiApplication::styleHints()->setStartDragTime(ms);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::startDragTime
|
|
|
|
\brief the time in milliseconds that a mouse button must be held down
|
|
|
|
before a drag and drop operation will begin
|
|
|
|
|
|
|
|
If you support drag and drop in your application, and want to start a drag
|
|
|
|
and drop operation after the user has held down a mouse button for a
|
|
|
|
certain amount of time, you should use this property's value as the delay.
|
|
|
|
|
|
|
|
Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for
|
|
|
|
starting a drag.
|
|
|
|
|
|
|
|
The default value is 500 ms.
|
|
|
|
|
|
|
|
\sa startDragDistance(), {Drag and Drop}
|
|
|
|
*/
|
|
|
|
|
|
|
|
int QApplication::startDragTime()
|
|
|
|
{
|
2011-08-31 08:47:09 +00:00
|
|
|
return qApp->styleHints()->startDragTime();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Sets the distance after which a drag should start to \a l pixels.
|
|
|
|
|
|
|
|
\sa startDragDistance()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QApplication::setStartDragDistance(int l)
|
|
|
|
{
|
2013-10-15 12:12:34 +00:00
|
|
|
QGuiApplication::styleHints()->setStartDragDistance(l);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::startDragDistance
|
|
|
|
|
|
|
|
If you support drag and drop in your application, and want to start a drag
|
|
|
|
and drop operation after the user has moved the cursor a certain distance
|
|
|
|
with a button held down, you should use this property's value as the
|
|
|
|
minimum distance required.
|
|
|
|
|
|
|
|
For example, if the mouse position of the click is stored in \c startPos
|
|
|
|
and the current position (e.g. in the mouse move event) is \c currentPos,
|
|
|
|
you can find out if a drag should be started with code like this:
|
|
|
|
|
2013-09-27 19:53:12 +00:00
|
|
|
\snippet code/src_gui_kernel_qapplication.cpp 6
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
Qt uses this value internally, e.g. in QFileDialog.
|
|
|
|
|
|
|
|
The default value is 4 pixels.
|
|
|
|
|
2012-05-10 11:10:23 +00:00
|
|
|
\sa startDragTime(), QPoint::manhattanLength(), {Drag and Drop}
|
2011-04-27 10:05:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
int QApplication::startDragDistance()
|
|
|
|
{
|
2011-09-21 10:19:46 +00:00
|
|
|
return qApp->styleHints()->startDragDistance();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Enters the main event loop and waits until exit() is called, then returns
|
|
|
|
the value that was set to exit() (which is 0 if exit() is called via
|
|
|
|
quit()).
|
|
|
|
|
|
|
|
It is necessary to call this function to start event handling. The main
|
|
|
|
event loop receives events from the window system and dispatches these to
|
|
|
|
the application widgets.
|
|
|
|
|
|
|
|
Generally, no user interaction can take place before calling exec(). As a
|
|
|
|
special case, modal widgets like QMessageBox can be used before calling
|
|
|
|
exec(), because modal widgets call exec() to start a local event loop.
|
|
|
|
|
|
|
|
To make your application perform idle processing, i.e., executing a special
|
|
|
|
function whenever there are no pending events, use a QTimer with 0 timeout.
|
|
|
|
More advanced idle processing schemes can be achieved using processEvents().
|
|
|
|
|
|
|
|
We recommend that you connect clean-up code to the
|
|
|
|
\l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
|
|
|
|
application's \c{main()} function. This is because, on some platforms the
|
|
|
|
QApplication::exec() call may not return. For example, on the Windows
|
|
|
|
platform, when the user logs off, the system terminates the process after Qt
|
|
|
|
closes all top-level windows. Hence, there is \e{no guarantee} that the
|
|
|
|
application will have time to exit its event loop and execute code at the
|
|
|
|
end of the \c{main()} function, after the QApplication::exec() call.
|
|
|
|
|
|
|
|
\sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
|
|
|
|
QCoreApplication::exec()
|
|
|
|
*/
|
|
|
|
int QApplication::exec()
|
|
|
|
{
|
2011-11-21 13:10:37 +00:00
|
|
|
return QGuiApplication::exec();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-02-11 00:33:55 +00:00
|
|
|
bool QApplicationPrivate::shouldQuit()
|
|
|
|
{
|
|
|
|
/* if there is no non-withdrawn primary window left (except
|
|
|
|
the ones without QuitOnClose), we emit the lastWindowClosed
|
|
|
|
signal */
|
|
|
|
QWidgetList list = QApplication::topLevelWidgets();
|
2013-06-18 12:42:43 +00:00
|
|
|
QWindowList processedWindows;
|
2012-02-11 00:33:55 +00:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
QWidget *w = list.at(i);
|
2014-02-11 12:13:37 +00:00
|
|
|
if (QWindow *window = w->windowHandle()) { // Menus, popup widgets may not have a QWindow
|
|
|
|
processedWindows.push_back(window);
|
|
|
|
if (w->isVisible() && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose))
|
|
|
|
return false;
|
|
|
|
}
|
2012-02-11 00:33:55 +00:00
|
|
|
}
|
2013-06-18 12:42:43 +00:00
|
|
|
return QGuiApplicationPrivate::shouldQuitInternal(processedWindows);
|
2012-02-11 00:33:55 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 11:42:02 +00:00
|
|
|
static inline void closeAllPopups()
|
|
|
|
{
|
|
|
|
// Close all popups: In case some popup refuses to close,
|
|
|
|
// we give up after 1024 attempts (to avoid an infinite loop).
|
|
|
|
int maxiter = 1024;
|
|
|
|
QWidget *popup;
|
|
|
|
while ((popup = QApplication::activePopupWidget()) && maxiter--)
|
|
|
|
popup->close();
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
/*! \reimp
|
|
|
|
*/
|
|
|
|
bool QApplication::notify(QObject *receiver, QEvent *e)
|
|
|
|
{
|
|
|
|
Q_D(QApplication);
|
|
|
|
// no events are delivered after ~QCoreApplication() has started
|
|
|
|
if (QApplicationPrivate::is_app_closing)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (receiver == 0) { // serious error
|
|
|
|
qWarning("QApplication::notify: Unexpected null receiver");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
d->checkReceiverThread(receiver);
|
|
|
|
#endif
|
|
|
|
|
2012-07-31 09:57:08 +00:00
|
|
|
if (receiver->isWindowType())
|
|
|
|
QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(receiver), e);
|
2012-03-29 07:25:29 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
if(e->spontaneous()) {
|
2012-10-23 16:52:29 +00:00
|
|
|
// Capture the current mouse and keyboard states. Doing so here is
|
2013-01-23 11:39:47 +00:00
|
|
|
// required in order to support Qt Test synthesized events. Real mouse
|
2012-10-23 16:52:29 +00:00
|
|
|
// and keyboard state updates from the platform plugin are managed by
|
|
|
|
// QGuiApplicationPrivate::process(Mouse|Wheel|Key|Touch|Tablet)Event();
|
|
|
|
switch (e->type()) {
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
{
|
2011-04-27 10:05:43 +00:00
|
|
|
QMouseEvent *me = static_cast<QMouseEvent*>(e);
|
2012-10-23 16:52:29 +00:00
|
|
|
QApplicationPrivate::modifier_buttons = me->modifiers();
|
|
|
|
QApplicationPrivate::mouse_buttons |= me->button();
|
|
|
|
break;
|
|
|
|
}
|
2014-01-19 18:44:31 +00:00
|
|
|
case QEvent::MouseButtonDblClick:
|
|
|
|
{
|
|
|
|
QMouseEvent *me = static_cast<QMouseEvent*>(e);
|
|
|
|
QApplicationPrivate::modifier_buttons = me->modifiers();
|
|
|
|
QApplicationPrivate::mouse_buttons |= me->button();
|
|
|
|
break;
|
|
|
|
}
|
2012-10-23 16:52:29 +00:00
|
|
|
case QEvent::MouseButtonRelease:
|
|
|
|
{
|
|
|
|
QMouseEvent *me = static_cast<QMouseEvent*>(e);
|
|
|
|
QApplicationPrivate::modifier_buttons = me->modifiers();
|
|
|
|
QApplicationPrivate::mouse_buttons &= ~me->button();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QEvent::KeyPress:
|
|
|
|
case QEvent::KeyRelease:
|
|
|
|
case QEvent::MouseMove:
|
|
|
|
#ifndef QT_NO_WHEELEVENT
|
|
|
|
case QEvent::Wheel:
|
|
|
|
#endif
|
|
|
|
case QEvent::TouchBegin:
|
|
|
|
case QEvent::TouchUpdate:
|
|
|
|
case QEvent::TouchEnd:
|
|
|
|
#ifndef QT_NO_TABLETEVENT
|
|
|
|
case QEvent::TabletMove:
|
|
|
|
case QEvent::TabletPress:
|
|
|
|
case QEvent::TabletRelease:
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
QInputEvent *ie = static_cast<QInputEvent*>(e);
|
|
|
|
QApplicationPrivate::modifier_buttons = ie->modifiers();
|
|
|
|
break;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2012-10-23 16:52:29 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_GESTURES
|
|
|
|
// walk through parents and check for gestures
|
|
|
|
if (d->gestureManager) {
|
|
|
|
switch (e->type()) {
|
|
|
|
case QEvent::Paint:
|
|
|
|
case QEvent::MetaCall:
|
|
|
|
case QEvent::DeferredDelete:
|
|
|
|
case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave:
|
|
|
|
case QEvent::Drop: case QEvent::DragResponse:
|
|
|
|
case QEvent::ChildAdded: case QEvent::ChildPolished:
|
|
|
|
case QEvent::ChildRemoved:
|
|
|
|
case QEvent::UpdateRequest:
|
|
|
|
case QEvent::UpdateLater:
|
|
|
|
case QEvent::LocaleChange:
|
|
|
|
case QEvent::Style:
|
|
|
|
case QEvent::IconDrag:
|
|
|
|
case QEvent::StyleChange:
|
|
|
|
case QEvent::GraphicsSceneDragEnter:
|
|
|
|
case QEvent::GraphicsSceneDragMove:
|
|
|
|
case QEvent::GraphicsSceneDragLeave:
|
|
|
|
case QEvent::GraphicsSceneDrop:
|
|
|
|
case QEvent::DynamicPropertyChange:
|
|
|
|
case QEvent::NetworkReplyUpdated:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (receiver->isWidgetType()) {
|
|
|
|
if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// a special case for events that go to QGesture objects.
|
|
|
|
// We pass the object to the gesture manager and it'll figure
|
|
|
|
// out if it's QGesture or not.
|
|
|
|
if (d->gestureManager->filterEvent(receiver, e))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // QT_NO_GESTURES
|
|
|
|
|
|
|
|
switch (e->type()) {
|
2012-09-07 11:42:02 +00:00
|
|
|
case QEvent::ApplicationDeactivate:
|
|
|
|
// Close all popups (triggers when switching applications
|
|
|
|
// by pressing ALT-TAB on Windows, which is not receive as key event.
|
|
|
|
closeAllPopups();
|
|
|
|
break;
|
|
|
|
case QEvent::Wheel: // User input and window activation makes tooltips sleep
|
2011-04-27 10:05:43 +00:00
|
|
|
case QEvent::ActivationChange:
|
|
|
|
case QEvent::KeyPress:
|
|
|
|
case QEvent::KeyRelease:
|
|
|
|
case QEvent::FocusOut:
|
|
|
|
case QEvent::FocusIn:
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
case QEvent::MouseButtonRelease:
|
|
|
|
case QEvent::MouseButtonDblClick:
|
|
|
|
d->toolTipFallAsleep.stop();
|
|
|
|
// fall-through
|
|
|
|
case QEvent::Leave:
|
|
|
|
d->toolTipWakeUp.stop();
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-06-20 07:53:22 +00:00
|
|
|
switch (e->type()) {
|
|
|
|
case QEvent::KeyPress:
|
|
|
|
{
|
|
|
|
bool isWidget = receiver->isWidgetType();
|
|
|
|
bool isWindow = receiver->isWindowType();
|
|
|
|
bool isGraphicsWidget = false;
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
isGraphicsWidget = !isWidget && !isWindow && qobject_cast<QGraphicsWidget *>(receiver);
|
|
|
|
#endif
|
|
|
|
if (!isWidget && !isGraphicsWidget && !isWindow) {
|
|
|
|
return d->notify_helper(receiver, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
QKeyEvent* key = static_cast<QKeyEvent*>(e);
|
|
|
|
#ifndef QT_NO_SHORTCUT
|
|
|
|
// Try looking for a Shortcut before sending key events
|
2013-08-12 18:25:42 +00:00
|
|
|
QObject *shortcutReceiver = receiver;
|
|
|
|
if (!isWidget && isWindow) {
|
|
|
|
QWindow *w = qobject_cast<QWindow *>(receiver);
|
|
|
|
QObject *focus = w ? w->focusObject() : 0;
|
|
|
|
if (focus)
|
|
|
|
shortcutReceiver = focus;
|
|
|
|
}
|
|
|
|
if (qApp->d_func()->shortcutMap.tryShortcutEvent(shortcutReceiver, key))
|
2013-06-20 07:53:22 +00:00
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
|
|
|
|
|| key->key() == Qt::Key_Tab
|
|
|
|
|| key->key() == Qt::Key_Left
|
|
|
|
|| key->key() == Qt::Key_Up
|
|
|
|
|| key->key() == Qt::Key_Right
|
|
|
|
|| key->key() == Qt::Key_Down);
|
|
|
|
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
bool res = false;
|
|
|
|
if (!receiver->isWidgetType()) {
|
|
|
|
res = d->notify_helper(receiver, e);
|
|
|
|
} else switch (e->type()) {
|
|
|
|
case QEvent::ShortcutOverride:
|
|
|
|
case QEvent::KeyPress:
|
|
|
|
case QEvent::KeyRelease:
|
|
|
|
{
|
|
|
|
bool isWidget = receiver->isWidgetType();
|
|
|
|
bool isGraphicsWidget = false;
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
|
|
|
|
#endif
|
|
|
|
QKeyEvent* key = static_cast<QKeyEvent*>(e);
|
|
|
|
bool def = key->isAccepted();
|
|
|
|
QPointer<QObject> pr = receiver;
|
|
|
|
while (receiver) {
|
|
|
|
if (def)
|
|
|
|
key->accept();
|
|
|
|
else
|
|
|
|
key->ignore();
|
|
|
|
res = d->notify_helper(receiver, e);
|
|
|
|
QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0;
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((res && key->isAccepted())
|
|
|
|
/*
|
|
|
|
QLineEdit will emit a signal on Key_Return, but
|
|
|
|
ignore the event, and sometimes the connected
|
|
|
|
slot deletes the QLineEdit (common in itemview
|
|
|
|
delegates), so we have to check if the widget
|
|
|
|
was destroyed even if the event was ignored (to
|
|
|
|
prevent a crash)
|
|
|
|
|
|
|
|
note that we don't have to reset pw while
|
|
|
|
propagating (because the original receiver will
|
|
|
|
be destroyed if one of its ancestors is)
|
|
|
|
*/
|
|
|
|
|| !pr
|
|
|
|
|| (isWidget && (w->isWindow() || !w->parentWidget()))
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
|| (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget()))
|
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget();
|
|
|
|
#else
|
|
|
|
receiver = w->parentWidget();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
qt_in_tab_key_event = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
case QEvent::MouseButtonRelease:
|
|
|
|
case QEvent::MouseButtonDblClick:
|
|
|
|
case QEvent::MouseMove:
|
|
|
|
{
|
|
|
|
QWidget* w = static_cast<QWidget *>(receiver);
|
|
|
|
|
|
|
|
QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
|
|
|
|
QPoint relpos = mouse->pos();
|
|
|
|
|
|
|
|
if (e->spontaneous()) {
|
2013-06-19 09:21:14 +00:00
|
|
|
if (e->type() != QEvent::MouseMove)
|
|
|
|
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms
|
|
|
|
// like Mac OS X (probably others too), can optimize their views by not
|
|
|
|
// dispatching mouse move events. We have attributes to control hover,
|
|
|
|
// and mouse tracking, but as long as we are deciding to implement this
|
|
|
|
// feature without choice of opting-in or out, you ALWAYS have to have
|
|
|
|
// tracking enabled. Therefore, the other properties give a false sense of
|
|
|
|
// performance enhancement.
|
|
|
|
if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) {
|
|
|
|
d->toolTipWidget = w;
|
|
|
|
d->toolTipPos = relpos;
|
|
|
|
d->toolTipGlobalPos = mouse->globalPos();
|
2013-07-01 05:10:48 +00:00
|
|
|
QStyle *s = d->toolTipWidget->style();
|
|
|
|
int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, 0, d->toolTipWidget, 0);
|
|
|
|
d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool eventAccepted = mouse->isAccepted();
|
|
|
|
|
|
|
|
QPointer<QWidget> pw = w;
|
|
|
|
while (w) {
|
2011-09-01 09:13:35 +00:00
|
|
|
QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), mouse->button(), mouse->buttons(),
|
2011-04-27 10:05:43 +00:00
|
|
|
mouse->modifiers());
|
|
|
|
me.spont = mouse->spontaneous();
|
Add timestamp to QInputEvent.
The mouse, touch, key events have no timestamp field currently,
meaning that the timestamp passed to QWindowSystemInterface's
handleMouse, Touch, KeyEvent functions will not be stored in the
generated events. The timestamp can be quite valuable in some cases
(e.g. when performing filtering of touch events) so losing this
information is not desirable. The patch adds a timestamp field to
QInputEvent, which is the base for mouse, touch, key, and other
events, and also makes QGuiApplication to store the timestamp in the
generated events.
Change-Id: Icb9de8b238cb341916eac33ce21603f4955baca7
Reviewed-on: http://codereview.qt.nokia.com/4196
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
2011-09-05 12:56:37 +00:00
|
|
|
me.setTimestamp(mouse->timestamp());
|
2014-01-19 18:44:31 +00:00
|
|
|
QGuiApplicationPrivate::setMouseEventFlags(&me, mouse->flags());
|
2011-04-27 10:05:43 +00:00
|
|
|
// throw away any mouse-tracking-only mouse events
|
|
|
|
if (!w->hasMouseTracking()
|
|
|
|
&& mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
|
|
|
|
// but still send them through all application event filters (normally done by notify_helper)
|
2012-05-17 07:39:46 +00:00
|
|
|
for (int i = 0; d->extraData && i < d->extraData->eventFilters.size(); ++i) {
|
2013-06-15 09:49:45 +00:00
|
|
|
QObject *obj = d->extraData->eventFilters.at(i);
|
2011-04-27 10:05:43 +00:00
|
|
|
if (!obj)
|
|
|
|
continue;
|
|
|
|
if (obj->d_func()->threadData != w->d_func()->threadData) {
|
|
|
|
qWarning("QApplication: Object event filter cannot be in a different thread.");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (obj->eventFilter(w, w == receiver ? mouse : &me))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
res = true;
|
|
|
|
} else {
|
|
|
|
w->setAttribute(Qt::WA_NoMouseReplay, false);
|
|
|
|
res = d->notify_helper(w, w == receiver ? mouse : &me);
|
|
|
|
e->spont = false;
|
|
|
|
}
|
|
|
|
eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
|
|
|
|
if (res && eventAccepted)
|
|
|
|
break;
|
|
|
|
if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
|
|
|
|
break;
|
|
|
|
relpos += w->pos();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse->setAccepted(eventAccepted);
|
|
|
|
|
|
|
|
if (e->type() == QEvent::MouseMove) {
|
|
|
|
if (!pw)
|
|
|
|
break;
|
|
|
|
|
|
|
|
w = static_cast<QWidget *>(receiver);
|
|
|
|
relpos = mouse->pos();
|
|
|
|
QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos);
|
|
|
|
while (w) {
|
|
|
|
if (w->testAttribute(Qt::WA_Hover) &&
|
|
|
|
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
|
2011-06-29 08:16:34 +00:00
|
|
|
QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff, mouse->modifiers());
|
2011-04-27 10:05:43 +00:00
|
|
|
d->notify_helper(w, &he);
|
|
|
|
}
|
|
|
|
if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
|
|
|
|
break;
|
|
|
|
relpos += w->pos();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->hoverGlobalPos = mouse->globalPos();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#ifndef QT_NO_WHEELEVENT
|
|
|
|
case QEvent::Wheel:
|
|
|
|
{
|
|
|
|
QWidget* w = static_cast<QWidget *>(receiver);
|
|
|
|
QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
|
|
|
|
QPoint relpos = wheel->pos();
|
|
|
|
bool eventAccepted = wheel->isAccepted();
|
|
|
|
|
2013-06-19 09:21:14 +00:00
|
|
|
if (e->spontaneous())
|
|
|
|
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
while (w) {
|
2012-01-09 10:25:40 +00:00
|
|
|
QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(),
|
|
|
|
wheel->modifiers());
|
2011-04-27 10:05:43 +00:00
|
|
|
we.spont = wheel->spontaneous();
|
|
|
|
res = d->notify_helper(w, w == receiver ? wheel : &we);
|
|
|
|
eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted();
|
|
|
|
e->spont = false;
|
|
|
|
if ((res && eventAccepted)
|
|
|
|
|| w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
|
|
|
|
break;
|
|
|
|
|
|
|
|
relpos += w->pos();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
wheel->setAccepted(eventAccepted);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifndef QT_NO_CONTEXTMENU
|
|
|
|
case QEvent::ContextMenu:
|
|
|
|
{
|
|
|
|
QWidget* w = static_cast<QWidget *>(receiver);
|
|
|
|
QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e);
|
|
|
|
QPoint relpos = context->pos();
|
|
|
|
bool eventAccepted = context->isAccepted();
|
|
|
|
while (w) {
|
|
|
|
QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
|
|
|
|
ce.spont = e->spontaneous();
|
|
|
|
res = d->notify_helper(w, w == receiver ? context : &ce);
|
|
|
|
eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
|
|
|
|
e->spont = false;
|
|
|
|
|
|
|
|
if ((res && eventAccepted)
|
|
|
|
|| w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
|
|
|
|
break;
|
|
|
|
|
|
|
|
relpos += w->pos();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
context->setAccepted(eventAccepted);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif // QT_NO_CONTEXTMENU
|
|
|
|
#ifndef QT_NO_TABLETEVENT
|
|
|
|
case QEvent::TabletMove:
|
|
|
|
case QEvent::TabletPress:
|
|
|
|
case QEvent::TabletRelease:
|
|
|
|
{
|
|
|
|
QWidget *w = static_cast<QWidget *>(receiver);
|
|
|
|
QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
|
2011-08-11 14:23:10 +00:00
|
|
|
QPointF relpos = tablet->posF();
|
2011-04-27 10:05:43 +00:00
|
|
|
bool eventAccepted = tablet->isAccepted();
|
|
|
|
while (w) {
|
2011-08-11 14:23:10 +00:00
|
|
|
QTabletEvent te(tablet->type(), relpos, tablet->globalPosF(),
|
|
|
|
tablet->device(), tablet->pointerType(),
|
2011-04-27 10:05:43 +00:00
|
|
|
tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
|
|
|
|
tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
|
|
|
|
tablet->modifiers(), tablet->uniqueId());
|
|
|
|
te.spont = e->spontaneous();
|
|
|
|
res = d->notify_helper(w, w == receiver ? tablet : &te);
|
|
|
|
eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
|
|
|
|
e->spont = false;
|
|
|
|
if ((res && eventAccepted)
|
|
|
|
|| w->isWindow()
|
|
|
|
|| w->testAttribute(Qt::WA_NoMousePropagation))
|
|
|
|
break;
|
|
|
|
|
|
|
|
relpos += w->pos();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
tablet->setAccepted(eventAccepted);
|
|
|
|
qt_tabletChokeMouse = tablet->isAccepted();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif // QT_NO_TABLETEVENT
|
|
|
|
|
|
|
|
#if !defined(QT_NO_TOOLTIP) || !defined(QT_NO_WHATSTHIS)
|
|
|
|
case QEvent::ToolTip:
|
|
|
|
case QEvent::WhatsThis:
|
|
|
|
case QEvent::QueryWhatsThis:
|
|
|
|
{
|
|
|
|
QWidget* w = static_cast<QWidget *>(receiver);
|
|
|
|
QHelpEvent *help = static_cast<QHelpEvent*>(e);
|
|
|
|
QPoint relpos = help->pos();
|
|
|
|
bool eventAccepted = help->isAccepted();
|
|
|
|
while (w) {
|
|
|
|
QHelpEvent he(help->type(), relpos, help->globalPos());
|
|
|
|
he.spont = e->spontaneous();
|
|
|
|
res = d->notify_helper(w, w == receiver ? help : &he);
|
|
|
|
e->spont = false;
|
|
|
|
eventAccepted = (w == receiver ? help : &he)->isAccepted();
|
|
|
|
if ((res && eventAccepted) || w->isWindow())
|
|
|
|
break;
|
|
|
|
|
|
|
|
relpos += w->pos();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
help->setAccepted(eventAccepted);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#if !defined(QT_NO_STATUSTIP) || !defined(QT_NO_WHATSTHIS)
|
|
|
|
case QEvent::StatusTip:
|
|
|
|
case QEvent::WhatsThisClicked:
|
|
|
|
{
|
|
|
|
QWidget *w = static_cast<QWidget *>(receiver);
|
|
|
|
while (w) {
|
|
|
|
res = d->notify_helper(w, e);
|
|
|
|
if ((res && e->isAccepted()) || w->isWindow())
|
|
|
|
break;
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef QT_NO_DRAGANDDROP
|
|
|
|
case QEvent::DragEnter: {
|
|
|
|
QWidget* w = static_cast<QWidget *>(receiver);
|
|
|
|
QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e);
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
// QGraphicsProxyWidget handles its own propagation,
|
|
|
|
// and we must not change QDragManagers currentTarget.
|
|
|
|
QWExtra *extra = w->window()->d_func()->extra;
|
|
|
|
if (extra && extra->proxyWidget) {
|
|
|
|
res = d->notify_helper(w, dragEvent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
while (w) {
|
|
|
|
if (w->isEnabled() && w->acceptDrops()) {
|
|
|
|
res = d->notify_helper(w, dragEvent);
|
|
|
|
if (res && dragEvent->isAccepted()) {
|
|
|
|
QDragManager::self()->setCurrentTarget(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (w->isWindow())
|
|
|
|
break;
|
2011-08-11 14:23:10 +00:00
|
|
|
dragEvent->p = w->mapToParent(dragEvent->p.toPoint());
|
2011-04-27 10:05:43 +00:00
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case QEvent::DragMove:
|
|
|
|
case QEvent::Drop:
|
|
|
|
case QEvent::DragLeave: {
|
|
|
|
QWidget* w = static_cast<QWidget *>(receiver);
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
// QGraphicsProxyWidget handles its own propagation,
|
|
|
|
// and we must not change QDragManagers currentTarget.
|
|
|
|
QWExtra *extra = w->window()->d_func()->extra;
|
|
|
|
bool isProxyWidget = extra && extra->proxyWidget;
|
|
|
|
if (!isProxyWidget)
|
|
|
|
#endif
|
2011-05-18 10:56:51 +00:00
|
|
|
w = qobject_cast<QWidget *>(QDragManager::self()->currentTarget());
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if (!w) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) {
|
|
|
|
QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
|
|
|
|
QWidget *origReciver = static_cast<QWidget *>(receiver);
|
|
|
|
while (origReciver && w != origReciver) {
|
2011-08-11 14:23:10 +00:00
|
|
|
dragEvent->p = origReciver->mapToParent(dragEvent->p.toPoint());
|
2011-04-27 10:05:43 +00:00
|
|
|
origReciver = origReciver->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = d->notify_helper(w, e);
|
|
|
|
if (e->type() != QEvent::DragMove
|
|
|
|
#ifndef QT_NO_GRAPHICSVIEW
|
|
|
|
&& !isProxyWidget
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case QEvent::TouchBegin:
|
|
|
|
// Note: TouchUpdate and TouchEnd events are never propagated
|
|
|
|
{
|
|
|
|
QWidget *widget = static_cast<QWidget *>(receiver);
|
|
|
|
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
|
|
|
|
bool eventAccepted = touchEvent->isAccepted();
|
2013-06-19 09:21:14 +00:00
|
|
|
bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
|
|
|
|
if (acceptTouchEvents && e->spontaneous()) {
|
|
|
|
const QPoint localPos = touchEvent->touchPoints()[0].pos().toPoint();
|
|
|
|
QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, e, localPos);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (widget) {
|
|
|
|
// first, try to deliver the touch event
|
2013-06-19 09:21:14 +00:00
|
|
|
acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
|
2011-11-30 16:51:00 +00:00
|
|
|
touchEvent->setTarget(widget);
|
2011-04-27 10:05:43 +00:00
|
|
|
touchEvent->setAccepted(acceptTouchEvents);
|
2012-05-30 11:53:24 +00:00
|
|
|
QPointer<QWidget> p = widget;
|
2011-04-27 10:05:43 +00:00
|
|
|
res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
|
|
|
|
eventAccepted = touchEvent->isAccepted();
|
|
|
|
if (p.isNull()) {
|
|
|
|
// widget was deleted
|
|
|
|
widget = 0;
|
|
|
|
} else {
|
|
|
|
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
|
|
|
|
}
|
|
|
|
touchEvent->spont = false;
|
|
|
|
if (res && eventAccepted) {
|
|
|
|
// the first widget to accept the TouchBegin gets an implicit grab.
|
|
|
|
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
|
|
|
|
const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
|
2011-12-10 14:30:18 +00:00
|
|
|
d->activeTouchPoints[QGuiApplicationPrivate::ActiveTouchPointsKey(touchEvent->device(), touchPoint.id())].target = widget;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QPoint offset = widget->pos();
|
|
|
|
widget = widget->parentWidget();
|
2011-11-30 16:51:00 +00:00
|
|
|
touchEvent->setTarget(widget);
|
2011-04-27 10:05:43 +00:00
|
|
|
for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
|
|
|
|
QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
|
|
|
|
QRectF rect = pt.rect();
|
|
|
|
rect.moveCenter(offset);
|
|
|
|
pt.d->rect = rect;
|
|
|
|
pt.d->startPos = pt.startPos() + offset;
|
|
|
|
pt.d->lastPos = pt.lastPos() + offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
touchEvent->setAccepted(eventAccepted);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QEvent::RequestSoftwareInputPanel:
|
2012-01-24 15:44:38 +00:00
|
|
|
inputMethod()->show();
|
2011-09-05 10:53:33 +00:00
|
|
|
break;
|
2011-04-27 10:05:43 +00:00
|
|
|
case QEvent::CloseSoftwareInputPanel:
|
2012-01-24 15:44:38 +00:00
|
|
|
inputMethod()->hide();
|
2011-04-27 10:05:43 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifndef QT_NO_GESTURES
|
|
|
|
case QEvent::NativeGesture:
|
|
|
|
{
|
|
|
|
// only propagate the first gesture event (after the GID_BEGIN)
|
|
|
|
QWidget *w = static_cast<QWidget *>(receiver);
|
|
|
|
while (w) {
|
|
|
|
e->ignore();
|
|
|
|
res = d->notify_helper(w, e);
|
|
|
|
if ((res && e->isAccepted()) || w->isWindow())
|
|
|
|
break;
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QEvent::Gesture:
|
|
|
|
case QEvent::GestureOverride:
|
|
|
|
{
|
|
|
|
if (receiver->isWidgetType()) {
|
|
|
|
QWidget *w = static_cast<QWidget *>(receiver);
|
|
|
|
QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
|
|
|
|
QList<QGesture *> allGestures = gestureEvent->gestures();
|
|
|
|
|
|
|
|
bool eventAccepted = gestureEvent->isAccepted();
|
|
|
|
bool wasAccepted = eventAccepted;
|
|
|
|
while (w) {
|
|
|
|
// send only gestures the widget expects
|
|
|
|
QList<QGesture *> gestures;
|
|
|
|
QWidgetPrivate *wd = w->d_func();
|
|
|
|
for (int i = 0; i < allGestures.size();) {
|
|
|
|
QGesture *g = allGestures.at(i);
|
|
|
|
Qt::GestureType type = g->gestureType();
|
|
|
|
QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit =
|
|
|
|
wd->gestureContext.find(type);
|
|
|
|
bool deliver = contextit != wd->gestureContext.end() &&
|
|
|
|
(g->state() == Qt::GestureStarted || w == receiver ||
|
|
|
|
(contextit.value() & Qt::ReceivePartialGestures));
|
|
|
|
if (deliver) {
|
|
|
|
allGestures.removeAt(i);
|
|
|
|
gestures.append(g);
|
|
|
|
} else {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!gestures.isEmpty()) { // we have gestures for this w
|
|
|
|
QGestureEvent ge(gestures);
|
|
|
|
ge.t = gestureEvent->t;
|
|
|
|
ge.spont = gestureEvent->spont;
|
|
|
|
ge.m_accept = wasAccepted;
|
2012-04-19 19:16:47 +00:00
|
|
|
ge.m_accepted = gestureEvent->m_accepted;
|
2011-04-27 10:05:43 +00:00
|
|
|
res = d->notify_helper(w, &ge);
|
|
|
|
gestureEvent->spont = false;
|
|
|
|
eventAccepted = ge.isAccepted();
|
|
|
|
for (int i = 0; i < gestures.size(); ++i) {
|
|
|
|
QGesture *g = gestures.at(i);
|
|
|
|
// Ignore res [event return value] because handling of multiple gestures
|
|
|
|
// packed into a single QEvent depends on not consuming the event
|
|
|
|
if (eventAccepted || ge.isAccepted(g)) {
|
|
|
|
// if the gesture was accepted, mark the target widget for it
|
2012-04-19 19:16:47 +00:00
|
|
|
gestureEvent->m_targetWidgets[g->gestureType()] = w;
|
2011-04-27 10:05:43 +00:00
|
|
|
gestureEvent->setAccepted(g, true);
|
|
|
|
} else {
|
|
|
|
// if the gesture was explicitly ignored by the application,
|
|
|
|
// put it back so a parent can get it
|
|
|
|
allGestures.append(g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allGestures.isEmpty()) // everything delivered
|
|
|
|
break;
|
|
|
|
if (w->isWindow())
|
|
|
|
break;
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
foreach (QGesture *g, allGestures)
|
|
|
|
gestureEvent->setAccepted(g, false);
|
|
|
|
gestureEvent->m_accept = false; // to make sure we check individual gestures
|
|
|
|
} else {
|
|
|
|
res = d->notify_helper(receiver, e);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif // QT_NO_GESTURES
|
2013-01-24 10:24:00 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
// Enable touch events on enter, disable on leave.
|
|
|
|
typedef void (*RegisterTouchWindowFn)(QWindow *, bool);
|
|
|
|
case QEvent::Enter:
|
|
|
|
if (receiver->isWidgetType()) {
|
|
|
|
QWidget *w = static_cast<QWidget *>(receiver);
|
|
|
|
if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
|
|
|
|
RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
|
|
|
|
(platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
|
|
|
|
if (registerTouchWindow)
|
|
|
|
registerTouchWindow(w->window()->windowHandle(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = d->notify_helper(receiver, e);
|
|
|
|
break;
|
|
|
|
case QEvent::Leave:
|
|
|
|
if (receiver->isWidgetType()) {
|
|
|
|
QWidget *w = static_cast<QWidget *>(receiver);
|
|
|
|
if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
|
|
|
|
RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
|
|
|
|
(platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
|
|
|
|
if (registerTouchWindow)
|
|
|
|
registerTouchWindow(w->window()->windowHandle(), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = d->notify_helper(receiver, e);
|
|
|
|
break;
|
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
default:
|
|
|
|
res = d->notify_helper(receiver, e);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
|
|
|
|
{
|
|
|
|
// send to all application event filters
|
|
|
|
if (sendThroughApplicationEventFilters(receiver, e))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (receiver->isWidgetType()) {
|
|
|
|
QWidget *widget = static_cast<QWidget *>(receiver);
|
|
|
|
|
2012-02-07 13:23:50 +00:00
|
|
|
#if !defined(Q_OS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
|
2011-04-27 10:05:43 +00:00
|
|
|
// toggle HasMouse widget state on enter and leave
|
|
|
|
if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
|
|
|
|
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window()))
|
|
|
|
widget->setAttribute(Qt::WA_UnderMouse, true);
|
|
|
|
else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave)
|
|
|
|
widget->setAttribute(Qt::WA_UnderMouse, false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (QLayout *layout=widget->d_func()->layout) {
|
|
|
|
layout->widgetEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// send to all receiver event filters
|
|
|
|
if (sendThroughObjectEventFilters(receiver, e))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// deliver the event
|
|
|
|
bool consumed = receiver->event(e);
|
|
|
|
e->spont = false;
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2012-06-11 14:13:24 +00:00
|
|
|
bool QApplicationPrivate::inPopupMode()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
return QApplicationPrivate::popupWidgets != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef QT_KEYPAD_NAVIGATION
|
|
|
|
/*!
|
|
|
|
Sets the kind of focus navigation Qt should use to \a mode.
|
|
|
|
|
2012-01-23 18:37:27 +00:00
|
|
|
This feature is available in Qt for Embedded Linux, and Windows CE
|
2011-04-27 10:05:43 +00:00
|
|
|
only.
|
|
|
|
|
|
|
|
\note On Windows CE this feature is disabled by default for touch device
|
|
|
|
mkspecs. To enable keypad navigation, build Qt with
|
|
|
|
QT_KEYPAD_NAVIGATION defined.
|
|
|
|
|
|
|
|
\since 4.6
|
|
|
|
|
|
|
|
\sa keypadNavigationEnabled()
|
|
|
|
*/
|
|
|
|
void QApplication::setNavigationMode(Qt::NavigationMode mode)
|
|
|
|
{
|
|
|
|
QApplicationPrivate::navigationMode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns what kind of focus navigation Qt is using.
|
|
|
|
|
2012-01-23 18:37:27 +00:00
|
|
|
This feature is available in Qt for Embedded Linux, and Windows CE only.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\note On Windows CE this feature is disabled by default for touch device
|
|
|
|
mkspecs. To enable keypad navigation, build Qt with
|
|
|
|
QT_KEYPAD_NAVIGATION defined.
|
|
|
|
|
|
|
|
\since 4.6
|
|
|
|
|
|
|
|
\sa keypadNavigationEnabled()
|
|
|
|
*/
|
|
|
|
Qt::NavigationMode QApplication::navigationMode()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::navigationMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets whether Qt should use focus navigation suitable for use with a
|
|
|
|
minimal keypad.
|
|
|
|
|
2012-01-23 18:37:27 +00:00
|
|
|
This feature is available in Qt for Embedded Linux, and Windows CE only.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\note On Windows CE this feature is disabled by default for touch device
|
|
|
|
mkspecs. To enable keypad navigation, build Qt with
|
|
|
|
QT_KEYPAD_NAVIGATION defined.
|
|
|
|
|
|
|
|
\deprecated
|
|
|
|
|
|
|
|
\sa setNavigationMode()
|
|
|
|
*/
|
|
|
|
void QApplication::setKeypadNavigationEnabled(bool enable)
|
|
|
|
{
|
|
|
|
if (enable) {
|
|
|
|
QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder);
|
2011-10-20 14:36:05 +00:00
|
|
|
} else {
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplication::setNavigationMode(Qt::NavigationModeNone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2013-10-02 14:51:05 +00:00
|
|
|
Returns \c true if Qt is set to use keypad navigation; otherwise returns
|
2012-01-23 18:37:27 +00:00
|
|
|
false. The default value is false.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-01-23 18:37:27 +00:00
|
|
|
This feature is available in Qt for Embedded Linux, and Windows CE only.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
\note On Windows CE this feature is disabled by default for touch device
|
|
|
|
mkspecs. To enable keypad navigation, build Qt with
|
|
|
|
QT_KEYPAD_NAVIGATION defined.
|
|
|
|
|
|
|
|
\deprecated
|
|
|
|
|
|
|
|
\sa navigationMode()
|
|
|
|
*/
|
|
|
|
bool QApplication::keypadNavigationEnabled()
|
|
|
|
{
|
|
|
|
return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder ||
|
|
|
|
QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QApplication::alert(QWidget *widget, int msec)
|
|
|
|
\since 4.3
|
|
|
|
|
|
|
|
Causes an alert to be shown for \a widget if the window is not the active
|
|
|
|
window. The alert is shown for \a msec miliseconds. If \a msec is zero (the
|
|
|
|
default), then the alert is shown indefinitely until the window becomes
|
|
|
|
active again.
|
|
|
|
|
|
|
|
Currently this function does nothing on Qt for Embedded Linux.
|
|
|
|
|
|
|
|
On Mac OS X, this works more at the application level and will cause the
|
|
|
|
application icon to bounce in the dock.
|
|
|
|
|
|
|
|
On Windows, this causes the window's taskbar entry to flash for a time. If
|
|
|
|
\a msec is zero, the flashing will stop and the taskbar entry will turn a
|
|
|
|
different color (currently orange).
|
|
|
|
|
|
|
|
On X11, this will cause the window to be marked as "demands attention", the
|
|
|
|
window must not be hidden (i.e. not have hide() called on it, but be
|
|
|
|
visible in some sort of way) in order for this to work.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::cursorFlashTime
|
|
|
|
\brief the text cursor's flash (blink) time in milliseconds
|
|
|
|
|
|
|
|
The flash time is the time required to display, invert and restore the
|
|
|
|
caret display. Usually the text cursor is displayed for half the cursor
|
|
|
|
flash time, then hidden for the same amount of time, but this may vary.
|
|
|
|
|
|
|
|
The default value on X11 is 1000 milliseconds. On Windows, the
|
2012-05-07 16:49:48 +00:00
|
|
|
\uicontrol{Control Panel} value is used and setting this property sets the cursor
|
2011-04-27 10:05:43 +00:00
|
|
|
flash time for all applications.
|
|
|
|
|
|
|
|
We recommend that widgets do not cache this value as it may change at any
|
|
|
|
time if the user changes the global desktop settings.
|
|
|
|
*/
|
2011-08-31 08:47:09 +00:00
|
|
|
void QApplication::setCursorFlashTime(int msecs)
|
|
|
|
{
|
2013-10-15 12:12:34 +00:00
|
|
|
QGuiApplication::styleHints()->setCursorFlashTime(msecs);
|
2011-08-31 08:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int QApplication::cursorFlashTime()
|
|
|
|
{
|
|
|
|
return qApp->styleHints()->cursorFlashTime();
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
/*!
|
|
|
|
\property QApplication::doubleClickInterval
|
|
|
|
\brief the time limit in milliseconds that distinguishes a double click
|
|
|
|
from two consecutive mouse clicks
|
|
|
|
|
|
|
|
The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
|
2011-08-31 08:47:09 +00:00
|
|
|
operating system's value is used.
|
2011-04-27 10:05:43 +00:00
|
|
|
*/
|
2011-08-31 08:47:09 +00:00
|
|
|
void QApplication::setDoubleClickInterval(int ms)
|
|
|
|
{
|
2013-10-15 12:12:34 +00:00
|
|
|
QGuiApplication::styleHints()->setMouseDoubleClickInterval(ms);
|
2011-08-31 08:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int QApplication::doubleClickInterval()
|
|
|
|
{
|
|
|
|
return qApp->styleHints()->mouseDoubleClickInterval();
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-08-15 10:56:14 +00:00
|
|
|
/*!
|
2012-09-24 11:05:23 +00:00
|
|
|
\fn QApplication::keyboardInputDirection()
|
2012-08-15 10:56:14 +00:00
|
|
|
\since 4.2
|
|
|
|
\deprecated
|
|
|
|
|
2013-01-20 15:24:58 +00:00
|
|
|
Returns the current keyboard input direction. Replaced with QInputMethod::inputDirection()
|
|
|
|
\sa QInputMethod::inputDirection()
|
2012-08-15 10:56:14 +00:00
|
|
|
*/
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
/*!
|
|
|
|
\property QApplication::keyboardInputInterval
|
|
|
|
\brief the time limit in milliseconds that distinguishes a key press
|
|
|
|
from two consecutive key presses
|
|
|
|
\since 4.2
|
|
|
|
|
|
|
|
The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
|
|
|
|
operating system's value is used.
|
|
|
|
*/
|
2011-08-31 08:47:09 +00:00
|
|
|
void QApplication::setKeyboardInputInterval(int ms)
|
|
|
|
{
|
2013-10-15 12:12:34 +00:00
|
|
|
QGuiApplication::styleHints()->setKeyboardInputInterval(ms);
|
2011-08-31 08:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int QApplication::keyboardInputInterval()
|
|
|
|
{
|
|
|
|
return qApp->styleHints()->keyboardInputInterval();
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\property QApplication::wheelScrollLines
|
|
|
|
\brief the number of lines to scroll a widget, when the
|
|
|
|
mouse wheel is rotated.
|
|
|
|
|
|
|
|
If the value exceeds the widget's number of visible lines, the widget
|
|
|
|
should interpret the scroll operation as a single \e{page up} or
|
|
|
|
\e{page down}. If the widget is an \l{QAbstractItemView}{item view class},
|
|
|
|
then the result of scrolling one \e line depends on the setting of the
|
|
|
|
widget's \l{QAbstractItemView::verticalScrollMode()}{scroll mode}. Scroll
|
|
|
|
one \e line can mean \l{QAbstractItemView::ScrollPerItem}{scroll one item}
|
|
|
|
or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}.
|
|
|
|
|
|
|
|
By default, this property has a value of 3.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
|
|
|
|
|
|
|
|
Enables the UI effect \a effect if \a enable is true, otherwise the effect
|
|
|
|
will not be used.
|
|
|
|
|
|
|
|
\note All effects are disabled on screens running at less than 16-bit color
|
|
|
|
depth.
|
|
|
|
|
|
|
|
\sa isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QApplication::isEffectEnabled(Qt::UIEffect effect)
|
|
|
|
|
2013-10-02 14:51:05 +00:00
|
|
|
Returns \c true if \a effect is enabled; otherwise returns \c false.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
By default, Qt will try to use the desktop settings. To prevent this, call
|
|
|
|
setDesktopSettingsAware(false).
|
|
|
|
|
|
|
|
\note All effects are disabled on screens running at less than 16-bit color
|
|
|
|
depth.
|
|
|
|
|
|
|
|
\sa setEffectEnabled(), Qt::UIEffect
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QApplication::beep()
|
|
|
|
|
|
|
|
Sounds the bell, using the default volume and sound. The function is \e not
|
|
|
|
available in Qt for Embedded Linux.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\macro qApp
|
|
|
|
\relates QApplication
|
|
|
|
|
|
|
|
A global pointer referring to the unique application object. It is
|
|
|
|
equivalent to the pointer returned by the QCoreApplication::instance()
|
|
|
|
function except that, in GUI applications, it is a pointer to a
|
|
|
|
QApplication instance.
|
|
|
|
|
|
|
|
Only one application object can be created.
|
|
|
|
|
|
|
|
\sa QCoreApplication::instance()
|
|
|
|
*/
|
|
|
|
|
2012-01-16 11:43:11 +00:00
|
|
|
/*!
|
2012-04-30 12:26:41 +00:00
|
|
|
\fn QLocale QApplication::keyboardInputLocale()
|
2012-01-16 11:43:11 +00:00
|
|
|
\since 4.2
|
|
|
|
\obsolete
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
Returns the current keyboard input locale. Replaced with QInputMethod::locale()
|
2012-01-16 11:43:11 +00:00
|
|
|
*/
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
|
|
|
|
{
|
2011-11-21 13:10:37 +00:00
|
|
|
return QGuiApplication::sendSpontaneousEvent(receiver, event);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-06-19 09:21:14 +00:00
|
|
|
void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEvent *event, QPoint localPos)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2013-06-19 09:21:14 +00:00
|
|
|
const bool setFocusOnRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease();
|
|
|
|
Qt::FocusPolicy focusPolicy = Qt::ClickFocus;
|
|
|
|
|
|
|
|
switch (event->type()) {
|
|
|
|
case QEvent::MouseButtonPress:
|
2014-01-19 18:44:31 +00:00
|
|
|
case QEvent::MouseButtonDblClick:
|
2013-06-19 09:21:14 +00:00
|
|
|
case QEvent::TouchBegin:
|
|
|
|
if (setFocusOnRelease)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case QEvent::MouseButtonRelease:
|
|
|
|
case QEvent::TouchEnd:
|
|
|
|
if (!setFocusOnRelease)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case QEvent::Wheel:
|
|
|
|
focusPolicy = Qt::WheelFocus;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QWidget *focusWidget = widget;
|
|
|
|
while (focusWidget) {
|
|
|
|
if (focusWidget->isEnabled()
|
2013-06-19 09:21:14 +00:00
|
|
|
&& focusWidget->rect().contains(localPos)
|
2011-04-27 10:05:43 +00:00
|
|
|
&& QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
|
2013-06-19 09:21:14 +00:00
|
|
|
focusWidget->setFocus(Qt::MouseFocusReason);
|
2011-04-27 10:05:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (focusWidget->isWindow())
|
|
|
|
break;
|
2013-11-16 16:17:15 +00:00
|
|
|
|
|
|
|
// find out whether this widget (or its proxy) already has focus
|
|
|
|
QWidget *f = focusWidget;
|
|
|
|
if (focusWidget->d_func()->extra && focusWidget->d_func()->extra->focus_proxy)
|
|
|
|
f = focusWidget->d_func()->extra->focus_proxy;
|
|
|
|
// if it has, stop here.
|
|
|
|
// otherwise a click on the focused widget would remove its focus if ClickFocus isn't set
|
|
|
|
if (f->hasFocus())
|
|
|
|
break;
|
|
|
|
|
2013-06-19 09:21:14 +00:00
|
|
|
localPos += focusWidget->pos();
|
2011-04-27 10:05:43 +00:00
|
|
|
focusWidget = focusWidget->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
|
|
|
|
{
|
|
|
|
QWidget *f = w;
|
|
|
|
while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
|
|
|
|
f = f->d_func()->extra->focus_proxy;
|
|
|
|
|
|
|
|
if ((w->focusPolicy() & policy) != policy)
|
|
|
|
return false;
|
|
|
|
if (w != f && (f->focusPolicy() & policy) != policy)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
|
|
|
|
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
|
|
|
|
|
|
|
|
// preserve the sub-pixel resolution
|
|
|
|
QRectF rect = touchPoint.screenRect();
|
|
|
|
const QPointF screenPos = rect.center();
|
|
|
|
const QPointF delta = screenPos - screenPos.toPoint();
|
|
|
|
|
|
|
|
rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
|
|
|
|
touchPoint.d->rect = rect;
|
2011-12-10 14:30:18 +00:00
|
|
|
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
|
|
|
|
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplicationPrivate::initializeMultitouch()
|
|
|
|
{
|
|
|
|
initializeMultitouch_sys();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QApplicationPrivate::cleanupMultitouch()
|
|
|
|
{
|
|
|
|
cleanupMultitouch_sys();
|
|
|
|
}
|
|
|
|
|
2011-12-10 14:30:18 +00:00
|
|
|
QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
int closestTouchPointId = -1;
|
2011-12-10 14:30:18 +00:00
|
|
|
QObject *closestTarget = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
qreal closestDistance = qreal(0.);
|
2011-12-10 14:30:18 +00:00
|
|
|
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(),
|
|
|
|
ite = activeTouchPoints.constEnd();
|
|
|
|
while (it != ite) {
|
|
|
|
if (it.key().device == device) {
|
|
|
|
const QTouchEvent::TouchPoint &touchPoint = it->touchPoint;
|
|
|
|
qreal dx = screenPos.x() - touchPoint.screenPos().x();
|
|
|
|
qreal dy = screenPos.y() - touchPoint.screenPos().y();
|
|
|
|
qreal distance = dx * dx + dy * dy;
|
|
|
|
if (closestTouchPointId == -1 || distance < closestDistance) {
|
|
|
|
closestTouchPointId = touchPoint.id();
|
|
|
|
closestDistance = distance;
|
|
|
|
closestTarget = it.value().target.data();
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-12-10 14:30:18 +00:00
|
|
|
++it;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-12-10 14:30:18 +00:00
|
|
|
return static_cast<QWidget *>(closestTarget);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-04-02 14:21:35 +00:00
|
|
|
bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
|
2011-11-27 15:42:23 +00:00
|
|
|
QTouchDevice *device,
|
2011-11-04 12:22:30 +00:00
|
|
|
const QList<QTouchEvent::TouchPoint> &touchPoints,
|
|
|
|
ulong timestamp)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QApplicationPrivate *d = self;
|
|
|
|
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
|
|
|
|
QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
|
|
|
|
|
|
|
|
for (int i = 0; i < touchPoints.count(); ++i) {
|
|
|
|
QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
|
|
|
|
// explicitly detach from the original touch point that we got, so even
|
|
|
|
// if the touchpoint structs are reused, we will make a copy that we'll
|
|
|
|
// deliver to the user (which might want to store the struct for later use).
|
|
|
|
touchPoint.d = touchPoint.d->detach();
|
|
|
|
|
|
|
|
// update state
|
2012-05-30 11:53:24 +00:00
|
|
|
QPointer<QObject> target;
|
2011-12-10 14:30:18 +00:00
|
|
|
ActiveTouchPointsKey touchInfoKey(device, touchPoint.id());
|
|
|
|
ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey];
|
|
|
|
if (touchPoint.state() == Qt::TouchPointPressed) {
|
2011-11-27 15:42:23 +00:00
|
|
|
if (device->type() == QTouchDevice::TouchPad) {
|
2011-04-27 10:05:43 +00:00
|
|
|
// on touch-pads, send all touch points to the same widget
|
2011-12-10 14:30:18 +00:00
|
|
|
target = d->activeTouchPoints.isEmpty()
|
2012-05-30 11:53:24 +00:00
|
|
|
? QPointer<QObject>()
|
2011-12-10 14:30:18 +00:00
|
|
|
: d->activeTouchPoints.constBegin().value().target;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2011-12-10 14:30:18 +00:00
|
|
|
if (!target) {
|
2011-04-27 10:05:43 +00:00
|
|
|
// determine which widget this event will go to
|
|
|
|
if (!window)
|
|
|
|
window = QApplication::topLevelAt(touchPoint.screenPos().toPoint());
|
|
|
|
if (!window)
|
|
|
|
continue;
|
2011-12-10 14:30:18 +00:00
|
|
|
target = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint()));
|
|
|
|
if (!target)
|
|
|
|
target = window;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2011-11-27 15:42:23 +00:00
|
|
|
if (device->type() == QTouchDevice::TouchScreen) {
|
2011-12-10 14:30:18 +00:00
|
|
|
QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos());
|
|
|
|
QWidget *widget = static_cast<QWidget *>(target.data());
|
2011-04-27 10:05:43 +00:00
|
|
|
if (closestWidget
|
2011-12-10 14:30:18 +00:00
|
|
|
&& (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) {
|
|
|
|
target = closestWidget;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-10 14:30:18 +00:00
|
|
|
touchInfo.target = target;
|
|
|
|
} else {
|
|
|
|
target = touchInfo.target;
|
|
|
|
if (!target)
|
2011-04-27 10:05:43 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-12-10 14:30:18 +00:00
|
|
|
Q_ASSERT(target.data() != 0);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2011-12-10 14:30:18 +00:00
|
|
|
StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[static_cast<QWidget *>(target.data())];
|
2011-04-27 10:05:43 +00:00
|
|
|
maskAndPoints.first |= touchPoint.state();
|
|
|
|
maskAndPoints.second.append(touchPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widgetsNeedingEvents.isEmpty())
|
2013-04-02 14:21:35 +00:00
|
|
|
return false;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2013-04-02 14:21:35 +00:00
|
|
|
bool accepted = false;
|
2011-04-27 10:05:43 +00:00
|
|
|
QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
|
|
|
|
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
QWidget *widget = it.key();
|
|
|
|
if (!QApplicationPrivate::tryModalHelper(widget, 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
QEvent::Type eventType;
|
2011-11-30 17:19:27 +00:00
|
|
|
switch (it.value().first) {
|
2011-04-27 10:05:43 +00:00
|
|
|
case Qt::TouchPointPressed:
|
|
|
|
eventType = QEvent::TouchBegin;
|
|
|
|
break;
|
|
|
|
case Qt::TouchPointReleased:
|
|
|
|
eventType = QEvent::TouchEnd;
|
|
|
|
break;
|
|
|
|
case Qt::TouchPointStationary:
|
|
|
|
// don't send the event if nothing changed
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
eventType = QEvent::TouchUpdate;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTouchEvent touchEvent(eventType,
|
2011-11-27 15:42:23 +00:00
|
|
|
device,
|
2011-04-27 10:05:43 +00:00
|
|
|
QApplication::keyboardModifiers(),
|
|
|
|
it.value().first,
|
|
|
|
it.value().second);
|
|
|
|
updateTouchPointsForWidget(widget, &touchEvent);
|
2011-11-04 12:22:30 +00:00
|
|
|
touchEvent.setTimestamp(timestamp);
|
2011-11-27 15:42:23 +00:00
|
|
|
touchEvent.setWindow(window->windowHandle());
|
2011-12-10 14:30:18 +00:00
|
|
|
touchEvent.setTarget(widget);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
switch (touchEvent.type()) {
|
|
|
|
case QEvent::TouchBegin:
|
|
|
|
{
|
|
|
|
// if the TouchBegin handler recurses, we assume that means the event
|
|
|
|
// has been implicitly accepted and continue to send touch events
|
2013-04-02 14:21:35 +00:00
|
|
|
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
|
|
|
|
accepted = true;
|
|
|
|
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) {
|
|
|
|
if (touchEvent.type() == QEvent::TouchEnd)
|
|
|
|
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false);
|
2013-04-02 14:21:35 +00:00
|
|
|
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted())
|
|
|
|
accepted = true;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-04-02 14:21:35 +00:00
|
|
|
return accepted;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 12:39:40 +00:00
|
|
|
void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp)
|
|
|
|
{
|
|
|
|
QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers());
|
|
|
|
touchEvent.setTimestamp(timestamp);
|
|
|
|
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it
|
|
|
|
= self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd();
|
|
|
|
QSet<QWidget *> widgetsNeedingCancel;
|
|
|
|
while (it != ite) {
|
|
|
|
QWidget *widget = static_cast<QWidget *>(it->target.data());
|
|
|
|
if (widget)
|
|
|
|
widgetsNeedingCancel.insert(widget);
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
for (QSet<QWidget *>::const_iterator widIt = widgetsNeedingCancel.constBegin(),
|
|
|
|
widItEnd = widgetsNeedingCancel.constEnd(); widIt != widItEnd; ++widIt) {
|
|
|
|
QWidget *widget = *widIt;
|
|
|
|
touchEvent.setWindow(widget->windowHandle());
|
|
|
|
touchEvent.setTarget(widget);
|
|
|
|
QApplication::sendSpontaneousEvent(widget, &touchEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-21 13:45:07 +00:00
|
|
|
void QApplicationPrivate::notifyThemeChanged()
|
|
|
|
{
|
|
|
|
QGuiApplicationPrivate::notifyThemeChanged();
|
|
|
|
clearSystemPalette();
|
|
|
|
initSystemPalette();
|
|
|
|
}
|
|
|
|
|
2012-07-09 10:50:00 +00:00
|
|
|
#ifndef QT_NO_DRAGANDDROP
|
|
|
|
void QApplicationPrivate::notifyDragStarted(const QDrag *drag)
|
|
|
|
{
|
|
|
|
// Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation.
|
|
|
|
QGuiApplicationPrivate::notifyDragStarted(drag);
|
|
|
|
qt_button_down = 0;
|
|
|
|
}
|
|
|
|
#endif // QT_NO_DRAGANDDROP
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#ifndef QT_NO_GESTURES
|
|
|
|
QGestureManager* QGestureManager::instance()
|
|
|
|
{
|
|
|
|
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
|
|
|
|
if (!qAppPriv)
|
|
|
|
return 0;
|
|
|
|
if (!qAppPriv->gestureManager)
|
|
|
|
qAppPriv->gestureManager = new QGestureManager(qApp);
|
|
|
|
return qAppPriv->gestureManager;
|
|
|
|
}
|
|
|
|
#endif // QT_NO_GESTURES
|
|
|
|
|
2012-05-14 16:02:16 +00:00
|
|
|
QPixmap QApplicationPrivate::applyQIconStyleHelper(QIcon::Mode mode, const QPixmap& base) const
|
|
|
|
{
|
|
|
|
QStyleOption opt(0);
|
2012-05-22 13:25:02 +00:00
|
|
|
opt.palette = QGuiApplication::palette();
|
|
|
|
return QApplication::style()->generatedIconPixmap(mode, base, &opt);
|
2012-05-14 16:02:16 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#include "moc_qapplication.cpp"
|