summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMorten Sorvig <morten.sorvig@nokia.com>2011-10-26 10:00:26 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-27 09:37:29 +0200
commitdb44fdf4d65493706dc9a0aaf5e58729dc7867f9 (patch)
tree430231ce03f1ccc9720836714db2dda8a572a5b8 /src/plugins
parentaf8795c2b5305cf92df3249c6bd3cc6292415d8f (diff)
Cocoa: Implement propagateSizeHints.
Change-Id: Idc1244ffbf975972f01d9ee48092500a72739d37 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm20
4 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index 78904bc7a7..3c1c0655f8 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -77,6 +77,8 @@ CGImageRef qt_mac_image_to_cgimage(const QImage &image);
NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge);
NSImage *qt_mac_create_nsimage(const QPixmap &pm);
+NSSize qt_mac_toNSSize(const QSize &qtSize);
+
QChar qt_mac_qtKey2CocoaKey(Qt::Key key);
Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode);
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 7e82405ce3..113415f480 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -128,6 +128,10 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm)
return qt_mac_cgimage_to_nsimage(qt_mac_image_to_cgimage(image));
}
+NSSize qt_mac_toNSSize(const QSize &qtSize)
+{
+ return NSMakeSize(qtSize.width(), qtSize.height());
+}
// Use this method to keep all the information in the TextSegment. As long as it is ordered
// we are in OK shape, and we can influence that ourselves.
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index dde64a1859..23aab63b75 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -64,6 +64,8 @@ public:
void raise();
void lower();
+ void propagateSizeHints();
+
WId winId() const;
NSView *contentView() const;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 840d4d96da..e587b05dec 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -140,6 +140,26 @@ void QCocoaWindow::lower()
[m_nsWindow orderFront: m_nsWindow];
}
+void QCocoaWindow::propagateSizeHints()
+{
+ [m_nsWindow setMinSize : qt_mac_toNSSize(window()->minimumSize())];
+ [m_nsWindow setMaxSize : qt_mac_toNSSize(window()->maximumSize())];
+
+ if (!window()->sizeIncrement().isNull())
+ [m_nsWindow setResizeIncrements : qt_mac_toNSSize(window()->sizeIncrement())];
+
+ // We must set the window frame after setting the minimum size to prevent the window
+ // from being resized to the minimum size. Use QWindow::baseSize if set, otherwise
+ // use the current size.
+ QSize baseSize = window()->baseSize();
+ QRect rect = geometry();
+ if (!baseSize.isNull()) {
+ [m_nsWindow setFrame : NSMakeRect(rect.x(), rect.y(), baseSize.width(), baseSize.height()) display : YES];
+ } else {
+ [m_nsWindow setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) display : YES];
+ }
+}
+
WId QCocoaWindow::winId() const
{
return WId(m_nsWindow);