An error occurred while loading the file. Please try again.
-
Jocelyn Turcotte authored
Also update all the examples to use 1.0 as 0.9 shouldn't be publically recommended. Change-Id: Ic58e35bdfd3a0f3d5201fc069b7103027ba84574 Reviewed-by:
Andras Becsi <andras.becsi@digia.com>
da4ea674
/*
Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef QWEBENGINEPAGE_H
#define QWEBENGINEPAGE_H
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebenginesettings.h>
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
class QUndoStack;
class QMenu;
class QPrinter;
// FIXME: Just forward-declare the to-be-removed frame and element classes for now.
// Referencing calls should be ported to be page-friendly or removed individually.
class QWebEngineFrame;
class QWebEngineElement;
class QWebEngineElementCollection;
class QWebEngineHistory;
class QWebEngineHistoryItem;
class QWebEnginePage;
class QWebEnginePagePrivate;
class QWebEnginePluginFactory;
class QWebEngineSecurityOrigin;
class QtViewportAttributesPrivate;
class QWebEngineHitTestResultPrivate;
namespace QtWebEnginePrivate {
template <typename T>
class QWebEngineCallbackPrivateBase : public QSharedData {
public:
virtual ~QWebEngineCallbackPrivateBase() {}
virtual void operator()(T) = 0;
};
template <typename T, typename F>
class QWebEngineCallbackPrivate : public QWebEngineCallbackPrivateBase<T> {
public:
QWebEngineCallbackPrivate(F callable) : m_callable(callable) {}
virtual void operator()(T value) Q_DECL_OVERRIDE { m_callable(value); }
private:
F m_callable;
};
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
} // namespace QtWebEnginePrivate
template <typename T>
class QWebEngineCallback {
public:
template <typename F>
QWebEngineCallback(F f) : d(new QtWebEnginePrivate::QWebEngineCallbackPrivate<T, F>(f)) { }
private:
QExplicitlySharedDataPointer<QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> > d;
friend class QWebEnginePage;
};
class QWEBENGINEWIDGETS_EXPORT QWebEngineHitTestResult {
public:
QWebEngineHitTestResult();
QWebEngineHitTestResult(const QWebEngineHitTestResult &other);
QWebEngineHitTestResult &operator=(const QWebEngineHitTestResult &other);
~QWebEngineHitTestResult();
bool isNull() const;
QPoint pos() const;
QRect boundingRect() const;
QWebEngineElement enclosingBlockElement() const;
QString title() const;
QString linkText() const;
QUrl linkUrl() const;
QUrl linkTitle() const;
QWebEngineFrame *linkTargetFrame() const;
QWebEngineElement linkElement() const;
QString alternateText() const; // for img, area, input and applet
QUrl imageUrl() const;
QPixmap pixmap() const;
bool isContentEditable() const;
bool isContentSelected() const;
QWebEngineElement element() const;
QWebEngineFrame *frame() const;
};
class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_OBJECT
// Hack to avoid undefined symbols with properties until we have them implemented.
#ifndef Q_MOC_RUN
Q_PROPERTY(bool modified READ isModified)
Q_PROPERTY(QString selectedText READ selectedText)
Q_PROPERTY(QString selectedHtml READ selectedHtml)
Q_PROPERTY(bool hasSelection READ hasSelection)
Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
Q_PROPERTY(QSize preferredContentsSize READ preferredContentsSize WRITE setPreferredContentsSize)
Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent)
Q_PROPERTY(LinkDelegationPolicy linkDelegationPolicy READ linkDelegationPolicy WRITE setLinkDelegationPolicy)
Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
Q_PROPERTY(bool contentEditable READ isContentEditable WRITE setContentEditable)
Q_ENUMS(LinkDelegationPolicy NavigationType WebAction)
// Ex-QWebFrame properties
Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
Q_PROPERTY(QUrl baseUrl READ baseUrl)
Q_PROPERTY(QIcon icon READ icon)
Q_PROPERTY(QSize contentsSize READ contentsSize)
Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
Q_PROPERTY(bool focus READ hasFocus)
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
#endif
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
Q_PROPERTY(QString title READ title)
Q_PROPERTY(QUrl url READ url WRITE setUrl)
public:
enum NavigationType {
NavigationTypeLinkClicked,
NavigationTypeFormSubmitted,
NavigationTypeBackOrForward,
NavigationTypeReload,
NavigationTypeFormResubmitted,
NavigationTypeOther
};
enum WebAction {
NoWebAction = - 1,
OpenLink,
OpenLinkInNewWindow,
OpenFrameInNewWindow,
DownloadLinkToDisk,
CopyLinkToClipboard,
OpenImageInNewWindow,
DownloadImageToDisk,
CopyImageToClipboard,
Back,
Forward,
Stop,
Reload,
Cut,
Copy,
Paste,
Undo,
Redo,
MoveToNextChar,
MoveToPreviousChar,
MoveToNextWord,
MoveToPreviousWord,
MoveToNextLine,
MoveToPreviousLine,
MoveToStartOfLine,
MoveToEndOfLine,
MoveToStartOfBlock,
MoveToEndOfBlock,
MoveToStartOfDocument,
MoveToEndOfDocument,
SelectNextChar,
SelectPreviousChar,
SelectNextWord,
SelectPreviousWord,
SelectNextLine,
SelectPreviousLine,
SelectStartOfLine,
SelectEndOfLine,
SelectStartOfBlock,
SelectEndOfBlock,
SelectStartOfDocument,
SelectEndOfDocument,
DeleteStartOfWord,
DeleteEndOfWord,
SetTextDirectionDefault,
SetTextDirectionLeftToRight,
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
SetTextDirectionRightToLeft,
ToggleBold,
ToggleItalic,
ToggleUnderline,
InspectElement,
InsertParagraphSeparator,
InsertLineSeparator,
SelectAll,
ReloadAndBypassCache,
PasteAndMatchStyle,
RemoveFormat,
ToggleStrikethrough,
ToggleSubscript,
ToggleSuperscript,
InsertUnorderedList,
InsertOrderedList,
Indent,
Outdent,
AlignCenter,
AlignJustified,
AlignLeft,
AlignRight,
StopScheduledPageRefresh,
CopyImageUrlToClipboard,
OpenLinkInThisWindow,
WebActionCount
};
enum FindFlag {
FindBackward = 1,
FindCaseSensitively = 2,
FindWrapsAroundDocument = 4,
HighlightAllOccurrences = 8
};
Q_DECLARE_FLAGS(FindFlags, FindFlag)
enum LinkDelegationPolicy {
DontDelegateLinks,
DelegateExternalLinks,
DelegateAllLinks
};
enum WebWindowType {
WebBrowserWindow,
WebModalDialog
};
enum PermissionPolicy {
PermissionUnknown,
PermissionGrantedByUser,
PermissionDeniedByUser
};
enum Feature {
Notifications,
Geolocation
};
// Ex-QWebFrame enum
281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
enum ValueOwnership {
QtOwnership,
ScriptOwnership,
AutoOwnership
};
enum FileSelectionMode {
FileSelectOpen,
FileSelectOpenMultiple,
};
class QWEBENGINEWIDGETS_EXPORT ViewportAttributes {
public:
ViewportAttributes();
ViewportAttributes(const QWebEnginePage::ViewportAttributes& other);
~ViewportAttributes();
QWebEnginePage::ViewportAttributes& operator=(const QWebEnginePage::ViewportAttributes& other);
inline qreal initialScaleFactor() const { return m_initialScaleFactor; }
inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; }
inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; }
inline qreal devicePixelRatio() const { return m_devicePixelRatio; }
inline bool isUserScalable() const { return m_isUserScalable; }
inline bool isValid() const { return m_isValid; }
inline QSizeF size() const { return m_size; }
private:
QSharedDataPointer<QtViewportAttributesPrivate> d;
qreal m_initialScaleFactor;
qreal m_minimumScaleFactor;
qreal m_maximumScaleFactor;
qreal m_devicePixelRatio;
bool m_isUserScalable;
bool m_isValid;
QSizeF m_size;
friend class QWebEnginePage;
};
explicit QWebEnginePage(QObject *parent = 0);
~QWebEnginePage();
QWebEngineFrame *mainFrame() const;
QWebEngineFrame *currentFrame() const;
QWebEngineFrame* frameAt(const QPoint& pos) const;
QWebEngineHistory *history() const;
QWebEngineSettings *settings() const;
void setView(QWidget *view);
QWidget *view() const;
bool isModified() const;
#ifndef QT_NO_UNDOSTACK
QUndoStack *undoStack() const;
#endif
void setNetworkAccessManager(QNetworkAccessManager *manager);
QNetworkAccessManager *networkAccessManager() const;
void setPluginFactory(QWebEnginePluginFactory *factory);
QWebEnginePluginFactory *pluginFactory() const;
quint64 totalBytes() const;
quint64 bytesReceived() const;
bool hasSelection() const;