diff options
author | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-06-03 12:58:23 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-06-04 10:12:57 +0000 |
commit | f5bdd92e5d0217bf3eec13395e4baa95bd8fda37 (patch) | |
tree | da61d04b35ab82bd7adfa701aa47910a27272477 /src | |
parent | 77162b16ebda05e335291b9917b358d1c129096c (diff) |
Move min/max size constrain logic to QPlatformWindow.
This increases the uniformity of the to/fromNativePixels
functions by removing a special case, and avoids pulling
the qwindow_p.h details into qhihgdpiscaling.cpp.
Keep the logic of constraining the device-independent
size.
Change-Id: Id0dae30a7c0170ff2e5d21b94d56719cc900c726
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qhighdpiscaling_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 1 |
4 files changed, 11 insertions, 17 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 0adcc65a2c..be127a54f3 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qhighdpiscaling_p.h" -#include "qwindow_p.h" // for QWINDOWSIZE_MAX #include "qguiapplication.h" #include "qscreen.h" #include "qplatformintegration.h" @@ -228,15 +227,4 @@ QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen) return platformScreen->geometry().topLeft(); } - -Q_GUI_EXPORT QSize QHighDpi::toNativePixelsConstrained(const QSize &size, const QWindow *window) -{ - const int width = size.width(); - const int height = size.height(); - return QSize(width > 0 && width < QWINDOWSIZE_MAX ? - QHighDpi::toNativePixels(width, window) : width, - height > 0 && height < QWINDOWSIZE_MAX ? - QHighDpi::toNativePixels(height, window) : height); -} - QT_END_NAMESPACE diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 6c96fa2e07..8347214823 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -284,9 +284,6 @@ inline QSize fromNativePixels(const QSize &pixelSize, const QWindow *window) return pixelSize / QHighDpiScaling::factor(window); } -// For converting minimum/maximum sizes of QWindow, limits to 0..QWINDOWSIZE_MAX -Q_GUI_EXPORT QSize toNativePixelsConstrained(const QSize &size, const QWindow *window); - inline QSize toNativePixels(const QSize &pointSize, const QWindow *window) { return pointSize * QHighDpiScaling::factor(window); diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 94e2f18959..78b8001a98 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -497,6 +497,14 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co } /*! + Returns a size with both dimentions bounded to [0, QWINDOWSIZE_MAX] +*/ +QSize QPlatformWindow::constrainWindowSize(const QSize &size) +{ + return size.boundedTo(QSize(0, 0)).boundedTo(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)); +} + +/*! Reimplement this method to set whether the window demands attention (for example, by flashing the taskbar icon) depending on \a enabled. @@ -637,7 +645,7 @@ void QPlatformWindow::requestUpdate() */ QSize QPlatformWindow::windowMinimumSize() const { - return QHighDpi::toNativePixelsConstrained(window()->minimumSize(), window()); + return QHighDpi::toNativePixels(constrainWindowSize(window()->minimumSize()), window()); } /*! @@ -645,7 +653,7 @@ QSize QPlatformWindow::windowMinimumSize() const */ QSize QPlatformWindow::windowMaximumSize() const { - return QHighDpi::toNativePixelsConstrained(window()->maximumSize(), window()); + return QHighDpi::toNativePixels(constrainWindowSize(window()->maximumSize()), window()); } /*! diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 0690ce12e1..c1f2a4bdf1 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -141,6 +141,7 @@ public: protected: static QString formatWindowTitle(const QString &title, const QString &separator); QPlatformScreen *screenForGeometry(const QRect &newGeometry) const; + static QSize constrainWindowSize(const QSize &size); QScopedPointer<QPlatformWindowPrivate> d_ptr; private: |