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 <QWebEngineView>
10#include <QWebEnginePage>
11#include <QPaintEvent>
12
13#include "marble_export.h"
14
15class MARBLE_EXPORT MarbleWebPage : public QWebEnginePage
16{
17 Q_OBJECT
18public:
19 explicit MarbleWebPage(QObject *parent = nullptr) : QWebEnginePage(parent){}
20
21Q_SIGNALS:
22 void linkClicked(const QUrl & url);
23protected:
24 bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override {
25 Q_UNUSED(isMainFrame)
26 if (type == QWebEnginePage::NavigationTypeLinkClicked) {
27 emit linkClicked(url);
28 return false;
29 }
30 return true;
31 }
32};
33
34class MARBLE_EXPORT MarbleWebView : public QWebEngineView
35{
36 Q_OBJECT
37public:
38 explicit MarbleWebView(QWidget *parent = nullptr);
39
40protected:
41 void contextMenuEvent(QContextMenuEvent *event) override;
42 void keyPressEvent(QKeyEvent *event) override;
43
44private Q_SLOTS:
45 void copySelectedText();
46
47private:
48 QMenu *m_contextMenu;
49 QAction *m_copyAction;
50};
51
52#endif // MARBLEWEBVIEW_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.