summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-14 10:06:26 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-14 10:07:56 (GMT)
commitaf2b01c4571b468a57cb4e5e72dab481f6d88eb1 (patch)
tree131655d6f0c2d8450a82f5cf412e5211c312f067 /src
parent0eb365bca2dc3b7244b3c9adec65a17cd36123be (diff)
downloadQt-af2b01c4571b468a57cb4e5e72dab481f6d88eb1.zip
Qt-af2b01c4571b468a57cb4e5e72dab481f6d88eb1.tar.gz
Qt-af2b01c4571b468a57cb4e5e72dab481f6d88eb1.tar.bz2
Use the correct font metrics function.
Qt::TextShowMnemonic removes the '&' for us. This is required if we want the multi-lenght-variant strings working. Reviewed-by: Thierry
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qmenu.cpp5
-rw-r--r--src/gui/widgets/qmenubar.cpp5
2 files changed, 2 insertions, 8 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 35b68b4..99f3880 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -285,10 +285,7 @@ void QMenuPrivate::updateActionRects() const
tabWidth = qMax(int(tabWidth), qfm.width(seq));
#endif
}
- int w = fm.boundingRect(QRect(), Qt::TextSingleLine, s).width();
- w -= s.count(QLatin1Char('&')) * fm.width(QLatin1Char('&'));
- w += s.count(QLatin1String("&&")) * fm.width(QLatin1Char('&'));
- sz.setWidth(w);
+ sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());
sz.setHeight(qMax(fm.height(), qfm.height()));
QIcon is = action->icon();
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index be6ed67..6b93879 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -447,10 +447,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
} else {
const QString s = action->text();
if(!s.isEmpty()) {
- const int w = fm.width(s)
- - s.count(QLatin1Char('&')) * fm.width(QLatin1Char('&'))
- + s.count(QLatin1String("&&")) * fm.width(QLatin1Char('&'));
- sz = QSize(w, fm.height());
+ sz = fm.size(Qt::TextShowMnemonic, s);
}
QIcon is = action->icon();