KDEWebKit

kwebview.cpp
1 /*
2  * This file is part of the KDE project.
3  *
4  * Copyright (C) 2007 Trolltech ASA
5  * Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
6  * Copyright (C) 2008 Laurent Montel <[email protected]>
7  * Copyright (C) 2008 Michael Howell <[email protected]>
8  * Copyright (C) 2009 Dawit Alemayehu <adawit @ kde.org>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public License
21  * along with this library; see the file COPYING.LIB. If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  */
26 
27 #include "kwebview.h"
28 #include "kwebview_p.h"
29 #include "kwebpage.h"
30 
31 #include <QMouseEvent>
32 
33 KWebView::KWebView(QWidget *parent, bool createCustomPage)
34  : QWebView(parent), d(new KWebViewPrivate<KWebView>(this))
35 {
36  if (createCustomPage) {
37  setPage(new KWebPage(this));
38  }
39 }
40 
42 {
43  delete d;
44 }
45 
47 {
48  return d->isExternalContentAllowed();
49 }
50 
52 {
53  d->setAllowExternalContent(allow);
54 }
55 
57 {
58  if (d->wheelEvent(event->delta())) {
59  event->accept();
60  } else {
61  QWebView::wheelEvent(event);
62  }
63 }
64 
66 {
67  d->pressedButtons = event->buttons();
68  d->keyboardModifiers = event->modifiers();
69  QWebView::mousePressEvent(event);
70 }
71 
73 {
74  if (d->mouseReleased(event->pos()) || d->handleUrlPasteFromClipboard(event)) {
75  event->accept();
76  return;
77  }
78 
79  QWebView::mouseReleaseEvent(event);
80 }
81 
void setAllowExternalContent(bool allow)
Set allow to false if you want to prevent access to remote content.
Definition: kwebview.cpp:51
void wheelEvent(QWheelEvent *event) override
Definition: kwebview.cpp:56
void mousePressEvent(QMouseEvent *event) override
Definition: kwebview.cpp:65
KWebView(QWidget *parent=nullptr, bool createCustomPage=true)
Constructs a KWebView object with parent parent.
Definition: kwebview.cpp:33
~KWebView()
Destroys the KWebView.
Definition: kwebview.cpp:41
void mouseReleaseEvent(QMouseEvent *event) override
Definition: kwebview.cpp:72
An enhanced QWebPage that provides integration with KDE Frameworks.
Definition: kwebpage.h:75
A re-implementation of QWebView that provides integration with KDE frameworks.
Definition: kwebview.h:57
bool isExternalContentAllowed() const
Returns true if access to remote content is allowed.
Definition: kwebview.cpp:46
QPoint pos() const const
int delta() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:53:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.