1
0

DeclarativeInputEngine.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef DECLARATIVEINPUTENGINE_H
  2. #define DECLARATIVEINPUTENGINE_H
  3. //============================================================================
  4. // INCLUDES
  5. //============================================================================
  6. #include <QObject>
  7. #include <QRect>
  8. struct DeclarativeInputEnginePrivate;
  9. /**
  10. * The input engine provides input context information and is responsible
  11. * for routing input events to focused QML items.
  12. * The InputEngine can be accessed as singleton instance from QML
  13. */
  14. class DeclarativeInputEngine : public QObject
  15. {
  16. Q_OBJECT
  17. Q_PROPERTY(QRect keyboardRectangle READ keyboardRectangle WRITE setKeyboardRectangle NOTIFY keyboardRectangleChanged FINAL)
  18. Q_PROPERTY(bool animating READ isAnimating WRITE setAnimating NOTIFY animatingChanged FINAL)
  19. Q_PROPERTY(int inputMode READ inputMode WRITE setInputMode NOTIFY inputModeChanged FINAL)
  20. Q_ENUMS(InputMode)
  21. private:
  22. DeclarativeInputEnginePrivate* d;
  23. friend class DeclarativeInputEnginePrivate;
  24. private slots:
  25. void animatingFinished();
  26. public:
  27. /**
  28. * The InputMode enum provides a list of valid input modes
  29. */
  30. enum InputMode {Latin, Numeric, Dialable};
  31. /**
  32. * Creates a dclarative input engine with the given parent
  33. */
  34. explicit DeclarativeInputEngine(QObject *parent = 0);
  35. /**
  36. * Virtual destructor
  37. */
  38. virtual ~DeclarativeInputEngine();
  39. /**
  40. * Returns the kesyboard rectangle
  41. */
  42. QRect keyboardRectangle() const;
  43. /**
  44. * Returns the animating status
  45. */
  46. bool isAnimating() const;
  47. /**
  48. * Use this property to set the animating status, for example during UI
  49. * transitioning states.
  50. */
  51. void setAnimating(bool Animating);
  52. /**
  53. * Returns the current input mode
  54. * \see InputMode for a list of valid input modes
  55. */
  56. int inputMode() const;
  57. /**
  58. * Use this function to set the current input mode
  59. * \see InputMode for a list of valid input modes
  60. */
  61. void setInputMode(int Mode);
  62. public slots:
  63. /**
  64. * Reverts the active key state without emitting the key event.
  65. * This method is useful when the user discards the current key and the
  66. * key state needs to be restored.
  67. * \note Not implemented yet and not used yet
  68. */
  69. void virtualKeyCancel();
  70. /**
  71. * Emits a key click event for the given key, text and modifiers.
  72. * Returns true if the key event was accepted by the input engine.
  73. * \note Not implemented yet and not used yet
  74. */
  75. bool virtualKeyClick(Qt::Key key, const QString & text, Qt::KeyboardModifiers modifiers);
  76. /**
  77. * Called by the keyboard layer to indicate that key was pressed, with the
  78. * given text and modifiers.
  79. * The key is set as an active key (down key). The actual key event is
  80. * triggered when the key is released by the virtualKeyRelease() method.
  81. * The key press event can be discarded by calling virtualKeyCancel().
  82. * The key press also initiates the key repeat timer if repeat is true.
  83. * Returns true if the key was accepted by this input engine.
  84. * \note Not implemented yet and not used yet
  85. */
  86. bool virtualKeyPress(Qt::Key key, const QString & text, Qt::KeyboardModifiers modifiers, bool repeat);
  87. /**
  88. * Releases the key at key. The method emits a key event for the input
  89. * method if the event has not been generated by a repeating timer.
  90. * The text and modifiers are passed to the input method.
  91. * Returns true if the key was accepted by the input engine
  92. * \note Not implemented yet and not used yet
  93. */
  94. bool virtualKeyRelease(Qt::Key key, const QString & text, Qt::KeyboardModifiers modifiers);
  95. /**
  96. * This function sends the given text to the focused QML item
  97. * \note This function will get replaced by virtualKeyClick function later
  98. */
  99. void sendKeyToFocusItem(const QString &keyText);
  100. /**
  101. * Reports the active keyboard rectangle to the engine
  102. */
  103. void setKeyboardRectangle(const QRect& Rect);
  104. signals:
  105. /**
  106. * Notify signal of keyboardRectangle property
  107. */
  108. void keyboardRectangleChanged();
  109. /**
  110. * Notify signal of animating property
  111. */
  112. void animatingChanged();
  113. /**
  114. * Notify signal of inputModep property
  115. */
  116. void inputModeChanged();
  117. }; // class CDeclarativeInputEngine
  118. //---------------------------------------------------------------------------
  119. #endif // DECLARATIVEINPUTENGINE_H