2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 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 <QWebView>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QWebElement>
|
2012-01-21 20:20:48 +01:00
|
|
|
#include <QTouchEvent>
|
|
|
|
|
2012-01-22 15:15:43 +01:00
|
|
|
#include "qz_namespace.h"
|
|
|
|
|
2012-04-03 19:28:12 +02:00
|
|
|
class WebPage;
|
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
class QT_QUPZILLA_EXPORT WebView : public QWebView
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-01-21 20:20:48 +01:00
|
|
|
explicit WebView(QWidget* parent = 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
QIcon icon() const;
|
2011-03-02 16:57:41 +01:00
|
|
|
QString title() const;
|
2012-01-21 20:20:48 +01:00
|
|
|
QUrl url() const;
|
|
|
|
|
2012-04-03 19:28:12 +02:00
|
|
|
WebPage* page() const;
|
2012-01-27 23:01:17 +01:00
|
|
|
void setPage(QWebPage* page);
|
2012-01-24 19:58:20 +01:00
|
|
|
|
2012-03-10 13:57:50 +01:00
|
|
|
void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray());
|
|
|
|
|
2012-04-04 14:45:45 +02:00
|
|
|
bool loadingError() const;
|
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
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
void addNotification(QWidget* notif);
|
2011-11-05 21:27:01 +01:00
|
|
|
bool eventFilter(QObject* obj, QEvent* event);
|
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
virtual QWidget* overlayForJsAlert() = 0;
|
2012-03-05 13:16:34 +01:00
|
|
|
virtual void disconnectObjects();
|
2011-07-11 20:30:49 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
static bool isUrlValid(const QUrl &url);
|
2012-01-21 20:20:48 +01:00
|
|
|
static QUrl guessUrlFromString(const QString &string);
|
2012-01-14 11:46:06 +01:00
|
|
|
|
2011-11-08 15:20:53 +01:00
|
|
|
signals:
|
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);
|
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();
|
|
|
|
|
2011-12-15 17:43:06 +01:00
|
|
|
void load(const QUrl &url);
|
2012-01-21 20:20:48 +01:00
|
|
|
void reload();
|
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
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void selectAll();
|
2012-01-21 20:20:48 +01:00
|
|
|
void printPage(QWebFrame* frame = 0);
|
2012-04-01 18:57:42 +02:00
|
|
|
void sendPageByMail();
|
2012-08-14 18:53:55 +02:00
|
|
|
void savePageAs();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
virtual void closeView() = 0;
|
2012-02-24 21:03:44 +01:00
|
|
|
virtual void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position) = 0;
|
|
|
|
virtual void openNewTab() { }
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
protected slots:
|
|
|
|
void slotLoadStarted();
|
|
|
|
void slotLoadProgress(int progress);
|
|
|
|
void slotLoadFinished();
|
|
|
|
void slotIconChanged();
|
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();
|
2012-03-23 13:58:31 +01:00
|
|
|
void downloadUrlToDisk();
|
2012-01-21 20:20:48 +01:00
|
|
|
void copyImageToClipboard();
|
|
|
|
void openActionUrl();
|
|
|
|
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
|
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();
|
|
|
|
void showSourceOfSelection();
|
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);
|
2012-06-26 23:39:23 +02:00
|
|
|
|
2012-03-08 13:05:57 +01:00
|
|
|
void createSearchEngine();
|
|
|
|
|
2012-01-22 11:49:58 +01:00
|
|
|
// Clicked frame actions
|
|
|
|
void loadClickedFrame();
|
|
|
|
void loadClickedFrameInNewTab();
|
|
|
|
void reloadClickedFrame();
|
|
|
|
void printClickedFrame();
|
|
|
|
void clickedFrameZoomIn();
|
|
|
|
void clickedFrameZoomOut();
|
|
|
|
void clickedFrameZoomReset();
|
|
|
|
void showClickedFrameSource();
|
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
protected:
|
2011-03-17 17:03:04 +01:00
|
|
|
void wheelEvent(QWheelEvent* event);
|
2012-01-21 20:20:48 +01:00
|
|
|
void mousePressEvent(QMouseEvent* event);
|
2012-01-24 19:12:31 +01:00
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
2012-02-22 18:33:44 +01:00
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2011-11-27 15:43:54 +01:00
|
|
|
void keyPressEvent(QKeyEvent* event);
|
2012-02-22 18:33:44 +01:00
|
|
|
void keyReleaseEvent(QKeyEvent* event);
|
2012-01-21 20:20:48 +01:00
|
|
|
void resizeEvent(QResizeEvent* event);
|
2011-11-27 15:43:54 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
void setZoom(int zoom);
|
2011-03-02 16:57:41 +01:00
|
|
|
void applyZoom();
|
2012-01-21 20:20:48 +01:00
|
|
|
QUrl lastUrl();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-22 00:20:29 +01:00
|
|
|
bool isMediaElement(const QWebElement &element);
|
2012-03-08 13:05:57 +01:00
|
|
|
void checkForForm(QMenu* menu, const QWebElement &element);
|
2012-01-22 00:20:29 +01:00
|
|
|
|
2012-01-22 11:49:58 +01:00
|
|
|
void createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, const QPoint &pos);
|
|
|
|
void createPageContextMenu(QMenu* menu, const QPoint &pos);
|
|
|
|
void createLinkContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
|
|
|
void createImageContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
|
|
|
void createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
|
|
|
void createMediaContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
2012-01-22 00:20:29 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void pauseMedia();
|
|
|
|
void muteMedia();
|
2012-03-30 13:43:47 +02:00
|
|
|
void frameStateChanged();
|
|
|
|
void emitChangedUrl();
|
2012-01-22 00:20:29 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
private:
|
2011-03-02 16:57:41 +01:00
|
|
|
QList<int> m_zoomLevels;
|
2011-10-30 17:20:22 +01:00
|
|
|
int m_currentZoom;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
QIcon m_siteIcon;
|
|
|
|
QUrl m_siteIconUrl;
|
2011-10-30 17:20:22 +01:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
bool m_isLoading;
|
|
|
|
int m_progress;
|
|
|
|
QUrl m_aboutToLoadUrl;
|
|
|
|
QUrl m_lastUrl;
|
2011-11-05 21:27:01 +01:00
|
|
|
|
2012-03-08 13:05:57 +01:00
|
|
|
QWebElement m_clickedElement;
|
2012-01-22 11:49:58 +01:00
|
|
|
QWebFrame* m_clickedFrame;
|
2012-01-24 19:12:31 +01:00
|
|
|
QUrl m_clickedUrl;
|
2012-04-01 10:48:50 +02:00
|
|
|
|
2012-04-03 19:28:12 +02:00
|
|
|
WebPage* m_page;
|
2012-04-01 10:48:50 +02:00
|
|
|
QAction* m_actionReload;
|
|
|
|
QAction* m_actionStop;
|
|
|
|
bool m_actionsInitialized;
|
2012-01-22 00:20:29 +01:00
|
|
|
|
2011-11-05 21:27:01 +01:00
|
|
|
QList<QTouchEvent::TouchPoint> m_touchPoints;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBVIEW_H
|