From 0175ad4d3ff3de93645b4a8b300ef3b7d6e15c04 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 26 Sep 2014 12:36:43 +0200 Subject: Fix regression in metric calculation of text with mnemonics Even when we do not intend to display the text, we still need to go through the processing of mnemonics to remove them from the text. Instead of capping the max underlines to 0, the TextDontPrint option now just saves adding the underline formats. Task-number: QTBUG-41593 Change-Id: I67790650dbed0092de2c63e5d5a9349dc02d5846 Reviewed-by: Friedemann Kleint Reviewed-by: Robert Loehning Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp') diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 3effeb895e..5c2c805506 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -64,6 +64,7 @@ private slots: void elidedMultiLengthF(); void inFontUcs4(); void lineWidth(); + void mnemonicTextWidth(); }; tst_QFontMetrics::tst_QFontMetrics() @@ -331,5 +332,16 @@ void tst_QFontMetrics::lineWidth() QVERIFY(smallFontMetrics.lineWidth() < bigFontMetrics.lineWidth()); } +void tst_QFontMetrics::mnemonicTextWidth() +{ + // QTBUG-41593 + QFont f; + QFontMetrics fm(f); + const QString f1 = "File"; + const QString f2 = "&File"; + + QCOMPARE(fm.size(Qt::TextShowMnemonic, f1), fm.size(Qt::TextShowMnemonic, f2)); + QCOMPARE(fm.size(Qt::TextHideMnemonic, f1), fm.size(Qt::TextHideMnemonic, f2)); +} QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" -- cgit v1.2.3