summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-11-19 11:16:45 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-11-24 13:42:13 (GMT)
commitf31d0e45952276f3de9c049c84a0ea52ce370e7f (patch)
treeaf80a3db435935018afa1bc8b7965d589fe7269d
parentfc835ea41dffaa7ac6247c2d0d602aadf0e0f09b (diff)
downloadQt-f31d0e45952276f3de9c049c84a0ea52ce370e7f.zip
Qt-f31d0e45952276f3de9c049c84a0ea52ce370e7f.tar.gz
Qt-f31d0e45952276f3de9c049c84a0ea52ce370e7f.tar.bz2
Mac: Fixes broken window decorations for QGraphicsProxyWidget.
The problem was the QMacStyle didn't handle the pixel metric for PM_TitleBarHeight correctly when passing a style option containing an unitialized rect (empty rect). It already had special logic for invalid rects, so the fix is simply to extend the check to also handle empty rects. Auto-test included. Task-number: QTBUG-4160 Reviewed-by: msorvig
-rw-r--r--src/gui/styles/qmacstyle_mac.mm4
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp24
2 files changed, 26 insertions, 2 deletions
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 38c3feb..51c2a96 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -2155,9 +2155,9 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
wdi.titleWidth = tb->rect.width();
QCFType<HIShapeRef> region;
HIRect hirect = qt_hirectForQRect(tb->rect);
- if (hirect.size.width == -1)
+ if (hirect.size.width <= 0)
hirect.size.width = 100;
- if (hirect.size.height == -1)
+ if (hirect.size.height <= 0)
hirect.size.height = 30;
HIThemeGetWindowShape(&hirect, &wdi, kWindowTitleBarRgn, &region);
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 36ee22c..42d5268 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -181,6 +181,7 @@ private slots:
void updateAndDelete();
void inputMethod();
void clickFocus();
+ void windowFrameMargins();
};
// Subclass that exposes the protected functions.
@@ -3506,6 +3507,29 @@ void tst_QGraphicsProxyWidget::clickFocus()
QVERIFY(!proxy->widget()->hasFocus());
}
+void tst_QGraphicsProxyWidget::windowFrameMargins()
+{
+ // Make sure the top margin is non-zero when passing Qt::Window.
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window);
+
+ qreal left, top, right, bottom;
+ proxy->getWindowFrameMargins(&left, &top, &right, &bottom);
+ QVERIFY(top > 0);
+
+ proxy->setWidget(new QPushButton("testtest"));
+ proxy->getWindowFrameMargins(&left, &top, &right, &bottom);
+ QVERIFY(top > 0);
+
+ QGraphicsScene scene;
+ scene.addItem(proxy);
+ proxy->getWindowFrameMargins(&left, &top, &right, &bottom);
+ QVERIFY(top > 0);
+
+ proxy->unsetWindowFrameMargins();
+ proxy->getWindowFrameMargins(&left, &top, &right, &bottom);
+ QVERIFY(top > 0);
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"