Skip to content

Commit

Permalink
Add FormattedNumberContentType separate from NumberContentType
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dobey committed Sep 23, 2022
1 parent b3f8613 commit 7471360
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/maliit/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
3 changes: 2 additions & 1 deletion connection/waylandinputmethodconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion input-context/minputcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/quick/maliitquick.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7471360

Please sign in to comment.