diff options
author | Aleix Pol <aleixpol@kde.org> | 2014-06-25 15:09:09 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-02 23:14:19 +0200 |
commit | 5f504166203d9562ef5b41a0f18ae191aa34ee63 (patch) | |
tree | a9e528110a7fd16a06e07b94659f70a33be81e4e /src | |
parent | 0541516907da117c391b6c8d9820209673fcd9cd (diff) |
Make it possible to know when a screen is being removed
So far, we had to listen to the QObject::destroyed signal from the QScreen
class to figure out whether a screen was removed. Often, this is already
too late, given that most of the QWindows have been moved by then and we
don't get to react before the windows are being set to the primary screen.
This patch introduces a new signal that will notify about a screen removal
before the screen is started to be destroyed, so that the application gets
to decide what to do with the screens before Qt decides to move things around.
[ChangeLog][QtGui][QGuiApplication] Added QGuiApplication::screenRemoved
signal to inform that a screen has been removed, before Qt reacts to it.
Change-Id: I99304179f4d345cae581a87baac6cff7b8773dea
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.h | 1 |
4 files changed, 25 insertions, 1 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 87c95e6420..96bea942ea 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -897,7 +897,19 @@ QList<QScreen *> QGuiApplication::screens() This signal is emitted whenever a new screen \a screen has been added to the system. - \sa screens(), primaryScreen() + \sa screens(), primaryScreen(), screenRemoved() +*/ + +/*! + \fn void QGuiApplication::screenRemoved(QScreen *screen) + + This signal is emitted whenever a \a screen is removed from the system. It + provides an opportunity to manage the windows on the screen before Qt falls back + to moving them to the primary screen. + + \sa screens(), screenAdded(), QObject::destroyed(), QWindow::setScreen() + + \since 5.4 */ diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index 1b1e1dabff..6e751e1275 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -165,6 +165,7 @@ public: Q_SIGNALS: void fontDatabaseChanged(); void screenAdded(QScreen *screen); + void screenRemoved(QScreen *screen); void lastWindowClosed(); void focusObjectChanged(QObject *focusObject); void focusWindowChanged(QWindow *focusWindow); diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 70ee631fc8..90f48d4593 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -74,6 +74,16 @@ QScreen::QScreen(QPlatformScreen *screen) { } + +/*! + Destroys the screen. + */ +QScreen::~QScreen() +{ + if (qApp) + Q_EMIT qApp->screenRemoved(this); +} + /*! Get the platform screen handle. */ diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index bdd5939657..9e439f5a20 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -89,6 +89,7 @@ class Q_GUI_EXPORT QScreen : public QObject Q_PROPERTY(qreal refreshRate READ refreshRate NOTIFY refreshRateChanged) public: + ~QScreen(); QPlatformScreen *handle() const; QString name() const; |