diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-11 10:42:27 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-11 10:44:06 (GMT) |
commit | 2d97f299f5f25888656696c6dad0924b243ce4fd (patch) | |
tree | daf8d5c520b7de3f2bb7758b9af2d79134c06d37 /src/gui | |
parent | 5e3f81237aae96181c9315b8e7c6c5368629a000 (diff) | |
download | Qt-2d97f299f5f25888656696c6dad0924b243ce4fd.zip Qt-2d97f299f5f25888656696c6dad0924b243ce4fd.tar.gz Qt-2d97f299f5f25888656696c6dad0924b243ce4fd.tar.bz2 |
QKeySequence::mnemonic: add a warning if the text contains severals '&'
Task-number: QTBUG-5667
Reviewed-by: Gabriel
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 1a76083..89c18fb 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1014,9 +1014,12 @@ bool QKeySequence::isEmpty() const */ QKeySequence QKeySequence::mnemonic(const QString &text) { + QKeySequence ret; + if(qt_sequence_no_mnemonics) - return QKeySequence(); + return ret; + bool found = false; int p = 0; while (p >= 0) { p = text.indexOf(QLatin1Char('&'), p) + 1; @@ -1025,13 +1028,22 @@ QKeySequence QKeySequence::mnemonic(const QString &text) if (text.at(p) != QLatin1Char('&')) { QChar c = text.at(p); if (c.isPrint()) { - c = c.toUpper(); - return QKeySequence(c.unicode() + Qt::ALT); + if (!found) { + c = c.toUpper(); + ret = QKeySequence(c.unicode() + Qt::ALT); +#ifdef QT_NO_DEBUG + return ret; +#else + found = true; + } else { + qWarning(qPrintable(QString::fromLatin1("QKeySequence::mnemonic: \"%1\" contains multiple occurences of '&'").arg(text))); +#endif + } } } p++; } - return QKeySequence(); + return ret; } /*! |