Remove QWindow pos, geometry and size as properties; pos->position

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 <samuel.rodal@digia.com>
bb10
Shawn Rutledge 2012-10-22 17:06:23 +02:00 committed by The Qt Project
parent 9be15cc1dc
commit 672e7c875e
5 changed files with 49 additions and 35 deletions

View File

@ -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 geometry
\sa position()
*/
/*!
\property QWindow::size
\brief the size of the window excluding any window frame
\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::geometry
\brief the geometry 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
To make sure the window is visible, make sure the geometry is within
the virtual geometry of its screen.
See the \l{Window Geometry} documentation for an overview of geometry
issues with windows.
By default, this property contains a value that depends on the user's
platform and screen geometry.
\sa size, pos
\sa setPosition()
*/
/*!
\fn QSize QWindow::size() const
\brief get the size of the window excluding any window frame
\sa resize()
*/
/*!
\fn void QWindow::resize(int w, int h)
set the size of the window, excluding any window frame, to a QSize
constructed from width \a w and height \a h
\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);
}

View File

@ -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)); }

View File

@ -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;
}

View File

@ -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);

View File

@ -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());
}
}