diff options
author | Bill King <bill.king@nokia.com> | 2009-11-18 22:32:16 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-11-18 22:32:16 (GMT) |
commit | 0186faea383f3f8223bffd1844e5a47ca22770a5 (patch) | |
tree | 8b17a7c752ada7c06d1d9b88575d5bd467dd3fbe /src/gui/widgets/qlabel.cpp | |
parent | c7ef9c969fb368027135c5e7b0e9b6f53c465702 (diff) | |
parent | 80cd617b05ad3e647c87dc063d40cde0617344ca (diff) | |
download | Qt-0186faea383f3f8223bffd1844e5a47ca22770a5.zip Qt-0186faea383f3f8223bffd1844e5a47ca22770a5.tar.gz Qt-0186faea383f3f8223bffd1844e5a47ca22770a5.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/gui/widgets/qlabel.cpp')
-rw-r--r-- | src/gui/widgets/qlabel.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index 3d908a1..ea711e8 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -1170,22 +1170,10 @@ void QLabelPrivate::updateShortcut() // But then we do want to hide the ampersands, so we can't use shortcutId. hasShortcut = false; - if (control) { - ensureTextPopulated(); - // Underline the first character that follows an ampersand - shortcutCursor = control->document()->find(QLatin1String("&")); - if (shortcutCursor.isNull()) - return; - hasShortcut = true; - shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); - shortcutCursor.deleteChar(); // remove the ampersand - shortcutCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); - } else { - if (!text.contains(QLatin1Char('&'))) - return; - hasShortcut = true; - shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); - } + if (!text.contains(QLatin1Char('&'))) + return; + hasShortcut = true; + shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); } #endif // QT_NO_SHORTCUT @@ -1456,6 +1444,24 @@ void QLabelPrivate::ensureTextPopulated() const doc->setPlainText(text); #endif doc->setUndoRedoEnabled(false); + +#ifndef QT_NO_SHORTCUT + if (hasShortcut) { + // Underline the first character that follows an ampersand (and remove the others ampersands) + int from = 0; + bool found = false; + QTextCursor cursor; + while (!(cursor = control->document()->find((QLatin1String("&")), from)).isNull()) { + cursor.deleteChar(); // remove the ampersand + cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); + from = cursor.position(); + if (!found && cursor.selectedText() != QLatin1String("&")) { //not a second & + found = true; + shortcutCursor = cursor; + } + } + } +#endif } } textDirty = false; |