mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Created new base WebView and WebPage classes.
- they can be used standalone, they are no longer bound to being in TabWidget
This commit is contained in:
parent
61d41046b6
commit
bbadb4ec37
@ -16,61 +16,94 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "webpage.h"
|
||||
#include "webview.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "tabwidget.h"
|
||||
#include "qupzilla.h"
|
||||
#include "downloadmanager.h"
|
||||
#include "webpluginfactory.h"
|
||||
#include "mainapplication.h"
|
||||
#ifdef NONBLOCK_JS_DIALOGS
|
||||
#include "ui_jsconfirm.h"
|
||||
#include "ui_jsalert.h"
|
||||
#include "ui_jsprompt.h"
|
||||
#endif
|
||||
#include "ui_closedialog.h"
|
||||
#include "widget.h"
|
||||
#include "globalfunctions.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "speeddial.h"
|
||||
#include "popupwebpage.h"
|
||||
#include "popupwebview.h"
|
||||
#include "networkmanagerproxy.h"
|
||||
|
||||
QString WebPage::UserAgent = "";
|
||||
|
||||
QString WebPage::m_lastUploadLocation = QDir::homePath();
|
||||
|
||||
WebPage::WebPage(WebView* parent, QupZilla* mainClass)
|
||||
: QWebPage(parent)
|
||||
WebPage::WebPage(QupZilla* mainClass)
|
||||
: QWebPage()
|
||||
, p_QupZilla(mainClass)
|
||||
, m_view(parent)
|
||||
, m_view(0)
|
||||
, m_speedDial(mApp->plugins()->speedDial())
|
||||
, m_fileWatcher(0)
|
||||
, m_runningLoop(0)
|
||||
, m_blockAlerts(false)
|
||||
, m_secureStatus(false)
|
||||
// , m_isOpeningNextWindowAsNewTab(false)
|
||||
, m_isClosing(false)
|
||||
{
|
||||
m_networkProxy = new NetworkManagerProxy(this);
|
||||
m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager());
|
||||
m_networkProxy->setPage(this);
|
||||
setNetworkAccessManager(m_networkProxy);
|
||||
|
||||
setForwardUnsupportedContent(true);
|
||||
setPluginFactory(new WebPluginFactory(this));
|
||||
history()->setMaximumItemCount(20);
|
||||
|
||||
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*)));
|
||||
// connect(this, SIGNAL(loadStarted()), this, SLOT(loadingStarted()));
|
||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished()));
|
||||
connect(m_view, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
|
||||
connect(this, SIGNAL(printRequested(QWebFrame*)), this, SLOT(printFrame(QWebFrame*)));
|
||||
connect(this, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
|
||||
|
||||
connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject()));
|
||||
connect(this, SIGNAL(printRequested(QWebFrame*)), this, SLOT(printFrame(QWebFrame*)));
|
||||
}
|
||||
|
||||
m_runningLoop = 0;
|
||||
QUrl WebPage::url() const
|
||||
{
|
||||
return mainFrame()->url();
|
||||
}
|
||||
|
||||
void WebPage::setWebView(TabbedWebView* view)
|
||||
{
|
||||
if (m_view == view) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_view) {
|
||||
delete m_view;
|
||||
m_view = 0;
|
||||
}
|
||||
|
||||
m_view = view;
|
||||
m_view->setWebPage(this);
|
||||
|
||||
connect(m_view, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
|
||||
}
|
||||
|
||||
void WebPage::scheduleAdjustPage()
|
||||
{
|
||||
if (m_view->isLoading()) {
|
||||
if (m_view && m_view->isLoading()) {
|
||||
m_adjustingScheduled = true;
|
||||
}
|
||||
else {
|
||||
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() + 1);
|
||||
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool WebPage::isRunningLoop()
|
||||
{
|
||||
return m_runningLoop;
|
||||
}
|
||||
|
||||
void WebPage::urlChanged(const QUrl &url)
|
||||
@ -101,19 +134,19 @@ void WebPage::finished()
|
||||
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() - 1);
|
||||
}
|
||||
|
||||
if (mainFrame()->url().scheme() == "file") {
|
||||
if (url().scheme() == "file") {
|
||||
if (!m_fileWatcher) {
|
||||
m_fileWatcher = new QFileSystemWatcher(this);
|
||||
connect(m_fileWatcher, SIGNAL(fileChanged(QString)), this, SLOT(watchedFileChanged(QString)));
|
||||
}
|
||||
|
||||
QString filePath = mainFrame()->url().toLocalFile();
|
||||
QString filePath = url().toLocalFile();
|
||||
|
||||
if (!m_fileWatcher->files().contains(filePath)) {
|
||||
if (QFile::exists(filePath) && !m_fileWatcher->files().contains(filePath)) {
|
||||
m_fileWatcher->addPath(filePath);
|
||||
}
|
||||
}
|
||||
else if (m_fileWatcher) {
|
||||
else if (m_fileWatcher && !m_fileWatcher->files().isEmpty()) {
|
||||
m_fileWatcher->removePaths(m_fileWatcher->files());
|
||||
}
|
||||
|
||||
@ -122,26 +155,24 @@ void WebPage::finished()
|
||||
|
||||
void WebPage::watchedFileChanged(const QString &file)
|
||||
{
|
||||
if (mainFrame()->url().toLocalFile() == file) {
|
||||
if (url().toLocalFile() == file) {
|
||||
triggerAction(QWebPage::Reload);
|
||||
}
|
||||
}
|
||||
|
||||
void WebPage::printFrame(QWebFrame* frame)
|
||||
{
|
||||
p_QupZilla->printPage(frame);
|
||||
}
|
||||
WebView* webView = qobject_cast<WebView*>(view());
|
||||
if (!webView) {
|
||||
return;
|
||||
}
|
||||
|
||||
//void WebPage::loadingStarted()
|
||||
//{
|
||||
// m_adBlockedEntries.clear();
|
||||
// m_blockAlerts = false;
|
||||
// m_SslCert.clear();
|
||||
//}
|
||||
webView->printPage(frame);
|
||||
}
|
||||
|
||||
void WebPage::addJavaScriptObject()
|
||||
{
|
||||
if (mainFrame()->url().toString() != "qupzilla:speeddial") {
|
||||
if (url().toString() != "qupzilla:speeddial") {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -175,16 +206,23 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
|
||||
qDebug() << "WebPage::UnsupportedContent error" << reply->errorString();
|
||||
}
|
||||
|
||||
void WebPage::downloadRequested(const QNetworkRequest &request)
|
||||
{
|
||||
DownloadManager* dManager = mApp->downManager();
|
||||
dManager->download(request, this);
|
||||
}
|
||||
|
||||
|
||||
void WebPage::setSSLCertificate(const QSslCertificate &cert)
|
||||
{
|
||||
// if (cert != m_SslCert) -- crashing on linux :-|
|
||||
// if (cert != m_SslCert)
|
||||
m_SslCert = cert;
|
||||
}
|
||||
|
||||
QSslCertificate WebPage::sslCertificate()
|
||||
{
|
||||
if (mainFrame()->url().scheme() == "https" &&
|
||||
m_SslCert.subjectInfo(QSslCertificate::CommonName).remove("*").contains(QRegExp(mainFrame()->url().host()))) {
|
||||
if (url().scheme() == "https" &&
|
||||
m_SslCert.subjectInfo(QSslCertificate::CommonName).remove("*").contains(QRegExp(url().host()))) {
|
||||
return m_SslCert;
|
||||
}
|
||||
else {
|
||||
@ -203,8 +241,10 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
|
||||
}
|
||||
|
||||
if (type == QWebPage::NavigationTypeFormResubmitted) {
|
||||
bool result = javaScriptConfirm(frame, tr("To show this page, QupZilla must resend request which do it again \n"
|
||||
"(like searching on making an shoping, which has been already done.)"));
|
||||
QString message = tr("To show this page, QupZilla must resend request which do it again \n"
|
||||
"(like searching on making an shoping, which has been already done.)");
|
||||
bool result = (QMessageBox::question(view(), tr("Resend request confirmation"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
@ -217,29 +257,21 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
|
||||
void WebPage::populateNetworkRequest(QNetworkRequest &request)
|
||||
{
|
||||
WebPage* pagePointer = this;
|
||||
WebView* webViewPointer = m_view;
|
||||
|
||||
QVariant variant = qVariantFromValue((void*) pagePointer);
|
||||
request.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100), variant);
|
||||
request.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 101), m_lastRequestType);
|
||||
|
||||
variant = qVariantFromValue((void*) webViewPointer);
|
||||
request.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 102), variant);
|
||||
}
|
||||
|
||||
QWebPage* WebPage::createWindow(QWebPage::WebWindowType type)
|
||||
{
|
||||
// if (m_isOpeningNextWindowAsNewTab)
|
||||
// return 0;
|
||||
// m_isOpeningNextWindowAsNewTab = false;
|
||||
// qDebug() << type;
|
||||
// QWebView* view = new QWebView();
|
||||
// view->show();
|
||||
// return view->page();
|
||||
|
||||
#if 0
|
||||
Q_UNUSED(type);
|
||||
int index = p_QupZilla->tabWidget()->addView(QUrl(), TabWidget::CleanSelectedPage);
|
||||
return p_QupZilla->weView(index)->page();
|
||||
#endif
|
||||
|
||||
return new PopupWebPage(type, p_QupZilla);
|
||||
}
|
||||
|
||||
void WebPage::addAdBlockRule(const QString &filter, const QUrl &url)
|
||||
@ -263,7 +295,7 @@ void WebPage::cleanBlockedObjects()
|
||||
}
|
||||
|
||||
findingStrings.append(entry.url.toString());
|
||||
QUrl mainFrameUrl = mainFrame()->url();
|
||||
QUrl mainFrameUrl = url();
|
||||
if (entry.url.scheme() == mainFrameUrl.scheme() && entry.url.host() == mainFrameUrl.host()) {
|
||||
//May be relative url
|
||||
QString relativeUrl = qz_makeRelativeUrl(mainFrameUrl, entry.url).toString();
|
||||
@ -296,16 +328,45 @@ QString WebPage::userAgentForUrl(const QUrl &url) const
|
||||
return UserAgent;
|
||||
}
|
||||
|
||||
bool WebPage::supportsExtension(Extension extension) const
|
||||
{
|
||||
Q_UNUSED(extension)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebPage::extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output)
|
||||
{
|
||||
if (extension == ChooseMultipleFilesExtension) {
|
||||
return QWebPage::extension(extension, option, output);
|
||||
const QWebPage::ChooseMultipleFilesExtensionOption* exOption = static_cast<const QWebPage::ChooseMultipleFilesExtensionOption*>(option);
|
||||
QWebPage::ChooseMultipleFilesExtensionReturn* exReturn = static_cast<QWebPage::ChooseMultipleFilesExtensionReturn*>(output);
|
||||
|
||||
if (!exOption || !exReturn) {
|
||||
return QWebPage::extension(extension, option, output);
|
||||
}
|
||||
|
||||
QString suggestedFileName;
|
||||
if (!exOption->suggestedFileNames.isEmpty()) {
|
||||
suggestedFileName = exOption->suggestedFileNames.first();
|
||||
}
|
||||
|
||||
exReturn->fileNames = QFileDialog::getOpenFileNames(0, tr("Select files to upload..."), suggestedFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
const ErrorPageExtensionOption* exOption = static_cast<const QWebPage::ErrorPageExtensionOption*>(option);
|
||||
ErrorPageExtensionReturn* exReturn = static_cast<QWebPage::ErrorPageExtensionReturn*>(output);
|
||||
|
||||
if (!exOption || !exReturn) {
|
||||
return QWebPage::extension(extension, option, output);
|
||||
}
|
||||
|
||||
WebPage* erPage = qobject_cast<WebPage*>(exOption->frame->page());
|
||||
|
||||
if (!erPage) {
|
||||
return QWebPage::extension(extension, option, output);
|
||||
}
|
||||
|
||||
QString errorString;
|
||||
if (exOption->domain == QWebPage::QtNetwork) {
|
||||
switch (exOption->error) {
|
||||
@ -414,9 +475,16 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
|
||||
|
||||
bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg, const QString &defaultValue, QString* result)
|
||||
{
|
||||
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
#ifndef NONBLOCK_JS_DIALOGS
|
||||
return QWebPage::javaScriptPrompt(originatingFrame, msg, defaultValue, result);
|
||||
#else
|
||||
if (m_runningLoop) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WebView* webView = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
ResizableFrame* widget = new ResizableFrame(webView->overlayForJsAlert());
|
||||
|
||||
ResizableFrame* widget = new ResizableFrame(_view->webTab());
|
||||
widget->setObjectName("jsFrame");
|
||||
Ui_jsPrompt* ui = new Ui_jsPrompt();
|
||||
ui->setupUi(widget);
|
||||
@ -426,14 +494,14 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
|
||||
widget->resize(originatingFrame->page()->viewportSize());
|
||||
widget->show();
|
||||
|
||||
connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
|
||||
connect(webView, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
|
||||
connect(ui->lineEdit, SIGNAL(returnPressed()), ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(animateClick()));
|
||||
|
||||
QEventLoop eLoop;
|
||||
m_runningLoop = &eLoop;
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
|
||||
|
||||
if (eLoop.exec() == 1) {
|
||||
if (eLoop.exec() == 1 || m_isClosing) {
|
||||
return result;
|
||||
}
|
||||
m_runningLoop = 0;
|
||||
@ -443,16 +511,24 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
|
||||
*result = x;
|
||||
|
||||
delete widget;
|
||||
_view->setFocus();
|
||||
webView->setFocus();
|
||||
|
||||
return _result;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
|
||||
{
|
||||
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
#ifndef NONBLOCK_JS_DIALOGS
|
||||
return QWebPage::javaScriptConfirm(originatingFrame, msg);
|
||||
#else
|
||||
if (m_runningLoop) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WebView* webView = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
ResizableFrame* widget = new ResizableFrame(webView->overlayForJsAlert());
|
||||
|
||||
ResizableFrame* widget = new ResizableFrame(_view->webTab());
|
||||
widget->setObjectName("jsFrame");
|
||||
Ui_jsConfirm* ui = new Ui_jsConfirm();
|
||||
ui->setupUi(widget);
|
||||
@ -461,13 +537,13 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
|
||||
widget->resize(originatingFrame->page()->viewportSize());
|
||||
widget->show();
|
||||
|
||||
connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
|
||||
connect(webView, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
|
||||
|
||||
QEventLoop eLoop;
|
||||
m_runningLoop = &eLoop;
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
|
||||
|
||||
if (eLoop.exec() == 1) {
|
||||
if (eLoop.exec() == 1 || m_isClosing) {
|
||||
return false;
|
||||
}
|
||||
m_runningLoop = 0;
|
||||
@ -475,20 +551,36 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
|
||||
bool result = ui->buttonBox->clickedButtonRole() == QDialogButtonBox::AcceptRole;
|
||||
|
||||
delete widget;
|
||||
_view->setFocus();
|
||||
webView->setFocus();
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
|
||||
{
|
||||
if (m_blockAlerts) {
|
||||
if (m_blockAlerts || m_runningLoop) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
#ifndef NONBLOCK_JS_DIALOGS
|
||||
QDialog dialog(view());
|
||||
Ui_CloseDialog* ui = new Ui_CloseDialog();
|
||||
ui->setupUi(&dialog);
|
||||
ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok);
|
||||
ui->dontAskAgain->setText(tr("Prevent this page from creating additional dialogs"));
|
||||
ui->textLabel->setText(Qt::escape(msg));
|
||||
ui->iconLabel->setPixmap(mApp->style()->standardPixmap(QStyle::SP_MessageBoxInformation));
|
||||
dialog.setWindowTitle(tr("JavaScript alert - %1").arg(originatingFrame->url().host()));
|
||||
dialog.exec();
|
||||
|
||||
if (ui->dontAskAgain->isChecked()) {
|
||||
m_blockAlerts = true;
|
||||
}
|
||||
#else
|
||||
WebView* webView = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
ResizableFrame* widget = new ResizableFrame(webView->overlayForJsAlert());
|
||||
|
||||
ResizableFrame* widget = new ResizableFrame(_view->webTab());
|
||||
widget->setObjectName("jsFrame");
|
||||
Ui_jsAlert* ui = new Ui_jsAlert();
|
||||
ui->setupUi(widget);
|
||||
@ -497,13 +589,13 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
|
||||
widget->resize(originatingFrame->page()->viewportSize());
|
||||
widget->show();
|
||||
|
||||
connect(_view, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
|
||||
connect(webView, SIGNAL(viewportResized(QSize)), widget, SLOT(slotResize(QSize)));
|
||||
|
||||
QEventLoop eLoop;
|
||||
m_runningLoop = &eLoop;
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
|
||||
|
||||
if (eLoop.exec() == 1) {
|
||||
if (eLoop.exec() == 1 || m_isClosing) {
|
||||
return;
|
||||
}
|
||||
m_runningLoop = 0;
|
||||
@ -512,7 +604,8 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
|
||||
|
||||
delete widget;
|
||||
|
||||
_view->setFocus();
|
||||
webView->setFocus();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)
|
||||
@ -535,12 +628,19 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)
|
||||
|
||||
void WebPage::disconnectObjects()
|
||||
{
|
||||
if (m_runningLoop) {
|
||||
m_runningLoop->exit(1);
|
||||
m_runningLoop = 0;
|
||||
}
|
||||
|
||||
disconnect(this);
|
||||
m_networkProxy->disconnectObjects();
|
||||
}
|
||||
|
||||
WebPage::~WebPage()
|
||||
{
|
||||
if (m_runningLoop) {
|
||||
m_runningLoop->exit(1);
|
||||
m_runningLoop = 0;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QWebFrame>
|
||||
#include <QWebHistory>
|
||||
#include <QtNetwork/QtNetwork>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
@ -34,8 +33,9 @@
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
class QupZilla;
|
||||
class WebView;
|
||||
class TabbedWebView;
|
||||
class SpeedDial;
|
||||
class NetworkManagerProxy;
|
||||
class WebPage : public QWebPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -49,11 +49,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
WebPage(WebView* parent, QupZilla* mainClass);
|
||||
void populateNetworkRequest(QNetworkRequest &request);
|
||||
WebPage(QupZilla* mainClass);
|
||||
~WebPage();
|
||||
|
||||
WebView* getView() { return m_view; }
|
||||
QUrl url() const;
|
||||
|
||||
void setWebView(TabbedWebView* view);
|
||||
void populateNetworkRequest(QNetworkRequest &request);
|
||||
|
||||
TabbedWebView* getView() { return m_view; }
|
||||
void setSSLCertificate(const QSslCertificate &cert);
|
||||
QSslCertificate sslCertificate();
|
||||
|
||||
@ -64,8 +68,8 @@ public:
|
||||
void addAdBlockRule(const QString &filter, const QUrl &url);
|
||||
QList<AdBlockedEntry> adBlockedEntries() { return m_adBlockedEntries; }
|
||||
|
||||
QupZilla* qupzilla() { return p_QupZilla; }
|
||||
void scheduleAdjustPage();
|
||||
bool isRunningLoop();
|
||||
|
||||
static QString UserAgent;
|
||||
QString userAgentForUrl(const QUrl &url) const;
|
||||
@ -78,7 +82,7 @@ signals:
|
||||
protected slots:
|
||||
QWebPage* createWindow(QWebPage::WebWindowType type);
|
||||
void handleUnsupportedContent(QNetworkReply* url);
|
||||
// void loadingStarted();
|
||||
|
||||
void progress(int prog);
|
||||
void finished();
|
||||
|
||||
@ -89,19 +93,21 @@ private slots:
|
||||
|
||||
void watchedFileChanged(const QString &file);
|
||||
void printFrame(QWebFrame* frame);
|
||||
void downloadRequested(const QNetworkRequest &request);
|
||||
|
||||
private:
|
||||
virtual bool supportsExtension(Extension extension) const { return (extension == ErrorPageExtension); }
|
||||
virtual bool supportsExtension(Extension extension) const;
|
||||
virtual bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||
bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type);
|
||||
|
||||
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
||||
|
||||
static QString m_lastUploadLocation;
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
NetworkManagerProxy* m_networkProxy;
|
||||
QNetworkRequest m_lastRequest;
|
||||
QWebPage::NavigationType m_lastRequestType;
|
||||
WebView* m_view;
|
||||
TabbedWebView* m_view;
|
||||
SpeedDial* m_speedDial;
|
||||
QSslCertificate m_SslCert;
|
||||
QList<QSslCertificate> m_SslCerts;
|
||||
@ -113,7 +119,8 @@ private:
|
||||
bool m_blockAlerts;
|
||||
bool m_secureStatus;
|
||||
bool m_adjustingScheduled;
|
||||
// bool m_isOpeningNextWindowAsNewTab;
|
||||
|
||||
bool m_isClosing;
|
||||
};
|
||||
|
||||
#endif // WEBPAGE_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,167 +19,95 @@
|
||||
#define WEBVIEW_H
|
||||
|
||||
#include <QWebView>
|
||||
#include <QDebug>
|
||||
#include <QTabWidget>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QWebElement>
|
||||
#include <QWebFrame>
|
||||
#include <QWebElementCollection>
|
||||
#include <QTouchEvent>
|
||||
#include <QClipboard>
|
||||
#include <QLabel>
|
||||
#include <QProcess>
|
||||
#include <QWebInspector>
|
||||
#include <QDockWidget>
|
||||
#include <QWebPage>
|
||||
#include <QHostInfo>
|
||||
#include <QPrintPreviewDialog>
|
||||
#include <QFile>
|
||||
|
||||
class QupZilla;
|
||||
class TabWidget;
|
||||
class WebPage;
|
||||
class NetworkManagerProxy;
|
||||
class WebTab;
|
||||
class LocationBar;
|
||||
class WebView : public QWebView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebView(QupZilla* mainClass, WebTab* webTab);
|
||||
~WebView();
|
||||
bool isLoading() { return m_isLoading;}
|
||||
int getLoading() { return m_progress; }
|
||||
explicit WebView(QWidget* parent = 0);
|
||||
|
||||
void zoomReset();
|
||||
QUrl url() const;
|
||||
QIcon icon() const;
|
||||
QString title() const;
|
||||
void reload();
|
||||
WebPage* webPage() const;
|
||||
WebTab* webTab() const;
|
||||
QString getIp() { return m_currentIp; }
|
||||
QLabel* animationLoading(int index, bool addMovie);
|
||||
QIcon siteIcon();
|
||||
void addNotification(QWidget* notif);
|
||||
bool hasRss() { return m_hasRss; }
|
||||
void setMouseWheelEnabled(bool state) { m_mouseWheelEnabled = state; }
|
||||
QUrl url() const;
|
||||
|
||||
bool isLoading() const;
|
||||
int loadProgress() const;
|
||||
|
||||
void addNotification(QWidget* notif);
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
void setLocationBar(LocationBar* bar) { m_locationBar = bar; }
|
||||
LocationBar* locationBar() { return m_locationBar; }
|
||||
virtual QWidget* overlayForJsAlert() = 0;
|
||||
|
||||
static QUrl guessUrlFromString(const QString &string);
|
||||
static bool isUrlValid(const QUrl &url);
|
||||
int tabIndex() const;
|
||||
|
||||
void disconnectObjects();
|
||||
static QUrl guessUrlFromString(const QString &string);
|
||||
|
||||
signals:
|
||||
void showUrl(QUrl url);
|
||||
void wantsCloseTab(int index);
|
||||
void changed();
|
||||
void ipChanged(QString ip);
|
||||
void showNotification(QWidget* notif);
|
||||
void viewportResized(QSize size);
|
||||
void rssChanged(bool state);
|
||||
void viewportResized(QSize);
|
||||
void showNotification(QWidget*);
|
||||
void iconChanged();
|
||||
|
||||
public slots:
|
||||
void load(const QUrl &url);
|
||||
void titleChanged();
|
||||
|
||||
void stop();
|
||||
void back();
|
||||
void forward();
|
||||
void slotReload();
|
||||
void iconChanged();
|
||||
void selectAll();
|
||||
void closeTab();
|
||||
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoomReset();
|
||||
|
||||
private slots:
|
||||
void copyText();
|
||||
void load(const QUrl &url);
|
||||
void reload();
|
||||
|
||||
void trackMouse(bool state) { m_mouseTrack = state; }
|
||||
void showImage();
|
||||
void copyImageToClipboard();
|
||||
void downloadImageToDisk();
|
||||
void searchSelectedText();
|
||||
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 linkHovered(const QString &link, const QString &title, const QString &content);
|
||||
void openUrlInNewWindow();
|
||||
void openUrlInNewTab();
|
||||
void downloadLinkToDisk();
|
||||
void sendLinkByMail();
|
||||
void bookmarkLink();
|
||||
void showSource();
|
||||
void showSourceOfSelection();
|
||||
void showSiteInfo();
|
||||
void getFocus(const QUrl &urla);
|
||||
void showInspector();
|
||||
void stopAnimation();
|
||||
void setIp(const QHostInfo &info);
|
||||
void checkRss();
|
||||
void back();
|
||||
void forward();
|
||||
|
||||
void selectAll();
|
||||
void printPage(QWebFrame* frame = 0);
|
||||
|
||||
virtual void closeView() = 0;
|
||||
|
||||
protected slots:
|
||||
void slotLoadStarted();
|
||||
void slotLoadProgress(int progress);
|
||||
void slotLoadFinished();
|
||||
void slotIconChanged();
|
||||
|
||||
// ClickedFrame
|
||||
void loadClickedFrame();
|
||||
void loadClickedFrameInNewTab();
|
||||
void reloadClickedFrame();
|
||||
void printClickedFrame();
|
||||
void clickedFrameZoomIn();
|
||||
void clickedFrameZoomOut();
|
||||
void clickedFrameZoomReset();
|
||||
void showClickedFrameSource();
|
||||
// Context menu slots
|
||||
void openUrlInNewWindow();
|
||||
void sendLinkByMail();
|
||||
void copyLinkToClipboard();
|
||||
void downloadLinkToDisk();
|
||||
void copyImageToClipboard();
|
||||
void openActionUrl();
|
||||
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
|
||||
void showSiteInfo();
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
||||
void setZoom(int zoom);
|
||||
void applyZoom();
|
||||
void copyText();
|
||||
QUrl lastUrl();
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
TabWidget* tabWidget() const;
|
||||
bool isCurrent();
|
||||
void applyZoom();
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
|
||||
QString m_hoveredLink;
|
||||
QList<int> m_zoomLevels;
|
||||
QUrl m_aboutToLoadUrl;
|
||||
QUrl m_lastUrl;
|
||||
QString m_currentIp;
|
||||
QIcon m_siteIcon;
|
||||
int m_progress;
|
||||
int m_currentZoom;
|
||||
|
||||
WebPage* m_page;
|
||||
WebTab* m_webTab;
|
||||
NetworkManagerProxy* m_networkProxy;
|
||||
LocationBar* m_locationBar;
|
||||
QMenu* m_menu;
|
||||
QWebFrame* m_clickedFrame;
|
||||
QIcon m_siteIcon;
|
||||
QUrl m_siteIconUrl;
|
||||
|
||||
bool m_mouseTrack;
|
||||
bool m_navigationVisible;
|
||||
bool m_mouseWheelEnabled;
|
||||
bool m_wantsClose;
|
||||
bool m_isLoading;
|
||||
|
||||
bool m_hasRss;
|
||||
bool m_rssChecked;
|
||||
int m_progress;
|
||||
QUrl m_aboutToLoadUrl;
|
||||
QUrl m_lastUrl;
|
||||
|
||||
QList<QTouchEvent::TouchPoint> m_touchPoints;
|
||||
//QTimer* m_loadingTimer;
|
||||
|
||||
// static QList<WebView*> s_deletedPointers;
|
||||
// static bool isPointerValid(WebView* pointer);
|
||||
};
|
||||
|
||||
#endif // WEBVIEW_H
|
||||
|
Loading…
Reference in New Issue
Block a user