summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qmenu.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-06 11:17:51 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-06 11:20:35 (GMT)
commit5fe595a0275f035ceaef1c3078b63eafda21fbf4 (patch)
treefe90469c6d3235f2e874cb0ddbd352f4d1b7b1fb /src/gui/widgets/qmenu.cpp
parentb78d252137aa592f5998b1adea278f066e518ec6 (diff)
downloadQt-5fe595a0275f035ceaef1c3078b63eafda21fbf4.zip
Qt-5fe595a0275f035ceaef1c3078b63eafda21fbf4.tar.gz
Qt-5fe595a0275f035ceaef1c3078b63eafda21fbf4.tar.bz2
QMenu: small little code simplification
Reviewed-by: trustme
Diffstat (limited to 'src/gui/widgets/qmenu.cpp')
-rw-r--r--src/gui/widgets/qmenu.cpp17
1 files 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);