summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qdesktopwidget.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-09-08 18:21:03 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-11-08 11:39:38 +0000
commitb254b03dc3b1cfcfc5f17158d2470e0a9a946a0e (patch)
treeff04bed068bb7f2117d0e3ed63593f12340cff2e /src/widgets/kernel/qdesktopwidget.cpp
parenteeca8895fc7e585f497e908368b8cc1a509847d3 (diff)
Deprecate QDesktopWidget in favor of QScreen
[ChangeLog][QtWidgets] QDesktopWidget has been deprecated. Use the corresponding QScreen functions instead. Task-number: QTBUG-62094 Change-Id: I0941d2aa27a06ec650ca52d6467e5bfb0ad43459 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/widgets/kernel/qdesktopwidget.cpp')
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 09e39c7cff..5fb7882932 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -176,17 +176,26 @@ void QDesktopWidgetPrivate::_q_updateScreens()
// Notice that we trigger screenCountChanged even if a screen was removed and another one added,
// in which case the total number of screens did not change. This is the only way for applications
// to notice that a screen was swapped out against another one.
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit q->screenCountChanged(targetLength);
+QT_WARNING_POP
}
foreach (int changedScreen, changedScreens)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit q->resized(changedScreen);
+QT_WARNING_POP
}
void QDesktopWidgetPrivate::_q_availableGeometryChanged()
{
Q_Q(QDesktopWidget);
if (QScreen *screen = qobject_cast<QScreen *>(q->sender()))
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit q->workAreaResized(QGuiApplication::screens().indexOf(screen));
+QT_WARNING_POP
}
QDesktopWidget::QDesktopWidget()
@@ -268,13 +277,8 @@ const QRect QDesktopWidget::availableGeometry(int screenNo) const
const QRect QDesktopWidgetPrivate::availableGeometry(int screenNo)
{
- QList<QScreen *> screens = QGuiApplication::screens();
- if (screenNo == -1)
- screenNo = 0;
- if (screenNo < 0 || screenNo >= screens.size())
- return QRect();
- else
- return screens.at(screenNo)->availableGeometry();
+ const QScreen *screen = QDesktopWidgetPrivate::screen(screenNo);
+ return screen ? screen->availableGeometry() : QRect();
}
const QRect QDesktopWidget::screenGeometry(int screenNo) const
@@ -284,13 +288,8 @@ const QRect QDesktopWidget::screenGeometry(int screenNo) const
const QRect QDesktopWidgetPrivate::screenGeometry(int screenNo)
{
- QList<QScreen *> screens = QGuiApplication::screens();
- if (screenNo == -1)
- screenNo = 0;
- if (screenNo < 0 || screenNo >= screens.size())
- return QRect();
- else
- return screens.at(screenNo)->geometry();
+ const QScreen *screen = QDesktopWidgetPrivate::screen(screenNo);
+ return screen ? screen->geometry() : QRect();
}
int QDesktopWidget::screenNumber(const QWidget *w) const
@@ -356,6 +355,16 @@ int QDesktopWidgetPrivate::screenNumber(const QPoint &p)
return screen ? QGuiApplication::screens().indexOf(screen) : primaryScreen();
}
+QScreen *QDesktopWidgetPrivate::screen(int screenNo)
+{
+ QList<QScreen *> screens = QGuiApplication::screens();
+ if (screenNo == -1)
+ screenNo = 0;
+ if (screenNo < 0 || screenNo >= screens.size())
+ return nullptr;
+ return screens.at(screenNo);
+}
+
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
}