Implement support for QGuiApp::setOverrideCursor()
Properly support application override cursors and move the documentation into the proper place. Change-Id: I0198b38e0d2e7b10f0fcae342b468e7f8341bf02 Reviewed-on: http://codereview.qt-project.org/5562 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
This commit is contained in:
parent
50f0aeee77
commit
84251f84b6
@ -1146,24 +1146,73 @@ void QGuiApplication::changeOverrideCursor(const QCursor &cursor)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QGuiApplication::setOverrideCursor(const QCursor &cursor, bool replace)
|
|
||||||
|
|
||||||
Use changeOverrideCursor(\a cursor) (if \a replace is true) or
|
|
||||||
setOverrideCursor(\a cursor) (if \a replace is false).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
|
static void applyCursor(QWindow *w, const QCursor &c)
|
||||||
|
{
|
||||||
|
QCursor cc = c;
|
||||||
|
QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances();
|
||||||
|
int cursorCount = cursors.count();
|
||||||
|
for (int i = 0; i < cursorCount; ++i) {
|
||||||
|
const QWeakPointer<QPlatformCursor> &cursor(cursors.at(i));
|
||||||
|
if (cursor)
|
||||||
|
cursor.data()->changeCursor(&cc, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QGuiApplication::setOverrideCursor(const QCursor &cursor)
|
||||||
|
|
||||||
|
Sets the application override cursor to \a cursor.
|
||||||
|
|
||||||
|
Application override cursors are intended for showing the user that the
|
||||||
|
application is in a special state, for example during an operation that
|
||||||
|
might take some time.
|
||||||
|
|
||||||
|
This cursor will be displayed in all the application's widgets until
|
||||||
|
restoreOverrideCursor() or another setOverrideCursor() is called.
|
||||||
|
|
||||||
|
Application cursors are stored on an internal stack. setOverrideCursor()
|
||||||
|
pushes the cursor onto the stack, and restoreOverrideCursor() pops the
|
||||||
|
active cursor off the stack. changeOverrideCursor() changes the curently
|
||||||
|
active application override cursor.
|
||||||
|
|
||||||
|
Every setOverrideCursor() must eventually be followed by a corresponding
|
||||||
|
restoreOverrideCursor(), otherwise the stack will never be emptied.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
\snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0
|
||||||
|
|
||||||
|
\sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(),
|
||||||
|
QWidget::setCursor()
|
||||||
|
*/
|
||||||
void QGuiApplication::setOverrideCursor(const QCursor &cursor)
|
void QGuiApplication::setOverrideCursor(const QCursor &cursor)
|
||||||
{
|
{
|
||||||
qGuiApp->d_func()->cursor_list.prepend(cursor);
|
qGuiApp->d_func()->cursor_list.prepend(cursor);
|
||||||
|
for (int i = 0; i < QGuiApplicationPrivate::window_list.size(); ++i)
|
||||||
|
applyCursor(QGuiApplicationPrivate::window_list.at(i), cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QGuiApplication::restoreOverrideCursor()
|
||||||
|
|
||||||
|
Undoes the last setOverrideCursor().
|
||||||
|
|
||||||
|
If setOverrideCursor() has been called twice, calling
|
||||||
|
restoreOverrideCursor() will activate the first cursor set. Calling this
|
||||||
|
function a second time restores the original widgets' cursors.
|
||||||
|
|
||||||
|
\sa setOverrideCursor(), overrideCursor()
|
||||||
|
*/
|
||||||
void QGuiApplication::restoreOverrideCursor()
|
void QGuiApplication::restoreOverrideCursor()
|
||||||
{
|
{
|
||||||
if (qGuiApp->d_func()->cursor_list.isEmpty())
|
if (qGuiApp->d_func()->cursor_list.isEmpty())
|
||||||
return;
|
return;
|
||||||
qGuiApp->d_func()->cursor_list.removeFirst();
|
qGuiApp->d_func()->cursor_list.removeFirst();
|
||||||
|
QCursor c(qGuiApp->d_func()->cursor_list.value(0, QCursor()));
|
||||||
|
for (int i = 0; i < QGuiApplicationPrivate::window_list.size(); ++i)
|
||||||
|
applyCursor(QGuiApplicationPrivate::window_list.at(i), c);
|
||||||
}
|
}
|
||||||
#endif// QT_NO_CURSOR
|
#endif// QT_NO_CURSOR
|
||||||
|
|
||||||
|
@ -5084,44 +5084,6 @@ int QApplication::keyboardInputInterval()
|
|||||||
available in Qt for Embedded Linux.
|
available in Qt for Embedded Linux.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QApplication::setOverrideCursor(const QCursor &cursor)
|
|
||||||
|
|
||||||
Sets the application override cursor to \a cursor.
|
|
||||||
|
|
||||||
Application override cursors are intended for showing the user that the
|
|
||||||
application is in a special state, for example during an operation that
|
|
||||||
might take some time.
|
|
||||||
|
|
||||||
This cursor will be displayed in all the application's widgets until
|
|
||||||
restoreOverrideCursor() or another setOverrideCursor() is called.
|
|
||||||
|
|
||||||
Application cursors are stored on an internal stack. setOverrideCursor()
|
|
||||||
pushes the cursor onto the stack, and restoreOverrideCursor() pops the
|
|
||||||
active cursor off the stack. changeOverrideCursor() changes the curently
|
|
||||||
active application override cursor.
|
|
||||||
|
|
||||||
Every setOverrideCursor() must eventually be followed by a corresponding
|
|
||||||
restoreOverrideCursor(), otherwise the stack will never be emptied.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
\snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0
|
|
||||||
|
|
||||||
\sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(),
|
|
||||||
QWidget::setCursor()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QApplication::restoreOverrideCursor()
|
|
||||||
|
|
||||||
Undoes the last setOverrideCursor().
|
|
||||||
|
|
||||||
If setOverrideCursor() has been called twice, calling
|
|
||||||
restoreOverrideCursor() will activate the first cursor set. Calling this
|
|
||||||
function a second time restores the original widgets' cursors.
|
|
||||||
|
|
||||||
\sa setOverrideCursor(), overrideCursor()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\macro qApp
|
\macro qApp
|
||||||
|
Loading…
Reference in New Issue
Block a user