9#include <QInputMethodEvent>
26#define LOC QString("MythUITextEdit: ")
44 LOG(VB_GENERAL, LOG_ERR,
LOC +
"selected state doesn't exist");
50 LOG(VB_GENERAL, LOG_ERR,
LOC +
"active state doesn't exist");
91 const QString &
filename, QDomElement &element,
bool showWarnings)
95 if (element.tagName() ==
"area")
99 else if (element.tagName() ==
"keyboardposition")
103 if (pos ==
"aboveedit")
105 else if (pos ==
"belowedit")
107 else if (pos ==
"screentop")
109 else if (pos ==
"screenbottom")
111 else if (pos ==
"screencenter")
116 QString(
"Unknown popup position '%1'").arg(pos));
157 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Missing text element.");
160 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Missing cursor element.");
163 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Missing background element.");
174 LOG(VB_GENERAL, LOG_ERR,
LOC +
"active state doesn't exist");
178 int height = fm.height();
183 int width = int(((
float)height / (
float)imageArea.height())
184 * (
float)imageArea.width());
228 for (
const auto& c : std::as_const(text))
241 const QChar *unichar = character.unicode();
244 if (!unichar->isPrint())
275 newmessage.append(str);
287 newmessage.remove(position, 1);
364 QClipboard *clipboard = QApplication::clipboard();
371 QClipboard *clipboard = QApplication::clipboard();
373 if (!clipboard->supportsSelection())
374 mode = QClipboard::Clipboard;
385 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_A)] = Qt::Key_Agrave;
386 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_A)] = Qt::Key_Aacute;
387 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_A)] = Qt::Key_Acircumflex;
388 map[
keyCombo(Qt::Key_Dead_Tilde, Qt::Key_A)] = Qt::Key_Atilde;
389 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_A)] = Qt::Key_Adiaeresis;
390 map[
keyCombo(Qt::Key_Dead_Abovering, Qt::Key_A)] = Qt::Key_Aring;
392 map[
keyCombo(Qt::Key_Dead_Cedilla, Qt::Key_C)] = Qt::Key_Ccedilla;
394 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_E)] = Qt::Key_Egrave;
395 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_E)] = Qt::Key_Eacute;
396 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_E)] = Qt::Key_Ecircumflex;
397 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_E)] = Qt::Key_Ediaeresis;
399 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_I)] = Qt::Key_Igrave;
400 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_I)] = Qt::Key_Iacute;
401 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_I)] = Qt::Key_Icircumflex;
402 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_I)] = Qt::Key_Idiaeresis;
404 map[
keyCombo(Qt::Key_Dead_Tilde, Qt::Key_N)] = Qt::Key_Ntilde;
406 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_O)] = Qt::Key_Ograve;
407 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_O)] = Qt::Key_Oacute;
408 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_O)] = Qt::Key_Ocircumflex;
409 map[
keyCombo(Qt::Key_Dead_Tilde, Qt::Key_O)] = Qt::Key_Otilde;
410 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_O)] = Qt::Key_Odiaeresis;
412 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_U)] = Qt::Key_Ugrave;
413 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_U)] = Qt::Key_Uacute;
414 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_U)] = Qt::Key_Ucircumflex;
415 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_U)] = Qt::Key_Udiaeresis;
417 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_Y)] = Qt::Key_Yacute;
418 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_Y)] = Qt::Key_ydiaeresis;
428 if (!
m_isIMEinput && (event->commitString().isEmpty() || event->preeditString().isEmpty()))
434 printf(
"IME: %s->%s PREEDIT=\"%s\" COMMIT=\"%s\"\n"
435 , (_bak) ?
"ON" :
"OFF"
437 , event->preeditString().toUtf8().constData()
438 , event->commitString().toUtf8().constData());
472 bool handled =
false;
477 Qt::KeyboardModifiers modifiers =
event->modifiers();
478 int keynum =
event->key();
480 if (keynum >= Qt::Key_Shift && keynum <= Qt::Key_CapsLock)
486 if (((modifiers & Qt::GroupSwitchModifier) != 0U) &&
487 (keynum >= Qt::Key_Dead_Grave) && (keynum <= Qt::Key_Dead_Horn))
497 LOG(VB_GUI, LOG_DEBUG, QString(
"Compose key: %1 Key: %2")
498 .arg(QString::number(
m_composeKey, 16), QString::number(keynum, 16)));
505 character = QChar(keycode);
507 if ((modifiers & Qt::ShiftModifier) != 0U)
508 character = character.toUpper();
510 character = character.toLower();
511 LOG(VB_GUI, LOG_DEBUG, QString(
"Found match for dead-key combo - %1").arg(character));
516 if (character.isEmpty())
517 character =
event->text();
522 for (
int i = 0; i < actions.size() && !handled; i++)
525 const QString&
action = actions[i];
532 else if (
action ==
"RIGHT")
540 else if (
action ==
"DOWN")
544 else if (
action ==
"PAGEUP")
548 else if (
action ==
"PAGEDOWN")
552 else if (
action ==
"DELETE")
556 else if (
action ==
"BACKSPACE")
560 else if (
action ==
"NEWLINE")
567 else if (
action ==
"SELECT" && keynum != Qt::Key_Space
568 &&
GetMythDB()->GetNumSetting(
"UseVirtualKeyboard", 1) == 1)
586 else if (
action ==
"COPY")
590 else if (
action ==
"PASTE")
610 bool handled =
false;
627 LOG(VB_GENERAL, LOG_ERR,
LOC +
"ERROR, bad parsing");
648 textedit->CopyFrom(
this);
A custom event that represents a mouse gesture.
Gesture GetGesture() const
Qt::MouseButton GetButton() const
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
std::chrono::milliseconds restart(void)
Returns milliseconds elapsed since last start() or restart() and resets the count.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
void start(void)
starts measuring elapsed time.
Image widget, displays a single image or multiple images in sequence.
void ForceSize(QSize size)
Force the dimensions of the widget and image to the given size.
This widget is used for grouping other widgets for display when a particular named state is called.
bool DisplayState(const QString &name)
A text entry and edit widget.
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
MythUIImage * m_cursorImage
bool InsertCharacter(const QString &character)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void SetInitialStates(void)
void PasteTextFromClipboard(QClipboard::Mode mode=QClipboard::Clipboard)
bool UpdateTmpString(const QString &str)
void SetText(const QString &text, bool moveCursor=true)
void RemoveCharacter(int position)
MythUITextEdit(MythUIType *parent, const QString &name)
PopupPosition m_keyboardPosition
void SetMaxLength(int length)
void CopyTextToClipboard(void)
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
MythUIStateType * m_backgroundState
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
void InsertText(const QString &text)
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
void Pulse(void) override
Pulse is called 70 times a second to trigger a single frame of an animation.
void CutTextToClipboard(void)
void Finalize(void) override
Perform any post-xml parsing initialisation tasks.
bool MoveCursor(MoveDirection moveDir)
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
bool inputMethodEvent(QInputMethodEvent *event) override
Input Method event handler.
All purpose text widget, displays a text string.
int MoveCursor(int lines)
QPoint CursorPosition(int text_offset)
const MythFontProperties * GetFontProperties()
void SetCutDown(Qt::TextElideMode mode)
virtual void SetText(const QString &text)
The base class on which all widgets and screens are based.
bool IsVisible(bool recurse=false) const
virtual void SetVisible(bool visible)
virtual void SetArea(const MythRect &rect)
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
virtual MythRect GetFullArea(void) const
void SetPosition(int x, int y)
Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality...
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
A popup onscreen keyboard for easy alphanumeric and text entry using a remote control or mouse.
static MythRect parseRect(const QString &text, bool normalize=true)
static QString getFirstText(QDomElement &element)
A C++ ripoff of the stroke library for MythTV.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
QPair< int, int > keyCombo
static QMap< keyCombo, int > gDeadKeyMap
static void LoadDeadKeys(QMap< QPair< int, int >, int > &map)
#define VERBOSE_XML(type, level, filename, element, msg)