summaryrefslogtreecommitdiffstats
path: root/src/core/api/qwebenginecontextmenurequest.cpp
blob: 0a98f8e56fce8c5509380b4f4f7a4b12c560ba33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default

#include "qwebenginecontextmenurequest.h"
#include "qwebenginecontextmenurequest_p.h"

QT_BEGIN_NAMESPACE

/*!
    \class QWebEngineContextMenuRequest
    \since 6.2
    \brief The QWebEngineContextMenuRequest class provides request for populating or extending a context menu with actions.

    \inmodule QtWebEngineCore

    QWebEngineContextMenuRequest is returned by QWebEngineView::lastContextMenuRequest() after a context menu event,
    and contains information about where the context menu event took place. This is also in the context
    in which any context specific QWebEnginePage::WebAction will be performed.
*/

/*!
    \enum QWebEngineContextMenuRequest::MediaType
    \readonly
    \since 6.2

    This enum describes the media type of the context menu request if any.

    \value MediaTypeNone The context is not a media type.
    \value MediaTypeImage The context is an image element.
    \value MediaTypeVideo The context is a video element.
    \value MediaTypeAudio The context is an audio element.
    \value MediaTypeCanvas The context is a canvas element.
    \value MediaTypeFile The context is a file.
    \value MediaTypePlugin The context is a plugin element.
*/

/*!
    \enum QWebEngineContextMenuRequest::EditFlag
    \readonly
    \since 6.2

    The available edit operations in the current context menu request.

    \value  CanUndo Undo is available.
    \value  CanRedo Redo is available.
    \value  CanCut Cut is available.
    \value  CanCopy Copy is available.
    \value  CanPaste Paste is available.
    \value  CanDelete Delete is available.
    \value  CanSelectAll Select All is available.
    \value  CanTranslate Translate is available.
    \value  CanEditRichly Context is richly editable.
*/

/*!
    \enum QWebEngineContextMenuRequest::MediaFlag
    \readonly
    \since 6.2

    The current media element's status and its available operations.
    \c MediaNone if the selected web page content is not a media element.

    \value  MediaInError An error occurred.
    \value  MediaPaused Media is paused.
    \value  MediaMuted Media is muted.
    \value  MediaLoop Media can be looped.
    \value  MediaCanSave Media can be saved.
    \value  MediaHasAudio Media has audio.
    \value  MediaCanToggleControls Media can show controls.
    \value  MediaControls Media controls are shown.
    \value  MediaCanPrint Media is printable.
    \value  MediaCanRotate Media is rotatable.
*/

/*!
     \internal
*/
QWebEngineContextMenuRequest::QWebEngineContextMenuRequest(
        QWebEngineContextMenuRequestPrivate *request)
    : d(request)
{
}

/*!
    Destroys the context menu request.
*/
QWebEngineContextMenuRequest::~QWebEngineContextMenuRequest() = default;

/*!
    \property QWebEngineContextMenuRequest::position
    \brief The position of the context menu request, usually the mouse
    position where the context menu event was triggered.
*/
QPoint QWebEngineContextMenuRequest::position() const
{
    return d->m_position;
}

/*!
    \property QWebEngineContextMenuRequest::selectedText
    \brief The selected text of the context menu request.
*/
QString QWebEngineContextMenuRequest::selectedText() const
{
    return d->m_selectedText;
}

/*!
    \property QWebEngineContextMenuRequest::linkText
    \brief The text of a link if the context menu request was requested for a link.
*/
QString QWebEngineContextMenuRequest::linkText() const
{
    return d->m_linkText;
}

/*!
    \property QWebEngineContextMenuRequest::linkUrl
    \brief The URL of a link if the menu context request is a link.

    It is not guaranteed to be a valid URL.
*/
QUrl QWebEngineContextMenuRequest::linkUrl() const
{
    return d->m_unfilteredLinkUrl;
}

