Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qinputcontrol.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qinputcontrol_p.h"
5#include <QtGui/qevent.h>
6
8
10 : QObject(parent)
11 , m_type(type)
12{
13}
14
16 : QObject(dd, parent)
17 , m_type(type)
18{
19}
20
22{
23 const QString text = event->text();
24 if (text.isEmpty())
25 return false;
26
27 const QChar c = text.at(0);
28
29 // Formatting characters such as ZWNJ, ZWJ, RLM, etc. This needs to go before the
30 // next test, since CTRL+SHIFT is sometimes used to input it on Windows.
31 if (c.category() == QChar::Other_Format)
32 return true;
33
34 // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards
35 if (event->modifiers() == Qt::ControlModifier
36 || event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
37 return false;
38 }
39
40 if (c.isPrint())
41 return true;
42
43 if (c.category() == QChar::Other_PrivateUse)
44 return true;
45
46 if (c.isHighSurrogate() && text.size() > 1 && text.at(1).isLowSurrogate())
47 return true;
48
49 if (m_type == TextEdit && c == u'\t')
50 return true;
51
52 return false;
53}
54
56{
57 if (ke->modifiers() == Qt::NoModifier
58 || ke->modifiers() == Qt::ShiftModifier
59 || ke->modifiers() == Qt::KeypadModifier) {
60 if (ke->key() < Qt::Key_Escape) {
61 return true;
62 } else {
63 switch (ke->key()) {
64 case Qt::Key_Return:
65 case Qt::Key_Enter:
66 case Qt::Key_Delete:
67 case Qt::Key_Home:
68 case Qt::Key_End:
70 case Qt::Key_Left:
71 case Qt::Key_Right:
72 case Qt::Key_Up:
73 case Qt::Key_Down:
74 case Qt::Key_Tab:
75 return true;
76 default:
77 break;
78 }
79 }
80#if QT_CONFIG(shortcut)
81 } else if (ke->matches(QKeySequence::Copy)
82 || ke->matches(QKeySequence::Paste)
83 || ke->matches(QKeySequence::Cut)
84 || ke->matches(QKeySequence::Redo)
85 || ke->matches(QKeySequence::Undo)
86 || ke->matches(QKeySequence::MoveToNextWord)
90 || ke->matches(QKeySequence::SelectNextWord)
93 || ke->matches(QKeySequence::SelectEndOfLine)
95 || ke->matches(QKeySequence::SelectEndOfBlock)
98 || ke->matches(QKeySequence::SelectAll)
99 ) {
100 return true;
101#endif
102 }
103 return false;
104}
105
107
108#include "moc_qinputcontrol_p.cpp"
\inmodule QtCore
static bool isCommonTextEditShortcut(const QKeyEvent *ke)
bool isAcceptableInput(const QKeyEvent *event) const
QInputControl(Type type, QObject *parent=nullptr)
The QKeyEvent class describes a key event.
Definition qevent.h:424
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
QString text
Combined button and popup list for selecting options.
@ Key_Escape
Definition qnamespace.h:663
@ Key_Tab
Definition qnamespace.h:664
@ Key_Return
Definition qnamespace.h:667
@ Key_Right
Definition qnamespace.h:679
@ Key_Enter
Definition qnamespace.h:668
@ Key_Backspace
Definition qnamespace.h:666
@ Key_Left
Definition qnamespace.h:677
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
@ Key_Delete
Definition qnamespace.h:670
@ Key_Home
Definition qnamespace.h:675
@ Key_End
Definition qnamespace.h:676
@ ShiftModifier
@ ControlModifier
@ KeypadModifier
@ NoModifier
GLenum type
struct _cl_event * event
const GLubyte * c
Definition moc.h:23