From 5f481c98de872e7c58a17f090be697c241b9f256 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Thu, 24 Jan 2013 00:27:41 +0000 Subject: Establish an opacity property for the QWindow Change-Id: I1e399a41bc3aa890498d579f48d03cc6dee484bf Reviewed-by: Gunnar Sletta --- src/gui/kernel/qwindow.cpp | 17 ++++++++++++++--- src/gui/kernel/qwindow.h | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f55e337334..9344f18fa0 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -642,7 +642,8 @@ void QWindow::lower() } /*! - Sets the window's opacity in the windowing system to \a level. + \property QWindow::opacity + \brief The opacity of the window in the windowing system. If the windowing system supports window opacity, this can be used to fade the window in and out, or to make it semitransparent. @@ -650,15 +651,25 @@ void QWindow::lower() A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below is treated as fully transparent. Values inbetween represent varying levels of translucency between the two extremes. + + The default value is 1.0. */ void QWindow::setOpacity(qreal level) { Q_D(QWindow); - if (level == d->opacity) // #fixme: Add property for 5.1 + if (level == d->opacity) return; d->opacity = level; - if (d->platformWindow) + if (d->platformWindow) { d->platformWindow->setOpacity(level); + emit opacityChanged(level); + } +} + +qreal QWindow::opacity() const +{ + Q_D(const QWindow); + return d->opacity; } /*! diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 2e2f12a8ab..478262da3f 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -112,6 +112,7 @@ 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) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) public: @@ -148,6 +149,8 @@ public: QString title() const; void setOpacity(qreal level); + qreal opacity() const; + void requestActivate(); bool isActive() const; @@ -287,6 +290,8 @@ Q_SIGNALS: void focusObjectChanged(QObject *object); + void opacityChanged(qreal opacity); + private Q_SLOTS: void screenDestroyed(QObject *screen); -- cgit v1.2.3