Skip to content

Commit 9624fe2

Browse files
committed
Add FormattedNumberContentType separate from NumberContentType
As formatted numbers and pure digits are separate content requirements and should have separate keyboard panels, provide the API to treat them separately, as they are treated in toolkits and wayland protocols. Fixes #31
1 parent 5500d44 commit 9624fe2

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

common/maliit/namespace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ namespace Maliit {
4444
//! only integer numbers allowed
4545
NumberContentType,
4646

47+
//! only numbers and formatted characters
48+
FormattedNumberContentType,
49+
4750
//! allows numbers and certain other characters used in phone numbers
4851
PhoneNumberContentType,
4952

connection/waylandinputmethodconnection.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ Maliit::TextContentType contentTypeFromWayland(uint32_t purpose)
137137
case QtWayland::zwp_text_input_v2::content_purpose_normal:
138138
return Maliit::FreeTextContentType;
139139
case QtWayland::zwp_text_input_v2::content_purpose_digits:
140-
case QtWayland::zwp_text_input_v2::content_purpose_number:
141140
return Maliit::NumberContentType;
141+
case QtWayland::zwp_text_input_v2::content_purpose_number:
142+
return Maliit::FormattedNumberContentType;
142143
case QtWayland::zwp_text_input_v2::content_purpose_phone:
143144
return Maliit::PhoneNumberContentType;
144145
case QtWayland::zwp_text_input_v2::content_purpose_url:

input-context/minputcontext.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,10 @@ Maliit::TextContentType MInputContext::contentType(Qt::InputMethodHints hints) c
643643
Maliit::TextContentType type = Maliit::FreeTextContentType;
644644
hints &= Qt::ImhExclusiveInputMask;
645645

646-
if (hints == Qt::ImhFormattedNumbersOnly || hints == Qt::ImhDigitsOnly) {
646+
if ( hints == Qt::ImhDigitsOnly) {
647647
type = Maliit::NumberContentType;
648+
} else if (hints == Qt::ImhFormattedNumbersOnly) {
649+
type = Maliit::FormattedNumberContentType;
648650
} else if (hints == Qt::ImhDialableCharactersOnly) {
649651
type = Maliit::PhoneNumberContentType;
650652
} else if (hints == Qt::ImhEmailCharactersOnly) {

src/quick/maliitquick.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class MaliitQuick: public QObject
3737
enum ContentType {
3838
FreeTextContentType = Maliit::FreeTextContentType,
3939
NumberContentType = Maliit::NumberContentType,
40+
FormattedNumberContentType = Maliit::FormattedNumberContentType;
4041
PhoneNumberContentType = Maliit::PhoneNumberContentType,
4142
EmailContentType = Maliit::EmailContentType,
4243
UrlContentType = Maliit::UrlContentType,

0 commit comments

Comments
 (0)