Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qaccessiblehelper.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 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
"qaccessiblehelper_p.h"
5
6
QT_BEGIN_NAMESPACE
7
8
using
namespace
Qt::StringLiterals;
9
10
/* This function will return the offset of the '&' in the text that would be
11
preceding the accelerator character.
12
If this text does not have an accelerator, -1 will be returned. */
13
static
qsizetype
qt_accAmpIndex
(
const
QString &text)
14
{
15
#
ifndef
QT_NO_SHORTCUT
16
if
(text.isEmpty())
17
return
-1;
18
19
qsizetype fa = 0;
20
while
((fa = text.indexOf(u'&', fa)) != -1) {
21
++fa;
22
if
(fa < text.size()) {
23
// ignore "&&"
24
if
(text.at(fa) == u'&') {
25
++fa;
26
continue
;
27
}
else
{
28
return
fa - 1;
29
break
;
30
}
31
}
32
}
33
34
return
-1;
35
#
else
36
Q_UNUSED(text);
37
return
-1;
38
#
endif
39
}
40
41
QString
qt_accStripAmp
(
const
QString &text)
42
{
43
QString newText(text);
44
qsizetype ampIndex = qt_accAmpIndex(newText);
45
if
(ampIndex != -1)
46
newText.remove(ampIndex, 1);
47
48
return
newText.replace(
"&&"_L1
,
"&"_L1
);
49
}
50
51
QT_END_NAMESPACE
QPlatformGraphicsBufferHelper
\inmodule QtGui
qt_accStripAmp
QString qt_accStripAmp(const QString &text)
Definition
qaccessiblehelper.cpp:41
qt_accAmpIndex
static qsizetype qt_accAmpIndex(const QString &text)
Definition
qaccessiblehelper.cpp:13
qtbase
src
gui
accessible
qaccessiblehelper.cpp
Generated on
for Qt by
1.14.0