From cd34da54269e6cd7fa5c18242d982736f022a14a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 22 Oct 2012 12:47:34 +0200 Subject: [PATCH] Rename all QWindow properties that have "window" in them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- examples/gui/analogclock/main.cpp | 2 +- examples/opengl/hellowindow/hellowindow.cpp | 2 +- examples/opengl/hellowindow/main.cpp | 8 +- .../opengl/paintedwindow/paintedwindow.cpp | 18 +- examples/qpa/windows/main.cpp | 12 +- examples/qpa/windows/window.cpp | 2 +- src/gui/accessible/qaccessibleobject.cpp | 2 +- src/gui/kernel/qguiapplication.cpp | 14 +- src/gui/kernel/qwindow.cpp | 159 ++++++++++-------- src/gui/kernel/qwindow.h | 47 +++--- .../dnd/qshapedpixmapdndwindow.cpp | 2 +- src/plugins/platforms/cocoa/qcocoamenubar.mm | 4 +- src/plugins/platforms/cocoa/qcocoawindow.mm | 34 ++-- .../windows/qwindowsbackingstore.cpp | 2 +- .../platforms/windows/qwindowscontext.cpp | 2 +- .../platforms/windows/qwindowsintegration.cpp | 6 +- .../platforms/windows/qwindowskeymapper.cpp | 6 +- .../platforms/windows/qwindowswindow.cpp | 10 +- src/plugins/platforms/xcb/qxcbdrag.cpp | 14 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 42 ++--- src/widgets/kernel/qapplication.cpp | 2 +- src/widgets/kernel/qwidget_qpa.cpp | 18 +- .../qguiapplication/tst_qguiapplication.cpp | 12 +- .../kernel/qinputmethod/tst_qinputmethod.cpp | 4 +- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 48 +++--- .../qaccessibility/tst_qaccessibility.cpp | 2 +- 26 files changed, 248 insertions(+), 226 deletions(-) diff --git a/examples/gui/analogclock/main.cpp b/examples/gui/analogclock/main.cpp index 87b5602946..acaf7c280b 100644 --- a/examples/gui/analogclock/main.cpp +++ b/examples/gui/analogclock/main.cpp @@ -61,7 +61,7 @@ private: //! [6] AnalogClockWindow::AnalogClockWindow() { - setWindowTitle("Analog Clock"); + setTitle("Analog Clock"); resize(200, 200); m_timerId = startTimer(1000); diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp index 7770949d45..b5166abe50 100644 --- a/examples/opengl/hellowindow/hellowindow.cpp +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -63,7 +63,7 @@ HelloWindow::HelloWindow(const QSharedPointer &renderer) : m_colorIndex(0), m_renderer(renderer), m_timer(0) { setSurfaceType(QWindow::OpenGLSurface); - setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); setGeometry(QRect(10, 10, 640, 480)); diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp index 618a499286..343160f755 100644 --- a/examples/opengl/hellowindow/main.cpp +++ b/examples/opengl/hellowindow/main.cpp @@ -71,7 +71,7 @@ int main(int argc, char **argv) HelloWindow *windowA = new HelloWindow(rendererA); windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0)); - windowA->setWindowTitle(QLatin1String("Thread A - Context A")); + windowA->setTitle(QLatin1String("Thread A - Context A")); windowA->setVisible(true); windows.prepend(windowA); @@ -85,13 +85,13 @@ int main(int argc, char **argv) HelloWindow *windowB = new HelloWindow(rendererA); windowB->setGeometry(QRect(center, windowSize).translated(delta / 2, 0)); - windowB->setWindowTitle(QLatin1String("Thread A - Context A")); + windowB->setTitle(QLatin1String("Thread A - Context A")); windowB->setVisible(true); windows.prepend(windowB); HelloWindow *windowC = new HelloWindow(rendererB); windowC->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta)); - windowC->setWindowTitle(QLatin1String("Thread B - Context B")); + windowC->setTitle(QLatin1String("Thread B - Context B")); windowC->setVisible(true); windows.prepend(windowC); @@ -113,7 +113,7 @@ int main(int argc, char **argv) window->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, -windowSize.height() / 2)); QChar id = QChar('B' + i); - window->setWindowTitle(QLatin1String("Thread ") + id + QLatin1String(" - Context ") + id); + window->setTitle(QLatin1String("Thread ") + id + QLatin1String(" - Context ") + id); window->setVisible(true); windows.prepend(window); } diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index 911011a303..0920e6e89d 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -56,7 +56,7 @@ PaintedWindow::PaintedWindow() format.setSamples(4); setSurfaceType(QWindow::OpenGLSurface); - setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + setFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); setFormat(format); create(); @@ -70,12 +70,12 @@ PaintedWindow::PaintedWindow() m_animation->setEndValue(qreal(1)); m_animation->setDuration(500); - requestWindowOrientation(Qt::PortraitOrientation); + requestOrientation(Qt::PortraitOrientation); QRect screenGeometry = screen()->availableGeometry(); QPoint center = screenGeometry.center(); - QRect windowRect = screen()->isLandscape(windowOrientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640); + QRect windowRect = screen()->isLandscape(orientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640); setGeometry(QRect(center - windowRect.center(), windowRect.size())); m_rotation = 0; @@ -142,13 +142,13 @@ void PaintedWindow::orientationChanged(Qt::ScreenOrientation newOrientation) QPainter p; p.begin(&m_prevImage); - p.setTransform(screen()->transformBetween(contentOrientation(), windowOrientation(), rect)); - paint(&p, screen()->mapBetween(contentOrientation(), windowOrientation(), rect)); + p.setTransform(screen()->transformBetween(contentOrientation(), orientation(), rect)); + paint(&p, screen()->mapBetween(contentOrientation(), orientation(), rect)); p.end(); p.begin(&m_nextImage); - p.setTransform(screen()->transformBetween(newOrientation, windowOrientation(), rect)); - paint(&p, screen()->mapBetween(newOrientation, windowOrientation(), rect)); + p.setTransform(screen()->transformBetween(newOrientation, orientation(), rect)); + paint(&p, screen()->mapBetween(newOrientation, orientation(), rect)); p.end(); m_deltaRotation = screen()->angleBetween(newOrientation, contentOrientation()); @@ -207,9 +207,9 @@ void PaintedWindow::paint() painter.setOpacity(m_rotation); painter.drawImage(0, 0, m_nextImage); } else { - QRect mapped = screen()->mapBetween(contentOrientation(), windowOrientation(), rect); + QRect mapped = screen()->mapBetween(contentOrientation(), orientation(), rect); - painter.setTransform(screen()->transformBetween(contentOrientation(), windowOrientation(), rect)); + painter.setTransform(screen()->transformBetween(contentOrientation(), orientation(), rect)); paint(&painter, mapped); painter.end(); } diff --git a/examples/qpa/windows/main.cpp b/examples/qpa/windows/main.cpp index da189ab447..4313dadc83 100644 --- a/examples/qpa/windows/main.cpp +++ b/examples/qpa/windows/main.cpp @@ -53,14 +53,14 @@ int main(int argc, char **argv) Window a; a.setFramePos(QPoint(10, 10)); - a.setWindowTitle(QStringLiteral("Window A")); - a.setObjectName(a.windowTitle()); + a.setTitle(QStringLiteral("Window A")); + a.setObjectName(a.title()); a.setVisible(true); Window b; b.setFramePos(QPoint(100, 100)); - b.setWindowTitle(QStringLiteral("Window B")); - b.setObjectName(b.windowTitle()); + b.setTitle(QStringLiteral("Window B")); + b.setObjectName(b.title()); b.setVisible(true); Window child(&b); @@ -79,8 +79,8 @@ int main(int argc, char **argv) geometry.moveCenter(screen->availableGeometry().center()); window->setGeometry(geometry); window->setVisible(true); - window->setWindowTitle(screen->name()); - window->setObjectName(window->windowTitle()); + window->setTitle(screen->name()); + window->setObjectName(window->title()); windows.push_back(window); } return app.exec(); diff --git a/examples/qpa/windows/window.cpp b/examples/qpa/windows/window.cpp index a9f29274ac..c64ec650e5 100644 --- a/examples/qpa/windows/window.cpp +++ b/examples/qpa/windows/window.cpp @@ -73,7 +73,7 @@ void Window::initialize() if (parent()) setGeometry(QRect(160, 120, 320, 240)); else { - setWindowFlags(windowFlags() | Qt::WindowTitleHint | Qt::WindowSystemMenuHint + setFlags(flags() | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); const QSize baseSize = QSize(640, 480); setGeometry(QRect(geometry().topLeft(), baseSize)); diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 5d958f01a9..bc108980cf 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -201,7 +201,7 @@ static QObjectList topLevelObjects() const QWindowList tlw(QGuiApplication::topLevelWindows()); for (int i = 0; i < tlw.count(); ++i) { QWindow *w = tlw.at(i); - if (w->windowType() != Qt::Popup && w->windowType() != Qt::Desktop) { + if (w->type() != Qt::Popup && w->type() != Qt::Desktop) { if (QAccessibleInterface *root = w->accessibleRoot()) { if (root->object()) list.append(root->object()); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index efb34ffe9f..ca9d60fcdf 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -422,14 +422,14 @@ QString QGuiApplication::applicationDisplayName() visible, this function returns zero. A modal window is a window which has its - \l{QWindow::windowModality}{windowModality} property set to Qt::WindowModal + \l{QWindow::modality}{modality} property set to Qt::WindowModal or Qt::ApplicationModal. A modal window must be closed before the user can continue with other parts of the program. Modal window are organized in a stack. This function returns the modal window at the top of the stack. - \sa Qt::WindowModality, QWindow::setWindowModality() + \sa Qt::WindowModality, QWindow::setModality() */ QWindow *QGuiApplication::modalWindow() { @@ -441,7 +441,7 @@ QWindow *QGuiApplication::modalWindow() void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) { bool shouldBeBlocked = false; - if ((window->windowType() & Qt::Popup) != Qt::Popup && !self->modalWindowList.isEmpty()) + if ((window->type() & Qt::Popup) != Qt::Popup && !self->modalWindowList.isEmpty()) shouldBeBlocked = self->isWindowBlocked(window); if (shouldBeBlocked != window->d_func()->blockedByModalWindow) { @@ -457,7 +457,7 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) self->modalWindowList.prepend(modal); // Send leave for currently entered window if it should be blocked - if (currentMouseWindow && (currentMouseWindow->windowType() & Qt::Popup) != Qt::Popup) { + if (currentMouseWindow && (currentMouseWindow->type() & Qt::Popup) != Qt::Popup) { bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); if (shouldBeBlocked) { // Remove the new window from modalWindowList temporarily so leave can go through @@ -525,7 +525,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking } } - Qt::WindowModality windowModality = modalWindow->windowModality(); + Qt::WindowModality windowModality = modalWindow->modality(); switch (windowModality) { case Qt::ApplicationModal: { @@ -2359,7 +2359,7 @@ static inline void applyCursor(const QList &l, const QCursor &c) { for (int i = 0; i < l.size(); ++i) { QWindow *w = l.at(i); - if (w->handle() && w->windowType() != Qt::Desktop) + if (w->handle() && w->type() != Qt::Desktop) applyCursor(w, c); } } @@ -2368,7 +2368,7 @@ static inline void applyWindowCursor(const QList &l) { for (int i = 0; i < l.size(); ++i) { QWindow *w = l.at(i); - if (w->handle() && w->windowType() != Qt::Desktop) + if (w->handle() && w->type() != Qt::Desktop) applyCursor(w, w->cursor()); } } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index ae0644a019..dd0e4dd993 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -411,7 +411,7 @@ bool QWindow::isTopLevel() const A modal window prevents other windows from getting any input. - \sa QWindow::windowModality + \sa QWindow::modality */ bool QWindow::isModal() const { @@ -419,7 +419,7 @@ bool QWindow::isModal() const return d->modality != Qt::NonModal; } -/*! \property QWindow::windowModality +/*! \property QWindow::modality \brief the modality of the window A modal window prevents other windows from receiving input events. Qt @@ -430,24 +430,24 @@ bool QWindow::isModal() const \sa Qt::WindowModality */ -Qt::WindowModality QWindow::windowModality() const +Qt::WindowModality QWindow::modality() const { Q_D(const QWindow); return d->modality; } -void QWindow::setWindowModality(Qt::WindowModality modality) +void QWindow::setModality(Qt::WindowModality modality) { Q_D(QWindow); if (d->modality == modality) return; d->modality = modality; - emit windowModalityChanged(modality); + emit modalityChanged(modality); } -/*! \fn void QWindow::windowModalityChanged(Qt::WindowModality windowModality) +/*! \fn void QWindow::modalityChanged(Qt::WindowModality modality) - This signal is emitted when the Qwindow::windowModality property changes to \a windowModality. + This signal is emitted when the Qwindow::modality property changes to \a modality. */ /*! @@ -510,15 +510,17 @@ QSurfaceFormat QWindow::format() const } /*! - Sets the window flags of the window to \a flags. + \property QWindow::flags + \brief the window flags of the window The window flags control the window's appearance in the windowing system, whether it's a dialog, popup, or a regular window, and whether it should have a title bar, etc. - \sa windowFlags() + The actual window flags might differ from the flags set with setFlags() + if the requested flags could not be fulfilled. */ -void QWindow::setWindowFlags(Qt::WindowFlags flags) +void QWindow::setFlags(Qt::WindowFlags flags) { Q_D(QWindow); if (d->platformWindow) @@ -526,15 +528,7 @@ void QWindow::setWindowFlags(Qt::WindowFlags flags) d->windowFlags = flags; } -/*! - Returns the window flags of the window. - - This might differ from the flags set with setWindowFlags() if the - requested flags could not be fulfilled. - - \sa setWindowFlags() -*/ -Qt::WindowFlags QWindow::windowFlags() const +Qt::WindowFlags QWindow::flags() const { Q_D(const QWindow); return d->windowFlags; @@ -546,16 +540,16 @@ Qt::WindowFlags QWindow::windowFlags() const This returns the part of the window flags that represents whether the window is a dialog, tooltip, popup, regular window, etc. - \sa windowFlags(), setWindowFlags() + \sa flags(), setFlags() */ -Qt::WindowType QWindow::windowType() const +Qt::WindowType QWindow::type() const { Q_D(const QWindow); return static_cast(int(d->windowFlags & Qt::WindowType_Mask)); } /*! - \property QWindow::windowTitle + \property QWindow::title \brief the window's title in the windowing system The window title might appear in the title area of the window decorations, @@ -563,9 +557,9 @@ Qt::WindowType QWindow::windowType() const be used by the windowing system to identify the window in other contexts, such as in the task switcher. - \sa windowFlags() + \sa flags() */ -void QWindow::setWindowTitle(const QString &title) +void QWindow::setTitle(const QString &title) { Q_D(QWindow); d->windowTitle = title; @@ -573,20 +567,20 @@ void QWindow::setWindowTitle(const QString &title) d->platformWindow->setWindowTitle(title); } -QString QWindow::windowTitle() const +QString QWindow::title() const { Q_D(const QWindow); return d->windowTitle; } /*! - \property QWindow::windowFilePath - \brief the file name this window is representing. + \brief set the file name this window is representing. - This property might be used by the windowing system to display the file + The windowing system might use \a filePath to display the path of the document this window is representing in the tile bar. + */ -void QWindow::setWindowFilePath(const QString &filePath) +void QWindow::setFilePath(const QString &filePath) { Q_D(QWindow); d->windowFilePath = filePath; @@ -594,20 +588,24 @@ void QWindow::setWindowFilePath(const QString &filePath) d->platformWindow->setWindowFilePath(filePath); } -QString QWindow::windowFilePath() const +/*! + \brief the file name this window is representing. + + \sa setFilePath() +*/ +QString QWindow::filePath() const { Q_D(const QWindow); return d->windowFilePath; } /*! - \property QWindow::windowIcon - \brief the window's icon in the windowing system + \brief set the window's \a icon in the windowing system The window icon might be used by the windowing system for example to decorate the window, and/or in the task switcher. */ -void QWindow::setWindowIcon(const QIcon &icon) +void QWindow::setIcon(const QIcon &icon) { Q_D(QWindow); d->windowIcon = icon; @@ -615,7 +613,12 @@ void QWindow::setWindowIcon(const QIcon &icon) d->platformWindow->setWindowIcon(icon); } -QIcon QWindow::windowIcon() const +/*! + \brief set the window's icon in the windowing system + + \sa setIcon() +*/ +QIcon QWindow::icon() const { Q_D(const QWindow); return d->windowIcon; @@ -668,7 +671,7 @@ void QWindow::setOpacity(qreal level) \sa isActive(), QGuiApplication::focusWindow() */ -void QWindow::requestActivateWindow() +void QWindow::requestActivate() { Q_D(QWindow); if (d->platformWindow) @@ -741,7 +744,7 @@ bool QWindow::isActive() const The default value is Qt::PrimaryOrientation - \sa requestWindowOrientation(), QScreen::orientation() + \sa requestOrientation(), QScreen::orientation() */ void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation) { @@ -774,12 +777,12 @@ Qt::ScreenOrientation QWindow::contentOrientation() const on a device that only handles landscape buffers, typically a desktop system). - If the return value is false, call windowOrientation() to get the actual + If the return value is false, call \l orientation() to get the actual supported orientation. - \sa windowOrientation(), reportContentOrientationChange(), QScreen::orientation() + \sa orientation(), reportContentOrientationChange(), QScreen::orientation() */ -bool QWindow::requestWindowOrientation(Qt::ScreenOrientation orientation) +bool QWindow::requestOrientation(Qt::ScreenOrientation orientation) { Q_D(QWindow); if (!d->platformWindow) @@ -794,34 +797,23 @@ bool QWindow::requestWindowOrientation(Qt::ScreenOrientation orientation) The default value is Qt::PrimaryOrientation. - \sa requestWindowOrientation() + \sa requestOrientation() */ -Qt::ScreenOrientation QWindow::windowOrientation() const +Qt::ScreenOrientation QWindow::orientation() const { Q_D(const QWindow); return d->windowOrientation; } /*! - Returns the window state. + \brief set the screen-occupation state of the window - \sa setWindowState() -*/ -Qt::WindowState QWindow::windowState() const -{ - Q_D(const QWindow); - return d->windowState; -} - -/*! - Sets the desired window \a state. - - The window state represents whether the window appears in the + The window \a state represents whether the window appears in the windowing system as maximized, minimized, fullscreen, or normal. The enum value Qt::WindowActive is not an accepted parameter. - \sa windowState(), showNormal(), showFullScreen(), showMinimized(), showMaximized() + \sa showNormal(), showFullScreen(), showMinimized(), showMaximized() */ void QWindow::setWindowState(Qt::WindowState state) { @@ -834,8 +826,28 @@ void QWindow::setWindowState(Qt::WindowState state) if (d->platformWindow) d->platformWindow->setWindowState(state); d->windowState = state; + emit windowStateChanged(d->windowState); } +/*! + \brief the screen-occupation state of the window + + \sa setWindowState() +*/ +Qt::WindowState QWindow::windowState() const +{ + Q_D(const QWindow); + return d->windowState; +} + +/*! + \fn QWindow::windowStateChanged(Qt::WindowState windowState) + + This signal is emitted when the \a windowState changes, either + by being set explicitly with setWindowState(), or automatically when + the user clicks one of the titlebar buttons or by other means. +*/ + /*! Sets the transient \a parent @@ -1463,7 +1475,7 @@ void QWindow::showFullScreen() { setWindowState(Qt::WindowFullScreen); setVisible(true); - requestActivateWindow(); + requestActivate(); } /*! @@ -1671,6 +1683,11 @@ bool QWindow::event(QEvent *ev) hideEvent(static_cast(ev)); break; + case QEvent::WindowStateChange: { + Q_D(QWindow); + emit windowStateChanged(d->windowState); + } + #ifndef QT_NO_TABLETEVENT case QEvent::TabletPress: case QEvent::TabletMove: @@ -1882,17 +1899,16 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed() } +#ifndef QT_NO_CURSOR /*! - \property QWindow::cursor - \brief the cursor shape for this window + \brief set the cursor shape for this window - The mouse cursor will assume this shape when it is over this + The mouse \a cursor will assume this shape when it is over this window, unless an override cursor is set. See the \l{Qt::CursorShape}{list of predefined cursor objects} for a range of useful shapes. - By default, this property contains a cursor with the Qt::ArrowCursor - shape. + By default, the cursor has the Qt::ArrowCursor shape. Some underlying window implementations will reset the cursor if it leaves a window even if the mouse is grabbed. If you want to have @@ -1901,14 +1917,6 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed() \sa QGuiApplication::setOverrideCursor() */ - -#ifndef QT_NO_CURSOR -QCursor QWindow::cursor() const -{ - Q_D(const QWindow); - return d->cursor; -} - void QWindow::setCursor(const QCursor &cursor) { Q_D(QWindow); @@ -1929,6 +1937,17 @@ void QWindow::unsetCursor() setCursor(Qt::ArrowCursor); } +/*! + \brief the cursor shape for this window + + \sa setCursor(), unsetCursor() +*/ +QCursor QWindow::cursor() const +{ + Q_D(const QWindow); + return d->cursor; +} + void QWindowPrivate::applyCursor() { Q_Q(QWindow); @@ -1940,6 +1959,6 @@ void QWindowPrivate::applyCursor() } } } -#endif +#endif // QT_NO_CURSOR QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 4832adfb63..1413d3db25 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -93,10 +93,15 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface Q_OBJECT Q_DECLARE_PRIVATE(QWindow) - Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) - Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath) - Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon) - Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality NOTIFY windowModalityChanged) + // All properties which are declared here are inherited by QQuickWindow and therefore available in QML. + // So please think carefully about what it does to the QML namespace if you add any new ones, + // particularly the possible meanings these names might have in any specializations of Window. + // For example "state" (meaning windowState) is not a good property to declare, because it has + // a different meaning in QQuickItem, and users will tend to assume it is the same for Window. + + Q_PROPERTY(QString title READ title WRITE setTitle) + Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged) + Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags) Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged) Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) @@ -110,9 +115,6 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged) -#ifndef QT_NO_CURSOR - Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor) -#endif public: @@ -135,29 +137,29 @@ public: bool isTopLevel() const; bool isModal() const; - Qt::WindowModality windowModality() const; - void setWindowModality(Qt::WindowModality windowModality); + Qt::WindowModality modality() const; + void setModality(Qt::WindowModality modality); void setFormat(const QSurfaceFormat &format); QSurfaceFormat format() const; QSurfaceFormat requestedFormat() const; - void setWindowFlags(Qt::WindowFlags flags); - Qt::WindowFlags windowFlags() const; - Qt::WindowType windowType() const; + void setFlags(Qt::WindowFlags flags); + Qt::WindowFlags flags() const; + Qt::WindowType type() const; - QString windowTitle() const; + QString title() const; void setOpacity(qreal level); - void requestActivateWindow(); + void requestActivate(); bool isActive() const; void reportContentOrientationChange(Qt::ScreenOrientation orientation); Qt::ScreenOrientation contentOrientation() const; - bool requestWindowOrientation(Qt::ScreenOrientation orientation); - Qt::ScreenOrientation windowOrientation() const; + bool requestOrientation(Qt::ScreenOrientation orientation); + Qt::ScreenOrientation orientation() const; Qt::WindowState windowState() const; void setWindowState(Qt::WindowState state); @@ -213,11 +215,11 @@ public: void resize(const QSize &newSize); inline void resize(int w, int h) { resize(QSize(w, h)); } - void setWindowFilePath(const QString &filePath); - QString windowFilePath() const; + void setFilePath(const QString &filePath); + QString filePath() const; - void setWindowIcon(const QIcon &icon); - QIcon windowIcon() const; + void setIcon(const QIcon &icon); + QIcon icon() const; void destroy(); @@ -256,7 +258,7 @@ public Q_SLOTS: void raise(); void lower(); - void setWindowTitle(const QString &); + void setTitle(const QString &); void setX(int arg) { @@ -289,7 +291,8 @@ public Q_SLOTS: Q_SIGNALS: void screenChanged(QScreen *screen); - void windowModalityChanged(Qt::WindowModality windowModality); + void modalityChanged(Qt::WindowModality modality); + void windowStateChanged(Qt::WindowState windowState); void xChanged(int arg); void yChanged(int arg); diff --git a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp index 94a9a390e5..e02ab1e10d 100644 --- a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp +++ b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp @@ -54,7 +54,7 @@ QShapedPixmapWindow::QShapedPixmapWindow() format.setAlphaBufferSize(8); setFormat(format); setSurfaceType(RasterSurface); - setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | + setFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput); create(); m_backingStore = new QBackingStore(this); diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 8434cb75e9..bae52c91b8 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -219,7 +219,7 @@ QList QCocoaMenuBar::merged() const bool QCocoaMenuBar::shouldDisable(QCocoaWindow *active) const { - if (active && (active->window()->windowModality() == Qt::NonModal)) + if (active && (active->window()->modality() == Qt::NonModal)) return false; if (m_window == active) { @@ -232,7 +232,7 @@ bool QCocoaMenuBar::shouldDisable(QCocoaWindow *active) const // the menubar should be disabled. The exception in Qt is that if the // modal window is the only window on screen, then we enable the menu bar. foreach (QWindow *w, topWindows) { - if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) { + if (w->isVisible() && w->modality() == Qt::ApplicationModal) { // check for other visible windows foreach (QWindow *other, topWindows) { if ((w != other) && (other->isVisible())) { diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index b9c5a401d0..c1c5f49d3f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -149,9 +149,9 @@ static bool isMouseEvent(NSEvent *ev) - (BOOL)canBecomeKeyWindow { // Most panels can be come the key window. Exceptions are: - if (m_cocoaPlatformWindow->window()->windowType() == Qt::ToolTip) + if (m_cocoaPlatformWindow->window()->type() == Qt::ToolTip) return NO; - if (m_cocoaPlatformWindow->window()->windowType() == Qt::SplashScreen) + if (m_cocoaPlatformWindow->window()->type() == Qt::SplashScreen) return NO; return YES; } @@ -252,7 +252,7 @@ void QCocoaWindow::setVisible(bool visible) #endif if (visible) { // We need to recreate if the modality has changed as the style mask will need updating - if (m_windowModality != window()->windowModality()) + if (m_windowModality != window()->modality()) recreateWindow(parent()); QCocoaWindow *parentCocoaWindow = 0; if (window()->transientParent()) { @@ -264,8 +264,8 @@ void QCocoaWindow::setVisible(bool visible) // Register popup windows so that the parent window can // close them when needed. - if (window()->windowType() == Qt::Popup) { - // qDebug() << "transientParent and popup" << window()->windowType() << Qt::Popup << (window()->windowType() & Qt::Popup); + if (window()->type() == Qt::Popup) { + // qDebug() << "transientParent and popup" << window()->type() << Qt::Popup << (window()->type() & Qt::Popup); parentCocoaWindow->m_activePopupWindow = window(); } @@ -281,12 +281,12 @@ void QCocoaWindow::setVisible(bool visible) syncWindowState(window()->windowState()); if (window()->windowState() != Qt::WindowMinimized) { - if ((window()->windowModality() == Qt::WindowModal - || window()->windowType() == Qt::Sheet) + if ((window()->modality() == Qt::WindowModal + || window()->type() == Qt::Sheet) && parentCocoaWindow) { // show the window as a sheet [NSApp beginSheet:m_nsWindow modalForWindow:parentCocoaWindow->m_nsWindow modalDelegate:nil didEndSelector:nil contextInfo:nil]; - } else if (window()->windowModality() != Qt::NonModal) { + } else if (window()->modality() != Qt::NonModal) { // show the window as application modal QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast(QGuiApplication::instance()->eventDispatcher()); Q_ASSERT(cocoaEventDispatcher != 0); @@ -300,7 +300,7 @@ void QCocoaWindow::setVisible(bool visible) } // We want the events to properly reach the popup - if (window()->windowType() == Qt::Popup) + if (window()->type() == Qt::Popup) [(NSPanel *)m_nsWindow setWorksWhenModal:YES]; } } @@ -366,7 +366,7 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags) Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; if (flags == Qt::Window) { styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask); - } else if ((flags & Qt::Dialog) && (window()->windowModality() != Qt::NonModal)) { + } else if ((flags & Qt::Dialog) && (window()->modality() != Qt::NonModal)) { styleMask = NSTitledWindowMask; } else if (!(flags & Qt::FramelessWindowHint)) { if (flags & Qt::WindowMaximizeButtonHint) @@ -435,7 +435,7 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon) NSButton *iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton]; if (iconButton == nil) { - NSString *title = QCFString::toNSString(window()->windowTitle()); + NSString *title = QCFString::toNSString(window()->title()); [m_nsWindow setRepresentedURL:[NSURL fileURLWithPath:title]]; iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton]; } @@ -596,7 +596,7 @@ void QCocoaWindow::windowWillClose() bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const { if (type == Qt::Widget) - type = window()->windowType(); + type = window()->type(); if (type == Qt::Tool) return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac. @@ -632,8 +632,8 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) // QPlatformWindow subclasses must sync up with QWindow on creation: propagateSizeHints(); - setWindowFlags(window()->windowFlags()); - setWindowTitle(window()->windowTitle()); + setWindowFlags(window()->flags()); + setWindowTitle(window()->title()); setWindowState(window()->windowState()); } else { // Child windows have no NSWindow, link the NSViews instead. @@ -648,8 +648,8 @@ NSWindow * QCocoaWindow::createNSWindow() NSRect frame = qt_mac_flipRect(window()->geometry(), window()); - Qt::WindowType type = window()->windowType(); - Qt::WindowFlags flags = window()->windowFlags(); + Qt::WindowType type = window()->type(); + Qt::WindowFlags flags = window()->flags(); NSUInteger styleMask = windowStyleMask(flags); NSWindow *createdWindow = 0; @@ -695,7 +695,7 @@ NSWindow * QCocoaWindow::createNSWindow() NSInteger level = windowLevel(flags); [createdWindow setLevel:level]; - m_windowModality = window()->windowModality(); + m_windowModality = window()->modality(); return createdWindow; } diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index 592586fde0..04fe558541 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -87,7 +87,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, QWindowsWindow *rw = QWindowsWindow::baseWindowOf(window); #ifndef Q_OS_WINCE - if (rw->format().hasAlpha() && (window->windowFlags() & Qt::FramelessWindowHint)) { + if (rw->format().hasAlpha() && (window->flags() & Qt::FramelessWindowHint)) { const long wl = GetWindowLong(rw->handle(), GWL_EXSTYLE); if ((wl & WS_EX_LAYERED) == 0) SetWindowLong(rw->handle(), GWL_EXSTYLE, wl | WS_EX_LAYERED); diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a0749388f9..aaa5573899 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -374,7 +374,7 @@ void QWindowsContext::setKeyGrabber(QWindow *w) QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) { - const Qt::WindowFlags flags = w ? w->windowFlags() : (Qt::WindowFlags)0; + const Qt::WindowFlags flags = w ? w->flags() : (Qt::WindowFlags)0; const Qt::WindowFlags type = flags & Qt::WindowType_Mask; uint style = 0; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index a02f0cd494..f6011ae082 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -354,10 +354,10 @@ QPlatformPixmap *QWindowsIntegration::createPlatformPixmap(QPlatformPixmap::Pixe QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const { QWindowsWindow::WindowData requested; - requested.flags = window->windowFlags(); + requested.flags = window->flags(); requested.geometry = window->geometry(); const QWindowsWindow::WindowData obtained - = QWindowsWindow::WindowData::create(window, requested, window->windowTitle()); + = QWindowsWindow::WindowData::create(window, requested, window->title()); if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) qDebug().nospace() << __FUNCTION__ << '<' << window << '\n' @@ -372,7 +372,7 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons if (!obtained.hwnd) return 0; if (requested.flags != obtained.flags) - window->setWindowFlags(obtained.flags); + window->setFlags(obtained.flags); return new QWindowsWindow(window, obtained); } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index c11bd8c53c..993a8d4228 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -682,16 +682,16 @@ static void showSystemMenu(QWindow* w) #define enabled (MF_BYCOMMAND | MF_ENABLED) #define disabled (MF_BYCOMMAND | MF_GRAYED) - EnableMenuItem(menu, SC_MINIMIZE, (topLevel->windowFlags() & Qt::WindowMinimizeButtonHint)?enabled:disabled); + EnableMenuItem(menu, SC_MINIMIZE, (topLevel->flags() & Qt::WindowMinimizeButtonHint)?enabled:disabled); bool maximized = IsZoomed(topLevelHwnd); - EnableMenuItem(menu, SC_MAXIMIZE, ! (topLevel->windowFlags() & Qt::WindowMaximizeButtonHint) || maximized?disabled:enabled); + EnableMenuItem(menu, SC_MAXIMIZE, ! (topLevel->flags() & Qt::WindowMaximizeButtonHint) || maximized?disabled:enabled); EnableMenuItem(menu, SC_RESTORE, maximized?enabled:disabled); // We should _not_ check with the setFixedSize(x,y) case here, since Windows is not able to check // this and our menu here would be out-of-sync with the menu produced by mouse-click on the // System Menu, or right-click on the title bar. - EnableMenuItem(menu, SC_SIZE, (topLevel->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) || maximized?disabled:enabled); + EnableMenuItem(menu, SC_SIZE, (topLevel->flags() & Qt::MSWindowsFixedSizeDialogHint) || maximized?disabled:enabled); EnableMenuItem(menu, SC_MOVE, maximized?disabled:enabled); EnableMenuItem(menu, SC_CLOSE, enabled); // Set bold on close menu item diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9aada91e73..25aae11d87 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -715,7 +715,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : setFlag(OpenGLSurface); QWindowsContext::instance()->addWindow(m_data.hwnd, this); if (aWindow->isTopLevel()) { - switch (aWindow->windowType()) { + switch (aWindow->type()) { case Qt::Window: case Qt::Dialog: case Qt::Sheet: @@ -893,8 +893,8 @@ void QWindowsWindow::show_sys() const int sm = SW_SHOWNORMAL; bool fakedMaximize = false; const QWindow *w = window(); - const Qt::WindowFlags flags = w->windowFlags(); - const Qt::WindowType type = w->windowType(); + const Qt::WindowFlags flags = w->flags(); + const Qt::WindowType type = w->type(); if (w->isTopLevel()) { const Qt::WindowState state = w->windowState(); if (state & Qt::WindowMinimized) { @@ -931,7 +931,7 @@ void QWindowsWindow::show_sys() const // partially from QWidgetPrivate::hide_sys() void QWindowsWindow::hide_sys() const { - const Qt::WindowFlags flags = window()->windowFlags(); + const Qt::WindowFlags flags = window()->flags(); if (flags != Qt::Desktop) { if (flags & Qt::Popup) ShowWindow(m_data.hwnd, SW_HIDE); @@ -979,7 +979,7 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const // to dialog frames, etc (see SetParent() ) if the top level state changes. if (wasTopLevel != isTopLevel) { const unsigned flags = isTopLevel ? unsigned(0) : unsigned(WindowCreationData::ForceChild); - setWindowFlags_sys(window()->windowFlags(), flags); + setWindowFlags_sys(window()->flags(), flags); } } } diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 27a926eca2..cd7237e4b4 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -396,7 +396,7 @@ void QXcbDrag::move(const QMouseEvent *me) QXcbWindow *w = 0; if (target) { w = connection()->platformWindowFromId(target); - if (w && (w->window()->windowType() == Qt::Desktop) /*&& !w->acceptDrops()*/) + if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) w = 0; } else { w = 0; @@ -507,7 +507,7 @@ void QXcbDrag::drop(const QMouseEvent *event) QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); - if (w && (w->window()->windowType() == Qt::Desktop) /*&& !w->acceptDrops()*/) + if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) w = 0; Transaction t = { @@ -722,7 +722,7 @@ void QXcbDrag::handle_xdnd_position(QWindow *w, const xcb_client_message_event_t p -= geometry.topLeft(); - if (!w || (w->windowType() == Qt::Desktop)) + if (!w || (w->type() == Qt::Desktop)) return; if (e->data.data32[0] != xdnd_dragsource) { @@ -912,7 +912,7 @@ void QXcbDrag::send_leave() QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); - if (w && (w->window()->windowType() == Qt::Desktop) /*&& !w->acceptDrops()*/) + if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) w = 0; if (w) @@ -1157,7 +1157,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) DNDDEBUG << "xdndEnable" << w << on; if (on) { QXcbWindow *xdnd_widget = 0; - if ((w->window()->windowType() == Qt::Desktop)) { + if ((w->window()->type() == Qt::Desktop)) { if (desktop_proxy) // *WE* already have one. return false; @@ -1191,7 +1191,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) return false; } } else { - if ((w->window()->windowType() == Qt::Desktop)) { + if ((w->window()->type() == Qt::Desktop)) { xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy)); delete desktop_proxy; desktop_proxy = 0; @@ -1225,7 +1225,7 @@ QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type r QXcbConnection *c = drag->connection(); QXcbWindow *xcb_window = c->platformWindowFromId(drag->xdnd_dragsource); - if (xcb_window && drag->currentDrag() && xcb_window->window()->windowType() != Qt::Desktop) { + if (xcb_window && drag->currentDrag() && xcb_window->window()->type() != Qt::Desktop) { QMimeData *data = drag->currentDrag()->mimeData(); if (data->hasFormat(QLatin1String(format))) result = data->data(QLatin1String(format)); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e29218d951..81ab3fe4ee 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -121,13 +121,13 @@ QT_BEGIN_NAMESPACE // Returns true if we should set WM_TRANSIENT_FOR on \a w static inline bool isTransient(const QWindow *w) { - return w->windowType() == Qt::Dialog - || w->windowType() == Qt::Sheet - || w->windowType() == Qt::Tool - || w->windowType() == Qt::SplashScreen - || w->windowType() == Qt::ToolTip - || w->windowType() == Qt::Drawer - || w->windowType() == Qt::Popup; + return w->type() == Qt::Dialog + || w->type() == Qt::Sheet + || w->type() == Qt::Tool + || w->type() == Qt::SplashScreen + || w->type() == Qt::ToolTip + || w->type() == Qt::Drawer + || w->type() == Qt::Popup; } static inline QImage::Format imageFormatForDepth(int depth) @@ -175,7 +175,7 @@ void QXcbWindow::create() m_configureNotifyPending = true; m_windowState = Qt::WindowNoState; - Qt::WindowType type = window()->windowType(); + Qt::WindowType type = window()->type(); if (type == Qt::Desktop) { m_window = m_screen->root(); @@ -309,7 +309,7 @@ void QXcbWindow::create() if (m_screen->syncRequestSupported()) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); - if (window()->windowFlags() & Qt::WindowContextHelpButtonHint) + if (window()->flags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); Q_XCB_CALL(xcb_change_property(xcb_connection(), @@ -347,7 +347,7 @@ void QXcbWindow::create() memset(&hints, 0, sizeof(hints)); xcb_wm_hints_set_normal(&hints); - xcb_wm_hints_set_input(&hints, !(window()->windowFlags() & Qt::WindowDoesNotAcceptFocus)); + xcb_wm_hints_set_input(&hints, !(window()->flags() & Qt::WindowDoesNotAcceptFocus)); xcb_set_wm_hints(xcb_connection(), m_window, &hints); @@ -375,11 +375,11 @@ void QXcbWindow::create() connection()->xi2Select(m_window); #endif - setWindowFlags(window()->windowFlags()); - setWindowTitle(window()->windowTitle()); setWindowState(window()->windowState()); + setWindowFlags(window()->flags()); + setWindowTitle(window()->title()); - if (window()->windowFlags() & Qt::WindowTransparentForInput) + if (window()->flags() & Qt::WindowTransparentForInput) setTransparentForMouseEvents(true); #ifndef QT_NO_DRAGANDDROP @@ -534,7 +534,7 @@ void QXcbWindow::show() else xcb_wm_hints_set_normal(&hints); - xcb_wm_hints_set_input(&hints, !(window()->windowFlags() & Qt::WindowDoesNotAcceptFocus)); + xcb_wm_hints_set_input(&hints, !(window()->flags() & Qt::WindowDoesNotAcceptFocus)); xcb_set_wm_hints(xcb_connection(), m_window, &hints); @@ -943,8 +943,8 @@ void QXcbWindow::updateMotifWmHintsBeforeMap() { QtMotifWmHints mwmhints = getMotifWmHints(connection(), m_window); - if (window()->windowModality() != Qt::NonModal) { - switch (window()->windowModality()) { + if (window()->modality() != Qt::NonModal) { + switch (window()->modality()) { case Qt::WindowModal: mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL; break; @@ -979,17 +979,17 @@ void QXcbWindow::updateMotifWmHintsBeforeMap() } } - if (window()->windowFlags() & Qt::WindowMinimizeButtonHint) { + if (window()->flags() & Qt::WindowMinimizeButtonHint) { mwmhints.flags |= MWM_HINTS_DECORATIONS; mwmhints.decorations |= MWM_DECOR_MINIMIZE; mwmhints.functions |= MWM_FUNC_MINIMIZE; } - if (window()->windowFlags() & Qt::WindowMaximizeButtonHint) { + if (window()->flags() & Qt::WindowMaximizeButtonHint) { mwmhints.flags |= MWM_HINTS_DECORATIONS; mwmhints.decorations |= MWM_DECOR_MAXIMIZE; mwmhints.functions |= MWM_FUNC_MAXIMIZE; } - if (window()->windowFlags() & Qt::WindowCloseButtonHint) + if (window()->flags() & Qt::WindowCloseButtonHint) mwmhints.functions |= MWM_FUNC_CLOSE; setMotifWmHints(connection(), m_window, mwmhints); @@ -999,7 +999,7 @@ void QXcbWindow::updateNetWmStateBeforeMap() { NetWmStates states(0); - const Qt::WindowFlags flags = window()->windowFlags(); + const Qt::WindowFlags flags = window()->flags(); if (flags & Qt::WindowStaysOnTopHint) { states |= NetWmStateAbove; states |= NetWmStateStaysOnTop; @@ -1015,7 +1015,7 @@ void QXcbWindow::updateNetWmStateBeforeMap() states |= NetWmStateMaximizedVert; } - if (window()->windowModality() != Qt::NonModal) + if (window()->modality() != Qt::NonModal) states |= NetWmStateModal; setNetWmStates(states); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 4a5fe0e82b..aeceba1886 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2331,7 +2331,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin return false; } - Qt::WindowModality windowModality = modalWindow->windowModality(); + Qt::WindowModality windowModality = modalWindow->modality(); QWidgetWindow *modalWidgetWindow = qobject_cast(modalWindow); if (windowModality == Qt::NonModal) { // determine the modality type if it hasn't been set on the diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 2950c19768..b4d9b9d2e3 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -107,7 +107,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win = topData()->window; } - win->setWindowFlags(data.window_flags); + win->setFlags(data.window_flags); fixPosIncludesFrame(); win->setGeometry(q->geometry()); win->setScreen(QGuiApplication::screens().value(topData()->screenIndex, 0)); @@ -134,7 +134,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive; win->create(); - data.window_flags = win->windowFlags(); + data.window_flags = win->flags(); QBackingStore *store = q->backingStore(); @@ -227,7 +227,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? if (q->windowHandle()) { - q->windowHandle()->setWindowFlags(f); + q->windowHandle()->setFlags(f); QWidget *parentWithWindow = newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0; if (parentWithWindow) { @@ -342,7 +342,7 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption) return; if (QWindow *window = q->windowHandle()) - window->setWindowTitle(caption); + window->setTitle(caption); } @@ -353,14 +353,14 @@ void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath) return; if (QWindow *window = q->windowHandle()) - window->setWindowFilePath(filePath); + window->setFilePath(filePath); } void QWidgetPrivate::setWindowIcon_sys() { Q_Q(QWidget); if (QWindow *window = q->windowHandle()) - window->setWindowIcon(q->windowIcon()); + window->setIcon(q->windowIcon()); } void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) @@ -463,7 +463,7 @@ void QWidget::activateWindow() QWindow *const wnd = window()->windowHandle(); if (wnd) - wnd->requestActivateWindow(); + wnd->requestActivate(); } // Position top level windows at the center, avoid showing @@ -640,7 +640,7 @@ void QWidgetPrivate::setFocus_sys() if (QWindow *nativeWindow = q->window()->windowHandle()) { if (nativeWindow != QGuiApplication::focusWindow() && q->testAttribute(Qt::WA_WState_Created)) { - nativeWindow->requestActivateWindow(); + nativeWindow->requestActivate(); } } } @@ -987,7 +987,7 @@ void QWidgetPrivate::setModal_sys() { Q_Q(QWidget); if (q->windowHandle()) - q->windowHandle()->setWindowModality(q->windowModality()); + q->windowHandle()->setModality(q->windowModality()); } #ifndef QT_NO_CURSOR diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index a7c38d6664..3417e18b7f 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -111,7 +111,7 @@ void tst_QGuiApplication::focusObject() // verify active window focus propagates to qguiapplication - window1.requestActivateWindow(); + window1.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&window1)); QCOMPARE(app.focusWindow(), &window1); @@ -247,10 +247,10 @@ void tst_QGuiApplication::changeFocusWindow() window2.show(); QVERIFY(QTest::qWaitForWindowExposed(&window1)); QVERIFY(QTest::qWaitForWindowExposed(&window2)); - window1.requestActivateWindow(); + window1.requestActivate(); QTRY_COMPARE(app.focusWindow(), &window1); - window2.requestActivateWindow(); + window2.requestActivate(); QTRY_COMPARE(app.focusWindow(), &window2); QCOMPARE(window1.windowDuringFocusAboutToChange, &window1); QCOMPARE(window1.windowDuringFocusOut, &window2); @@ -381,14 +381,14 @@ void tst_QGuiApplication::modalWindow() BlockableWindow *windowModalWindow1 = new BlockableWindow; windowModalWindow1->setTransientParent(window1); - windowModalWindow1->setWindowModality(Qt::WindowModal); + windowModalWindow1->setModality(Qt::WindowModal); BlockableWindow *windowModalWindow2 = new BlockableWindow; windowModalWindow2->setTransientParent(windowModalWindow1); - windowModalWindow2->setWindowModality(Qt::WindowModal); + windowModalWindow2->setModality(Qt::WindowModal); BlockableWindow *applicationModalWindow1 = new BlockableWindow; - applicationModalWindow1->setWindowModality(Qt::ApplicationModal); + applicationModalWindow1->setModality(Qt::ApplicationModal); // show the 2 windows, nothing is blocked window1->show(); diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index 21ed4c42b1..2697cdaa30 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -202,7 +202,7 @@ void tst_qinputmethod::cursorRectangle() DummyWindow window; window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - window.requestActivateWindow(); + window.requestActivate(); QTRY_COMPARE(qApp->focusWindow(), &window); window.setFocusObject(&m_inputItem); @@ -300,7 +300,7 @@ void tst_qinputmethod::inputMethodAccepted() DummyWindow window; window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - window.requestActivateWindow(); + window.requestActivate(); QTRY_COMPARE(qApp->focusWindow(), &window); window.setFocusObject(&disabledItem); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index f85e48022a..a3eeeb15c7 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -113,7 +113,7 @@ public: Window() { reset(); - setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + setFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); } void reset() @@ -268,7 +268,7 @@ void tst_QWindow::isActive() QTRY_VERIFY(child.isExposed()); - child.requestActivateWindow(); + child.requestActivate(); QTRY_VERIFY(QGuiApplication::focusWindow() == &child); QVERIFY(child.isActive()); @@ -288,7 +288,7 @@ void tst_QWindow::isActive() dialog.setGeometry(110, 110, 300, 30); dialog.show(); - dialog.requestActivateWindow(); + dialog.requestActivate(); QTRY_VERIFY(dialog.isExposed()); QCoreApplication::processEvents(); @@ -302,7 +302,7 @@ void tst_QWindow::isActive() // parent is active QVERIFY(child.isActive()); - window.requestActivateWindow(); + window.requestActivate(); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); QCoreApplication::processEvents(); @@ -731,9 +731,9 @@ void tst_QWindow::orientation() window.reportContentOrientationChange(Qt::PrimaryOrientation); QCOMPARE(window.contentOrientation(), Qt::PrimaryOrientation); - QVERIFY(!window.requestWindowOrientation(Qt::LandscapeOrientation) || window.windowOrientation() == Qt::LandscapeOrientation); - QVERIFY(!window.requestWindowOrientation(Qt::PortraitOrientation) || window.windowOrientation() == Qt::PortraitOrientation); - QVERIFY(!window.requestWindowOrientation(Qt::PrimaryOrientation) || window.windowOrientation() == Qt::PrimaryOrientation); + QVERIFY(!window.requestOrientation(Qt::LandscapeOrientation) || window.orientation() == Qt::LandscapeOrientation); + QVERIFY(!window.requestOrientation(Qt::PortraitOrientation) || window.orientation() == Qt::PortraitOrientation); + QVERIFY(!window.requestOrientation(Qt::PrimaryOrientation) || window.orientation() == Qt::PrimaryOrientation); QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation))); window.reportContentOrientationChange(Qt::LandscapeOrientation); @@ -812,7 +812,7 @@ void tst_QWindow::activateAndClose() for (int i = 0; i < 10; ++i) { QWindow window; window.show(); - window.requestActivateWindow(); + window.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&window)); QCOMPARE(qGuiApp->focusWindow(), &window); } @@ -914,29 +914,29 @@ void tst_QWindow::windowModality() qRegisterMetaType("Qt::WindowModality"); QWindow window; - QSignalSpy spy(&window, SIGNAL(windowModalityChanged(Qt::WindowModality))); + QSignalSpy spy(&window, SIGNAL(modalityChanged(Qt::WindowModality))); - QCOMPARE(window.windowModality(), Qt::NonModal); - window.setWindowModality(Qt::NonModal); - QCOMPARE(window.windowModality(), Qt::NonModal); + QCOMPARE(window.modality(), Qt::NonModal); + window.setModality(Qt::NonModal); + QCOMPARE(window.modality(), Qt::NonModal); QCOMPARE(spy.count(), 0); - window.setWindowModality(Qt::WindowModal); - QCOMPARE(window.windowModality(), Qt::WindowModal); + window.setModality(Qt::WindowModal); + QCOMPARE(window.modality(), Qt::WindowModal); QCOMPARE(spy.count(), 1); - window.setWindowModality(Qt::WindowModal); - QCOMPARE(window.windowModality(), Qt::WindowModal); + window.setModality(Qt::WindowModal); + QCOMPARE(window.modality(), Qt::WindowModal); QCOMPARE(spy.count(), 1); - window.setWindowModality(Qt::ApplicationModal); - QCOMPARE(window.windowModality(), Qt::ApplicationModal); + window.setModality(Qt::ApplicationModal); + QCOMPARE(window.modality(), Qt::ApplicationModal); QCOMPARE(spy.count(), 2); - window.setWindowModality(Qt::ApplicationModal); - QCOMPARE(window.windowModality(), Qt::ApplicationModal); + window.setModality(Qt::ApplicationModal); + QCOMPARE(window.modality(), Qt::ApplicationModal); QCOMPARE(spy.count(), 2); - window.setWindowModality(Qt::NonModal); - QCOMPARE(window.windowModality(), Qt::NonModal); + window.setModality(Qt::NonModal); + QCOMPARE(window.modality(), Qt::NonModal); QCOMPARE(spy.count(), 3); } @@ -1050,13 +1050,13 @@ void tst_QWindow::windowModality_QTBUG27039() InputTestWindow modalA; modalA.setTransientParent(&parent); modalA.setGeometry(10, 10, 20, 20); - modalA.setWindowModality(Qt::ApplicationModal); + modalA.setModality(Qt::ApplicationModal); modalA.show(); InputTestWindow modalB; modalB.setTransientParent(&parent); modalB.setGeometry(30, 10, 20, 20); - modalB.setWindowModality(Qt::ApplicationModal); + modalB.setModality(Qt::ApplicationModal); modalB.show(); QPointF local(5, 5); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index d8d98a4126..242dacb55e 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -813,7 +813,7 @@ void tst_QAccessibility::mainWindowTest() child.setGeometry(10, 10, 20, 20); child.show(); - child.requestActivateWindow(); + child.requestActivate(); QTRY_VERIFY(QGuiApplication::focusWindow() == &child); QAccessibleStateChangeEvent deactivate(&window, activeState);