summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-11-28 15:58:03 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-29 14:00:01 +0100
commit4db95ffd7dd67f5657ddefd6e8072851e1d93c51 (patch)
treebdcb8e8dc60311c971df504dda94f73e80b973b7
parent3d3fdcd3a588722b0004f4ef0c91f01ebc6c7b96 (diff)
Added screenChanged() signal and handle screen destruction in QWindow.
It can be useful to get a signal when the QScreen changes, for example when having bindings to QScreen properties in QML. Change-Id: I919dd12c656485b28b393aec5eedac4c01593afc Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
-rw-r--r--src/gui/kernel/qwindow.cpp26
-rw-r--r--src/gui/kernel/qwindow.h4
2 files changed, 28 insertions, 2 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 4156fd87e6..400ed29380 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -69,6 +69,7 @@ QWindow::QWindow(QScreen *targetScreen)
//screen list is populated.
Q_ASSERT(d->screen);
+ connect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
QGuiApplicationPrivate::window_list.prepend(this);
}
@@ -674,12 +675,33 @@ void QWindow::setScreen(QScreen *newScreen)
const bool wasCreated = d->platformWindow != 0;
if (wasCreated)
destroy();
+ if (d->screen)
+ disconnect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
d->screen = newScreen;
- if (wasCreated)
- create();
+ if (newScreen) {
+ connect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
+ if (wasCreated)
+ create();
+ }
+ emit screenChanged(newScreen);
}
}
+void QWindow::screenDestroyed(QObject *object)
+{
+ Q_D(QWindow);
+ if (object == static_cast<QObject *>(d->screen))
+ setScreen(0);
+}
+
+/*!
+ \fn QWindow::screenChanged(QScreen *screen)
+
+ This signal is emitted when a window's screen changes, either
+ by being set explicitly with setScreen(), or automatically when
+ the window's screen is removed.
+*/
+
/*!
Returns the accessibility interface for the object that the window represents
\preliminary
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index c1dcee4121..11ff6b101d 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -248,6 +248,7 @@ public Q_SLOTS:
Q_SIGNALS:
void backBufferReady();
+ void screenChanged(QScreen *screen);
void xChanged(int arg);
@@ -261,6 +262,9 @@ Q_SIGNALS:
void orientationChanged(Qt::ScreenOrientation arg);
+private Q_SLOTS:
+ void screenDestroyed(QObject *screen);
+
protected:
virtual void exposeEvent(QExposeEvent *);
virtual void resizeEvent(QResizeEvent *);