1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 17:42:10 +01:00
falkonOfficial/src/lib/webengine/webview.h

196 lines
5.5 KiB
C
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
2011-03-03 18:29:20 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
2011-03-02 16:57:41 +01:00
#ifndef WEBVIEW_H
#define WEBVIEW_H
#include <QIcon>
#include <QWebEngineView>
#include "qzcommon.h"
#include "loadrequest.h"
class WebPage;
class LoadRequest;
2015-02-08 11:13:12 +01:00
class IconLoader;
2015-09-29 23:15:46 +02:00
class WebHitTestResult;
class QUPZILLA_EXPORT WebView : public QWebEngineView
2011-03-02 16:57:41 +01:00
{
Q_OBJECT
public:
explicit WebView(QWidget* parent = 0);
~WebView();
2011-03-02 16:57:41 +01:00
QIcon icon() const;
QString title() const;
bool isTitleEmpty() const;
WebPage* page() const;
void setPage(WebPage* page);
void load(const QUrl &url);
void load(const LoadRequest &request);
bool isLoading() const;
int loadingProgress() const;
void fakeLoadingProgress(int progress);
2011-03-02 16:57:41 +01:00
// Set zoom level (0 - 17)
int zoomLevel() const;
void setZoomLevel(int level);
QPoint mapToViewport(const QPoint &pos) const;
void restoreHistory(const QByteArray &data);
void addNotification(QWidget* notif);
2015-09-29 17:21:49 +02:00
bool eventFilter(QObject *obj, QEvent *event);
QWidget *inputWidget() const;
virtual QWidget* overlayWidget() = 0;
2011-03-02 16:57:41 +01:00
static bool isUrlValid(const QUrl &url);
static QList<int> zoomLevels();
// Force context menu event to be sent on mouse release
// This allows to override right mouse button events (eg. for mouse gestures)
static bool forceContextMenuOnMouseRelease();
static void setForceContextMenuOnMouseRelease(bool force);
signals:
2015-02-08 11:13:12 +01:00
void iconChanged();
void viewportResized(QSize);
void showNotification(QWidget*);
2012-04-03 20:23:15 +02:00
void privacyChanged(bool);
void zoomLevelChanged(int);
2011-03-02 16:57:41 +01:00
public slots:
void zoomIn();
void zoomOut();
void zoomReset();
void editUndo();
void editRedo();
void editCut();
void editCopy();
void editPaste();
void editSelectAll();
void editDelete();
void reloadBypassCache();
void back();
void forward();
void showSource();
2012-04-01 18:57:42 +02:00
void sendPageByMail();
2011-03-02 16:57:41 +01:00
void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position);
virtual void closeView() = 0;
virtual void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) = 0;
2011-03-02 16:57:41 +01:00
virtual bool isFullScreen() = 0;
virtual void requestFullScreen(bool enable) = 0;
protected slots:
void slotLoadStarted();
void slotLoadProgress(int progress);
void slotLoadFinished(bool ok);
void slotUrlChanged(const QUrl &url);
2015-02-08 11:13:12 +01:00
void slotIconUrlChanged(const QUrl &url);
// Context menu slots
2011-03-02 16:57:41 +01:00
void openUrlInNewWindow();
void sendLinkByMail();
void copyLinkToClipboard();
void copyImageToClipboard();
void downloadLinkToDisk();
void downloadImageToDisk();
void downloadMediaToDisk();
void openActionUrl();
2011-03-02 16:57:41 +01:00
void showSiteInfo();
void searchSelectedText();
void searchSelectedTextInBackgroundTab();
void bookmarkLink();
void openUrlInSelectedTab();
void openUrlInBackgroundTab();
// To support user's option whether to open in selected or background tab
void userDefinedOpenUrlInNewTab(const QUrl &url = QUrl(), bool invert = false);
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
protected:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
2015-09-29 17:21:49 +02:00
void resizeEvent(QResizeEvent *event);
2015-09-29 23:15:46 +02:00
void contextMenuEvent(QContextMenuEvent *event);
2015-09-29 17:21:49 +02:00
virtual void _wheelEvent(QWheelEvent *event);
virtual void _mousePressEvent(QMouseEvent *event);
virtual void _mouseReleaseEvent(QMouseEvent *event);
virtual void _mouseMoveEvent(QMouseEvent *event);
virtual void _keyPressEvent(QKeyEvent *event);
virtual void _keyReleaseEvent(QKeyEvent *event);
2015-09-29 23:15:46 +02:00
virtual void _contextMenuEvent(QContextMenuEvent *event);
void loadRequest(const LoadRequest &req);
2011-03-02 16:57:41 +01:00
void applyZoom();
2015-09-29 23:15:46 +02:00
void createContextMenu(QMenu *menu, const WebHitTestResult &hitTest);
void createPageContextMenu(QMenu *menu);
void createLinkContextMenu(QMenu *menu, const WebHitTestResult &hitTest);
void createImageContextMenu(QMenu *menu, const WebHitTestResult &hitTest);
void createSelectedTextContextMenu(QMenu *menu, const WebHitTestResult &hitTest);
2015-09-30 15:26:52 +02:00
void createMediaContextMenu(QMenu *menu, const WebHitTestResult &hitTest);
2015-09-29 23:15:46 +02:00
void checkForForm(QAction *action, const QPoint &pos);
2015-09-29 23:15:46 +02:00
void createSearchEngine();
private slots:
2014-01-04 22:37:18 +01:00
void addSpeedDial();
void configureSpeedDial();
void reloadAllSpeedDials();
2015-09-30 15:26:52 +02:00
void toggleMediaPause();
void toggleMediaMute();
private:
void initializeActions();
int m_currentZoomLevel;
2011-03-02 16:57:41 +01:00
QIcon m_siteIcon;
2015-02-08 11:13:12 +01:00
IconLoader* m_siteIconLoader;
int m_progress;
QUrl m_clickedUrl;
QPoint m_clickedPos;
WebPage* m_page;
bool m_firstLoad;
QWidget *m_rwhvqt;
2015-09-29 17:21:49 +02:00
static bool s_forceContextMenuOnMouseRelease;
2011-03-02 16:57:41 +01:00
};
#endif // WEBVIEW_H