diff --git a/imports/QtDesktop/TextField.qml b/imports/QtDesktop/TextField.qml
index 3d2ca196617fe33acf93b12b257de399d2782083..81d5605c323c78910db8e99d20c8ea28a5abad0d 100644
--- a/imports/QtDesktop/TextField.qml
+++ b/imports/QtDesktop/TextField.qml
@@ -170,7 +170,7 @@ FocusScope {
         selectedTextColor: syspal.highlightedText
 
         // Todo move these margins to StyleItem
-        anchors.leftMargin: 4
+        anchors.leftMargin: styleHint.indexOf("rounded") > -1 ? 8: 4
         anchors.topMargin: 4
         anchors.rightMargin: 4
         anchors.bottomMargin: 4
diff --git a/src/qstyleitem.cpp b/src/qstyleitem.cpp
index 18986887e1075b385d48b97f8b5c0907852778df..9a81d6f56466baea15aa4868791e0617a8173df5 100644
--- a/src/qstyleitem.cpp
+++ b/src/qstyleitem.cpp
@@ -60,6 +60,36 @@ static inline HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &re
                       convertRect.width() - rect.width(), convertRect.height() - rect.height());
 }
 
+/*! \internal
+
+    Returns the CoreGraphics CGContextRef of the paint device. 0 is
+    returned if it can't be obtained. It is the caller's responsibility to
+    CGContextRelease the context when finished using it.
+
+    \warning This function is only available on Mac OS X.
+    \warning This function is duplicated in qmacstyle_mac.mm
+*/
+CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
+{
+
+    if (pdev->devType() == QInternal::Image) {
+         const QImage *i = static_cast<const  QImage*>(pdev);
+         QImage *image = const_cast< QImage*>(i);
+        CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
+        uint flags = kCGImageAlphaPremultipliedFirst;
+        flags |= kCGBitmapByteOrder32Host;
+        CGContextRef ret = 0;
+
+        ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
+                                    8, image->bytesPerLine(), colorspace, flags);
+
+        CGContextTranslateCTM(ret, 0, image->height());
+        CGContextScaleCTM(ret, 1, -1);
+        return ret;
+    }
+    return 0;
+}
+
 #endif
 
 QStyleItem::QStyleItem(QQuickPaintedItem *parent)
@@ -107,6 +137,7 @@ QStyleItem::QStyleItem(QQuickPaintedItem *parent)
     connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem()));
     connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem()));
 
+    connect(this, SIGNAL(hintChanged()), this, SLOT(updateSizeHint()));
     connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint()));
     connect(this, SIGNAL(contentWidthChanged(int)), this, SLOT(updateSizeHint()));
     connect(this, SIGNAL(contentHeightChanged(int)), this, SLOT(updateSizeHint()));
@@ -545,6 +576,8 @@ QSize QStyleItem::sizeFromContents(int width, int height)
         break;
     case Edit:
         size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, m_styleoption, QSize(width,height));
+        if (hint().contains("rounded"))
+            size += QSize(0, 2);
         break;
     case GroupBox:
         size = qApp->style()->sizeFromContents(QStyle::CT_GroupBox, m_styleoption, QSize(width,height));
@@ -833,7 +866,7 @@ void QStyleItem::paint(QPainter *painter)
         break;
     case ToolButton:
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         if (style() == "mac" && hint().contains("segmented")) {
             const QPaintDevice *target = painter->device();
              HIThemeSegmentDrawInfo sgi;
@@ -891,7 +924,7 @@ void QStyleItem::paint(QPainter *painter)
         qApp->style()->drawControl(QStyle::CE_RadioButton, m_styleoption, painter);
         break;
     case Edit: {
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         if (style() == "mac" && hint().contains("rounded")) {
             const QPaintDevice *target = painter->device();
             HIThemeFrameDrawInfo fdi;
@@ -913,7 +946,7 @@ void QStyleItem::paint(QPainter *painter)
     }
         break;
     case MacHelpButton:
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     {
         const QPaintDevice *target = painter->device();
         HIThemeButtonDrawInfo fdi;