2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2016-04-06 17:22:44 +02:00
|
|
|
* 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
|
|
|
|
|
2015-01-27 11:01:52 +01:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QWebEngineView>
|
2012-01-21 20:20:48 +01:00
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2014-03-19 21:27:43 +01:00
|
|
|
#include "loadrequest.h"
|
2012-01-22 15:15:43 +01:00
|
|
|
|
2012-04-03 19:28:12 +02:00
|
|
|
class WebPage;
|
2014-03-19 21:27:43 +01:00
|
|
|
class LoadRequest;
|
2015-02-08 11:13:12 +01:00
|
|
|
class IconLoader;
|
2015-09-29 23:15:46 +02:00
|
|
|
class WebHitTestResult;
|
2012-04-03 19:28:12 +02:00
|
|
|
|
2015-01-27 11:01:52 +01:00
|
|
|
class QUPZILLA_EXPORT WebView : public QWebEngineView
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-01-21 20:20:48 +01:00
|
|
|
explicit WebView(QWidget* parent = 0);
|
2014-03-24 21:21:07 +01:00
|
|
|
~WebView();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
QIcon icon() const;
|
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
QString title() const;
|
|
|
|
bool isTitleEmpty() const;
|
|
|
|
|
2012-04-03 19:28:12 +02:00
|
|
|
WebPage* page() const;
|
2015-09-24 23:00:27 +02:00
|
|
|
void setPage(WebPage* page);
|
2012-01-24 19:58:20 +01:00
|
|
|
|
2015-08-30 14:44:00 +02:00
|
|
|
void load(const QUrl &url);
|
2014-03-19 21:27:43 +01:00
|
|
|
void load(const LoadRequest &request);
|
2012-01-21 20:20:48 +01:00
|
|
|
bool isLoading() const;
|
2012-06-27 18:29:00 +02:00
|
|
|
|
|
|
|
int loadingProgress() const;
|
|
|
|
void fakeLoadingProgress(int progress);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-03-29 15:49:49 +01:00
|
|
|
// Set zoom level (0 - 17)
|
|
|
|
int zoomLevel() const;
|
|
|
|
void setZoomLevel(int level);
|
|
|
|
|
2016-04-06 17:22:44 +02:00
|
|
|
QPoint mapToViewport(const QPoint &pos) const;
|
|
|
|
|
2015-08-29 19:15:33 +02:00
|
|
|
void restoreHistory(const QByteArray &data);
|
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
void addNotification(QWidget* notif);
|
2015-09-29 17:21:49 +02:00
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2011-11-05 21:27:01 +01:00
|
|
|
|
2015-10-02 15:23:59 +02:00
|
|
|
QWidget *inputWidget() const;
|
2014-04-01 16:32:55 +02:00
|
|
|
virtual QWidget* overlayWidget() = 0;
|
2011-07-11 20:30:49 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
static bool isUrlValid(const QUrl &url);
|
2014-03-29 15:49:49 +01:00
|
|
|
static QList<int> zoomLevels();
|
2012-01-14 11:46:06 +01:00
|
|
|
|
2014-04-05 13:20:21 +02:00
|
|
|
// 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);
|
|
|
|
|
2011-11-08 15:20:53 +01:00
|
|
|
signals:
|
2015-02-08 11:13:12 +01:00
|
|
|
void iconChanged();
|
2012-01-21 20:20:48 +01:00
|
|
|
void viewportResized(QSize);
|
|
|
|
void showNotification(QWidget*);
|
2012-04-03 20:23:15 +02:00
|
|
|
void privacyChanged(bool);
|
2014-03-29 15:49:49 +01:00
|
|
|
void zoomLevelChanged(int);
|
2011-11-08 15:20:53 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
public slots:
|
2012-01-21 20:20:48 +01:00
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
void zoomReset();
|
|
|
|
|
2014-03-10 16:55:11 +01:00
|
|
|
void editUndo();
|
|
|
|
void editRedo();
|
|
|
|
void editCut();
|
|
|
|
void editCopy();
|
|
|
|
void editPaste();
|
|
|
|
void editSelectAll();
|
|
|
|
void editDelete();
|
|
|
|
|
|
|
|
void reloadBypassCache();
|
2011-12-15 17:43:06 +01:00
|
|
|
|
2011-10-29 23:01:17 +02:00
|
|
|
void back();
|
|
|
|
void forward();
|
2012-01-21 20:20:48 +01:00
|
|
|
|
2015-05-24 21:26:17 +02:00
|
|
|
void showSource();
|
2012-04-01 18:57:42 +02:00
|
|
|
void sendPageByMail();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-02-12 13:48:34 +01:00
|
|
|
void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position);
|
2013-11-09 13:32:03 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
virtual void closeView() = 0;
|
2014-03-19 21:27:43 +01:00
|
|
|
virtual void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) = 0;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2015-10-05 17:39:52 +02:00
|
|
|
virtual bool isFullScreen() = 0;
|
|
|
|
virtual void requestFullScreen(bool enable) = 0;
|
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
protected slots:
|
|
|
|
void slotLoadStarted();
|
|
|
|
void slotLoadProgress(int progress);
|
2015-10-01 19:25:17 +02:00
|
|
|
void slotLoadFinished(bool ok);
|
2015-10-09 21:32:43 +02:00
|
|
|
void slotUrlChanged(const QUrl &url);
|
2015-02-08 11:13:12 +01:00
|
|
|
void slotIconUrlChanged(const QUrl &url);
|
2011-11-27 15:43:54 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
// Context menu slots
|
2011-03-02 16:57:41 +01:00
|
|
|
void openUrlInNewWindow();
|
|
|
|
void sendLinkByMail();
|
2012-01-21 20:20:48 +01:00
|
|
|
void copyLinkToClipboard();
|
2016-08-16 12:57:11 +02:00
|
|
|
void copyImageToClipboard();
|
2015-10-04 19:35:02 +02:00
|
|
|
void downloadLinkToDisk();
|
|
|
|
void downloadImageToDisk();
|
|
|
|
void downloadMediaToDisk();
|
2012-01-21 20:20:48 +01:00
|
|
|
void openActionUrl();
|
2011-03-02 16:57:41 +01:00
|
|
|
void showSiteInfo();
|
2012-01-22 11:49:58 +01:00
|
|
|
void searchSelectedText();
|
2012-06-01 20:25:37 +02:00
|
|
|
void searchSelectedTextInBackgroundTab();
|
2012-01-22 11:49:58 +01:00
|
|
|
void bookmarkLink();
|
2012-01-22 15:15:43 +01:00
|
|
|
void openUrlInSelectedTab();
|
|
|
|
void openUrlInBackgroundTab();
|
2012-01-22 11:49:58 +01:00
|
|
|
|
2012-06-26 23:39:23 +02:00
|
|
|
// To support user's option whether to open in selected or background tab
|
2012-07-03 11:28:14 +02:00
|
|
|
void userDefinedOpenUrlInNewTab(const QUrl &url = QUrl(), bool invert = false);
|
2013-01-26 12:04:30 +01:00
|
|
|
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
|
2012-06-26 23:39:23 +02:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
protected:
|
2015-10-23 11:50:56 +02:00
|
|
|
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);
|
2011-11-27 15:43:54 +01:00
|
|
|
|
2014-06-06 23:29:49 +02:00
|
|
|
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
|
|
|
|
2015-09-30 14:57:08 +02:00
|
|
|
void checkForForm(QAction *action, const QPoint &pos);
|
2015-09-29 23:15:46 +02:00
|
|
|
void createSearchEngine();
|
2015-09-30 14:57:08 +02:00
|
|
|
|
2012-01-22 00:20:29 +01:00
|
|
|
private slots:
|
2014-01-04 22:37:18 +01:00
|
|
|
void addSpeedDial();
|
|
|
|
void configureSpeedDial();
|
2014-05-30 15:12:36 +02:00
|
|
|
void reloadAllSpeedDials();
|
2012-01-22 00:20:29 +01:00
|
|
|
|
2015-09-30 15:26:52 +02:00
|
|
|
void toggleMediaPause();
|
|
|
|
void toggleMediaMute();
|
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
private:
|
2014-10-17 18:37:18 +02:00
|
|
|
void initializeActions();
|
|
|
|
|
2014-03-29 15:49:49 +01:00
|
|
|
int m_currentZoomLevel;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
QIcon m_siteIcon;
|
2015-02-08 11:13:12 +01:00
|
|
|
IconLoader* m_siteIconLoader;
|
2011-10-30 17:20:22 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
int m_progress;
|
2011-11-05 21:27:01 +01:00
|
|
|
|
2012-01-24 19:12:31 +01:00
|
|
|
QUrl m_clickedUrl;
|
2015-09-30 15:05:28 +02:00
|
|
|
QPoint m_clickedPos;
|
2012-04-01 10:48:50 +02:00
|
|
|
|
2012-04-03 19:28:12 +02:00
|
|
|
WebPage* m_page;
|
2015-08-30 14:44:00 +02:00
|
|
|
bool m_firstLoad;
|
2013-02-10 14:09:11 +01:00
|
|
|
|
2015-10-14 12:11:57 +02:00
|
|
|
QWidget *m_rwhvqt;
|
2015-09-29 17:21:49 +02:00
|
|
|
|
2014-04-05 13:20:21 +02:00
|
|
|
static bool s_forceContextMenuOnMouseRelease;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBVIEW_H
|