1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-23 02:32:10 +02:00
falkonOfficial/src/webview/webview.h

125 lines
3.1 KiB
C
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
* 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>
#include <QWebFrame>
#include <QWebElementCollection>
#include <QTouchEvent>
2011-03-02 16:57:41 +01:00
#include <QClipboard>
#include <QPrintPreviewDialog>
#include <QFile>
2011-03-02 16:57:41 +01:00
class WebView : public QWebView
{
Q_OBJECT
public:
explicit WebView(QWidget* parent = 0);
2011-03-02 16:57:41 +01:00
QIcon icon() const;
2011-03-02 16:57:41 +01:00
QString title() const;
QUrl url() const;
bool isLoading() const;
int loadProgress() const;
2011-03-02 16:57:41 +01:00
void addNotification(QWidget* notif);
bool eventFilter(QObject* obj, QEvent* event);
virtual QWidget* overlayForJsAlert() = 0;
2011-03-02 16:57:41 +01:00
static bool isUrlValid(const QUrl &url);
static QUrl guessUrlFromString(const QString &string);
signals:
void viewportResized(QSize);
void showNotification(QWidget*);
void iconChanged();
2011-03-02 16:57:41 +01:00
public slots:
void zoomIn();
void zoomOut();
void zoomReset();
void load(const QUrl &url);
void reload();
void back();
void forward();
2011-03-02 16:57:41 +01:00
void selectAll();
void printPage(QWebFrame* frame = 0);
2011-03-02 16:57:41 +01:00
virtual void closeView() = 0;
2011-03-02 16:57:41 +01:00
protected slots:
void slotLoadStarted();
void slotLoadProgress(int progress);
void slotLoadFinished();
void slotIconChanged();
// Context menu slots
2011-03-02 16:57:41 +01:00
void openUrlInNewWindow();
void sendLinkByMail();
void copyLinkToClipboard();
void downloadLinkToDisk();
void copyImageToClipboard();
void openActionUrl();
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
2011-03-02 16:57:41 +01:00
void showSiteInfo();
protected:
2011-03-17 17:03:04 +01:00
void wheelEvent(QWheelEvent* event);
void mousePressEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void resizeEvent(QResizeEvent* event);
void setZoom(int zoom);
2011-03-02 16:57:41 +01:00
void applyZoom();
void copyText();
QUrl lastUrl();
2011-03-02 16:57:41 +01:00
bool isMediaElement(const QWebElement &element);
QMenu* createMediaContextMenu(const QWebHitTestResult &hitTest);
private slots:
void pauseMedia();
void muteMedia();
void controlsMedia();
private:
2011-03-02 16:57:41 +01:00
QList<int> m_zoomLevels;
int m_currentZoom;
2011-03-02 16:57:41 +01:00
QIcon m_siteIcon;
QUrl m_siteIconUrl;
bool m_isLoading;
int m_progress;
QUrl m_aboutToLoadUrl;
QUrl m_lastUrl;
QWebElement m_mediaElement;
QList<QTouchEvent::TouchPoint> m_touchPoints;
2011-03-02 16:57:41 +01:00
};
#endif // WEBVIEW_H