diff options
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index db6afe1faa..bf3eb67778 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -115,6 +115,9 @@ QT_BEGIN_NAMESPACE windowing systems that do not make this information visible to the application, isExposed() will simply return the same value as isVisible(). + QWindow::Visibility queried through visibility() is a convenience API + combining the functions of visible() and windowState(). + \section1 Rendering There are two Qt APIs that can be used to render content into a window, @@ -216,6 +219,120 @@ QWindow::~QWindow() } /*! + \enum QWindow::Visibility + \since 5.1 + + This enum describes what part of the screen the window occupies or should + occupy. + + \value Windowed The window occupies part of the screen, but not necessarily + the entire screen. This state will occur only on windowing systems which + support showing multiple windows simultaneously. In this state it is + possible for the user to move and resize the window manually, if + WindowFlags permit it and if it is supported by the windowing system. + + \value Minimized The window is reduced to an entry or icon on the task bar, + dock, task list or desktop, depending on how the windowing system handles + minimized windows. + + \value Maximized The window occupies one entire screen, and the titlebar is + still visible. On most windowing systems this is the state achieved by + clicking the maximize button on the toolbar. + + \value FullScreen The window occupies one entire screen, is not resizable, + and there is no titlebar. On some platforms which do not support showing + multiple simultaneous windows, this can be the usual visibility when the + window is not hidden. + + \value AutomaticVisibility This means to give the window a default visible + state, which might be fullscreen or windowed depending on the platform. + It can be given as a parameter to setVisibility but will never be + read back from the visibility accessor. + + \value Hidden The window is not visible in any way, however it may remember + a latent visibility which can be restored by setting AutomaticVisibility. +*/ + +/*! + \property QWindow::visibility + \brief the screen-occupation state of the window + \since 5.1 + + Visibility is whether the window should appear in the windowing system as + normal, minimized, maximized, fullscreen or hidden. + + To set the visibility to AutomaticVisibility means to give the window + a default visible state, which might be fullscreen or windowed depending on + the platform. + When reading the visibility property you will always get the actual state, + never AutomaticVisibility. +*/ +QWindow::Visibility QWindow::visibility() const +{ + Q_D(const QWindow); + return d->visibility; +} + +void QWindow::setVisibility(Visibility v) +{ + switch (v) { + case Hidden: + hide(); + break; + case AutomaticVisibility: + show(); + break; + case Windowed: + showNormal(); + break; + case Minimized: + showMinimized(); + break; + case Maximized: + showMaximized(); + break; + case FullScreen: + showFullScreen(); + break; + default: + Q_ASSERT(false); + break; + } +} + +void QWindowPrivate::updateVisibility() +{ + Q_Q(QWindow); + + QWindow::Visibility old = visibility; + + if (visible) { + switch (windowState) { + case Qt::WindowMinimized: + visibility = QWindow::Minimized; + break; + case Qt::WindowMaximized: + visibility = QWindow::Maximized; + break; + case Qt::WindowFullScreen: + visibility = QWindow::FullScreen; + break; + case Qt::WindowNoState: + visibility = QWindow::Windowed; + break; + default: + Q_ASSERT(false); + break; + } + } else { + visibility = QWindow::Hidden; + } + + if (visibility != old) + emit q->visibilityChanged(visibility); +} + +/*! Sets the \a surfaceType of the window. Specifies whether the window is meant for raster rendering with @@ -264,6 +381,7 @@ void QWindow::setVisible(bool visible) return; d->visible = visible; emit visibleChanged(visible); + d->updateVisibility(); if (!d->platformWindow) create(); @@ -808,6 +926,7 @@ void QWindow::setWindowState(Qt::WindowState state) d->platformWindow->setWindowState(state); d->windowState = state; emit windowStateChanged(d->windowState); + d->updateVisibility(); } /*! @@ -1724,6 +1843,7 @@ bool QWindow::event(QEvent *ev) case QEvent::WindowStateChange: { Q_D(QWindow); emit windowStateChanged(d->windowState); + d->updateVisibility(); break; } |