diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-14 14:34:52 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-18 13:22:35 (GMT) |
commit | 020b02a16aa69fad173a3b32ec98f05e9a33034d (patch) | |
tree | 334598b0923e3e101ee517415da06750a6ae294a /src/gui/styles | |
parent | e7653f2d2cef626b1dc9ad07753b99c38b015eac (diff) | |
download | Qt-020b02a16aa69fad173a3b32ec98f05e9a33034d.zip Qt-020b02a16aa69fad173a3b32ec98f05e9a33034d.tar.gz Qt-020b02a16aa69fad173a3b32ec98f05e9a33034d.tar.bz2 |
Fixed: No margin between the text and the shortcut in menu with stylesheet
If padding, margin border are set on an menu item with stylesheet,
no space appeared between the text and the shortcut.
Fix that by adding the 12px space, same as in QCommonStyle equivalent
function
Note that this patch also remove unused code, since the variable with
and height were not used.
example to reproduce the bug: the following stylesheet on a mainwindow
that contains a menu with one action with a shortcut
QMenu::item { border: 1px solid red; }
Task-number: 252610
Reveiwed-by: jbache
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qstylesheetstyle.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index cd44bfd..fdd51c3 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4806,13 +4806,10 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) { return QSize(sz.width(), subRule.size().height()); } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) { - int width = csz.width(), height = qMax(csz.height(), mi->fontMetrics.height()); - if (!mi->icon.isNull()) { - int iconExtent = pixelMetric(PM_SmallIconSize); - height = qMax(height, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()); - } - width += mi->tabWidth; - return subRule.boxSize(csz.expandedTo(subRule.minimumContentsSize())); + int width = csz.width(); + if (mi->text.contains(QLatin1Char('\t'))) + width += 12; //as in QCommonStyle + return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height()))); } } break; |