summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp14
-rw-r--r--src/gui/kernel/qwindow.cpp159
-rw-r--r--src/gui/kernel/qwindow.h47
4 files changed, 122 insertions, 100 deletions
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<QWindow *> &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<QWindow *> &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<Qt::WindowType>(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,9 +826,29 @@ 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
This is a hint to the window manager that this window is a dialog or pop-up
@@ -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<QHideEvent *>(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);