If decodestring can't translate the string return Qt::Key_unknown.

Change-Id: Ie082b326e944a28b4e29984a527e3841a05b32f6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
bb10
David Faure 2012-01-03 13:34:49 +01:00 committed by Qt by Nokia
parent 13c5c81cfa
commit 3e2f32547d
2 changed files with 9 additions and 0 deletions

View File

@ -1316,6 +1316,9 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
if (found)
break;
}
// We couldn't translate the key.
if (!found)
return Qt::Key_unknown;
}
return ret;
}

View File

@ -537,6 +537,9 @@ void tst_QKeySequence::parseString_data()
QTest::newRow("Win+A") << "Win+a" << QKeySequence(Qt::Key_unknown);
QTest::newRow("4+3=2") << "4+3=2" << QKeySequence(Qt::Key_unknown);
QTest::newRow("Super+Meta+A") << "Super+Meta+A" << QKeySequence(Qt::Key_unknown);
QTest::newRow("Meta+Trolls") << "Meta+Trolls" << QKeySequence(Qt::Key_unknown);
QTest::newRow("Alabama") << "Alabama" << QKeySequence(Qt::Key_unknown);
QTest::newRow("Simon+G") << "Simon+G" << QKeySequence(Qt::Key_unknown);
}
void tst_QKeySequence::parseString()
@ -559,6 +562,9 @@ void tst_QKeySequence::fromString()
QFETCH(QString, neutralString);
QFETCH(QString, platformString);
if (strSequence == "Ctrly") // Key_Unknown gives empty string
return;
QKeySequence ks1(strSequence);
QKeySequence ks2 = QKeySequence::fromString(ks1.toString());
QKeySequence ks3 = QKeySequence::fromString(neutralString, QKeySequence::PortableText);