From 5fe595a0275f035ceaef1c3078b63eafda21fbf4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 6 Aug 2009 13:17:51 +0200 Subject: QMenu: small little code simplification Reviewed-by: trustme --- src/gui/widgets/qmenu.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 3b6743a..ccf81f8 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1707,12 +1707,9 @@ QRect QMenu::actionGeometry(QAction *act) const QSize QMenu::sizeHint() const { Q_D(const QMenu); - ensurePolished(); d->updateActionRects(); QSize s; - QStyleOption opt(0); - opt.init(this); for (int i = 0; i < d->actionRects.count(); ++i) { const QRect &rect = d->actionRects.at(i); if (rect.isNull()) @@ -1725,15 +1722,11 @@ QSize QMenu::sizeHint() const // Note that the action rects calculated above already include // the top and left margins, so we only need to add margins for // the bottom and right. - if (const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this)) { - s.rwidth() += fw; - s.rheight() += fw; - } - - s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this); - s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this); - - s += QSize(d->rightmargin, d->bottommargin); + QStyleOption opt(0); + opt.init(this); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this); + s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin; + s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin; return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this); -- cgit v0.12