Marble

MarbleWebView.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
4//
5
6#ifndef MARBLEWEBVIEW_H
7#define MARBLEWEBVIEW_H
8
9#include <QPaintEvent>
10#include <QWebEnginePage>
11#include <QWebEngineView>
12
13#include "marble_export.h"
14
15class MARBLE_EXPORT MarbleWebPage : public QWebEnginePage
16{
17 Q_OBJECT
18public:
19 explicit MarbleWebPage(QObject *parent = nullptr)
20 : QWebEnginePage(parent)
21 {
22 }
23
24Q_SIGNALS:
25 void linkClicked(const QUrl &url);
26
27protected:
28 bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override
29 {
30 Q_UNUSED(isMainFrame)
31 if (type == QWebEnginePage::NavigationTypeLinkClicked) {
32 emit linkClicked(url);
33 return false;
34 }
35 return true;
36 }
37};
38
39class MARBLE_EXPORT MarbleWebView : public QWebEngineView
40{
41 Q_OBJECT
42public:
43 explicit MarbleWebView(QWidget *parent = nullptr);
44
45protected:
46 void contextMenuEvent(QContextMenuEvent *event) override;
47 void keyPressEvent(QKeyEvent *event) override;
48
49private Q_SLOTS:
50 void copySelectedText();
51
52private:
53 QMenu *m_contextMenu;
54 QAction *m_copyAction;
55};
56
57#endif // MARBLEWEBVIEW_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:51:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.