diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d4fb5b3..f7d310d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,9 +113,6 @@ set(PLUGINS_SOURCES src/maliit/plugins/abstractinputmethod.h src/maliit/plugins/abstractinputmethodhost.cpp src/maliit/plugins/abstractinputmethodhost.h - src/maliit/plugins/extensionevent.cpp - src/maliit/plugins/extensionevent.h - src/maliit/plugins/extensionevent_p.h src/maliit/plugins/inputmethodplugin.h src/maliit/plugins/keyoverride.cpp src/maliit/plugins/keyoverride.h @@ -126,11 +123,6 @@ set(PLUGINS_SOURCES src/maliit/plugins/plugindescription.h src/maliit/plugins/subviewdescription.cpp src/maliit/plugins/subviewdescription.h - src/maliit/plugins/updateevent.cpp - src/maliit/plugins/updateevent.h - src/maliit/plugins/updateevent_p.h - src/maliit/plugins/updatereceiver.cpp - src/maliit/plugins/updatereceiver.h src/maliit/standaloneinputmethod.cpp src/maliit/standaloneinputmethod.h src/maliit/standaloneinputmethodhost.cpp diff --git a/examples/plugins/cxx/helloworld/helloworldinputmethod.h b/examples/plugins/cxx/helloworld/helloworldinputmethod.h index ca87bd4c..7ef6dc2e 100644 --- a/examples/plugins/cxx/helloworld/helloworldinputmethod.h +++ b/examples/plugins/cxx/helloworld/helloworldinputmethod.h @@ -54,7 +54,6 @@ class HelloWorldInputMethod /* Optional, rarely used */ /* Using default implementations - virtual bool imExtensionEvent(MImExtensionEvent *event); virtual void showLanguageNotification(); virtual void setKeyOverrides(const QMap > &overrides); virtual void processKeyEvent(QEvent::Type keyType, Qt::Key keyCode, diff --git a/examples/plugins/cxx/override/overrideinputmethod.h b/examples/plugins/cxx/override/overrideinputmethod.h index e9c0dd4c..9566bac9 100644 --- a/examples/plugins/cxx/override/overrideinputmethod.h +++ b/examples/plugins/cxx/override/overrideinputmethod.h @@ -58,7 +58,6 @@ class OverrideInputMethod /* Optional, rarely used */ /* Using default implementations - virtual bool imExtensionEvent(MImExtensionEvent *event); virtual void showLanguageNotification(); virtual void processKeyEvent(QEvent::Type keyType, Qt::Key keyCode, Qt::KeyboardModifiers modifiers, const QString &text, diff --git a/src/maliit/plugins/abstractinputmethod.cpp b/src/maliit/plugins/abstractinputmethod.cpp index 0ee8511a..f2ae7c7d 100644 --- a/src/maliit/plugins/abstractinputmethod.cpp +++ b/src/maliit/plugins/abstractinputmethod.cpp @@ -180,9 +180,3 @@ void MAbstractInputMethod::setKeyOverrides(const QMap > &overrides); - /*! - * \brief handles extension event not covered by a dedicated method. - * - * Must return true if event is handled, otherwise false. - * Extensions can be registered on the application side, and will be passed through to - * the input method, allowing to add integration points between application and input method. - * Reimplementing this method is optional. - * - * \param event event to handle - */ - virtual bool imExtensionEvent(MImExtensionEvent *event); - Q_SIGNALS: /*! * \brief Inform that active subview is changed to \a subViewId for \a state. diff --git a/src/maliit/plugins/extensionevent.cpp b/src/maliit/plugins/extensionevent.cpp deleted file mode 100644 index 08f16ff1..00000000 --- a/src/maliit/plugins/extensionevent.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#include -#include - -MImExtensionEventPrivate::~MImExtensionEventPrivate() -{} - -MImExtensionEvent::MImExtensionEvent(Type type) - : d_ptr(new MImExtensionEventPrivate) -{ - d_ptr->type = type; -} - -MImExtensionEvent::MImExtensionEvent(MImExtensionEventPrivate *dd, - Type type) - : d_ptr(dd) -{ - d_ptr->type = type; -} - -MImExtensionEvent::~MImExtensionEvent() -{ - Q_D(MImExtensionEvent); - delete d; -} - -MImExtensionEvent::Type MImExtensionEvent::type() const -{ - Q_D(const MImExtensionEvent); - return d->type; -} diff --git a/src/maliit/plugins/extensionevent.h b/src/maliit/plugins/extensionevent.h deleted file mode 100644 index 5844b097..00000000 --- a/src/maliit/plugins/extensionevent.h +++ /dev/null @@ -1,55 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#ifndef MIMEXTENSIONEVENT_H -#define MIMEXTENSIONEVENT_H - -#include - -class MImExtensionEventPrivate; - -/*! \ingroup pluginapi - * \brief Base class for extending signaling from input method system to - * plugins. - * - * This event can be subclassed for future additions. - * - * \sa MAbstractInputMethod::imExtensionEvent(MImExtensionEvent *event) - */ -class MImExtensionEvent -{ -public: - //! Defines valid types for input method extension event - enum Type { - None, - Update - }; - - explicit MImExtensionEvent(Type type); - virtual ~MImExtensionEvent(); - - //! Returns the type of the event - Type type() const; - -protected: - MImExtensionEvent(MImExtensionEventPrivate *dd, - Type type); - - MImExtensionEventPrivate * const d_ptr; - -private: - Q_DISABLE_COPY(MImExtensionEvent) - Q_DECLARE_PRIVATE(MImExtensionEvent) -}; - -#endif diff --git a/src/maliit/plugins/extensionevent_p.h b/src/maliit/plugins/extensionevent_p.h deleted file mode 100644 index fe4e73ea..00000000 --- a/src/maliit/plugins/extensionevent_p.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MIMEXTENSIONEVENT_P_H -#define MIMEXTENSIONEVENT_P_H - -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#include - -class MImExtensionEventPrivate -{ -public: - virtual ~MImExtensionEventPrivate(); - - MImExtensionEvent::Type type; -}; -#endif // MIMEXTENSIONEVENT_P_H diff --git a/src/maliit/plugins/updateevent.cpp b/src/maliit/plugins/updateevent.cpp deleted file mode 100644 index b1f58e02..00000000 --- a/src/maliit/plugins/updateevent.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#include -#include -#include -#include -#include - -MImUpdateEventPrivate::MImUpdateEventPrivate() - : update() - , changedProperties() - , lastHints(Qt::ImhNone) -{} - -MImUpdateEventPrivate::MImUpdateEventPrivate(const QMap &newUpdate, - const QStringList &newChangedProperties, - const Qt::InputMethodHints &newLastHints) - : update(newUpdate) - , changedProperties(newChangedProperties) - , lastHints(newLastHints) -{} - -bool MImUpdateEventPrivate::isFlagSet(Qt::InputMethodHint hint, - bool *changed) const -{ - bool result = false; - - if (update.contains(Maliit::Internal::inputMethodHints)) { - const Qt::InputMethodHints hints(static_cast( - update.value(Maliit::Internal::inputMethodHints).toInt())); - - result = (hints & hint); - } - - if (changed) { - *changed = (result != ((lastHints & hint) != 0)); - } - - return result; -} - -QVariant MImUpdateEventPrivate::extractProperty(const QString &key, - bool *changed) const -{ - if (changed) { - *changed = changedProperties.contains(key); - } - - return update.value(key); -} - -MImUpdateEvent::MImUpdateEvent(const QMap &update, - const QStringList &changedProperties) - : MImExtensionEvent(new MImUpdateEventPrivate(update, changedProperties, Qt::InputMethodHints()), - MImExtensionEvent::Update) -{} - -MImUpdateEvent::MImUpdateEvent(const QMap &update, - const QStringList &changedProperties, - const Qt::InputMethodHints &lastHints) - : MImExtensionEvent(new MImUpdateEventPrivate(update, changedProperties, lastHints), - MImExtensionEvent::Update) -{} - -QVariant MImUpdateEvent::value(const QString &key) const -{ - Q_D(const MImUpdateEvent); - return d->update.value(key); -} - -QStringList MImUpdateEvent::propertiesChanged() const -{ - Q_D(const MImUpdateEvent); - return d->changedProperties; -} - -Qt::InputMethodHints MImUpdateEvent::hints(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return static_cast( - d->extractProperty(Maliit::Internal::inputMethodHints, changed).toInt()); -} - -bool MImUpdateEvent::westernNumericInputEnforced(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return d->extractProperty(Maliit::InputMethodQuery::westernNumericInputEnforced, changed).toBool(); -} - -bool MImUpdateEvent::preferNumbers(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return d->isFlagSet(Qt::ImhPreferNumbers, changed); -} - -bool MImUpdateEvent::translucentInputMethod(bool *changed) const -{ - Q_D(const MImUpdateEvent); - return d->extractProperty(Maliit::InputMethodQuery::translucentInputMethod, changed).toBool(); -} diff --git a/src/maliit/plugins/updateevent.h b/src/maliit/plugins/updateevent.h deleted file mode 100644 index aab34f83..00000000 --- a/src/maliit/plugins/updateevent.h +++ /dev/null @@ -1,81 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#ifndef MIMUPDATEEVENT_H -#define MIMUPDATEEVENT_H - -#include - -#include - -class MImUpdateEventPrivate; -class MImUpdateReceiver; - -/*! \ingroup pluginapi - * \brief Monitor the input method properties sent by the application. - */ -class MImUpdateEvent - : public MImExtensionEvent -{ -public: - //! C'tor - //! \param update the map containing all properties. - //! \param propertiesChanged a string list of changed properties. - explicit MImUpdateEvent(const QMap &update, - const QStringList &propertiesChanged); - - //! C'tor - //! \param update the map containing all properties. - //! \param propertiesChanged a string list of changed properties. - //! \param lastHints the last input method hints, as compared to the new - //! ones in the updates map. Necessary to detect whether a flag - //! flipped between update event. - explicit MImUpdateEvent(const QMap &update, - const QStringList &propertiesChanged, - const Qt::InputMethodHints &lastHints); - - //! Returns invalid QVariant if key is invalid. - QVariant value(const QString &key) const; - - //! Returns list of keys that have changed, compared to last update event. - QStringList propertiesChanged() const; - - //! Returns the focus widget's input method hints. - //! \param changed whether this value changed with this event. - Qt::InputMethodHints hints(bool *changed = 0) const; - - //! Returns whether western numeric input should be shown, overridding - //! language-specific numeric inputs. - //! False by default. - //! \param changed whether this value changed with this event. - bool westernNumericInputEnforced(bool *changed = 0) const; - - //! Returns whether input field has Qt::ImhPreferNumbers hint set. - //! False by default. - //! \param changed whether this value changed with this event. - bool preferNumbers(bool *changed = 0) const; - - //! Returns whether the input method should be styled translucently. Useful - //! when apps need to display a lot of information, for example terminals. - //! False by default. - //! \param changed whether this value changed with this event. - bool translucentInputMethod(bool *changed = 0) const; - -private: - Q_DISABLE_COPY(MImUpdateEvent) - Q_DECLARE_PRIVATE(MImUpdateEvent) - - friend class MImUpdateReceiver; // Allows receiver to copy PIMPL instance. -}; - -#endif // MIMUPDATEEVENT_H diff --git a/src/maliit/plugins/updateevent_p.h b/src/maliit/plugins/updateevent_p.h deleted file mode 100644 index b3b07995..00000000 --- a/src/maliit/plugins/updateevent_p.h +++ /dev/null @@ -1,42 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#ifndef MIMUPDATEEVENT_P_H -#define MIMUPDATEEVENT_P_H - -#include - -#include - -class MImUpdateEventPrivate - : public MImExtensionEventPrivate -{ -public: - QMap update; - QStringList changedProperties; - Qt::InputMethodHints lastHints; - - explicit MImUpdateEventPrivate(); - - explicit MImUpdateEventPrivate(const QMap &newUpdate, - const QStringList &newChangedProperties, - const Qt::InputMethodHints &newLastHints); - - bool isFlagSet(Qt::InputMethodHint hint, - bool *changed = 0) const; - - QVariant extractProperty(const QString &key, - bool *changed = 0) const; -}; - -#endif // MIMUPDATEEVENT_P_H diff --git a/src/maliit/plugins/updatereceiver.cpp b/src/maliit/plugins/updatereceiver.cpp deleted file mode 100644 index ac642b42..00000000 --- a/src/maliit/plugins/updatereceiver.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#include - -#include -#include -#include -#include -#include - -// Choosing inheritance instead of typedef, as we might want to add -// receiver-specific data later. -class MImUpdateReceiverPrivate - : public MImUpdateEventPrivate -{}; - -MImUpdateReceiver::MImUpdateReceiver(QObject *parent) - : QObject(parent) - , d_ptr(new MImUpdateReceiverPrivate) -{} - -MImUpdateReceiver::~MImUpdateReceiver() -{ - // TODO: Find out why using QScopedPointer for the PIMPL fails to compile. - delete d_ptr; -} - -void MImUpdateReceiver::process(MImUpdateEvent *ev) -{ - if (not ev) { - return; - } - - // TODO: Replace this ever-growing, switch-like structure with a more - // concise solution, based on Qt reflection (via QMetaObject and Qt - // properties). - Q_D(MImUpdateReceiver); - d->changedProperties = ev->d_func()->changedProperties; - d->update = ev->d_func()->update; - - bool changed = false; - bool value = ev->westernNumericInputEnforced(&changed); - - if (changed) { - Q_EMIT westernNumericInputEnforcedChanged(value); - } - - changed = false; - value = ev->preferNumbers(&changed); - - if (changed) { - Q_EMIT preferNumbersChanged(value); - } - - changed = false; - value = ev->translucentInputMethod(&changed); - - if (changed) { - Q_EMIT translucentInputMethodChanged(value); - } -} - -bool MImUpdateReceiver::westernNumericInputEnforced() const -{ - Q_D(const MImUpdateReceiver); - return d->extractProperty(Maliit::InputMethodQuery::westernNumericInputEnforced).toBool(); -} - -bool MImUpdateReceiver::preferNumbers() const -{ - Q_D(const MImUpdateReceiver); - return d->isFlagSet(Qt::ImhPreferNumbers); -} - -bool MImUpdateReceiver::translucentInputMethod() const -{ - Q_D(const MImUpdateReceiver); - return d->extractProperty(Maliit::InputMethodQuery::translucentInputMethod).toBool(); -} diff --git a/src/maliit/plugins/updatereceiver.h b/src/maliit/plugins/updatereceiver.h deleted file mode 100644 index 244a7427..00000000 --- a/src/maliit/plugins/updatereceiver.h +++ /dev/null @@ -1,74 +0,0 @@ -/* * This file is part of Maliit framework * - * - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * - * - * This library is free software; you can redistribute it and/or - * modify it 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. - */ - -#ifndef MIMUPDATERECEIVER_H -#define MIMUPDATERECEIVER_H - -#include - -class MImUpdateReceiverPrivate; -class MImUpdateEvent; - -/*! \ingroup pluginapi - * \brief An example that turns data-polling from events into data-pushing via - * properties and change notifications. - * - * Used in combination with MImUpdateEvents: The event is propagated down to - * the final component, where it is then processed by an event receiver. The - * receiver therefore acts as an endpoint for events, allowing the actual - * consumers of input method properties to listen to property changes. Using - * this approach, consumers are completely decoupled from the event propagation - * itself. Event receivers implemented in plugins are supposed to be more - * specialized than the generic MImUpdateReceiver. They can be designed to only - * carry the properties that are required for a given endpoint. The life time - * of event receivers usually exceeds the life time of events, which makes it - * possible to keep signal connections between consumers and event receivers - * alive. - */ -class MImUpdateReceiver - : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(MImUpdateReceiver) - Q_DECLARE_PRIVATE(MImUpdateReceiver) - - Q_PROPERTY(bool westernNumericInputEnforced - READ westernNumericInputEnforced - NOTIFY westernNumericInputEnforcedChanged) - Q_PROPERTY(bool preferNumbers - READ preferNumbers - NOTIFY preferNumbersChanged) - Q_PROPERTY(bool translucentInputMethod - READ translucentInputMethod - NOTIFY translucentInputMethodChanged) - -public: - explicit MImUpdateReceiver(QObject *parent = 0); - virtual ~MImUpdateReceiver(); - - void process(MImUpdateEvent *ev); - - bool westernNumericInputEnforced() const; - bool preferNumbers() const; - bool translucentInputMethod() const; - -Q_SIGNALS: - void westernNumericInputEnforcedChanged(bool value); - void preferNumbersChanged(bool value); - void translucentInputMethodChanged(bool value); - -private: - MImUpdateReceiverPrivate *const d_ptr; -}; - -#endif // MIMUPDATERECEIVER_H diff --git a/src/maliit/standaloneinputmethod.cpp b/src/maliit/standaloneinputmethod.cpp index 45008a27..cea629ea 100644 --- a/src/maliit/standaloneinputmethod.cpp +++ b/src/maliit/standaloneinputmethod.cpp @@ -20,7 +20,6 @@ #include "maliit/plugins/abstractinputmethod.h" #include "maliit/plugins/inputmethodplugin.h" -#include #include #include @@ -107,13 +106,7 @@ void StandaloneInputMethod::handleWidgetStateChanged(unsigned int, mInputMethod->handleVisualizationPriorityChange(newVisualization); } - const Qt::InputMethodHints lastHints = newState.value(Maliit::Internal::inputMethodHints).value(); - MImUpdateEvent ev(newState, changedProperties, lastHints); - // general notification last - if (!changedProperties.isEmpty()) { - mInputMethod->imExtensionEvent(&ev); - } mInputMethod->update(); // Make sure windows get hidden when no longer focus diff --git a/src/mimpluginmanager.cpp b/src/mimpluginmanager.cpp index 2f4fef5d..e6ce54ec 100644 --- a/src/mimpluginmanager.cpp +++ b/src/mimpluginmanager.cpp @@ -19,7 +19,6 @@ #include #include "mimsettings.h" #include "mimhwkeyboardtracker.h" -#include #include "mimsubviewoverride.h" #include "maliit/namespaceinternal.h" #include "windowgroup.h" @@ -1311,14 +1310,8 @@ void MIMPluginManager::handleWidgetStateChanged(unsigned int clientId, } } - const Qt::InputMethodHints lastHints = static_cast(newState.value(Maliit::Internal::inputMethodHints).toInt()); - MImUpdateEvent ev(newState, changedProperties, lastHints); - // general notification last Q_FOREACH (MAbstractInputMethod *target, targets()) { - if (not changedProperties.isEmpty()) { - (void) target->imExtensionEvent(&ev); - } target->update(); }