From 4a28e02ba9a4dbf15754a21856805cf140e35123 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Thu, 16 Jun 2022 14:49:52 -0400 Subject: [PATCH] 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 --- common/maliit/namespace.h | 3 +++ connection/waylandinputmethodconnection.cpp | 3 ++- input-context/minputcontext.cpp | 4 +++- src/quick/maliitquick.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/maliit/namespace.h b/common/maliit/namespace.h index 13e411bc..42e5985d 100644 --- a/common/maliit/namespace.h +++ b/common/maliit/namespace.h @@ -44,6 +44,9 @@ namespace Maliit { //! only integer numbers allowed NumberContentType, + //! only numbers and formatted characters + FormattedNumberContentType, + //! allows numbers and certain other characters used in phone numbers PhoneNumberContentType, diff --git a/connection/waylandinputmethodconnection.cpp b/connection/waylandinputmethodconnection.cpp index bef77287..1f4b066f 100644 --- a/connection/waylandinputmethodconnection.cpp +++ b/connection/waylandinputmethodconnection.cpp @@ -137,8 +137,9 @@ Maliit::TextContentType contentTypeFromWayland(uint32_t purpose) case QtWayland::zwp_text_input_v2::content_purpose_normal: return Maliit::FreeTextContentType; case QtWayland::zwp_text_input_v2::content_purpose_digits: - case QtWayland::zwp_text_input_v2::content_purpose_number: return Maliit::NumberContentType; + case QtWayland::zwp_text_input_v2::content_purpose_number: + return Maliit::FormattedNumberContentType; case QtWayland::zwp_text_input_v2::content_purpose_phone: return Maliit::PhoneNumberContentType; case QtWayland::zwp_text_input_v2::content_purpose_url: diff --git a/input-context/minputcontext.cpp b/input-context/minputcontext.cpp index dfe0df96..5984d135 100644 --- a/input-context/minputcontext.cpp +++ b/input-context/minputcontext.cpp @@ -643,8 +643,10 @@ Maliit::TextContentType MInputContext::contentType(Qt::InputMethodHints hints) c Maliit::TextContentType type = Maliit::FreeTextContentType; hints &= Qt::ImhExclusiveInputMask; - if (hints == Qt::ImhFormattedNumbersOnly || hints == Qt::ImhDigitsOnly) { + if ( hints == Qt::ImhDigitsOnly) { type = Maliit::NumberContentType; + } else if (hints == Qt::ImhFormattedNumbersOnly) { + type = Maliit::FormattedNumberContentType; } else if (hints == Qt::ImhDialableCharactersOnly) { type = Maliit::PhoneNumberContentType; } else if (hints == Qt::ImhEmailCharactersOnly) { diff --git a/src/quick/maliitquick.h b/src/quick/maliitquick.h index dba8f5d2..42776b18 100644 --- a/src/quick/maliitquick.h +++ b/src/quick/maliitquick.h @@ -37,6 +37,7 @@ class MaliitQuick: public QObject enum ContentType { FreeTextContentType = Maliit::FreeTextContentType, NumberContentType = Maliit::NumberContentType, + FormattedNumberContentType = Maliit::FormattedNumberContentType, PhoneNumberContentType = Maliit::PhoneNumberContentType, EmailContentType = Maliit::EmailContentType, UrlContentType = Maliit::UrlContentType,