[Kde-hardware-devel] [Patch] bluedevil: restrict PIN input to numeric
Torsten Duwe
duwe at suse.de
Wed Nov 24 17:26:58 CET 2010
[I'm somehow not able to upload this to reviewboard]
The current bluedevil PIN inputs allow for arbitrary characters to be entered;
especially tabs and newlines will prevent a successful pairing. This patch
changes the generic KLineEdit fields into KRestrictedLine, providing an
appropriate restriction to numeric input. The fields are also initialised as
empty. (I hope the <customwidget> tag forgives skipping an intermediate
class.)
Sigend-off-by: Torsten Duwe <duwe at suse.de>
--
daemon/helpers/requestpin/dialogWidget.ui | 8 ++++----
daemon/helpers/requestpin/requestpin.cpp | 1 +
wizard/pages/pin.ui | 8 ++++----
wizard/pages/pinpage.cpp | 1 +
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/daemon/helpers/requestpin/dialogWidget.ui
b/src/daemon/helpers/requestpin/dialogWidget.ui
index c222775..c81c621 100644
--- a/src/daemon/helpers/requestpin/dialogWidget.ui
+++ b/src/daemon/helpers/requestpin/dialogWidget.ui
@@ -46,9 +46,9 @@
</layout>
</item>
<item row="1" column="1">
- <widget class="KLineEdit" name="pin">
+ <widget class="KRestrictedLine" name="pin">
<property name="inputMask">
- <string notr="true">99999999; </string>
+ <string notr="true"></string>
</property>
<property name="maxLength">
<number>8</number>
@@ -85,9 +85,9 @@
</widget>
<customwidgets>
<customwidget>
- <class>KLineEdit</class>
+ <class>KRestrictedLine</class>
<extends>QLineEdit</extends>
- <header>klineedit.h</header>
+ <header>krestrictedline.h</header>
</customwidget>
</customwidgets>
<resources/>
diff --git a/src/daemon/helpers/requestpin/requestpin.cpp
b/src/daemon/helpers/requestpin/requestpin.cpp
index 9061b73..ebee3f5 100644
--- a/src/daemon/helpers/requestpin/requestpin.cpp
+++ b/src/daemon/helpers/requestpin/requestpin.cpp
@@ -94,6 +94,7 @@ void RequestPin::introducePin()
dialog->setMaximumWidth(300);
dialog->setMaximumHeight(150);
+ dialogWidget->pin->setValidChars(QString("0123456789"));
dialogWidget->pin->setFocus(Qt::ActiveWindowFocusReason);
if (dialog->exec() == KDialog::Accepted) {
cout << dialogWidget->pin->text().toLatin1().data();
diff --git a/src/wizard/pages/pin.ui b/src/wizard/pages/pin.ui
index 6ae86a3..364bfce 100644
--- a/src/wizard/pages/pin.ui
+++ b/src/wizard/pages/pin.ui
@@ -72,12 +72,12 @@
</widget>
</item>
<item>
- <widget class="KLineEdit" name="pinEdit">
+ <widget class="KRestrictedLine" name="pinEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="inputMask">
- <string notr="true">99999999; </string>
+ <string notr="true"></string>
</property>
<property name="text">
<string/>
@@ -141,9 +144,9 @@
</widget>
<customwidgets>
<customwidget>
- <class>KLineEdit</class>
+ <class>KRestrictedLine</class>
<extends>QLineEdit</extends>
- <header>klineedit.h</header>
+ <header>krestrictedline.h</header>
</customwidget>
</customwidgets>
<resources/>
diff --git a/src/wizard/pages/pinpage.cpp b/src/wizard/pages/pinpage.cpp
index a929d31..980540e 100644
--- a/src/wizard/pages/pinpage.cpp
+++ b/src/wizard/pages/pinpage.cpp
@@ -45,6 +45,7 @@ void PinPage::manualToggle(bool checked)
if (checked == true) {
pinEdit->setFocus();
pinEdit->setCursorPosition(0);
+ pinEdit->setValidChars(QString("0123456789"));
}
pinEdit->setEnabled(checked);
More information about the Kde-hardware-devel
mailing list