1
0

FreeVirtualKeyboardInputContext.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef FREEVIRTUALKEYBOARDINPUTCONTEXT_H
  2. #define FREEVIRTUALKEYBOARDINPUTCONTEXT_H
  3. //============================================================================
  4. // INCLUDES
  5. //============================================================================
  6. #include <QRectF>
  7. #include <qpa/qplatforminputcontext.h>
  8. //============================================================================
  9. // FORWARD DECLARATIONS
  10. //============================================================================
  11. class QQmlEngine;
  12. class QJSEngine;
  13. class FreeVirtualKeyboardInputContextPrivate;
  14. /**
  15. * Implementation of QPlatformInputContext
  16. */
  17. class FreeVirtualKeyboardInputContext : public QPlatformInputContext
  18. {
  19. Q_OBJECT
  20. private:
  21. /**
  22. * The input contet creates the InputEngine object and provides it
  23. * as a singleton to the QML context
  24. */
  25. static QObject* inputEngineProvider(QQmlEngine *engine, QJSEngine *scriptEngine);
  26. protected:
  27. /**
  28. * Protected constructor - use instance function to get the one and only
  29. * object
  30. */
  31. FreeVirtualKeyboardInputContext();
  32. public:
  33. /**
  34. * Virtual destructor
  35. */
  36. virtual ~FreeVirtualKeyboardInputContext();
  37. /**
  38. * Returns input context validity. Deriving implementations should
  39. * return true - so we simply return true
  40. */
  41. virtual bool isValid() const;
  42. /**
  43. * This function can be reimplemented to return virtual keyboard rectangle
  44. * in currently active window coordinates. Default implementation returns
  45. * invalid rectangle.
  46. */
  47. virtual QRectF keyboardRect() const;
  48. /**
  49. * Simply calls the emitInputPanelVisibleChanged() function
  50. */
  51. virtual void showInputPanel();
  52. /**
  53. * Simply calls the emitInputPanelVisibleChanged() function
  54. */
  55. virtual void hideInputPanel();
  56. /**
  57. * Returns input panel visibility status.
  58. * This value will be available in QGuiApplication::inputMethod()->isVisible()
  59. */
  60. virtual bool isInputPanelVisible() const;
  61. /**
  62. * This function returns true whenever input method is animating
  63. * shown or hidden.
  64. */
  65. virtual bool isAnimating() const;
  66. /**
  67. * This virtual method gets called to notify updated focus to object.
  68. * \warning Input methods must not call this function directly.
  69. * This function does the main work. It sets the input mode of the
  70. * InputEngine singleton and it ensures that the focused QML object is
  71. * visible if it is a child item of a Flickable
  72. */
  73. virtual void setFocusObject(QObject *object);
  74. /**
  75. * Use this static instance function to access the singleton input context
  76. * instance
  77. */
  78. static FreeVirtualKeyboardInputContext* instance();
  79. private:
  80. FreeVirtualKeyboardInputContextPrivate *d;
  81. private slots:
  82. /**
  83. * This function scrolls the QML item into visible area if the focused
  84. * QML item is child of a flickable
  85. */
  86. void ensureFocusedObjectVisible();
  87. }; // FreeVirtualKeyboardInputContext
  88. //------------------------------------------------------------------------------
  89. #endif // FREEVIRTUALKEYBOARDINPUTCONTEXT_H