From 672e7c875e8680818e23d0aef98129d95eb7e91c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 22 Oct 2012 17:06:23 +0200 Subject: [PATCH] Remove QWindow pos, geometry and size as properties; pos->position MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Abbreviated properties are to be avoided. But all 3 of these properties are redundant from the QML perspective; and because QRect, QPoint and QSize are (wisely) not QObjects, it's not possible to bind to _their_ properties, which make these QWindow properties less useful than users might assume that they are. Change-Id: I19c00b54b1d2712f9418e8bcf56e35a8008b89ef Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 51 ++++++++++++++++++--------- src/gui/kernel/qwindow.h | 9 ++--- src/gui/kernel/qwindow_p.h | 4 +-- src/testlib/qtestsystem.h | 2 +- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 12 +++---- 5 files changed, 46 insertions(+), 32 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index dd0e4dd..9fb3c70 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1056,9 +1056,14 @@ void QWindow::setSizeIncrement(const QSize &size) Sets the geometry of the window, excluding its window frame, to a rectangle constructed from \a posx, \a posy, \a w and \a h. - \sa geometry + \sa geometry() */ +/*! + \brief Sets the geometry of the window, excluding its window frame, to \a rect. + + \sa geometry() +*/ void QWindow::setGeometry(const QRect &rect) { Q_D(QWindow); @@ -1198,40 +1203,52 @@ void QWindow::setFramePos(const QPoint &point) } /*! - \property QWindow::pos - \brief the position of the window on the desktop + \fn void QWindow::setPosition(const QPoint &pt) + \brief set the position of the window on the desktop to \a pt + + \sa position() +*/ + +/*! + \fn void QWindow::setPosition(int posx, int posy) + \brief set the position of the window on the desktop to \a posx, \a posy - \sa geometry + \sa position() */ /*! - \property QWindow::size - \brief the size of the window excluding any window frame + \fn QPoint QWindow::position() const + \brief get the position of the window on the desktop excluding any window frame - \sa geometry + \sa setPosition() */ /*! - \property QWindow::geometry - \brief the geometry of the window excluding any window frame + \fn QSize QWindow::size() const + \brief get the size of the window excluding any window frame - To make sure the window is visible, make sure the geometry is within - the virtual geometry of its screen. + \sa resize() +*/ - See the \l{Window Geometry} documentation for an overview of geometry - issues with windows. +/*! + \fn void QWindow::resize(int w, int h) - By default, this property contains a value that depends on the user's - platform and screen geometry. + set the size of the window, excluding any window frame, to a QSize + constructed from width \a w and height \a h - \sa size, pos + \sa size(), geometry() */ +/*! + \brief set the size of the window, excluding any window frame, to \a newSize + + \sa size(), geometry() +*/ void QWindow::resize(const QSize &newSize) { Q_D(QWindow); if (d->platformWindow) { - d->platformWindow->setGeometry(QRect(pos(), newSize)); + d->platformWindow->setGeometry(QRect(position(), newSize)); } else { d->geometry.setSize(newSize); } diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 3b11a87..1d5a134 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -106,9 +106,6 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(QPoint pos READ pos WRITE setPos) - Q_PROPERTY(QSize size READ size WRITE resize) - Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry) Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) @@ -236,10 +233,10 @@ public: inline int y() const { return geometry().y(); } inline QSize size() const { return geometry().size(); } - inline QPoint pos() const { return geometry().topLeft(); } + inline QPoint position() const { return geometry().topLeft(); } - inline void setPos(const QPoint &pt) { setGeometry(QRect(pt, size())); } - inline void setPos(int posx, int posy) { setPos(QPoint(posx, posy)); } + inline void setPosition(const QPoint &pt) { setGeometry(QRect(pt, size())); } + inline void setPosition(int posx, int posy) { setPosition(QPoint(posx, posy)); } void resize(const QSize &newSize); inline void resize(int w, int h) { resize(QSize(w, h)); } diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index bce6a4f..e522368 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -104,9 +104,9 @@ public: QPoint globalPosition() const { Q_Q(const QWindow); - QPoint offset = q->pos(); + QPoint offset = q->position(); for (const QWindow *p = q->parent(); p; p = p->parent()) - offset += p->pos(); + offset += p->position(); return offset; } diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 094570b..dd60aae 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -92,7 +92,7 @@ namespace QTest // qWaitForWindowShown() will generate bogus results. if (window->isActive()) { int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever - while (window->pos().isNull()) { + while (window->position().isNull()) { if (waitNo++ > timeout / 10) break; qWait(10); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index a3eeeb1..6e1f221 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -186,10 +186,10 @@ void tst_QWindow::positioning() QMargins originalMargins = window.frameMargins(); - QCOMPARE(window.pos(), window.framePos() + QPoint(originalMargins.left(), originalMargins.top())); + QCOMPARE(window.position(), window.framePos() + QPoint(originalMargins.left(), originalMargins.top())); QVERIFY(window.frameGeometry().contains(window.geometry())); - QPoint originalPos = window.pos(); + QPoint originalPos = window.position(); QPoint originalFramePos = window.framePos(); window.setWindowState(Qt::WindowFullScreen); @@ -200,7 +200,7 @@ void tst_QWindow::positioning() QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 3); - QTRY_COMPARE(originalPos, window.pos()); + QTRY_COMPARE(originalPos, window.position()); QTRY_COMPARE(originalFramePos, window.framePos()); QTRY_COMPARE(originalMargins, window.frameMargins()); @@ -215,14 +215,14 @@ void tst_QWindow::positioning() QTRY_VERIFY(window.received(QEvent::Move)); QTRY_COMPARE(framePos, window.framePos()); QTRY_COMPARE(originalMargins, window.frameMargins()); - QCOMPARE(window.pos(), window.framePos() + QPoint(originalMargins.left(), originalMargins.top())); + QCOMPARE(window.position(), window.framePos() + QPoint(originalMargins.left(), originalMargins.top())); // and back to regular positioning window.reset(); - window.setPos(originalPos); + window.setPosition(originalPos); QTRY_VERIFY(window.received(QEvent::Move)); - QTRY_COMPARE(originalPos, window.pos()); + QTRY_COMPARE(originalPos, window.position()); } } -- 2.7.4