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

162 lines
4.9 KiB
C
Raw Normal View History

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 WebTab;
class LocationBar;
2011-03-02 16:57:41 +01:00
class WebView : public QWebView
{
Q_OBJECT
public:
explicit WebView(QupZilla* mainClass, WebTab* webTab);
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();
WebPage* webPage() const;
WebTab* webTab() const;
2011-03-02 16:57:41 +01:00
QString getIp() { return m_currentIp; }
QLabel* animationLoading(int index, bool addMovie);
QIcon siteIcon();
2011-03-02 16:57:41 +01:00
void addNotification(QWidget* notif);
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
void setMouseWheelEnabled(bool state) { m_mouseWheelEnabled = state; }
2011-03-02 16:57:41 +01:00
void setLocationBar(LocationBar* bar) { m_locationBar = bar; }
LocationBar* locationBar() { return m_locationBar; }
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();
2011-03-02 16:57:41 +01:00
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 closeTab();
2011-03-02 16:57:41 +01:00
void zoomIn();
void zoomOut();
private slots:
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);
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 downloadLinkToDisk();
void sendLinkByMail();
void bookmarkLink();
void showSource();
2011-08-19 15:57:51 +02:00
#if QT_VERSION == 0x040800
void showSourceOfSelection();
2011-08-19 15:57:51 +02:00
#endif
2011-03-02 16:57:41 +01:00
void showSiteInfo();
void getFocus(const QUrl &urla);
void showInspector();
void stopAnimation();
2011-04-24 09:08:53 +02:00
void setIp(const QHostInfo &info);
void checkRss();
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);
void mouseMoveEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* 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;
QUrl m_lastUrl;
2011-03-02 16:57:41 +01:00
bool m_wantsClose;
QString m_currentIp;
QList<QPair<QString,QString> > m_rss;
QIcon m_siteIcon;
2011-03-02 16:57:41 +01:00
WebPage* m_page;
WebTab* m_webTab;
2011-03-02 16:57:41 +01:00
NetworkManagerProxy* m_networkProxy;
LocationBar* m_locationBar;
bool m_mouseTrack;
bool m_navigationVisible;
bool m_mouseWheelEnabled;
2011-03-02 16:57:41 +01:00
//QTimer* m_loadingTimer; //Too confusing
signals:
void showUrl(QUrl url);
void siteIconChanged();
void wantsCloseTab(int index);
void changed();
void ipChanged(QString ip);
void showNotification(QWidget* notif);
void viewportResized(QSize size);
void rssChanged(bool state);
2011-03-02 16:57:41 +01:00
};
#endif // WEBVIEW_H