Make inputmask 'X' mask character require non-blank input
The implementation for the X mask would accept any printable character. Since that includes the blank character, there was no difference in behavior between the requiring X and optional x: both would allow the input to be unset, i.e. blank. This change should be seen in conjunction with the doc improvement qtbase:da0af1e and the corresponding change to the QLineEdit widget, where the same input mask handling code is duplicated. This patch series also concludes the old task questioning whether text() should strip blanks even when they are valid input (answer: yes, continue to do that), and so a couple of XFAILS was removed from the autotest. [ChangeLog][QtQuick][TextInput] Inputmask X character now requires non-blank input. Task-number: QTBUG-76320 Change-Id: I606ae04259f29f748b3ce604048c6eb6f10c2ff9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
ae44beb0ce
commit
f372438840
|
@ -3957,7 +3957,7 @@ bool QQuickTextInputPrivate::isValidInput(QChar key, QChar mask) const
|
|||
return true;
|
||||
break;
|
||||
case 'X':
|
||||
if (key.isPrint())
|
||||
if (key.isPrint() && key != m_blank)
|
||||
return true;
|
||||
break;
|
||||
case 'x':
|
||||
|
|
|
@ -6408,8 +6408,20 @@ void tst_qquicktextinput::setInputMask_data()
|
|||
QTest::newRow(QString(insert_mode + "blank=input").toLatin1())
|
||||
<< QString("9999;0")
|
||||
<< QString("2004")
|
||||
<< QString("24")
|
||||
<< QString("2004")
|
||||
<< QString("2004")
|
||||
<< bool(insert_text);
|
||||
QTest::newRow(QString(insert_mode + "any_opt").toLatin1())
|
||||
<< QString("@xxx@")
|
||||
<< QString("@A C@")
|
||||
<< QString("@AC@")
|
||||
<< QString("@A C@")
|
||||
<< bool(insert_text);
|
||||
QTest::newRow(QString(insert_mode + "any_req").toLatin1())
|
||||
<< QString("@XXX@")
|
||||
<< QString("@A C@")
|
||||
<< QString("@AC@@")
|
||||
<< QString("@AC@@")
|
||||
<< bool(insert_text);
|
||||
}
|
||||
}
|
||||
|
@ -6452,9 +6464,6 @@ void tst_qquicktextinput::setInputMask()
|
|||
QTest::keyClick(&window, input.at(i).toLatin1());
|
||||
}
|
||||
|
||||
QEXPECT_FAIL( "keys blank=input", "To eat blanks or not? Known issue. Task 43172", Abort);
|
||||
QEXPECT_FAIL( "insert blank=input", "To eat blanks or not? Known issue. Task 43172", Abort);
|
||||
|
||||
QCOMPARE(textInput->text(), expectedText);
|
||||
QCOMPARE(textInput->displayText(), expectedDisplay);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue