2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
|
|
|
* Copyright (C) 2010-2011 nowrep
|
|
|
|
*
|
|
|
|
* 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 <QDebug>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QWebElement>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QWebInspector>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QWebPage>
|
|
|
|
#include <QHostInfo>
|
|
|
|
|
|
|
|
class QupZilla;
|
|
|
|
class TabWidget;
|
|
|
|
class WebPage;
|
|
|
|
class NetworkManagerProxy;
|
|
|
|
|
|
|
|
class WebView : public QWebView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-03-17 17:03:04 +01:00
|
|
|
explicit WebView(QupZilla* mainClass, QWidget* parent = 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
~WebView();
|
|
|
|
bool isLoading() { return m_isLoading;}
|
|
|
|
int getLoading() { return m_progress; }
|
|
|
|
|
|
|
|
void zoomReset();
|
|
|
|
void load(QUrl url);
|
|
|
|
QUrl url() const;
|
|
|
|
QString title() const;
|
|
|
|
void reload();
|
|
|
|
WebPage* getPage() const;
|
|
|
|
QString getIp() { return m_currentIp; }
|
|
|
|
QLabel* animationLoading(int index, bool addMovie);
|
|
|
|
void addNotification(QWidget* notif);
|
2011-03-03 14:25:02 +01:00
|
|
|
bool hasRss() { return !m_rss.isEmpty(); }
|
|
|
|
QList<QPair<QString,QString> > getRss() { return m_rss; }
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
static QUrl guessUrlFromString(const QString &string);
|
|
|
|
static bool isUrlValid(const QUrl &url);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void stop(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Stop); loadFinished(true);} }
|
|
|
|
void back(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Back);} }
|
|
|
|
void forward(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Forward);} }
|
|
|
|
void slotReload(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Reload);} }
|
|
|
|
void iconChanged();
|
|
|
|
void selectAll();
|
|
|
|
|
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void showImage();
|
|
|
|
void copyImageToClipboard();
|
|
|
|
void downloadImageToDisk();
|
|
|
|
void searchOnGoogle();
|
|
|
|
void copyLinkToClipboard();
|
|
|
|
void loadStarted();
|
|
|
|
void downloadRequested(const QNetworkRequest &request);
|
|
|
|
void setProgress(int prog);
|
|
|
|
void loadFinished(bool state);
|
|
|
|
void linkClicked(const QUrl &url);
|
|
|
|
void urlChanged(const QUrl &url);
|
2011-03-18 15:01:01 +01:00
|
|
|
void titleChanged();
|
2011-03-02 16:57:41 +01:00
|
|
|
void linkHovered(const QString &link, const QString &title, const QString &content);
|
|
|
|
void openUrlInNewWindow();
|
|
|
|
void openUrlInNewTab();
|
|
|
|
void closeTab();
|
|
|
|
void downloadLinkToDisk();
|
|
|
|
void sendLinkByMail();
|
|
|
|
void bookmarkLink();
|
|
|
|
void showSource();
|
|
|
|
void showSiteInfo();
|
|
|
|
void getFocus(const QUrl &urla);
|
|
|
|
void showInspector();
|
|
|
|
void stopAnimation();
|
|
|
|
void setIp(QHostInfo info);
|
2011-03-03 14:25:02 +01:00
|
|
|
void checkRss();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
private:
|
2011-03-17 17:03:04 +01:00
|
|
|
void keyPressEvent(QKeyEvent* event);
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
void contextMenuEvent(QContextMenuEvent* event);
|
|
|
|
void wheelEvent(QWheelEvent* event);
|
2011-03-02 16:57:41 +01:00
|
|
|
TabWidget* tabWidget() const;
|
|
|
|
int tabIndex() const;
|
|
|
|
bool isCurrent();
|
|
|
|
void applyZoom();
|
|
|
|
|
|
|
|
QupZilla* p_QupZilla;
|
|
|
|
int m_progress;
|
|
|
|
bool m_isLoading;
|
|
|
|
QString m_hoveredLink;
|
|
|
|
QList<int> m_zoomLevels;
|
|
|
|
int m_currentZoom;
|
|
|
|
QUrl m_aboutToLoadUrl;
|
2011-03-10 16:23:53 +01:00
|
|
|
QUrl m_lastUrl;
|
2011-03-02 16:57:41 +01:00
|
|
|
bool m_wantsClose;
|
|
|
|
QString m_currentIp;
|
2011-03-03 14:25:02 +01:00
|
|
|
QList<QPair<QString,QString> > m_rss;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
WebPage* m_page;
|
|
|
|
NetworkManagerProxy* m_networkProxy;
|
|
|
|
//QTimer* m_loadingTimer; //Too confusing
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void showUrl(QUrl url);
|
|
|
|
void siteIconChanged();
|
|
|
|
void setPrivacy(bool state);
|
|
|
|
void wantsCloseTab(int index);
|
|
|
|
void changed();
|
|
|
|
void ipChanged(QString ip);
|
|
|
|
void showNotification(QWidget* notif);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBVIEW_H
|