Introduced QWindow properties {min/max}imum{Width/Height}
These are useful when QWindow is exposed to QML. Change-Id: I7ec49ef365183e2c784605889e8ea22c2ef34781 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>bb10
parent
774b643b85
commit
f01b498310
|
|
@ -941,9 +941,24 @@ void QWindow::setMinimumSize(const QSize &size)
|
|||
QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX));
|
||||
if (d->minimumSize == adjustedSize)
|
||||
return;
|
||||
QSize oldSize = d->minimumSize;
|
||||
d->minimumSize = adjustedSize;
|
||||
if (d->platformWindow && isTopLevel())
|
||||
d->platformWindow->propagateSizeHints();
|
||||
if (d->minimumSize.width() != oldSize.width())
|
||||
emit minimumWidthChanged(d->minimumSize.width());
|
||||
if (d->minimumSize.height() != oldSize.height())
|
||||
emit minimumHeightChanged(d->minimumSize.height());
|
||||
}
|
||||
|
||||
void QWindow::setMinimumWidth(int w)
|
||||
{
|
||||
setMinimumSize(QSize(w, minimumHeight()));
|
||||
}
|
||||
|
||||
void QWindow::setMinimumHeight(int h)
|
||||
{
|
||||
setMinimumSize(QSize(minimumWidth(), h));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -959,9 +974,24 @@ void QWindow::setMaximumSize(const QSize &size)
|
|||
QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX));
|
||||
if (d->maximumSize == adjustedSize)
|
||||
return;
|
||||
QSize oldSize = d->maximumSize;
|
||||
d->maximumSize = adjustedSize;
|
||||
if (d->platformWindow && isTopLevel())
|
||||
d->platformWindow->propagateSizeHints();
|
||||
if (d->maximumSize.width() != oldSize.width())
|
||||
emit maximumWidthChanged(d->maximumSize.width());
|
||||
if (d->maximumSize.height() != oldSize.height())
|
||||
emit maximumHeightChanged(d->maximumSize.height());
|
||||
}
|
||||
|
||||
void QWindow::setMaximumWidth(int w)
|
||||
{
|
||||
setMaximumSize(QSize(w, maximumHeight()));
|
||||
}
|
||||
|
||||
void QWindow::setMaximumHeight(int h)
|
||||
{
|
||||
setMaximumSize(QSize(maximumWidth(), h));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -1059,6 +1089,26 @@ void QWindow::setGeometry(const QRect &rect)
|
|||
\brief the height of the window's geometry
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QWindow::minimumWidth
|
||||
\brief the minimum width of the window's geometry
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QWindow::minimumHeight
|
||||
\brief the minimum height of the window's geometry
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QWindow::maximumWidth
|
||||
\brief the maximum width of the window's geometry
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QWindow::maximumHeight
|
||||
\brief the maximum height of the window's geometry
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the geometry of the window, excluding its window frame.
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,10 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
|
|||
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)
|
||||
Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
|
||||
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
|
||||
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
|
@ -170,6 +174,11 @@ public:
|
|||
|
||||
bool isExposed() const;
|
||||
|
||||
int minimumWidth() const { return minimumSize().width(); }
|
||||
int minimumHeight() const { return minimumSize().height(); }
|
||||
int maximumWidth() const { return maximumSize().width(); }
|
||||
int maximumHeight() const { return maximumSize().height(); }
|
||||
|
||||
QSize minimumSize() const;
|
||||
QSize maximumSize() const;
|
||||
QSize baseSize() const;
|
||||
|
|
@ -273,6 +282,11 @@ public Q_SLOTS:
|
|||
setGeometry(QRect(x(), y(), width(), arg));
|
||||
}
|
||||
|
||||
void setMinimumWidth(int w);
|
||||
void setMinimumHeight(int h);
|
||||
void setMaximumWidth(int w);
|
||||
void setMaximumHeight(int h);
|
||||
|
||||
Q_SIGNALS:
|
||||
void screenChanged(QScreen *screen);
|
||||
void windowModalityChanged(Qt::WindowModality windowModality);
|
||||
|
|
@ -283,6 +297,11 @@ Q_SIGNALS:
|
|||
void widthChanged(int arg);
|
||||
void heightChanged(int arg);
|
||||
|
||||
void minimumWidthChanged(int arg);
|
||||
void minimumHeightChanged(int arg);
|
||||
void maximumWidthChanged(int arg);
|
||||
void maximumHeightChanged(int arg);
|
||||
|
||||
void visibleChanged(bool arg);
|
||||
void contentOrientationChanged(Qt::ScreenOrientation orientation);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ public:
|
|||
, positionPolicy(WindowFrameExclusive)
|
||||
, contentOrientation(Qt::PrimaryOrientation)
|
||||
, windowOrientation(Qt::PrimaryOrientation)
|
||||
, minimumSize(0, 0)
|
||||
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
|
||||
, modality(Qt::NonModal)
|
||||
, blockedByModalWindow(false)
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ private slots:
|
|||
void touchCancel();
|
||||
void touchCancelWithTouchToMouse();
|
||||
void orientation();
|
||||
void sizes();
|
||||
void close();
|
||||
void activateAndClose();
|
||||
void mouseEventSequence();
|
||||
|
|
@ -739,6 +740,58 @@ void tst_QWindow::orientation()
|
|||
QCOMPARE(spy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_QWindow::sizes()
|
||||
{
|
||||
QWindow window;
|
||||
|
||||
QSignalSpy minimumWidthSpy(&window, SIGNAL(minimumWidthChanged(int)));
|
||||
QSignalSpy minimumHeightSpy(&window, SIGNAL(minimumHeightChanged(int)));
|
||||
QSignalSpy maximumWidthSpy(&window, SIGNAL(maximumWidthChanged(int)));
|
||||
QSignalSpy maximumHeightSpy(&window, SIGNAL(maximumHeightChanged(int)));
|
||||
|
||||
QSize oldMaximum = window.maximumSize();
|
||||
|
||||
window.setMinimumWidth(10);
|
||||
QCOMPARE(window.minimumWidth(), 10);
|
||||
QCOMPARE(window.minimumHeight(), 0);
|
||||
QCOMPARE(window.minimumSize(), QSize(10, 0));
|
||||
QCOMPARE(window.maximumSize(), oldMaximum);
|
||||
QCOMPARE(minimumWidthSpy.count(), 1);
|
||||
QCOMPARE(minimumHeightSpy.count(), 0);
|
||||
QCOMPARE(maximumWidthSpy.count(), 0);
|
||||
QCOMPARE(maximumHeightSpy.count(), 0);
|
||||
|
||||
window.setMinimumHeight(10);
|
||||
QCOMPARE(window.minimumWidth(), 10);
|
||||
QCOMPARE(window.minimumHeight(), 10);
|
||||
QCOMPARE(window.minimumSize(), QSize(10, 10));
|
||||
QCOMPARE(window.maximumSize(), oldMaximum);
|
||||
QCOMPARE(minimumWidthSpy.count(), 1);
|
||||
QCOMPARE(minimumHeightSpy.count(), 1);
|
||||
QCOMPARE(maximumWidthSpy.count(), 0);
|
||||
QCOMPARE(maximumHeightSpy.count(), 0);
|
||||
|
||||
window.setMaximumWidth(100);
|
||||
QCOMPARE(window.maximumWidth(), 100);
|
||||
QCOMPARE(window.maximumHeight(), oldMaximum.height());
|
||||
QCOMPARE(window.minimumSize(), QSize(10, 10));
|
||||
QCOMPARE(window.maximumSize(), QSize(100, oldMaximum.height()));
|
||||
QCOMPARE(minimumWidthSpy.count(), 1);
|
||||
QCOMPARE(minimumHeightSpy.count(), 1);
|
||||
QCOMPARE(maximumWidthSpy.count(), 1);
|
||||
QCOMPARE(maximumHeightSpy.count(), 0);
|
||||
|
||||
window.setMaximumHeight(100);
|
||||
QCOMPARE(window.maximumWidth(), 100);
|
||||
QCOMPARE(window.maximumHeight(), 100);
|
||||
QCOMPARE(window.minimumSize(), QSize(10, 10));
|
||||
QCOMPARE(window.maximumSize(), QSize(100, 100));
|
||||
QCOMPARE(minimumWidthSpy.count(), 1);
|
||||
QCOMPARE(minimumHeightSpy.count(), 1);
|
||||
QCOMPARE(maximumWidthSpy.count(), 1);
|
||||
QCOMPARE(maximumHeightSpy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_QWindow::close()
|
||||
{
|
||||
QWindow a;
|
||||
|
|
|
|||
Loading…
Reference in New Issue