vvimcmdlineedit.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef VVIMCMDLINEEDIT_H
  2. #define VVIMCMDLINEEDIT_H
  3. #include "vlineedit.h"
  4. #include "utils/vvim.h"
  5. class QKeyEvent;
  6. class QFocusEvent;
  7. class VVimCmdLineEdit : public VLineEdit
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit VVimCmdLineEdit(QWidget *p_parent = 0);
  12. void reset(VVim::CommandLineType p_type);
  13. // Set the command to @p_cmd with leader unchanged.
  14. void setCommand(const QString &p_cmd);
  15. // Get the command.
  16. QString getCommand() const;
  17. void restoreUserLastInput();
  18. QVariant inputMethodQuery(Qt::InputMethodQuery p_query) const Q_DECL_OVERRIDE;
  19. signals:
  20. // User has finished the input and the command is ready to execute.
  21. void commandFinished(VVim::CommandLineType p_type, const QString &p_cmd);
  22. // User cancelled the input.
  23. void commandCancelled();
  24. // User request the next command in the history.
  25. void requestNextCommand(VVim::CommandLineType p_type, const QString &p_cmd);
  26. // User request the previous command in the history.
  27. void requestPreviousCommand(VVim::CommandLineType p_type, const QString &p_cmd);
  28. // Emit when the input text changed.
  29. void commandChanged(VVim::CommandLineType p_type, const QString &p_cmd);
  30. // Emit when expecting to read a register.
  31. void requestRegister(int p_key, int p_modifiers);
  32. protected:
  33. void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
  34. void focusOutEvent(QFocusEvent *p_event) Q_DECL_OVERRIDE;
  35. private:
  36. // Return the leader of @p_type.
  37. QString commandLineTypeLeader(VVim::CommandLineType p_type);
  38. void setRegisterPending(bool p_pending);
  39. void setInputMethodEnabled(bool p_enabled);
  40. VVim::CommandLineType m_type;
  41. // The latest command user input.
  42. QString m_userLastInput;
  43. // Whether we are expecting a register name to read.
  44. bool m_registerPending;
  45. QString m_originStyleSheet;
  46. // Whether enable input method.
  47. bool m_enableInputMethod;
  48. };
  49. #endif // VVIMCMDLINEEDIT_H