diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-29 15:34:39 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-29 15:34:39 (GMT) |
commit | 703491332328ad11fbdc78ffc26a82e291dd8bde (patch) | |
tree | 7827210254d4f0f90370c98b9e5d8981950b578c /src/gui | |
parent | 2f85cc0cb758b0efe4d7b5af1b79eda13be970f3 (diff) | |
download | Qt-703491332328ad11fbdc78ffc26a82e291dd8bde.zip Qt-703491332328ad11fbdc78ffc26a82e291dd8bde.tar.gz Qt-703491332328ad11fbdc78ffc26a82e291dd8bde.tar.bz2 |
QMenuBar: adding autotest for the geometry calculation
Also fixed a bug that would take the VMargin 3 times instead of 2.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/qmenubar.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 5a8c0e2..7982d98 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -273,8 +273,6 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const const_cast<QMenuBarPrivate*>(this)->updateGeometries(); QRect ret = actionRects.at(index); - const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); - ret.translate(fw, fw); return QStyle::visualRect(q->layoutDirection(), q->rect(), ret); } @@ -480,8 +478,9 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const } //calculate position - int x = ((start == -1) ? hmargin : start) + itemSpacing; - int y = vmargin; + const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); + int x = fw + ((start == -1) ? hmargin : start) + itemSpacing; + int y = fw + vmargin; for(int i = 0; i < actions.count(); i++) { QRect &rect = actionRects[i]; if (rect.isNull()) @@ -1665,7 +1664,9 @@ QSize QMenuBar::sizeHint() const const QRect &actionRect = d->actionRects.at(i); ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height())); } - ret += QSize(2*fw + 2*hmargin, 2*fw + 2*vmargin); + //the action geometries already contain the top and left + //margins. So we only need to add those from right and bottom. + ret += QSize(fw + hmargin, fw + vmargin); } int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; if(d->leftWidget) { |