Version: (using Devel) Installed from: Compiled sources Compiler: gcc (GCC) 4.1.2 20061115 (prerelease) (SUSE Linux) OS: Linux I tried to use KRestrictedLine in my application, only to find out that the current version of KRestrictedLine doesn't work at all - setting any set of valid characters has no effect, it's still possible to write anything into the input line. The attached patch should fix this problem - partially at least, as it's still possible to copy/paste wrong characters. I don't know if KRestrictedLine is meant to be deprecated or not, either way, I suppose I'm going to use KLineEdit with a validator instead. The patch: Index: kdeui/widgets/krestrictedline.cpp =================================================================== --- kdeui/widgets/krestrictedline.cpp (revision 798773) +++ kdeui/widgets/krestrictedline.cpp (working copy) @@ -49,7 +49,7 @@ { // let KLineEdit process "special" keys and return/enter // so that we still can use the default key binding - if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || e->key() == Qt::Key_Delete || e->text().length() < 32) + if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace || (e->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::GroupSwitchModifier))) { KLineEdit::keyPressEvent(e); return;
Created attachment 24405 [details] patch Attaching the patch as a file.
Any progress/info on this bug? I just encountered the same problem in my application.
The patch works but the general implementation is not the best, as it can't filter out characters like "á" ('+a) as they aren't detected in the keyPressEvent I managed to write a better implementation that will work with every key using a custom QValidator. However it breaks the current behaviour of the "invalidChar(int)" signal as it returns a keycode, and such isn't possible when using the QValidator method I'm going to apply the patch until I can manage to improve the QValidator approach Regards
SVN commit 966333 by darioandres: Fix the broken behaviour of KRestrictedLine (this needs a better implementation) BUG: 161012 M +3 -1 krestrictedline.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=966333
SVN commit 966335 by darioandres: Backport to 4.2branch of: SVN commit 966333 by darioandres: Fix the broken behaviour of KRestrictedLine (this needs a better implementation) CCBUG: 161012 M +3 -1 krestrictedline.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=966335
Reopening as this is not fully fixed. (but it should work as the older versions)
SVN commit 1014077 by dfaure: Fix KRestrictedLine to not let composed characters like éèú etc. go through, if they're not wanted. And add test code for KRestrictedLine in klineedittest. But with possible event compression in keyPressEvent and the way inputMethodEvent works, we really get QStrings as input, not "int key" like the API assumes here. So we should really use a validator instead, so we can remove unwanted chars and keep the others, which means a different signal signature. Dario, can you commit your validator, commented out, for kde5? :-) CCBUG: 161012 M +22 -1 tests/klineedittest.cpp M +6 -1 tests/klineedittest.h M +38 -20 widgets/krestrictedline.cpp M +3 -3 widgets/krestrictedline.h WebSVN link: http://websvn.kde.org/?view=rev&revision=1014077
Created attachment 36616 [details] (Old) patch to use a QValidator The patch it is a bit old and I have already discovered some errors (small style issues), the invalidChar signal not being connected properly. But that can wait for KDE5.
Thanks for the report Tomas. Are you able to confirm if this is still an issue when building using KRestricedLine, thanks.
Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone!
This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone!