summaryrefslogtreecommitdiffstats
path: root/src/core/render_view_context_menu_qt.h
blob: 71901424c892747ed9da60767070c455998d36f5 (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
// Copyright (C) 2018 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

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#ifndef RENDER_VIEW_CONTEXT_MENU_QT_H
#define RENDER_VIEW_CONTEXT_MENU_QT_H

#include "web_contents_adapter_client.h"

QT_FORWARD_DECLARE_CLASS(QWebEngineContextMenuRequest)

namespace QtWebEngineCore {

class Q_WEBENGINECORE_EXPORT RenderViewContextMenuQt
{
public:
    enum ContextMenuItem {
        Back = 0,
        Forward,
        Reload,

        Cut,
        Copy,
        Paste,

        Undo,
        Redo,
        SelectAll,

        PasteAndMatchStyle,

        OpenLinkInNewWindow,
        OpenLinkInNewTab,
        CopyLinkToClipboard,
        DownloadLinkToDisk,

        CopyImageToClipboard,
        CopyImageUrlToClipboard,
        DownloadImageToDisk,

        CopyMediaUrlToClipboard,
        ToggleMediaControls,
        ToggleMediaLoop,
        DownloadMediaToDisk,

        InspectElement,
        ExitFullScreen,
        SavePage,
        ViewSource,

        SpellingSuggestions,

        Separator
    };

    static const QString getMenuItemName(RenderViewContextMenuQt::ContextMenuItem menuItem);

    RenderViewContextMenuQt(QWebEngineContextMenuRequest *data);
    void initMenu();

protected:
    virtual bool hasInspector() = 0;
    virtual bool isFullScreenMode() = 0;

    virtual void addMenuItem(ContextMenuItem menuItem) = 0;
    virtual bool isMenuItemEnabled(ContextMenuItem menuItem) = 0;

    QWebEngineContextMenuRequest *m_contextData;

private:
    void appendCanvasItems();
    void appendCopyItem();
    void appendEditableItems();
    void appendExitFullscreenItem();
    void appendDeveloperItems();
    void appendImageItems();
    void appendLinkItems();
    void appendMediaItems();
    void appendPageItems();
    void appendSpellingSuggestionItems();
    void appendSeparatorItem();
    bool canViewSource();
};

}

#endif // RENDER_VIEW_CONTEXT_MENU_QT_H