MythTV master
mythuitextedit.h
Go to the documentation of this file.
1#ifndef MYTHUI_TEXTEDIT_H_
2#define MYTHUI_TEXTEDIT_H_
3
4#include <QString>
5#include <QClipboard>
6
11
12class QInputMethodEvent;
13
15class MythUIStateType;
16class MythUIImage;
17class MythUIText;
18
19enum InputFilter : std::uint8_t
20{
26 FilterPunct = 0x08
27};
28
35{
36 Q_OBJECT
37
38 public:
39 MythUITextEdit(MythUIType *parent, const QString &name);
40 ~MythUITextEdit() override = default;
41
42 void Pulse(void) override; // MythUIType
43 bool keyPressEvent(QKeyEvent *event) override; // MythUIType
44 bool inputMethodEvent(QInputMethodEvent *event) override; // MythUIType
45 bool gestureEvent(MythGestureEvent *event) override; // MythUIType
46 void Reset(void) override; // MythUIType
47
48 void SetText(const QString &text, bool moveCursor = true);
49 void InsertText(const QString &text);
50 QString GetText(void) const { return m_message; }
51
52 void SetFilter(InputFilter filter) { m_filter = filter; }
53 void SetPassword(bool isPassword) { m_isPassword = isPassword; }
54 void SetMaxLength(int length);
55
56 enum MoveDirection : std::uint8_t
57 { MoveLeft, MoveRight, MoveUp, MoveDown, MovePageUp, MovePageDown, MoveEnd };
58 bool MoveCursor(MoveDirection moveDir);
59
60 void SetKeyboardPosition(PopupPosition pos) { m_keyboardPosition = pos; }
61 PopupPosition GetKeyboardPosition(void) { return m_keyboardPosition; }
62
63 // StorageUser
64 void SetDBValue(const QString &text) override { SetText(text); } // StorageUser
65 QString GetDBValue(void) const override { return GetText(); } // StorageUser
66
67 signals:
69
70 public slots:
71 void Select();
72 void Deselect();
73
74 protected:
75 bool ParseElement(const QString &filename, QDomElement &element,
76 bool showWarnings) override; // MythUIType
77 void CopyFrom(MythUIType *base) override; // MythUIType
78 void CreateCopy(MythUIType *parent) override; // MythUIType
79 void Finalize(void) override; // MythUIType
80
81 void Init(void);
82 void SetInitialStates(void);
83
84 bool InsertCharacter(const QString &character);
85 void RemoveCharacter(int position);
86
87 void CutTextToClipboard(void);
88 void CopyTextToClipboard(void);
89 void PasteTextFromClipboard(QClipboard::Mode mode = QClipboard::Clipboard);
90 bool UpdateTmpString(const QString &str);
91
92 bool m_initialized { false };
93
94 int m_blinkInterval { 0 };
95 int m_cursorBlinkRate { 40 };
97
98 int m_maxLength { 255 };
99
100 QString m_message;
102 int m_position { -1 };
103
104 bool m_isPassword { false };
105
106 PopupPosition m_keyboardPosition { VK_POSBELOWEDIT };
107
108 MythUIStateType *m_backgroundState { nullptr };
109 MythUIImage *m_cursorImage { nullptr };
110 MythUIText *m_text { nullptr };
111
112 int m_composeKey { 0 };
113
114 bool m_isIMEinput { false };
116};
117
118#endif
A custom event that represents a mouse gesture.
Definition: mythgesture.h:40
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:14
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
This widget is used for grouping other widgets for display when a particular named state is called.
A text entry and edit widget.
~MythUITextEdit() override=default
void SetPassword(bool isPassword)
QString GetText(void) const
void SetKeyboardPosition(PopupPosition pos)
void Init(void)
PopupPosition GetKeyboardPosition(void)
void SetFilter(InputFilter filter)
MythTimer m_lastKeyPress
void valueChanged()
void SetDBValue(const QString &text) override
QString GetDBValue(void) const override
QString m_messageBak
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
virtual bool gestureEvent(MythGestureEvent *event)
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuitype.cpp:456
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
virtual bool inputMethodEvent(QInputMethodEvent *event)
Input Method event handler.
Definition: mythuitype.cpp:998
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitype.cpp:73
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
virtual bool keyPressEvent(QKeyEvent *event)
Key event handler.
Definition: mythuitype.cpp:989
#define MUI_PUBLIC
Definition: mythuiexp.h:9
InputFilter
@ FilterAlpha
@ FilterPunct
@ FilterNone
@ FilterSymbols
@ FilterNumeric
@ FilterAlphaNumeric
PopupPosition
Preferred position to place virtual keyboard popup.
@ VK_POSBELOWEDIT
Mode
Definition: synaesthesia.h:23