summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2012-11-01 17:03:45 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-02 12:16:49 +0100
commitf01b498310ea7c05ec73669b34cb83b9f159006f (patch)
tree43bf9895d85ac8ca405ba1041bec23bd44aaa3e1 /src/gui
parent774b643b850d770f16d04856aa613ebf394f913b (diff)
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>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qwindow.cpp50
-rw-r--r--src/gui/kernel/qwindow.h19
-rw-r--r--src/gui/kernel/qwindow_p.h1
3 files changed, 70 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index a17270912f..d845be3d01 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -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));
}
/*!
@@ -1060,6 +1090,26 @@ void QWindow::setGeometry(const QRect &rect)
*/
/*!
+ \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.
\sa frameMargins(), frameGeometry()
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 62268cd88a..4832adfb63 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -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);
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 159f05d1a5..bce6a4ff04 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -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)