5 #include <QApplication> 9 #include <QDomDocument> 26 #define LOC QString("MythUITextEdit: ") 64 LOG(VB_GENERAL, LOG_ERR,
LOC +
"selected state doesn't exist");
70 LOG(VB_GENERAL, LOG_ERR,
LOC +
"active state doesn't exist");
109 const QString &filename, QDomElement &element,
bool showWarnings)
113 if (element.tagName() ==
"area")
117 else if (element.tagName() ==
"keyboardposition")
121 if (pos ==
"aboveedit")
123 else if (pos ==
"belowedit")
125 else if (pos ==
"screentop")
127 else if (pos ==
"screenbottom")
129 else if (pos ==
"screencenter")
133 VERBOSE_XML(VB_GENERAL, LOG_ERR, filename, element,
134 QString(
"Unknown popup position '%1'").arg(pos));
172 dynamic_cast<MythUIStateType *>(
GetChild(
"background"));
175 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Missing text element.");
178 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Missing cursor element.");
181 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Missing background element.");
192 LOG(VB_GENERAL, LOG_ERR,
LOC +
"active state doesn't exist");
196 int height = fm.height();
201 int width = int(((
float)height / (
float)imageArea.height())
202 * (
float)imageArea.width());
246 for (; i < text.size(); ++i)
261 const QChar *unichar = character.unicode();
264 if (!unichar->isPrint())
293 newmessage.remove(position, 1);
370 QClipboard *clipboard = QApplication::clipboard();
377 QClipboard *clipboard = QApplication::clipboard();
379 if (!clipboard->supportsSelection())
380 mode = QClipboard::Clipboard;
391 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_A)] = Qt::Key_Agrave;
392 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_A)] = Qt::Key_Aacute;
393 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_A)] = Qt::Key_Acircumflex;
394 map[
keyCombo(Qt::Key_Dead_Tilde, Qt::Key_A)] = Qt::Key_Atilde;
395 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_A)] = Qt::Key_Adiaeresis;
396 map[
keyCombo(Qt::Key_Dead_Abovering, Qt::Key_A)] = Qt::Key_Aring;
398 map[
keyCombo(Qt::Key_Dead_Cedilla, Qt::Key_C)] = Qt::Key_Ccedilla;
400 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_E)] = Qt::Key_Egrave;
401 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_E)] = Qt::Key_Eacute;
402 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_E)] = Qt::Key_Ecircumflex;
403 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_E)] = Qt::Key_Ediaeresis;
405 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_I)] = Qt::Key_Igrave;
406 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_I)] = Qt::Key_Iacute;
407 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_I)] = Qt::Key_Icircumflex;
408 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_I)] = Qt::Key_Idiaeresis;
410 map[
keyCombo(Qt::Key_Dead_Tilde, Qt::Key_N)] = Qt::Key_Ntilde;
412 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_O)] = Qt::Key_Ograve;
413 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_O)] = Qt::Key_Oacute;
414 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_O)] = Qt::Key_Ocircumflex;
415 map[
keyCombo(Qt::Key_Dead_Tilde, Qt::Key_O)] = Qt::Key_Otilde;
416 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_O)] = Qt::Key_Odiaeresis;
418 map[
keyCombo(Qt::Key_Dead_Grave, Qt::Key_U)] = Qt::Key_Ugrave;
419 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_U)] = Qt::Key_Uacute;
420 map[
keyCombo(Qt::Key_Dead_Circumflex, Qt::Key_U)] = Qt::Key_Ucircumflex;
421 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_U)] = Qt::Key_Udiaeresis;
423 map[
keyCombo(Qt::Key_Dead_Acute, Qt::Key_Y)] = Qt::Key_Yacute;
424 map[
keyCombo(Qt::Key_Dead_Diaeresis, Qt::Key_Y)] = Qt::Key_ydiaeresis;
434 bool handled =
false;
439 Qt::KeyboardModifiers modifiers =
event->modifiers();
440 int keynum =
event->key();
442 if (keynum >= Qt::Key_Shift && keynum <= Qt::Key_CapsLock)
448 if ((modifiers & Qt::GroupSwitchModifier) &&
449 (keynum >= Qt::Key_Dead_Grave) && (keynum <= Qt::Key_Dead_Horn))
459 LOG(VB_GUI, LOG_DEBUG, QString(
"Compose key: %1 Key: %2").arg(QString::number(
m_composeKey, 16)).arg(QString::number(keynum, 16)));
466 character = QChar(keycode);
468 if (modifiers & Qt::ShiftModifier)
469 character = character.toUpper();
471 character = character.toLower();
472 LOG(VB_GUI, LOG_DEBUG, QString(
"Found match for dead-key combo - %1").arg(character));
477 if (character.isEmpty())
478 character = event->text();
483 for (
int i = 0; i < actions.size() && !handled; i++)
486 QString
action = actions[i];
493 else if (
action ==
"RIGHT")
501 else if (
action ==
"DOWN")
505 else if (
action ==
"PAGEUP")
509 else if (
action ==
"PAGEDOWN")
513 else if (
action ==
"DELETE")
517 else if (
action ==
"BACKSPACE")
521 else if (
action ==
"NEWLINE")
528 else if (
action ==
"SELECT" && keynum != Qt::Key_Space
529 &&
GetMythDB()->GetNumSetting(
"UseVirtualKeyboard", 1) == 1)
546 else if (
action ==
"COPY")
550 else if (
action ==
"PASTE")
568 bool handled =
false;
585 LOG(VB_GENERAL, LOG_ERR,
LOC +
"ERROR, bad parsing");
#define VERBOSE_XML(type, level, filename, element, msg)
int restart(void)
Returns milliseconds elapsed since last start() or restart() and resets the count.
void PasteTextFromClipboard(QClipboard::Mode mode=QClipboard::Clipboard)
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
static QMap< keyCombo, int > gDeadKeyMap
bool IsVisible(bool recurse=false) const
void RemoveCharacter(int position)
virtual void SetText(const QString &text)
void CutTextToClipboard(void)
MythScreenStack * GetStack(const QString &stackname)
Gesture gesture(void) const
Get the gesture type.
bool gestureEvent(MythGestureEvent *) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
The base class on which all widgets and screens are based.
void SetPosition(int x, int y)
Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality...
MythUIImage * m_cursorImage
bool keyPressEvent(QKeyEvent *) override
Key event handler.
MythUITextEdit(MythUIType *parent, const QString &name)
void Finalize(void) override
Perform any post-xml parsing initialisation tasks.
virtual void SetVisible(bool visible)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void SetMaxLength(const int length)
void CopyTextToClipboard(void)
QPair< int, int > keyCombo
A C++ ripoff of the stroke library for MythTV.
void SetInitialStates(void)
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
static QString getFirstText(QDomElement &element)
A text entry and edit widget.
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
A custom event that represents a mouse gesture.
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
void SetCutDown(Qt::TextElideMode mode)
void SetText(const QString &text, bool moveCursor=true)
MythMainWindow * GetMythMainWindow(void)
int elapsed(void) const
Returns milliseconds elapsed since last start() or restart()
static void LoadDeadKeys(QMap< QPair< int, int >, int > &map)
virtual void SetArea(const MythRect &rect)
#define LOG(_MASK_, _LEVEL_, _STRING_)
MythUIStateType * m_backgroundState
virtual MythRect GetFullArea(void) const
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
bool InsertCharacter(const QString &character)
bool DisplayState(const QString &name)
void InsertText(const QString &text)
bool MoveCursor(MoveDirection)
static MythRect parseRect(const QString &text, bool normalize=true)
bool Create(void) override
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
int MoveCursor(int lines)
const MythFontProperties * GetFontProperties()
void ForceSize(const QSize &size)
Force the dimensions of the widget and image to the given size.
PopupPosition m_keyboardPosition
A popup onscreen keyboard for easy alphanumeric and text entry using a remote control or mouse.
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
void start(void)
starts measuring elapsed time.
void Pulse(void) override
Pulse is called 70 times a second to trigger a single frame of an animation.
QPoint CursorPosition(int text_offset)
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.