Marble

MarbleWebView.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <[email protected]>
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 
15 class MARBLE_EXPORT MarbleWebPage : public QWebEnginePage
16 {
17  Q_OBJECT
18 public:
19  explicit MarbleWebPage(QObject *parent = nullptr) : QWebEnginePage(parent){}
20 
21 Q_SIGNALS:
22  void linkClicked(const QUrl & url);
23 protected:
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 
34 class MARBLE_EXPORT MarbleWebView : public QWebEngineView
35 {
36  Q_OBJECT
37 public:
38  explicit MarbleWebView(QWidget *parent = nullptr);
39 
40 protected:
41  void contextMenuEvent(QContextMenuEvent *event) override;
42  void keyPressEvent(QKeyEvent *event) override;
43 
44 private Q_SLOTS:
45  void copySelectedText();
46 
47 private:
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-2023 The KDE developers.
Generated on Wed Oct 4 2023 04:09:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.