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>
This commit is contained in:
parent
3d3fdcd3a5
commit
4db95ffd7d
@ -69,6 +69,7 @@ QWindow::QWindow(QScreen *targetScreen)
|
|||||||
//screen list is populated.
|
//screen list is populated.
|
||||||
Q_ASSERT(d->screen);
|
Q_ASSERT(d->screen);
|
||||||
|
|
||||||
|
connect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
|
||||||
QGuiApplicationPrivate::window_list.prepend(this);
|
QGuiApplicationPrivate::window_list.prepend(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,12 +675,33 @@ void QWindow::setScreen(QScreen *newScreen)
|
|||||||
const bool wasCreated = d->platformWindow != 0;
|
const bool wasCreated = d->platformWindow != 0;
|
||||||
if (wasCreated)
|
if (wasCreated)
|
||||||
destroy();
|
destroy();
|
||||||
|
if (d->screen)
|
||||||
|
disconnect(d->screen, SIGNAL(destroyed(QObject *)), this, SLOT(screenDestroyed(QObject *)));
|
||||||
d->screen = newScreen;
|
d->screen = newScreen;
|
||||||
if (wasCreated)
|
if (newScreen) {
|
||||||
create();
|
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
|
Returns the accessibility interface for the object that the window represents
|
||||||
\preliminary
|
\preliminary
|
||||||
|
@ -248,6 +248,7 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void backBufferReady();
|
void backBufferReady();
|
||||||
|
void screenChanged(QScreen *screen);
|
||||||
|
|
||||||
void xChanged(int arg);
|
void xChanged(int arg);
|
||||||
|
|
||||||
@ -261,6 +262,9 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
void orientationChanged(Qt::ScreenOrientation arg);
|
void orientationChanged(Qt::ScreenOrientation arg);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void screenDestroyed(QObject *screen);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void exposeEvent(QExposeEvent *);
|
virtual void exposeEvent(QExposeEvent *);
|
||||||
virtual void resizeEvent(QResizeEvent *);
|
virtual void resizeEvent(QResizeEvent *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user