/*!
    \property QWebEngineContextMenuRequest::mediaUrl
    \brief The URL of the media element if the context menu request is a media element.
*/
QUrl QWebEngineContextMenuRequest::mediaUrl() const
{
    return d->m_mediaUrl;
}

/*!
    \property QWebEngineContextMenuRequest::mediaType
    \brief The type of the media element or \c MediaTypeNone
    if the context menu request is not a media element.
*/
QWebEngineContextMenuRequest::MediaType QWebEngineContextMenuRequest::mediaType() const
{
    return static_cast<QWebEngineContextMenuRequest::MediaType>(d->m_mediaType);
}

/*!
    \property QWebEngineContextMenuRequest::isContentEditable
    \brief Whether the context menu request is editable by the user.
*/
bool QWebEngineContextMenuRequest::isContentEditable() const
{
    return d->m_isEditable;
}

/*!
    \property QWebEngineContextMenuRequest::misspelledWord
    \brief The misspelled word if the menu context request is a word
    considered misspelled by the spell-checker.

    For possible replacements of the word, see spellCheckerSuggestions().
*/
QString QWebEngineContextMenuRequest::misspelledWord() const
{
    return d->m_misspelledWord;
}


/*!
    \property QWebEngineContextMenuRequest::spellCheckerSuggestions
    \brief A list of suggested replacements for misspelledWord() if the menu
    context request is a word considered misspelled by the spell-checker.
*/
QStringList QWebEngineContextMenuRequest::spellCheckerSuggestions() const
{
    return d->m_spellCheckerSuggestions;
}

/*!
    \property QWebEngineContextMenuRequest::accepted
    \brief Whether the request is accepted.
*/
bool QWebEngineContextMenuRequest::isAccepted() const
{
    return d->m_accepted;
}

void QWebEngineContextMenuRequest::setAccepted(bool accepted)
{
    d->m_accepted = accepted;
}

/*!
    \property QWebEngineContextMenuRequest::mediaFlags
    \brief The current media element's status and its available operations.

    Returns \c MediaNone if the selected web page content is not a media element.
*/
QWebEngineContextMenuRequest::MediaFlags QWebEngineContextMenuRequest::mediaFlags() const
{
    return static_cast<QWebEngineContextMenuRequest::MediaFlags>(d->m_mediaFlags);
}

/*!
    \property QWebEngineContextMenuRequest::editFlags
    \brief The available edit operations in the current context.

    Returns \c CanDoNone if no actions are available.
*/
QWebEngineContextMenuRequest::EditFlags QWebEngineContextMenuRequest::editFlags() const
{
    return static_cast<QWebEngineContextMenuRequest::EditFlags>(d->m_editFlags);
}

/*!
  \internal
*/
QUrl QWebEngineContextMenuRequest::filteredLinkUrl() const
{
    return d->m_filteredLinkUrl;
}

/*!
  \internal
*/
QString QWebEngineContextMenuRequest::altText() const
{
    return d->m_altText;
}

/*!
  \internal
*/
QString QWebEngineContextMenuRequest::titleText() const
{
    return d->m_titleText;
}

/*!
  \internal
*/
QUrl QWebEngineContextMenuRequest::referrerUrl() const
{
    return !d->m_frameUrl.isEmpty() ? d->m_frameUrl : d->m_pageUrl;
}

/*!
  \internal
*/
QtWebEngineCore::ReferrerPolicy QWebEngineContextMenuRequest::referrerPolicy() const
{
    return d->m_referrerPolicy;
}

/*!
  \internal
*/
QString QWebEngineContextMenuRequest::suggestedFileName() const
{
    return d->m_suggestedFileName;
}

/*!
  \internal
*/
bool QWebEngineContextMenuRequest::hasImageContent() const
{
    return d->m_hasImageContent;
}

QT_END_NAMESPACE

#include "moc_qwebenginecontextmenurequest.cpp"