1 /*************************************************************************** 2 ** 3 ** Copyright (C) 2013 BlackBerry Limited. All rights reserved. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the plugins of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #include "qqnxabstractvirtualkeyboard.h" 41 42 QT_BEGIN_NAMESPACE 43 QQnxAbstractVirtualKeyboard(QObject * parent)44QQnxAbstractVirtualKeyboard::QQnxAbstractVirtualKeyboard(QObject *parent) 45 : QObject(parent) 46 , m_height(0) 47 , m_visible(false) 48 , m_locale(QLocale::system()) 49 , m_keyboardMode(Default) 50 , m_enterKeyType(DefaultReturn) 51 { 52 } 53 setKeyboardMode(KeyboardMode mode)54void QQnxAbstractVirtualKeyboard::setKeyboardMode(KeyboardMode mode) 55 { 56 if (mode == m_keyboardMode) 57 return; 58 59 m_keyboardMode = mode; 60 61 if (m_visible) 62 applyKeyboardOptions(); 63 } 64 setEnterKeyType(EnterKeyType type)65void QQnxAbstractVirtualKeyboard::setEnterKeyType(EnterKeyType type) 66 { 67 if (type == m_enterKeyType) 68 return; 69 70 m_enterKeyType = type; 71 72 if (m_visible) 73 applyKeyboardOptions(); 74 } 75 setInputHints(int inputHints)76void QQnxAbstractVirtualKeyboard::setInputHints(int inputHints) 77 { 78 if (inputHints & Qt::ImhEmailCharactersOnly) { 79 setKeyboardMode(QQnxAbstractVirtualKeyboard::Email); 80 } else if (inputHints & Qt::ImhDialableCharactersOnly) { 81 setKeyboardMode(QQnxAbstractVirtualKeyboard::Phone); 82 } else if (inputHints & Qt::ImhUrlCharactersOnly) { 83 setKeyboardMode(QQnxAbstractVirtualKeyboard::Url); 84 } else if (inputHints & Qt::ImhFormattedNumbersOnly || inputHints & Qt::ImhDigitsOnly) { 85 setKeyboardMode(QQnxAbstractVirtualKeyboard::Number); 86 } else if (inputHints & Qt::ImhDate || inputHints & Qt::ImhTime) { 87 setKeyboardMode(QQnxAbstractVirtualKeyboard::NumPunc); // Use NumPunc so that : is available. 88 } else if (inputHints & Qt::ImhHiddenText) { 89 setKeyboardMode(QQnxAbstractVirtualKeyboard::Password); 90 } else { 91 setKeyboardMode(QQnxAbstractVirtualKeyboard::Default); 92 } 93 } 94 setHeight(int height)95void QQnxAbstractVirtualKeyboard::setHeight(int height) 96 { 97 if (height == m_height) 98 return; 99 100 const int effectiveHeight = this->height(); 101 102 m_height = height; 103 104 if (effectiveHeight != this->height()) 105 emit heightChanged(this->height()); 106 } 107 setVisible(bool visible)108void QQnxAbstractVirtualKeyboard::setVisible(bool visible) 109 { 110 if (visible == m_visible) 111 return; 112 113 const int effectiveHeight = height(); 114 115 m_visible = visible; 116 117 emit visibilityChanged(visible); 118 119 if (effectiveHeight != height()) 120 emit heightChanged(height()); 121 } 122 setLocale(const QLocale & locale)123void QQnxAbstractVirtualKeyboard::setLocale(const QLocale &locale) 124 { 125 if (locale == m_locale) 126 return; 127 128 m_locale = locale; 129 130 emit localeChanged(locale); 131 } 132 133 QQnxAbstractVirtualKeyboard::EnterKeyType qtEnterKeyTypeToQnx(Qt::EnterKeyType type)134 QQnxAbstractVirtualKeyboard::qtEnterKeyTypeToQnx(Qt::EnterKeyType type) 135 { 136 switch (type) { 137 case Qt::EnterKeyDone: 138 return Done; 139 case Qt::EnterKeyGo: 140 return Go; 141 case Qt::EnterKeyNext: 142 return Next; 143 case Qt::EnterKeySearch: 144 return Search; 145 case Qt::EnterKeySend: 146 return Send; 147 case Qt::EnterKeyDefault: 148 case Qt::EnterKeyReturn: 149 case Qt::EnterKeyPrevious: // unsupported 150 return DefaultReturn; 151 } 152 } 153 154 QT_END_NAMESPACE 155