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();
|
2011-04-24 09:08:53 +02:00
|
|
|
void load(const QUrl &url);
|
2011-03-02 16:57:41 +01:00
|
|
|
QUrl url() const;
|
|
|
|
QString title() const;
|
|
|
|
void reload();
|
2011-03-22 21:36:15 +01:00
|
|
|
WebPage* webPage() const;
|
2011-03-02 16:57:41 +01:00
|
|
|
QString getIp() { return m_currentIp; }
|
|
|
|
QLabel* animationLoading(int index, bool addMovie);
|
2011-04-04 17:03:41 +02:00
|
|
|
QIcon siteIcon();
|
2011-03-02 16:57:41 +01:00
|
|
|
void addNotification(QWidget* notif);
|
2011-03-03 14:25:02 +01:00
|
|
|
bool hasRss() { return !m_rss.isEmpty(); }
|
2011-04-24 09:08:53 +02:00
|
|
|
QList<QPair<QString,QString> > getRss() { return m_rss; } //FIXME: Make RSS as struct
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
static QUrl guessUrlFromString(const QString &string);
|
|
|
|
static bool isUrlValid(const QUrl &url);
|
2011-03-25 19:16:21 +01:00
|
|
|
int tabIndex() const;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
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:
|
2011-04-22 07:45:15 +02:00
|
|
|
void trackMouse(bool state) { m_mouseTrack = state; }
|
2011-03-02 16:57:41 +01:00
|
|
|
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();
|
2011-04-24 09:08:53 +02:00
|
|
|
void setIp(const QHostInfo &info);
|
2011-03-03 14:25:02 +01:00
|
|
|
void checkRss();
|
2011-03-31 16:01:59 +02:00
|
|
|
void slotIconChanged();
|
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-04-22 07:45:15 +02:00
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2011-03-02 16:57:41 +01:00
|
|
|
TabWidget* tabWidget() 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-04-04 16:00:27 +02:00
|
|
|
QIcon m_siteIcon;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
WebPage* m_page;
|
|
|
|
NetworkManagerProxy* m_networkProxy;
|
2011-04-22 07:45:15 +02:00
|
|
|
|
|
|
|
bool m_mouseTrack;
|
|
|
|
bool m_navigationVisible;
|
2011-03-02 16:57:41 +01:00
|
|
|
//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
|