diff options
Diffstat (limited to 'src/plugins/platforms/android')
6 files changed, 274 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/src/androidjniinput.cpp b/src/plugins/platforms/android/src/androidjniinput.cpp index 75cb617ca8..b31e74bb52 100644 --- a/src/plugins/platforms/android/src/androidjniinput.cpp +++ b/src/plugins/platforms/android/src/androidjniinput.cpp @@ -411,6 +411,24 @@ namespace QtAndroidInput case 0x00000018: return Qt::Key_VolumeUp; + case 0x000000b7: // KEYCODE_PROG_RED + return Qt::Key_Red; + + case 0x000000b8: // KEYCODE_PROG_GREEN + return Qt::Key_Green; + + case 0x000000b9: // KEYCODE_PROG_YELLOW + return Qt::Key_Yellow; + + case 0x000000ba: // KEYCODE_PROG_BLUE + return Qt::Key_Blue; + + case 0x000000a6: // KEYCODE_CHANNEL_UP + return Qt::Key_ChannelUp; + + case 0x000000a7: // KEYCODE_CHANNEL_DOWN + return Qt::Key_ChannelDown; + case 0x00000000: // KEYCODE_UNKNOWN case 0x00000011: // KEYCODE_STAR ?!?!? case 0x00000012: // KEYCODE_POUND ?!?!? diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index 91ad2b368f..8899d98795 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -66,6 +66,7 @@ #endif #include "qandroidplatformtheme.h" +#include "qandroidsystemlocale.h" QT_BEGIN_NAMESPACE @@ -108,6 +109,8 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidFDB = new QAndroidPlatformFontDatabase(); m_androidPlatformServices = new QAndroidPlatformServices(); m_androidPlatformClipboard = new QAndroidPlatformClipboard(); + + m_androidSystemLocale = new QAndroidSystemLocale; } bool QAndroidPlatformIntegration::hasCapability(Capability cap) const @@ -183,6 +186,7 @@ QAndroidPlatformIntegration::~QAndroidPlatformIntegration() { delete m_androidPlatformNativeInterface; delete m_androidFDB; + delete m_androidSystemLocale; QtAndroid::setAndroidPlatformIntegration(NULL); } QPlatformFontDatabase *QAndroidPlatformIntegration::fontDatabase() const diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index 6cc191701d..346d0c0953 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE class QDesktopWidget; class QAndroidPlatformServices; +class QAndroidSystemLocale; #ifdef ANDROID_PLUGIN_OPENGL class QAndroidOpenGLPlatformWindow; @@ -154,6 +155,7 @@ private: QAndroidPlatformNativeInterface *m_androidPlatformNativeInterface; QAndroidPlatformServices *m_androidPlatformServices; QPlatformClipboard *m_androidPlatformClipboard; + QAndroidSystemLocale *m_androidSystemLocale; mutable QAndroidInputContext m_platformInputContext; }; diff --git a/src/plugins/platforms/android/src/qandroidsystemlocale.cpp b/src/plugins/platforms/android/src/qandroidsystemlocale.cpp new file mode 100644 index 0000000000..24ae503335 --- /dev/null +++ b/src/plugins/platforms/android/src/qandroidsystemlocale.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qandroidsystemlocale.h" +#include "androidjnimain.h" +#include "private/qjniobject_p.h" +#include "private/qjnihelpers_p.h" +#include "qdatetime.h" +#include "qstringlist.h" +#include "qvariant.h" + +QT_BEGIN_NAMESPACE + +QAndroidSystemLocale::QAndroidSystemLocale() : m_locale(QLocale::C) +{ +} + +void QAndroidSystemLocale::getLocaleFromJava() const +{ + QWriteLocker locker(&m_lock); + + QJNILocalRef<jobject> javaLocaleRef; + QJNIObject javaActivity(QtAndroid::activity()); + if (javaActivity.isValid()) { + QJNIObject resources(javaActivity.callObjectMethod<jobject>("getResources", "()Landroid/content/res/Resources;").object()); + QJNIObject configuration(resources.callObjectMethod<jobject>("getConfiguration", "()Landroid/content/res/Configuration;").object()); + + javaLocaleRef = configuration.getObjectField<jobject>("locale", "Ljava/util/Locale;"); + } else { + javaLocaleRef = QJNIObject::callStaticObjectMethod<jobject>("java/util/Locale", "getDefault", "()Ljava/util/Locale;"); + } + + QJNIObject javaLocaleObject(javaLocaleRef.object()); + QString languageCode = qt_convertJString(javaLocaleObject.callObjectMethod<jstring>("getLanguage", "()Ljava/lang/String;").object()); + QString countryCode = qt_convertJString(javaLocaleObject.callObjectMethod<jstring>("getCountry", "()Ljava/lang/String;").object()); + + m_locale = QLocale(languageCode + QLatin1Char('_') + countryCode); +} + +QVariant QAndroidSystemLocale::query(QueryType type, QVariant in) const +{ + if (type == LocaleChanged) { + getLocaleFromJava(); + return QVariant(); + } + + QReadLocker locker(&m_lock); + + switch (type) { + case DecimalPoint: + return m_locale.decimalPoint(); + case GroupSeparator: + return m_locale.groupSeparator(); + case ZeroDigit: + return m_locale.zeroDigit(); + case NegativeSign: + return m_locale.negativeSign(); + case DateFormatLong: + return m_locale.dateFormat(QLocale::LongFormat); + case DateFormatShort: + return m_locale.dateFormat(QLocale::ShortFormat); + case TimeFormatLong: + return m_locale.timeFormat(QLocale::LongFormat); + case TimeFormatShort: + return m_locale.timeFormat(QLocale::ShortFormat); + case DayNameLong: + return m_locale.dayName(in.toInt(), QLocale::LongFormat); + case DayNameShort: + return m_locale.dayName(in.toInt(), QLocale::ShortFormat); + case MonthNameLong: + return m_locale.monthName(in.toInt(), QLocale::LongFormat); + case MonthNameShort: + return m_locale.monthName(in.toInt(), QLocale::ShortFormat); + case StandaloneMonthNameLong: + return m_locale.standaloneMonthName(in.toInt(), QLocale::LongFormat); + case StandaloneMonthNameShort: + return m_locale.standaloneMonthName(in.toInt(), QLocale::ShortFormat); + case DateToStringLong: + return m_locale.toString(in.toDate(), QLocale::LongFormat); + case DateToStringShort: + return m_locale.toString(in.toDate(), QLocale::ShortFormat); + case TimeToStringLong: + return m_locale.toString(in.toTime(), QLocale::LongFormat); + case TimeToStringShort: + return m_locale.toString(in.toTime(), QLocale::ShortFormat); + case DateTimeFormatLong: + return m_locale.dateTimeFormat(QLocale::LongFormat); + case DateTimeFormatShort: + return m_locale.dateTimeFormat(QLocale::ShortFormat); + case DateTimeToStringLong: + return m_locale.toString(in.toDateTime(), QLocale::LongFormat); + case DateTimeToStringShort: + return m_locale.toString(in.toDateTime(), QLocale::ShortFormat); + case PositiveSign: + return m_locale.positiveSign(); + case AMText: + return m_locale.amText(); + case PMText: + return m_locale.pmText(); + case FirstDayOfWeek: + return m_locale.firstDayOfWeek(); + case CurrencySymbol: + return m_locale .currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt())); + case CurrencyToString: { + switch (in.type()) { + case QVariant::Int: + return m_locale .toCurrencyString(in.toInt()); + case QVariant::UInt: + return m_locale .toCurrencyString(in.toUInt()); + case QVariant::Double: + return m_locale .toCurrencyString(in.toDouble()); + case QVariant::LongLong: + return m_locale .toCurrencyString(in.toLongLong()); + case QVariant::ULongLong: + return m_locale .toCurrencyString(in.toULongLong()); + default: + break; + } + return QString(); + } + case StringToStandardQuotation: + return m_locale.quoteString(in.value<QStringRef>()); + case StringToAlternateQuotation: + return m_locale.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation); + case ListToSeparatedString: + return m_locale.createSeparatedList(in.value<QStringList>()); + case LocaleChanged: + Q_ASSERT_X(false, Q_FUNC_INFO, "This can't happen."); + default: + break; + } + return QVariant(); +} + +QLocale QAndroidSystemLocale::fallbackUiLocale() const +{ + QReadLocker locker(&m_lock); + return m_locale; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/src/qandroidsystemlocale.h b/src/plugins/platforms/android/src/qandroidsystemlocale.h new file mode 100644 index 0000000000..fc2f6fad98 --- /dev/null +++ b/src/plugins/platforms/android/src/qandroidsystemlocale.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QANDROIDSYSTEMLOCALE_H +#define QANDROIDSYSTEMLOCALE_H + +#include "private/qlocale_p.h" +#include <QtCore/qreadwritelock.h> + +QT_BEGIN_NAMESPACE + +class QAndroidSystemLocale : public QSystemLocale +{ +public: + QAndroidSystemLocale(); + + virtual QVariant query(QueryType type, QVariant in) const; + virtual QLocale fallbackUiLocale() const; + +private: + void getLocaleFromJava() const; + + mutable QLocale m_locale; + mutable QReadWriteLock m_lock; +}; + +QT_END_NAMESPACE + +#endif // QANDROIDSYSTEMLOCALE_H diff --git a/src/plugins/platforms/android/src/src.pri b/src/plugins/platforms/android/src/src.pri index 76539b50ab..0fd9ace1fc 100644 --- a/src/plugins/platforms/android/src/src.pri +++ b/src/plugins/platforms/android/src/src.pri @@ -23,7 +23,8 @@ SOURCES += $$PWD/androidplatformplugin.cpp \ $$PWD/qandroidplatformtheme.cpp \ $$PWD/qandroidplatformmenubar.cpp \ $$PWD/qandroidplatformmenu.cpp \ - $$PWD/qandroidplatformmenuitem.cpp + $$PWD/qandroidplatformmenuitem.cpp \ + $$PWD/qandroidsystemlocale.cpp HEADERS += $$PWD/qandroidplatformintegration.h \ @@ -39,7 +40,8 @@ HEADERS += $$PWD/qandroidplatformintegration.h \ $$PWD/qandroidplatformtheme.h \ $$PWD/qandroidplatformmenubar.h \ $$PWD/qandroidplatformmenu.h \ - $$PWD/qandroidplatformmenuitem.h + $$PWD/qandroidplatformmenuitem.h \ + $$PWD/qandroidsystemlocale.h #Non-standard install directory, QTBUG-29859 |