1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Initial port to QtWebEngine

This is first quick port to QtWebEngine, most of advanced features
are not working yet. Please read README.

For now, it will use separate profile directory as well as browser
session, that means you can use both QtWebEngine and QtWebKit versions
at the same time.
This commit is contained in:
David Rosca 2015-01-27 11:01:52 +01:00
parent cc08957148
commit 60b2386a6e
107 changed files with 1013 additions and 570 deletions

1
.gitignore vendored
View File

@ -5,7 +5,6 @@ DEBIAN
*.autosave
*~
*.a
*.orig
*.qm
*.o
!qt_*.qm

View File

@ -24,4 +24,4 @@ src_main.depends = sub-src-lib
src_plugins.subdir = src/plugins
src_plugins.depends = sub-src-lib
SUBDIRS += src_lib src_main src_plugins
SUBDIRS += src_lib src_main

View File

@ -1,99 +1,15 @@
QupZilla Web Browser
QupZilla Web Browser - QtWebEngine
----------------------------------------------------------------------------------------
[![Build Status](https://travis-ci.org/QupZilla/qupzilla.svg?branch=master)](https://travis-ci.org/QupZilla/qupzilla)
Homepage: [http://www.qupzilla.com](http://www.qupzilla.com)
Blog: [http://blog.qupzilla.com](http://blog.qupzilla.com)
IRC: `#qupzilla` at `irc.freenode.net`
Translations: [https://www.transifex.com](https://www.transifex.com/projects/p/qupzilla)
About QupZilla
THIS IS QTWEBENGINE BRANCH
----------------------------------------------------------------------------------------
QupZilla is a new and very fast QtWebKit browser. It aims to be a lightweight web browser
available through all major platforms. This project has been originally started only
for educational purposes. But from its start, QupZilla has grown into a feature-rich browser.
QupZilla has all standard functions you expect from a web browser. It includes bookmarks,
history (both also in sidebar) and tabs. Above that, you can manage RSS feeds with an included
RSS reader, block ads with a built-in AdBlock plugin, block Flash content with Click2Flash
and edit the local CA Certificates database with an SSL Manager.
QupZilla's main aim is to be a very fast and very stable QtWebKit browser available to everyone.
There are already a lot of QtWebKit browsers available, but they are either bound to the KDE
environment (rekonq), are not actively developed or very unstable and miss important
features. But there is missing a multi-platform, modern and actively developed browser. QupZilla
is trying to fill this gap by providing a very stable browsing experience.
History
----------------------------------------------------------------------------------------
The very first version of QupZilla has been released in December 2010 and it was written
in Python with PyQt4 bindings. After a few versions, QupZilla has been completely rewritten
in C++ with the Qt Framework. The Windows version of QupZilla was compiled using MingW, but due to
a huge problem with Flash, it is now compiled with Microsoft Visual C++ Compiler 2008.
First public release was 1.0.0-b4.
Compiling
----------------------------------------------------------------------------------------
Before you start compiling, make sure that you have installed the Qt (>=4.7) development libraries
and you have read the [BUILDING](https://github.com/QupZilla/qupzilla/blob/master/BUILDING) information.
**Linux**
* OpenSSL (libcrypto) is required
* pkg-config is recommended (to correctly detect versions of QtWebKit)
* pkg-config is required for Hunspell spellcheck
* Hunspell development package for spellcheck
* QtWebKit 2.3 is needed to have support for spellcheck
**Windows**
* OpenSSL (libeay32) is required
* QtWebKit 2.3 is required
* Hunspell library is required for spellcheck
Then you can start compiling by running this commands:
$ qmake
$ make
After a successful compilation the executable binary can be found in the bin/ directory.
On Fedora and possibly other Linux distributions you need to replace `qmake` with `qmake-qt4` or `qmake-qt5` since `qmake` is for Qt3.
On Linux/Unix: To install QupZilla, run this command: (it may be necessary to run it as root)
$ make install
On Mac OS X: To deploy QupZilla in dmg image, run this command:
$ ./mac/macdeploy.sh full-path-to-macdeployqt
You need to specify path to `macdeployqt` only if it is not in PATH.
Current version
----------------------------------------------------------------------------------------
The current stable version of QupZilla is 1.8.6. You can download precompiled packages
and the sources from the download section at [homepage](http://www.qupzilla.com/download).
However, if you want the latest revision, just take the latest code snapshot either by
downloading a tarball or running:
$ git clone git://github.com/QupZilla/qupzilla.git
If you are using Ubuntu, you can download QupZilla from PPA:
$ sudo add-apt-repository ppa:nowrep/qupzilla
$ sudo apt-get update
$ sudo apt-get install qupzilla
for development version:
$ sudo apt-get install qupzilla-next
FAQ and Changelog
----------------------------------------------------------------------------------------
If you are experiencing some sort of problem, please read the FAQ before you open an issue.
[FAQ](https://github.com/QupZilla/qupzilla/wiki/FAQ) | [Changelog](https://github.com/QupZilla/qupzilla/blob/master/CHANGELOG) | [Bug Reports](https://github.com/QupZilla/qupzilla/wiki/Bug-Reports)
Master branch is now for QtWebEngine. It is still in very early development state, so except
a lot of features found in QtWebKit branch not working here. Thanks for understanding!
For QtWebKit, please use [v1.8](https://github.com/QupZilla/qupzilla/tree/v1.8)

View File

@ -53,8 +53,7 @@
#include <QString>
#include <QStringList>
#include <QNetworkRequest>
#include <QWebFrame>
#include <QWebPage>
#include <QWebEnginePage>
// Version for Qt < 4.8 has one issue, it will wrongly
// count .co.uk (and others) as second-level domain
@ -352,12 +351,13 @@ bool AdBlockRule::matchObject(const QNetworkRequest &request) const
bool AdBlockRule::matchSubdocument(const QNetworkRequest &request) const
{
QWebFrame* originatingFrame = static_cast<QWebFrame*>(request.originatingObject());
#if QTWEBENGINE_DISABLED
QWebEngineFrame* originatingFrame = static_cast<QWebEngineFrame*>(request.originatingObject());
if (!originatingFrame) {
return false;
}
QWebPage* page = originatingFrame->page();
QWebEnginePage* page = originatingFrame->page();
if (!page) {
return false;
}
@ -365,6 +365,9 @@ bool AdBlockRule::matchSubdocument(const QNetworkRequest &request) const
bool match = !(originatingFrame == page->mainFrame());
return hasException(SubdocumentOption) ? !match : match;
#else
return false;
#endif
}
bool AdBlockRule::matchXmlHttpRequest(const QNetworkRequest &request) const

View File

@ -82,8 +82,7 @@
#include <QDesktopServices>
#include <QPrintPreviewDialog>
#include <QPrinter>
#include <QWebFrame>
#include <QWebHistory>
#include <QWebEngineHistory>
#include <QMessageBox>
#include <QDesktopWidget>
#include <QToolTip>
@ -105,7 +104,11 @@
#endif
#endif /* Q_OS_WIN */
#if QTWEBENGINE_DISABLED
const QString BrowserWindow::WEBKITVERSION = qWebKitVersion();
#else
const QString BrowserWindow::WEBKITVERSION = QSL("QtWebEngine");
#endif
static QKeySequence actionShortcut(QKeySequence shortcut, QKeySequence fallBack, QKeySequence shortcutRTL = QKeySequence(), QKeySequence fallbackRTL = QKeySequence())
{
@ -197,6 +200,7 @@ void BrowserWindow::postLaunch()
switch (m_windowType) {
case Qz::BW_FirstAppWindow:
#if QTWEBENGINE_DISABLED
if (mApp->isStartingAfterCrash()) {
addTab = true;
startUrl = QUrl("qupzilla:restore");
@ -204,6 +208,11 @@ void BrowserWindow::postLaunch()
else if (afterLaunch == 3 && mApp->restoreManager()) {
addTab = !mApp->restoreSession(this, mApp->restoreManager()->restoreData());
}
#else
if (afterLaunch == 3 && mApp->restoreManager()) {
addTab = !mApp->restoreSession(this, mApp->restoreManager()->restoreData());
}
#endif
else {
// Pinned tabs are restored in MainApplication::restoreStateSlot
// Make sure they will be restored also when not restoring session
@ -427,7 +436,11 @@ void BrowserWindow::createEncodingSubMenu(const QString &name, QStringList &code
std::sort(codecNames.begin(), codecNames.end());
QMenu* subMenu = new QMenu(name, menu);
#if QTWEBENGINE_DISABLED
const QString activeCodecName = QWebSettings::globalSettings()->defaultTextEncoding();
#else
const QString activeCodecName = QL1S("UTF-8");
#endif
foreach (const QString &codecName, codecNames) {
subMenu->addAction(createEncodingAction(codecName, activeCodecName, subMenu));
@ -668,7 +681,9 @@ void BrowserWindow::changeEncoding()
{
if (QAction* action = qobject_cast<QAction*>(sender())) {
const QString encoding = action->data().toString();
QWebSettings::globalSettings()->setDefaultTextEncoding(encoding);
#if QTWEBENGINE_DISABLED
QWebEngineSettings::globalSettings()->setDefaultTextEncoding(encoding);
#endif
Settings settings;
settings.setValue("Web-Browser-Settings/DefaultEncoding", encoding);
@ -742,8 +757,9 @@ void BrowserWindow::showHistoryManager()
mApp->browsingLibrary()->showHistory(this);
}
void BrowserWindow::showSource(QWebFrame* frame, const QString &selectedHtml)
void BrowserWindow::showSource(QWebEngineFrame* frame, const QString &selectedHtml)
{
#if QTWEBENGINE_DISABLED
if (!frame) {
frame = weView()->page()->mainFrame();
}
@ -751,6 +767,7 @@ void BrowserWindow::showSource(QWebFrame* frame, const QString &selectedHtml)
SourceViewer* source = new SourceViewer(frame, selectedHtml);
QzTools::centerWidgetToParent(source, this);
source->show();
#endif
}
SideBar* BrowserWindow::addSideBar()
@ -863,12 +880,14 @@ void BrowserWindow::toggleTabsOnTop(bool enable)
void BrowserWindow::toggleCaretBrowsing()
{
#if QTWEBENGINE_DISABLED
#if QTWEBKIT_FROM_2_3
bool enable = !QWebSettings::globalSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled);
bool enable = !QWebEngineSettings::globalSettings()->testAttribute(QWebEngineSettings::CaretBrowsingEnabled);
Settings().setValue("Web-Browser-Settings/CaretBrowsing", enable);
QWebSettings::globalSettings()->setAttribute(QWebSettings::CaretBrowsingEnabled, enable);
QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::CaretBrowsingEnabled, enable);
#endif
#endif
}
@ -1000,7 +1019,11 @@ void BrowserWindow::createSidebarsMenu(QMenu* menu)
void BrowserWindow::createEncodingMenu(QMenu* menu)
{
#if QTWEBENGINE_DISABLED
const QString activeCodecName = QWebSettings::globalSettings()->defaultTextEncoding();
#else
const QString activeCodecName = QL1S("UTF-8");
#endif
QStringList isoCodecs, utfCodecs, windowsCodecs, isciiCodecs, otherCodecs;
@ -1193,7 +1216,7 @@ bool BrowserWindow::event(QEvent* event)
return QMainWindow::event(event);
}
void BrowserWindow::printPage(QWebFrame* frame)
void BrowserWindow::printPage(QWebEngineFrame* frame)
{
QPrintPreviewDialog* dialog = new QPrintPreviewDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
@ -1206,9 +1229,11 @@ void BrowserWindow::printPage(QWebFrame* frame)
connect(dialog, SIGNAL(paintRequested(QPrinter*)), weView(), SLOT(print(QPrinter*)));
}
else {
#if QTWEBENGINE_DISABLED
dialog->printer()->setDocName(QzTools::getFileNameFromUrl(QzTools::frameUrl(frame)));
connect(dialog, SIGNAL(paintRequested(QPrinter*)), frame, SLOT(print(QPrinter*)));
#endif
}
dialog->open();
@ -1216,8 +1241,10 @@ void BrowserWindow::printPage(QWebFrame* frame)
void BrowserWindow::savePageScreen()
{
#if QTWEBENGINE_DISABLED
PageScreen* dialog = new PageScreen(weView(), this);
dialog->show();
#endif
}
void BrowserWindow::resizeEvent(QResizeEvent* event)
@ -1409,6 +1436,7 @@ void BrowserWindow::keyPressEvent(QKeyEvent* event)
m_tabWidget->setCurrentIndex(number - 1);
return;
}
#if QTWEBENGINE_DISABLED
if (event->modifiers() & Qt::ControlModifier && m_useSpeedDialNumberShortcuts) {
const QUrl url = mApp->plugins()->speedDial()->urlForShortcut(number - 1);
if (url.isValid()) {
@ -1422,6 +1450,7 @@ void BrowserWindow::keyPressEvent(QKeyEvent* event)
if (number == 2)
m_tabWidget->nextTab();
}
#endif
}
QMainWindow::keyPressEvent(event);

View File

@ -28,7 +28,7 @@
class QLabel;
class QVBoxLayout;
class QSplitter;
class QWebFrame;
class QWebEngineFrame;
class QTimer;
class Menu;
@ -142,8 +142,8 @@ public slots:
void bookmarkPage();
void bookmarkAllTabs();
void loadAddress(const QUrl &url);
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
void printPage(QWebFrame* frame = 0);
void showSource(QWebEngineFrame* frame = 0, const QString &selectedHtml = QString());
void printPage(QWebEngineFrame* frame = 0);
private slots:
void addTab();

View File

@ -209,6 +209,9 @@ MainApplication::MainApplication(int &argc, char** argv)
appId.append(QLatin1String("Portable"));
}
// QtWebEngine
appId.append(QL1S("-QtWebEngine"));
// TODO: This should generate some random string for appId
if (newInstance) {
if (startProfile.isEmpty() || startProfile == QLatin1String("default")) {
@ -516,7 +519,11 @@ QNetworkDiskCache* MainApplication::networkCache()
Settings settings;
const QString defaultBasePath = QString("%1/networkcache/").arg(DataPaths::currentProfilePath());
const QString basePath = settings.value("Web-Browser-Settings/CachePath", defaultBasePath).toString();
#if QTWEBENGINE_DISABLED
const QString cachePath = QString("%1/%2-Qt%3/").arg(basePath, qWebKitVersion(), qVersion());
#else
const QString cachePath = QString("%1/QtWebEngine/").arg(basePath);
#endif
m_networkCache = new QNetworkDiskCache(this);
m_networkCache->setCacheDirectory(cachePath);
@ -533,6 +540,7 @@ BrowsingLibrary* MainApplication::browsingLibrary()
return m_browsingLibrary;
}
#if QTWEBENGINE_DISABLED
RSSManager* MainApplication::rssManager()
{
if (!m_rssManager) {
@ -540,11 +548,12 @@ RSSManager* MainApplication::rssManager()
}
return m_rssManager;
}
#endif
NetworkManager* MainApplication::networkManager()
QNetworkAccessManager* MainApplication::networkManager()
{
if (!m_networkManager) {
m_networkManager = new NetworkManager(this);
m_networkManager = new QNetworkAccessManager(this);
}
return m_networkManager;
}
@ -636,8 +645,10 @@ void MainApplication::startPrivateBrowsing(const QUrl &startUrl)
void MainApplication::reloadUserStyleSheet()
{
#if QTWEBENGINE_DISABLED
const QUrl userCss = userStyleSheet(Settings().value("Web-Browser-Settings/userStyleSheet", QString()).toString());
QWebSettings::globalSettings()->setUserStyleSheetUrl(userCss);
QWebEngineSettings::globalSettings()->setUserStyleSheetUrl(userCss);
#endif
}
void MainApplication::restoreOverrideCursor()
@ -690,7 +701,9 @@ void MainApplication::postLaunch()
}
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, DataPaths::currentProfilePath());
QWebHistoryInterface::setDefaultInterface(new WebHistoryInterface(this));
#if QTWEBENGINE_DISABLED
QWebEngineHistoryInterface::setDefaultInterface(new WebHistoryInterface(this));
#endif
connect(this, SIGNAL(messageReceived(QString)), this, SLOT(messageReceived(QString)));
connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveSettings()));
@ -758,7 +771,6 @@ void MainApplication::saveSettings()
}
m_searchEnginesManager->saveSettings();
m_networkManager->saveSettings();
m_plugins->shutdown();
DataPaths::clearTempData();
@ -854,6 +866,7 @@ void MainApplication::loadSettings()
loadTheme(activeTheme);
#if QTWEBENGINE_DISABLED
QWebSettings* webSettings = QWebSettings::globalSettings();
// Web browsing settings
@ -915,9 +928,12 @@ void MainApplication::loadSettings()
webSettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, IconProvider::emptyWebIcon().pixmap(16, 16));
webSettings->setWebGraphic(QWebSettings::MissingImageGraphic, QPixmap());
#endif
if (isPrivate()) {
#if QTWEBENGINE_DISABLED
webSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
#endif
history()->setSaving(false);
}

View File

@ -28,6 +28,7 @@
class QMenu;
class QNetworkDiskCache;
class QNetworkAccessManager;
class History;
class AutoFill;
@ -39,7 +40,6 @@ class RSSManager;
class ProxyStyle;
class PluginProxy;
class BrowserWindow;
class NetworkManager;
class BrowsingLibrary;
class DownloadManager;
class UserAgentManager;
@ -92,7 +92,7 @@ public:
BrowsingLibrary* browsingLibrary();
RSSManager* rssManager();
NetworkManager* networkManager();
QNetworkAccessManager* networkManager();
RestoreManager* restoreManager();
DownloadManager* downloadManager();
UserAgentManager* userAgentManager();
@ -157,7 +157,7 @@ private:
BrowsingLibrary* m_browsingLibrary;
RSSManager* m_rssManager;
NetworkManager* m_networkManager;
QNetworkAccessManager* m_networkManager;
RestoreManager* m_restoreManager;
DownloadManager* m_downloadManager;
UserAgentManager* m_userAgentManager;

View File

@ -36,7 +36,7 @@
#include <QApplication>
#include <QMetaObject>
#include <QStatusBar>
#include <QWebPage>
#include <QWebEnginePage>
#include <QMenuBar>
#ifdef Q_OS_MAC
@ -303,11 +303,13 @@ void MainMenu::webSearch()
void MainMenu::showSiteInfo()
{
#if QTWEBENGINE_DISABLED
if (m_window) {
SiteInfo* info = new SiteInfo(m_window->weView(), m_window);
info->setAttribute(Qt::WA_DeleteOnClose);
info->show();
}
#endif
}
void MainMenu::showDownloadManager()
@ -403,8 +405,10 @@ void MainMenu::aboutToShowViewMenu()
m_actions[QSL("View/FullScreen")]->setChecked(m_window->isFullScreen());
m_actions[QSL("View/PageSource")]->setEnabled(true);
#if QTWEBENGINE_DISABLED
#if QTWEBKIT_FROM_2_3
m_actions[QSL("View/CaretBrowsing")]->setChecked(m_window->weView()->settings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
m_actions[QSL("View/CaretBrowsing")]->setChecked(m_window->weView()->settings()->testAttribute(QWebEngineSettings::CaretBrowsingEnabled));
#endif
#endif
}
@ -421,12 +425,12 @@ void MainMenu::aboutToShowEditMenu()
WebView* view = m_window->weView();
m_actions[QSL("Edit/Undo")]->setEnabled(view->pageAction(QWebPage::Undo)->isEnabled());
m_actions[QSL("Edit/Redo")]->setEnabled(view->pageAction(QWebPage::Redo)->isEnabled());
m_actions[QSL("Edit/Cut")]->setEnabled(view->pageAction(QWebPage::Cut)->isEnabled());
m_actions[QSL("Edit/Copy")]->setEnabled(view->pageAction(QWebPage::Copy)->isEnabled());
m_actions[QSL("Edit/Paste")]->setEnabled(view->pageAction(QWebPage::Paste)->isEnabled());
m_actions[QSL("Edit/SelectAll")]->setEnabled(view->pageAction(QWebPage::SelectAll)->isEnabled());
m_actions[QSL("Edit/Undo")]->setEnabled(view->pageAction(QWebEnginePage::Undo)->isEnabled());
m_actions[QSL("Edit/Redo")]->setEnabled(view->pageAction(QWebEnginePage::Redo)->isEnabled());
m_actions[QSL("Edit/Cut")]->setEnabled(view->pageAction(QWebEnginePage::Cut)->isEnabled());
m_actions[QSL("Edit/Copy")]->setEnabled(view->pageAction(QWebEnginePage::Copy)->isEnabled());
m_actions[QSL("Edit/Paste")]->setEnabled(view->pageAction(QWebEnginePage::Paste)->isEnabled());
m_actions[QSL("Edit/SelectAll")]->setEnabled(view->pageAction(QWebEnginePage::SelectAll)->isEnabled());
m_actions[QSL("Edit/Find")]->setEnabled(true);
}

View File

@ -132,14 +132,20 @@ QString ProfileManager::currentProfile() const
QString ProfileManager::startingProfile() const
{
#if QTWEBENGINE_DISABLED
QSettings settings(DataPaths::path(DataPaths::Profiles) + QLatin1String("/profiles.ini"), QSettings::IniFormat);
return settings.value(QLatin1String("Profiles/startProfile"), QLatin1String("default")).toString();
#else
return QString("qtwebengine");
#endif
}
void ProfileManager::setStartingProfile(const QString &profileName)
{
#if QTWEBENGINE_DISABLED
QSettings settings(DataPaths::path(DataPaths::Profiles) + QLatin1String("/profiles.ini"), QSettings::IniFormat);
settings.setValue(QLatin1String("Profiles/startProfile"), profileName);
#endif
}
QStringList ProfileManager::availableProfiles() const

View File

@ -146,6 +146,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG true
#endif
#if QTWEBENGINE_DISABLED
#define QTWEBKIT_FROM_2_2 \
(QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)))
@ -157,5 +158,15 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
#define QTWEBKIT_TO_2_3 \
(QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 3, 0)))
#else
#define QTWEBKIT_FROM_2_2 true
#define QTWEBKIT_TO_2_2 false
#define QTWEBKIT_FROM_2_3 true
#define QTWEBKIT_TO_2_3 false
#undef USE_QTWEBKIT_2_2
#undef USE_QTWEBKIT_2_3
#endif
#endif // QZCOMMON_H

View File

@ -30,7 +30,6 @@
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QWebFrame>
#include <QNetworkRequest>
#if QT_VERSION >= 0x050000
@ -170,7 +169,7 @@ void AutoFill::removeAllEntries()
}
// If password was filled in the page, returns all saved passwords on this page
QVector<PasswordEntry> AutoFill::completeFrame(QWebFrame* frame)
QVector<PasswordEntry> AutoFill::completeFrame(QWebEngineFrame* frame)
{
bool completed = false;
QVector<PasswordEntry> list;
@ -202,12 +201,13 @@ QVector<PasswordEntry> AutoFill::completeFrame(QWebFrame* frame)
void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingData)
{
#if QTWEBENGINE_DISABLED
// Don't save in private browsing
if (mApp->isPrivate()) {
return;
}
QWebFrame* frame = qobject_cast<QWebFrame*>(request.originatingObject());
QWebEngineFrame* frame = qobject_cast<QWebEngineFrame*>(request.originatingObject());
if (!frame) {
return;
}
@ -259,6 +259,7 @@ void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingDa
AutoFillNotification* aWidget = new AutoFillNotification(frameUrl, formData, updateData);
webView->addNotification(aWidget);
#endif
}
QByteArray AutoFill::exportPasswords()

View File

@ -23,7 +23,7 @@
#include "qzcommon.h"
class QUrl;
class QWebFrame;
class QWebEngineFrame;
class QWebElement;
class QNetworkRequest;
@ -61,7 +61,7 @@ public:
void removeAllEntries();
void post(const QNetworkRequest &request, const QByteArray &outgoingData);
QVector<PasswordEntry> completeFrame(QWebFrame* frame);
QVector<PasswordEntry> completeFrame(QWebEngineFrame *frame);
QByteArray exportPasswords();
bool importPasswords(const QByteArray &data);

View File

@ -18,9 +18,7 @@
#include "pageformcompleter.h"
#include "qzregexp.h"
#include <QWebPage>
#include <QWebFrame>
#include <QWebElement>
#include <QWebEnginePage>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
@ -31,25 +29,25 @@ PageFormCompleter::PageFormCompleter()
{
}
PageFormData PageFormCompleter::extractFormData(QWebPage* page, const QByteArray &postData)
PageFormData PageFormCompleter::extractFormData(QWebEnginePage* page, const QByteArray &postData)
{
m_page = page;
return extractFormData(postData);
}
PageFormData PageFormCompleter::extractFormData(QWebFrame* frame, const QByteArray &postData)
PageFormData PageFormCompleter::extractFormData(QWebEngineFrame* frame, const QByteArray &postData)
{
m_frame = frame;
return extractFormData(postData);
}
bool PageFormCompleter::completeFormData(QWebPage* page, const QByteArray &data)
bool PageFormCompleter::completeFormData(QWebEnginePage* page, const QByteArray &data)
{
m_page = page;
return completeFormData(data);
}
bool PageFormCompleter::completeFormData(QWebFrame* frame, const QByteArray &data)
bool PageFormCompleter::completeFormData(QWebEngineFrame* frame, const QByteArray &data)
{
m_frame = frame;
return completeFormData(data);
@ -73,6 +71,7 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
return formData;
}
#if QTWEBENGINE_DISABLED
const QWebElementCollection allForms = getAllElementsFromPage("form");
// Find form that contains password value sent in data
@ -109,6 +108,7 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
formData.username = usernameValue;
formData.password = passwordValue;
#endif
return formData;
}
@ -123,6 +123,7 @@ bool PageFormCompleter::completeFormData(const QByteArray &data) const
QStringList inputTypes;
inputTypes << "text" << "password" << "email";
#if QTWEBENGINE_DISABLED
// Find all input elements in the page
const QWebElementCollection inputs = getAllElementsFromPage("input");
@ -144,6 +145,7 @@ bool PageFormCompleter::completeFormData(const QByteArray &data) const
}
}
}
#endif
return completed;
}
@ -212,6 +214,7 @@ QByteArray PageFormCompleter::convertWebKitFormBoundaryIfNecessary(const QByteAr
PageFormCompleter::QueryItem PageFormCompleter::findUsername(const QWebElement &form) const
{
#if QTWEBENGINE_DISABLED
// Try to find username (or email) field in the form.
QStringList selectors;
selectors << "input[type=\"text\"][name*=\"user\"]"
@ -234,6 +237,7 @@ PageFormCompleter::QueryItem PageFormCompleter::findUsername(const QWebElement &
}
}
}
#endif
return QueryItem();
}
@ -254,6 +258,7 @@ PageFormCompleter::QueryItems PageFormCompleter::createQueryItems(QByteArray dat
return arguments;
}
#if QTWEBENGINE_DISABLED
QWebElementCollection PageFormCompleter::getAllElementsFromPage(const QString &selector) const
{
QWebElementCollection list;
@ -280,3 +285,5 @@ QWebElementCollection PageFormCompleter::getAllElementsFromPage(const QString &s
return list;
}
#endif

View File

@ -24,8 +24,8 @@
#include "qzcommon.h"
class QWebPage;
class QWebFrame;
class QWebEnginePage;
class QWebEngineFrame;
class QWebElement;
class QWebElementCollection;
@ -44,11 +44,11 @@ class QUPZILLA_EXPORT PageFormCompleter
public:
explicit PageFormCompleter();
PageFormData extractFormData(QWebPage* page, const QByteArray &postData);
PageFormData extractFormData(QWebFrame* frame, const QByteArray &postData);
PageFormData extractFormData(QWebEnginePage* page, const QByteArray &postData);
PageFormData extractFormData(QWebEngineFrame* frame, const QByteArray &postData);
bool completeFormData(QWebPage* page, const QByteArray &data);
bool completeFormData(QWebFrame* frame, const QByteArray &data);
bool completeFormData(QWebEnginePage* page, const QByteArray &data);
bool completeFormData(QWebEngineFrame* frame, const QByteArray &data);
private:
typedef QPair<QString, QString> QueryItem;
@ -62,10 +62,12 @@ private:
QByteArray convertWebKitFormBoundaryIfNecessary(const QByteArray &data) const;
QueryItem findUsername(const QWebElement &form) const;
QueryItems createQueryItems(QByteArray data) const;
#if QTWEBENGINE_DISABLED
QWebElementCollection getAllElementsFromPage(const QString &selector) const;
#endif
QWebPage* m_page;
QWebFrame* m_frame;
QWebEnginePage* m_page;
QWebEngineFrame* m_frame;
};
#endif // PAGEFORMCOMPLETER_H

View File

@ -40,7 +40,9 @@ BookmarksIcon::BookmarksIcon(QWidget* parent)
connect(mApp->bookmarks(), SIGNAL(bookmarkAdded(BookmarkItem*)), this, SLOT(bookmarksChanged()));
connect(mApp->bookmarks(), SIGNAL(bookmarkRemoved(BookmarkItem*)), this, SLOT(bookmarksChanged()));
connect(mApp->bookmarks(), SIGNAL(bookmarkChanged(BookmarkItem*)), this, SLOT(bookmarksChanged()));
#if QTWEBENGINE_DISABLED
connect(mApp->plugins()->speedDial(), SIGNAL(pagesChanged()), this, SLOT(speedDialChanged()));
#endif
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(iconClicked()));
}
@ -59,7 +61,9 @@ void BookmarksIcon::checkBookmark(const QUrl &url, bool forceCheck)
QList<BookmarkItem*> items = mApp->bookmarks()->searchBookmarks(url);
m_bookmark = items.isEmpty() ? 0 : items.first();
if (m_bookmark || !mApp->plugins()->speedDial()->pageForUrl(url).url.isEmpty()) {
#if QTWEBENGINE_DISABLED
#endif
if (m_bookmark /*|| !mApp->plugins()->speedDial()->pageForUrl(url).url.isEmpty()*/) {
setBookmarkSaved();
}
else {

View File

@ -50,6 +50,7 @@ BookmarksWidget::~BookmarksWidget()
void BookmarksWidget::toggleSpeedDial()
{
#if QTWEBENGINE_DISABLED
const SpeedDial::Page page = m_speedDial->pageForUrl(m_view->url());
if (page.url.isEmpty()) {
@ -61,6 +62,7 @@ void BookmarksWidget::toggleSpeedDial()
}
closePopup();
#endif
}
void BookmarksWidget::toggleBookmark()
@ -104,6 +106,7 @@ void BookmarksWidget::init()
// it dynamically changes and so, it's not good choice for this widget.
setLayoutDirection(QApplication::layoutDirection());
#if QTWEBENGINE_DISABLED
// Init SpeedDial button
const SpeedDial::Page page = m_speedDial->pageForUrl(m_view->url());
if (page.url.isEmpty()) {
@ -114,6 +117,7 @@ void BookmarksWidget::init()
ui->speeddialButton->setFlat(false);
ui->speeddialButton->setText(tr("Remove from Speed Dial"));
}
#endif
// Init Bookmarks button
if (m_bookmark) {

View File

@ -23,7 +23,7 @@
#include "qztools.h"
#include <QNetworkCookie>
#include <QWebSettings>
#include <QWebEngineSettings>
#include <QDateTime>
//#define COOKIE_DEBUG
@ -56,6 +56,7 @@ void CookieJar::loadSettings()
m_blacklist = settings.value("blacklist", QStringList()).toStringList();
settings.endGroup();
#if QTWEBENGINE_DISABLED
#if QTWEBKIT_FROM_2_3
switch (m_allowThirdParty) {
case 0:
@ -71,6 +72,7 @@ void CookieJar::loadSettings()
break;
}
#endif
#endif
}
void CookieJar::setAllowCookies(bool allow)

View File

@ -31,7 +31,7 @@
#include <QFileIconProvider>
#include <QListWidgetItem>
#include <QTemporaryFile>
#include <QWebHistory>
#include <QWebEngineHistory>
#include <QFileDialog>
#if QT_VERSION >= 0x050000

View File

@ -138,6 +138,7 @@ void DownloadItem::startDownloadingFromFtp(const QUrl &url)
return;
}
#if QTWEBENGINE_DISABLED
m_ftpDownloader = new FtpDownloader(this);
connect(m_ftpDownloader, SIGNAL(finished()), this, SLOT(finished()));
connect(m_ftpDownloader, SIGNAL(dataTransferProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
@ -153,6 +154,7 @@ void DownloadItem::startDownloadingFromFtp(const QUrl &url)
if (m_ftpDownloader->error() != QFtp::NoError) {
error();
}
#endif
}
void DownloadItem::parentResized(const QSize &size)
@ -182,7 +184,7 @@ void DownloadItem::finished()
#endif
m_timer.stop();
QString host = m_reply ? m_reply->url().host() : m_ftpDownloader->url().host();
QString host = m_reply->url().host();
ui->downloadInfo->setText(tr("Done - %1 (%2)").arg(host, QDateTime::currentDateTime().toString(Qt::DefaultLocaleShortDate)));
ui->progressBar->hide();
ui->button->hide();
@ -193,7 +195,9 @@ void DownloadItem::finished()
m_reply->deleteLater();
}
else {
#if QTWEBENGINE_DISABLED
m_ftpDownloader->deleteLater();
#endif
}
m_item->setSizeHint(sizeHint());
@ -327,7 +331,9 @@ void DownloadItem::stop(bool askForDeleteFile)
host = m_reply->url().host();
}
else if (m_ftpDownloader) {
#if QTWEBENGINE_DISABLED
host = m_ftpDownloader->url().host();
#endif
}
m_openAfterFinish = false;
m_timer.stop();
@ -335,8 +341,10 @@ void DownloadItem::stop(bool askForDeleteFile)
m_reply->abort();
}
else if (m_ftpDownloader) {
#if QTWEBENGINE_DISABLED
m_ftpDownloader->abort();
m_ftpDownloader->close();
#endif
}
QString outputfile = QFileInfo(m_outputFile).absoluteFilePath();
m_outputFile.close();
@ -455,10 +463,12 @@ void DownloadItem::error()
if (m_reply && m_reply->error() != QNetworkReply::NoError) {
ui->downloadInfo->setText(tr("Error: ") + m_reply->errorString());
}
#if QTWEBENGINE_DISABLED
else if (m_ftpDownloader && m_ftpDownloader->error() != QFtp::NoError) {
stop(false);
ui->downloadInfo->setText(tr("Error: ") + m_ftpDownloader->errorString());
}
#endif
}
void DownloadItem::updateDownload()
@ -468,6 +478,7 @@ void DownloadItem::updateDownload()
#endif
// after caling stop() (from readyRead()) m_reply will be a dangling pointer,
// thus it should be checked after m_outputFile.isOpen()
#if QTWEBENGINE_DISABLED
if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() &&
((m_reply && m_reply->isFinished()) ||
(m_ftpDownloader && m_ftpDownloader->isFinished())
@ -476,6 +487,13 @@ void DownloadItem::updateDownload()
downloadProgress(0, 0);
finished();
}
#else
if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() &&
((m_reply && m_reply->isFinished()))) {
downloadProgress(0, 0);
finished();
}
#endif
}
DownloadItem::~DownloadItem()

View File

@ -221,9 +221,12 @@ void DownloadManager::download(const QNetworkRequest &request, const DownloadInf
QNetworkRequest req = request;
req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100), 0);
#if QTWEBENGINE_DISABLED
handleUnsupportedContent(m_networkManager->get(req), info);
#endif
}
#if QTWEBENGINE_DISABLED
void DownloadManager::handleUnsupportedContent(QNetworkReply* reply, const DownloadInfo &info)
{
if (!info.page || reply->url().scheme() == QLatin1String("qupzilla")) {
@ -247,6 +250,7 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply* reply, const Downl
h->setListWidget(ui->list);
h->handleUnsupportedContent(reply, info);
}
#endif
void DownloadManager::itemCreated(QListWidgetItem* item, DownloadItem* downItem)
{
@ -349,3 +353,4 @@ DownloadManager::~DownloadManager()
{
delete ui;
}

View File

@ -30,12 +30,12 @@ class DownloadManager;
class QNetworkReply;
class QNetworkRequest;
class QNetworkAccessManager;
class QListWidgetItem;
class QUrl;
class DownloadItem;
class EcWin7;
class NetworkManager;
class WebPage;
class QUPZILLA_EXPORT DownloadManager : public QWidget
@ -65,7 +65,10 @@ public:
void loadSettings();
void download(const QNetworkRequest &request, const DownloadInfo &info);
#if QTWEBENGINE_DISABLED
void handleUnsupportedContent(QNetworkReply* reply, const DownloadInfo &info);
#endif
bool canClose();
@ -107,7 +110,7 @@ private:
void keyPressEvent(QKeyEvent* e);
Ui::DownloadManager* ui;
NetworkManager* m_networkManager;
QNetworkAccessManager* m_networkManager;
QBasicTimer m_timer;
QString m_lastDownloadPath;

View File

@ -27,7 +27,7 @@
#include "qzsettings.h"
#include <QApplication>
#include <QWebHistory>
#include <QWebEngineHistory>
#include <QSqlQuery>
static QKeySequence actionShortcut(QKeySequence shortcut, QKeySequence fallback, QKeySequence shortcutRTL, QKeySequence fallbackRTL)

View File

@ -19,8 +19,10 @@
#include "mainapplication.h"
#include "history.h"
#if QTWEBENGINE_DISABLED
WebHistoryInterface::WebHistoryInterface(QObject* parent)
: QWebHistoryInterface(parent)
: QWebEngineHistoryInterface(parent)
{
}
@ -33,3 +35,5 @@ bool WebHistoryInterface::historyContains(const QString &url) const
{
return m_clickedLinks.find(url) != m_clickedLinks.end();
}
#endif

View File

@ -18,12 +18,13 @@
#ifndef WEBHISTORYINTERFACE_H
#define WEBHISTORYINTERFACE_H
#include <QWebHistoryInterface>
#include <set>
#include "qzcommon.h"
class QUPZILLA_EXPORT WebHistoryInterface : public QWebHistoryInterface
#if QTWEBENGINE_DISABLED
class QUPZILLA_EXPORT WebHistoryInterface : public QWebEngineHistoryInterface
{
public:
explicit WebHistoryInterface(QObject* parent = 0);
@ -36,4 +37,6 @@ private:
};
#endif
#endif // WEBHISTORYINTERFACE_H

View File

@ -1,5 +1,5 @@
isEqual(QT_MAJOR_VERSION, 5) {
QT += webkitwidgets network widgets printsupport sql script gui-private
QT += webenginewidgets network widgets printsupport sql script gui-private
} else {
QT += core gui webkit sql network script concurrent
}
@ -12,7 +12,9 @@ DEFINES *= QUPZILLA_SHAREDLIBRARY
include(../defines.pri)
include(../../translations/translations.pri)
include(3rdparty/qtsingleapplication/qtsingleapplication.pri)
include(plugins/qtwebkit/qtwebkit-plugins.pri)
# QTWEBENGINE DISABLED
#include(plugins/qtwebkit/qtwebkit-plugins.pri)
CONFIG(debug, debug|release): include(../../tests/modeltest/modeltest.pri)

View File

@ -61,7 +61,6 @@ LocationBar::LocationBar(BrowserWindow* window)
m_bookmarkIcon = new BookmarksIcon(this);
m_goIcon = new GoIcon(this);
m_rssIcon = new RssIcon(this);
m_siteIcon = new SiteIcon(m_window, this);
m_autofillIcon = new AutoFillIcon(this);
DownIcon* down = new DownIcon(this);
@ -69,7 +68,6 @@ LocationBar::LocationBar(BrowserWindow* window)
addWidget(m_siteIcon, LineEdit::LeftSide);
addWidget(m_autofillIcon, LineEdit::RightSide);
addWidget(m_bookmarkIcon, LineEdit::RightSide);
addWidget(m_rssIcon, LineEdit::RightSide);
addWidget(m_goIcon, LineEdit::RightSide);
addWidget(down, LineEdit::RightSide);
@ -104,7 +102,6 @@ LocationBar::LocationBar(BrowserWindow* window)
// Hide icons by default
m_goIcon->setVisible(qzSettings->alwaysShowGoIcon);
m_rssIcon->hide();
m_autofillIcon->hide();
QTimer::singleShot(0, this, SLOT(updatePlaceHolderText()));
@ -120,17 +117,18 @@ void LocationBar::setWebView(TabbedWebView* view)
m_webView = view;
m_bookmarkIcon->setWebView(m_webView);
m_rssIcon->setWebView(m_webView);
m_siteIcon->setWebView(m_webView);
m_autofillIcon->setWebView(m_webView);
connect(m_webView, SIGNAL(loadStarted()), SLOT(loadStarted()));
connect(m_webView, SIGNAL(loadProgress(int)), SLOT(loadProgress(int)));
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(loadFinished()));
connect(m_webView, SIGNAL(iconChanged()), this, SLOT(updateSiteIcon()));
connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(showUrl(QUrl)));
connect(m_webView, SIGNAL(rssChanged(bool)), this, SLOT(setRssIconVisible(bool)));
connect(m_webView, SIGNAL(privacyChanged(bool)), this, SLOT(setPrivacyState(bool)));
#if QTWEBENGINE_DISABLED
connect(m_webView, SIGNAL(iconChanged()), this, SLOT(updateSiteIcon()));
#endif
}
void LocationBar::setText(const QString &text)
@ -299,11 +297,9 @@ void LocationBar::setGoIconVisible(bool state)
{
if (state) {
m_bookmarkIcon->hide();
m_rssIcon->hide();
m_goIcon->show();
}
else {
m_rssIcon->setVisible(m_webView && m_webView->hasRss());
m_bookmarkIcon->show();
if (!qzSettings->alwaysShowGoIcon) {
@ -316,8 +312,6 @@ void LocationBar::setGoIconVisible(bool state)
void LocationBar::setRssIconVisible(bool state)
{
m_rssIcon->setVisible(state);
updateTextMargins();
}

View File

@ -33,7 +33,7 @@
#include <QSplitter>
#include <QHBoxLayout>
#include <QStackedWidget>
#include <QWebHistory>
#include <QWebEngineHistory>
#include <QMouseEvent>
#include <QStyleOption>
@ -212,13 +212,13 @@ void NavigationBar::aboutToShowHistoryBackMenu()
return;
}
m_menuBack->clear();
QWebHistory* history = m_window->weView()->history();
QWebEngineHistory* history = m_window->weView()->history();
int curindex = history->currentItemIndex();
int count = 0;
for (int i = curindex - 1; i >= 0; i--) {
QWebHistoryItem item = history->itemAt(i);
QWebEngineHistoryItem item = history->itemAt(i);
if (item.isValid()) {
QString title = titleForUrl(item.title(), item.url());
@ -247,12 +247,12 @@ void NavigationBar::aboutToShowHistoryNextMenu()
}
m_menuForward->clear();
QWebHistory* history = m_window->weView()->history();
QWebEngineHistory* history = m_window->weView()->history();
int curindex = history->currentItemIndex();
int count = 0;
for (int i = curindex + 1; i < history->count(); i++) {
QWebHistoryItem item = history->itemAt(i);
QWebEngineHistoryItem item = history->itemAt(i);
if (item.isValid()) {
QString title = titleForUrl(item.title(), item.url());
@ -276,7 +276,7 @@ void NavigationBar::aboutToShowHistoryNextMenu()
void NavigationBar::clearHistory()
{
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
history->clear();
refreshHistory();
}
@ -290,7 +290,7 @@ void NavigationBar::contextMenuRequested(const QPoint &pos)
void NavigationBar::loadHistoryIndex()
{
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
if (QAction* action = qobject_cast<QAction*>(sender())) {
loadHistoryItem(history->itemAt(action->data().toInt()));
@ -307,7 +307,7 @@ void NavigationBar::loadHistoryIndexInNewTab(int index)
return;
}
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
loadHistoryItemInNewTab(history->itemAt(index));
}
@ -317,7 +317,7 @@ void NavigationBar::refreshHistory()
return;
}
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
m_buttonBack->setEnabled(history->canGoBack());
m_buttonForward->setEnabled(history->canGoForward());
}
@ -334,13 +334,13 @@ void NavigationBar::reload()
void NavigationBar::goBack()
{
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
history->back();
}
void NavigationBar::goBackInNewTab()
{
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
if (!history->canGoBack()) {
return;
@ -351,13 +351,13 @@ void NavigationBar::goBackInNewTab()
void NavigationBar::goForward()
{
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
history->forward();
}
void NavigationBar::goForwardInNewTab()
{
QWebHistory* history = m_window->weView()->page()->history();
QWebEngineHistory* history = m_window->weView()->page()->history();
if (!history->canGoForward()) {
return;
@ -387,19 +387,19 @@ QIcon NavigationBar::iconForPage(const QUrl &url, const QIcon &sIcon)
return icon;
}
void NavigationBar::loadHistoryItem(const QWebHistoryItem &item)
void NavigationBar::loadHistoryItem(const QWebEngineHistoryItem &item)
{
m_window->weView()->page()->history()->goToItem(item);
refreshHistory();
}
void NavigationBar::loadHistoryItemInNewTab(const QWebHistoryItem &item)
void NavigationBar::loadHistoryItemInNewTab(const QWebEngineHistoryItem &item)
{
TabWidget* tabWidget = m_window->tabWidget();
int tabIndex = tabWidget->duplicateTab(tabWidget->currentIndex());
QWebHistory* history = m_window->weView(tabIndex)->page()->history();
QWebEngineHistory* history = m_window->weView(tabIndex)->page()->history();
history->goToItem(item);
if (qzSettings->newTabPosition == Qz::NT_SelectedTab) {

View File

@ -24,7 +24,7 @@
class QHBoxLayout;
class QSplitter;
class QWebHistoryItem;
class QWebEngineHistoryItem;
class ToolButton;
class WebSearchBar;
@ -90,8 +90,8 @@ private:
QString titleForUrl(QString title, const QUrl &url);
QIcon iconForPage(const QUrl &url, const QIcon &sIcon);
void loadHistoryItem(const QWebHistoryItem &item);
void loadHistoryItemInNewTab(const QWebHistoryItem &item);
void loadHistoryItem(const QWebEngineHistoryItem &item);
void loadHistoryItemInNewTab(const QWebEngineHistoryItem &item);
BrowserWindow* m_window;

View File

@ -36,7 +36,9 @@
#include <QStringListModel>
#include <QMenu>
#include <QTimer>
#include <QWebFrame>
#if QTWEBENGINE_DISABLED
#include <QWebEngineFrame>
#endif
#include <QClipboard>
#include <QContextMenuEvent>
@ -217,8 +219,10 @@ void WebSearchBar::searchInNewTab()
void WebSearchBar::completeMenuWithAvailableEngines(QMenu* menu)
{
Q_UNUSED(menu)
#if QTWEBENGINE_DISABLED
WebView* view = m_window->weView();
QWebFrame* frame = view->page()->mainFrame();
QWebEngineFrame* frame = view->page()->mainFrame();
QWebElementCollection elements = frame->documentElement().findAll(QLatin1String("link[rel=search]"));
foreach (const QWebElement &element, elements) {
@ -237,6 +241,7 @@ void WebSearchBar::completeMenuWithAvailableEngines(QMenu* menu)
menu->addAction(view->icon(), tr("Add %1 ...").arg(title), this, SLOT(addEngineFromAction()))->setData(url);
}
#endif
}
void WebSearchBar::addEngineFromAction()

View File

@ -27,6 +27,8 @@
#include <QNetworkReply>
#include <QFile>
#if QTWEBENGINE_DISABLED
CaBundleUpdater::CaBundleUpdater(NetworkManager* manager, QObject* parent)
: QObject(parent)
, m_manager(manager)
@ -146,3 +148,5 @@ void CaBundleUpdater::replyFinished()
mApp->networkManager()->loadSettings();
}
}
#endif

View File

@ -18,6 +18,8 @@
#ifndef CABUNDLEUPDATER_H
#define CABUNDLEUPDATER_H
#if QTWEBENGINE_DISABLED
#include <QObject>
#include "qzcommon.h"
@ -54,4 +56,6 @@ private:
int m_latestBundleVersion;
};
#endif
#endif // CABUNDLEUPDATER_H

View File

@ -54,6 +54,8 @@
#include <QAuthenticator>
#include <QDirIterator>
#if QTWEBENGINE_DISABLED
static QString fileNameForCert(const QSslCertificate &cert)
{
QString certFileName = CertificateInfoWidget::certificateItemText(cert);
@ -74,8 +76,6 @@ NetworkManager::NetworkManager(QObject* parent)
, m_ignoreAllWarnings(false)
, m_disableWeakCiphers(true)
{
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authentication(QNetworkReply*,QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthentication(QNetworkProxy,QAuthenticator*)));
connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(sslError(QNetworkReply*,QList<QSslError>)));
connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(setSSLConfiguration(QNetworkReply*)));
@ -341,7 +341,7 @@ void NetworkManager::authentication(QNetworkReply* reply, QAuthenticator* auth)
}
// Try to set the originating WebTab as a current tab
QWebFrame* frame = qobject_cast<QWebFrame*>(reply->request().originatingObject());
QWebEngineFrame* frame = qobject_cast<QWebEngineFrame*>(reply->request().originatingObject());
if (frame) {
WebPage* page = qobject_cast<WebPage*>(frame->page());
if (page) {
@ -462,63 +462,6 @@ void NetworkManager::ftpAuthentication(const QUrl &url, QAuthenticator* auth)
}
}
void NetworkManager::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator* auth)
{
QString userName;
QString password;
QVector<PasswordEntry> psws = mApp->autoFill()->getFormData(QUrl(proxy.hostName()));
if (psws.isEmpty()) {
QDialog* dialog = new QDialog();
dialog->setWindowTitle(tr("Proxy authorisation required"));
QFormLayout* formLa = new QFormLayout(dialog);
QLabel* label = new QLabel(dialog);
QLabel* userLab = new QLabel(dialog);
QLabel* passLab = new QLabel(dialog);
userLab->setText(tr("Username: "));
passLab->setText(tr("Password: "));
QLineEdit* user = new QLineEdit(dialog);
QLineEdit* pass = new QLineEdit(dialog);
pass->setEchoMode(QLineEdit::Password);
QDialogButtonBox* box = new QDialogButtonBox(dialog);
box->addButton(QDialogButtonBox::Ok);
box->addButton(QDialogButtonBox::Cancel);
connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
QCheckBox* rememberCheck = new QCheckBox(tr("Remember username and password for this proxy."), dialog);
label->setText(tr("A username and password are being requested by proxy %1. ").arg(proxy.hostName()));
formLa->addRow(label);
formLa->addRow(userLab, user);
formLa->addRow(passLab, pass);
formLa->addRow(rememberCheck);
formLa->addWidget(box);
if (dialog->exec() != QDialog::Accepted) {
return;
}
if (rememberCheck->isChecked()) {
mApp->autoFill()->addEntry(QUrl(proxy.hostName()), user->text(), pass->text());
}
userName = user->text();
password = pass->text();
}
else {
userName = psws.at(0).username;
password = psws.at(0).password;
}
auth->setUser(userName);
auth->setPassword(password);
}
QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
{
if (op == PostOperation && outgoingData) {
@ -775,3 +718,5 @@ void NetworkManager::loadCertificates()
new CaBundleUpdater(this, this);
#endif
}
#endif

View File

@ -18,6 +18,8 @@
#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H
#if QTWEBENGINE_DISABLED
#include <QSslError>
#include <QStringList>
@ -64,9 +66,7 @@ signals:
void sslDialogClosed();
private slots:
void authentication(QNetworkReply* reply, QAuthenticator* auth);
void ftpAuthentication(const QUrl &url, QAuthenticator* auth);
void proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator* auth);
void sslError(QNetworkReply* reply, QList<QSslError> errors);
void setSSLConfiguration(QNetworkReply* reply);
@ -90,4 +90,6 @@ private:
bool m_sendReferer;
};
#endif
#endif // NETWORKMANAGER_H

View File

@ -23,6 +23,8 @@
#include <QNetworkRequest>
#if QTWEBENGINE_DISABLED
NetworkManagerProxy::NetworkManagerProxy(QObject* parent)
: QNetworkAccessManager(parent)
, m_page(0)
@ -57,3 +59,5 @@ QNetworkReply* NetworkManagerProxy::createRequest(QNetworkAccessManager::Operati
return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
#endif

View File

@ -18,6 +18,8 @@
#ifndef NETWORKMANAGERPROXY_H
#define NETWORKMANAGERPROXY_H
#if QTWEBENGINE_DISABLED
#include <QNetworkAccessManager>
#include "qzcommon.h"
@ -40,4 +42,6 @@ private:
NetworkManager* m_manager;
};
#endif
#endif // NETWORKMANAGERPROXY_H

View File

@ -22,6 +22,7 @@
#include "iconprovider.h"
#include "mainapplication.h"
#if QTWEBENGINE_DISABLED
#include <QWebSecurityOrigin>
#include <QFileIconProvider>
#include <QDateTime>
@ -576,3 +577,5 @@ void FtpDownloader::onDone(bool err)
emit finished();
}
}
#endif

View File

@ -24,6 +24,8 @@
#include <QNetworkReply>
#include <QBuffer>
#if QTWEBENGINE_DISABLED
#if QT_VERSION >= 0x050000
#include "qftp.h"
#include "qurlinfo.h"
@ -128,4 +130,6 @@ signals:
void finished();
void errorOccured(QFtp::Error);
};
#endif
#endif // FTPSCHEMEHANDLER_H

View File

@ -28,6 +28,8 @@
#include "datapaths.h"
#include "iconprovider.h"
#if QTWEBENGINE_DISABLED
#include <QTextStream>
#include <QTimer>
#include <QSettings>
@ -36,7 +38,7 @@
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#else
#include <QWebPage>
#include <QWebEnginePage>
#endif
static QString authorString(const char* name, const QString &mail)
@ -499,3 +501,5 @@ QString QupZillaSchemeReply::configPage()
return page;
}
#endif

View File

@ -21,6 +21,8 @@
#include <QNetworkReply>
#include <QBuffer>
#if QTWEBENGINE_DISABLED
#include "schemehandler.h"
#include "qzcommon.h"
@ -60,4 +62,6 @@ private:
QString m_pageName;
};
#endif
#endif // QUPZILLASCHEMEHANDLER_H

View File

@ -29,7 +29,6 @@
#include <QNetworkReply>
#include <QMessageBox>
#include <QWebElement>
#include <QSqlQuery>
#include <QBuffer>
@ -261,6 +260,7 @@ void SearchEnginesManager::addEngine(const Engine &engine)
void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView* view)
{
#if QTWEBENGINE_DISABLED
QWebElement formElement = element.parent();
while (!formElement.isNull()) {
@ -362,6 +362,7 @@ void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView
}
addEngine(engine);
#endif
}
void SearchEnginesManager::addEngine(OpenSearchEngine* engine)

View File

@ -26,7 +26,7 @@
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#else
#include <QWebPage>
#include <QWebEnginePage>
#endif
AboutDialog::AboutDialog(QWidget* parent)
@ -75,11 +75,15 @@ void AboutDialog::showAbout()
Qz::VERSION
#endif
);
#if QTWEBENGINE_DISABLED
m_aboutHtml += tr("<b>WebKit version %1</b></p>").arg(qWebKitVersion());
#endif
m_aboutHtml += QString("<p>&copy; %1 %2<br/>").arg(Qz::COPYRIGHT, Qz::AUTHOR);
m_aboutHtml += tr("<small>Build time: %1 </small></p>").arg(Qz::BUILDTIME);
m_aboutHtml += QString("<p><a href=%1>%1</a></p>").arg(Qz::WWWADDRESS);
#if QTWEBENGINE_DISABLED
m_aboutHtml += "<p>" + (mApp->windowCount() > 0 ? mApp->getWindow()->weView()->page()->userAgentForUrl(QUrl()) : QString()) + "</p>";
#endif
m_aboutHtml += "</div></center>";
}
ui->textBrowser->setHtml(m_aboutHtml);

View File

@ -34,7 +34,6 @@ BrowsingLibrary::BrowsingLibrary(BrowserWindow* window, QWidget* parent)
, ui(new Ui::BrowsingLibrary)
, m_historyManager(new HistoryManager(window))
, m_bookmarksManager(new BookmarksManager(window))
, m_rssManager(mApp->rssManager())
, m_rssLoaded(false)
{
ui->setupUi(this);
@ -49,7 +48,6 @@ BrowsingLibrary::BrowsingLibrary(BrowserWindow* window, QWidget* parent)
ui->tabs->AddTab(m_historyManager, QIcon(":/icons/other/bighistory.png"), tr("History"));
ui->tabs->AddTab(m_bookmarksManager, QIcon(":/icons/other/bigstar.png"), tr("Bookmarks"));
ui->tabs->AddTab(m_rssManager, QIcon(":/icons/other/feed.png"), tr("RSS"));
ui->tabs->SetMode(FancyTabWidget::Mode_LargeSidebar);
ui->tabs->setFocus();
@ -79,7 +77,6 @@ void BrowsingLibrary::currentIndexChanged(int index)
case 2:
if (!m_rssLoaded) {
m_rssManager->refreshTable();
m_rssLoaded = true;
}
ui->searchLine->hide();
@ -134,6 +131,7 @@ void BrowsingLibrary::showBookmarks(BrowserWindow* window)
void BrowsingLibrary::showRSS(BrowserWindow* window)
{
#if QTWEBENGINE_DISABLED
ui->tabs->SetCurrentIndex(2);
show();
m_rssManager->setMainWindow(window);
@ -145,6 +143,7 @@ void BrowsingLibrary::showRSS(BrowserWindow* window)
raise();
activateWindow();
#endif
}
void BrowsingLibrary::closeEvent(QCloseEvent* e)
@ -155,10 +154,6 @@ void BrowsingLibrary::closeEvent(QCloseEvent* e)
settings.setValue("historyState", m_historyManager->saveState());
settings.endGroup();
e->accept();
// Saves a few megabytes
m_rssManager->deleteAllTabs();
m_rssLoaded = false;
}
void BrowsingLibrary::keyPressEvent(QKeyEvent* e)

View File

@ -33,8 +33,10 @@
#include <QNetworkCookie>
#include <QMessageBox>
#if QTWEBENGINE_DISABLED
#include <QWebDatabase>
#include <QWebSettings>
#endif
#include <QWebEngineSettings>
#include <QNetworkDiskCache>
#include <QDateTime>
#include <QSqlQuery>
@ -78,21 +80,27 @@ void ClearPrivateData::clearWebDatabases()
{
const QString profile = DataPaths::currentProfilePath();
#if QTWEBENGINE_DISABLED
QWebDatabase::removeAllDatabases();
#endif
QzTools::removeDir(profile + "/Databases");
}
void ClearPrivateData::clearCache()
{
mApp->networkCache()->clear();
QWebSettings::globalSettings()->clearMemoryCaches();
#if QTWEBENGINE_DISABLED
QWebEngineSettings::globalSettings()->clearMemoryCaches();
#endif
QFile::remove(DataPaths::currentProfilePath() + "/ApplicationCache.db");
}
void ClearPrivateData::clearIcons()
{
QWebSettings::globalSettings()->clearIconDatabase();
#if QTWEBENGINE_DISABLED
QWebEngineSettings::globalSettings()->clearIconDatabase();
#endif
IconProvider::instance()->clearIconsDatabase();
}

View File

@ -331,9 +331,9 @@ void MacMenuReceiver::quitApp()
}
}
void MacMenuReceiver::printPage(QWebFrame* frame)
void MacMenuReceiver::printPage(QWebEngineFrame* frame)
{
callSlot("printPage", false, Q_ARG(QWebFrame*, frame));
callSlot("printPage", false, Q_ARG(QWebEngineFrame*, frame));
}
void MacMenuReceiver::showBookmarksToolbar()
@ -341,9 +341,9 @@ void MacMenuReceiver::showBookmarksToolbar()
callSlot("showBookmarksToolbar");
}
void MacMenuReceiver::showSource(QWebFrame* frame, const QString &selectedHtml)
void MacMenuReceiver::showSource(QWebEngineFrame* frame, const QString &selectedHtml)
{
callSlot("showSource", false, Q_ARG(QWebFrame*, frame), Q_ARG(const QString &, selectedHtml));
callSlot("showSource", false, Q_ARG(QWebEngineFrame*, frame), Q_ARG(const QString &, selectedHtml));
}
void MacMenuReceiver::bookmarkPage()

View File

@ -23,7 +23,7 @@
#include "qzcommon.h"
class QWebFrame;
class QWebEngineFrame;
class Menu;
class QMenu;
class QAction;
@ -127,9 +127,9 @@ private slots:
void closeWindow();
void quitApp();
void printPage(QWebFrame* frame = 0);
void printPage(QWebEngineFrame* frame = 0);
void showBookmarksToolbar();
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
void showSource(QWebEngineFrame* frame = 0, const QString &selectedHtml = QString());
void bookmarkPage();
void showPageInfo();
void showWebInspector(bool toggle = true);

View File

@ -23,9 +23,11 @@
#include "browserwindow.h"
#include "settings.h"
#if QTWEBENGINE_DISABLED
#include <QFileDialog>
#include <QMessageBox>
#include <QWebFrame>
#include <QWebEngineFrame>
#include <QLabel>
#include <QTimer>
#include <QMovie>
@ -191,7 +193,7 @@ void PageScreen::saveAsDocument(const QString &format)
void PageScreen::createThumbnail()
{
QWebPage* page = m_view->page();
QWebEnginePage* page = m_view->page();
const int heightLimit = 20000;
const QPoint originalScrollPosition = page->mainFrame()->scrollPosition();
@ -275,3 +277,5 @@ PageScreen::~PageScreen()
{
delete ui;
}
#endif

View File

@ -23,6 +23,8 @@
#include "qzcommon.h"
#if QTWEBENGINE_DISABLED
namespace Ui
{
class PageScreen;
@ -63,4 +65,6 @@ private:
QStringList m_formats;
};
#endif
#endif // PAGESCREEN_H

View File

@ -26,11 +26,13 @@
#include "qztools.h"
#include "iconprovider.h"
#if QTWEBENGINE_DISABLED
#include <QMenu>
#include <QMessageBox>
#include <QFileDialog>
#include <QNetworkDiskCache>
#include <QWebFrame>
#include <QWebEngineFrame>
#include <QClipboard>
#include <QWebSecurityOrigin>
#include <QWebDatabase>
@ -66,7 +68,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
ui->listWidget->item(0)->setSelected(true);
WebPage* webPage = view->page();
QWebFrame* frame = view->page()->mainFrame();
QWebEngineFrame* frame = view->page()->mainFrame();
QString title = view->title();
QSslCertificate cert = webPage->sslCertificate();
m_baseUrl = frame->baseUrl();
@ -103,7 +105,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
ui->treeTags->addTopLevelItem(item);
}
if (encoding.isEmpty()) {
encoding = QWebSettings::globalSettings()->defaultTextEncoding();
encoding = QWebEngineSettings::globalSettings()->defaultTextEncoding();
}
ui->encodingLabel->setText(encoding.toUpper());
@ -298,3 +300,5 @@ SiteInfo::~SiteInfo()
delete ui;
delete m_certWidget;
}
#endif

View File

@ -23,6 +23,8 @@
#include <QDialog>
#include <QUrl>
#if QTWEBENGINE_DISABLED
namespace Ui
{
class SiteInfo;
@ -62,4 +64,6 @@ private:
QUrl m_baseUrl;
};
#endif
#endif // SITEINFO_H

View File

@ -29,10 +29,11 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QInputDialog>
#include <QWebFrame>
#include <QTimer>
SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
#if QTWEBENGINE_DISABLED
SourceViewer::SourceViewer(QWebEngineFrame* frame, const QString &selectedHtml)
: QWidget(0)
, m_frame(frame)
, m_selectedHtml(selectedHtml)
@ -231,3 +232,5 @@ void SourceViewer::goToLine()
m_sourceEdit->goToLine(line);
}
#endif

View File

@ -18,6 +18,8 @@
#ifndef SOURCEVIEWER_H
#define SOURCEVIEWER_H
#if QTWEBENGINE_DISABLED
#include <QWidget>
#include <QPointer>
@ -27,13 +29,13 @@ class PlainEditWithLines;
class QBoxLayout;
class QStatusBar;
class QWebFrame;
class QWebEngineFrame;
class QUPZILLA_EXPORT SourceViewer : public QWidget
{
Q_OBJECT
public:
explicit SourceViewer(QWebFrame* frame, const QString &selectedHtml);
explicit SourceViewer(QWebEngineFrame* frame, const QString &selectedHtml);
PlainEditWithLines* sourceEdit() { return m_sourceEdit; }
private slots:
@ -54,7 +56,7 @@ private slots:
private:
QBoxLayout* m_layout;
PlainEditWithLines* m_sourceEdit;
QPointer<QWebFrame> m_frame;
QPointer<QWebEngineFrame> m_frame;
QStatusBar* m_statusBar;
QString m_selectedHtml;
@ -66,4 +68,6 @@ private:
QAction* m_actionPaste;
};
#endif
#endif // SOURCEVIEWER_H

View File

@ -24,6 +24,8 @@
#include <QShortcut>
#include <QKeyEvent>
#if QTWEBENGINE_DISABLED
SourceViewerSearch::SourceViewerSearch(SourceViewer* parent)
: AnimatedWidget(AnimatedWidget::Up)
, m_sourceViewer(parent)
@ -132,3 +134,5 @@ bool SourceViewerSearch::eventFilter(QObject* obj, QEvent* event)
return AnimatedWidget::eventFilter(obj, event);
}
#endif

View File

@ -23,6 +23,8 @@
#include "qzcommon.h"
#include "animatedwidget.h"
#if QTWEBENGINE_DISABLED
namespace Ui
{
class SourceViewerSearch;
@ -59,4 +61,6 @@ private:
QTextDocument::FindFlags m_findFlags;
};
#endif
#endif // SOURCEVIEWERSEARCH_H

View File

@ -29,7 +29,6 @@
#include <QStatusBar>
#include <QToolTip>
#include <QStylePainter>
#include <QWebFrame>
#include <QTimer>
TipLabel::TipLabel(QWidget* parent)
@ -125,18 +124,22 @@ void StatusBarMessage::showMessage(const QString &message)
else {
#endif
WebView* view = m_window->weView();
QWebFrame* mainFrame = view->page()->mainFrame();
#if QTWEBENGINE_DISABLED
QWebEngineFrame* mainFrame = view->page()->mainFrame();
#endif
int horizontalScrollSize = 0;
int verticalScrollSize = 0;
const int scrollbarSize = m_window->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
#if QTWEBENGINE_DISABLED
if (mainFrame->scrollBarMaximum(Qt::Horizontal)) {
horizontalScrollSize = scrollbarSize;
}
if (mainFrame->scrollBarMaximum(Qt::Vertical)) {
verticalScrollSize = scrollbarSize;
}
#endif
m_statusBarText->setText(message);
m_statusBarText->setMaximumWidth(view->width() - verticalScrollSize);

View File

@ -20,7 +20,7 @@
#include "qztools.h"
#include "settings.h"
#include <QWebPage> // QTWEBKIT_VERSION_CHECK macro
#include <QWebEnginePage> // QTWEBKIT_VERSION_CHECK macro
UserAgentManager::UserAgentManager(QObject* parent)
: QObject(parent)

View File

@ -51,8 +51,10 @@
#include <QFormLayout>
#include <QMenu>
#include <QTimer>
#include <QWebView>
#include <QWebEngineView>
#include <QNetworkRequest>
#if QTWEBENGINE_DISABLED
#include <QWebHitTestResult>
QUrl ClickToFlash::acceptedUrl;
@ -152,9 +154,9 @@ void ClickToFlash::findElement()
}
QWidget* parent = parentWidget();
QWebView* view = 0;
QWebEngineView* view = 0;
while (parent) {
if (QWebView* aView = qobject_cast<QWebView*>(parent)) {
if (QWebEngineView* aView = qobject_cast<QWebEngineView*>(parent)) {
view = aView;
break;
}
@ -165,7 +167,7 @@ void ClickToFlash::findElement()
}
QPoint objectPos = view->mapFromGlobal(m_toolButton->mapToGlobal(m_toolButton->pos()));
QWebFrame* objectFrame = view->page()->frameAt(objectPos);
QWebEngineFrame* objectFrame = view->page()->frameAt(objectPos);
QWebHitTestResult hitResult;
QWebElement hitElement;
@ -183,12 +185,12 @@ void ClickToFlash::findElement()
// HitTestResult failed, trying to find element by src
// attribute in elements at all frames on page (less accurate)
QList<QWebFrame*> frames;
QList<QWebEngineFrame*> frames;
frames.append(objectFrame);
frames.append(view->page()->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
QWebEngineFrame* frame = frames.takeFirst();
if (!frame) {
continue;
}
@ -320,3 +322,5 @@ void ClickToFlash::showInfo()
QzTools::centerWidgetToParent(widg, m_page->view());
widg->show();
}
#endif

View File

@ -42,6 +42,8 @@
#ifndef CLICKTOFLASH_H
#define CLICKTOFLASH_H
#if QTWEBENGINE_DISABLED
#include "qzcommon.h"
// Qt Includes
@ -98,5 +100,7 @@ private:
WebPage* m_page;
};
#endif
#endif // CLICKTOFLASH_H

View File

@ -21,7 +21,11 @@
#include <QPixmap>
#include <QtPlugin>
#include <QNetworkRequest>
#if QTWEBENGINE_DISABLED
#include <QWebHitTestResult>
#endif
#include <QNetworkAccessManager>
#include "qzcommon.h"

View File

@ -29,7 +29,7 @@
Plugins::Plugins(QObject* parent)
: QObject(parent)
, m_pluginsLoaded(false)
, m_speedDial(new SpeedDial(this))
//, m_speedDial(new SpeedDial(this))
{
loadSettings();
}

View File

@ -22,11 +22,13 @@
#include "qztools.h"
#include "autosaver.h"
#if QTWEBENGINE_DISABLED
#include <QDir>
#include <QCryptographicHash>
#include <QFileDialog>
#include <QWebFrame>
#include <QWebPage>
#include <QWebEngineFrame>
#include <QWebEnginePage>
#include <QImage>
#define ENSURE_LOADED if (!m_loaded) loadSettings();
@ -124,7 +126,7 @@ QUrl SpeedDial::urlForShortcut(int key)
return QUrl::fromEncoded(m_webPages.at(key).url.toUtf8());
}
void SpeedDial::addWebFrame(QWebFrame* frame)
void SpeedDial::addWebFrame(QWebEngineFrame* frame)
{
if (!m_webFrames.contains(frame)) {
m_webFrames.append(frame);
@ -146,8 +148,8 @@ void SpeedDial::addPage(const QUrl &url, const QString &title)
m_webPages.append(page);
m_regenerateScript = true;
foreach (QWebFrame* frame, cleanFrames()) {
frame->page()->triggerAction(QWebPage::Reload);
foreach (QWebEngineFrame* frame, cleanFrames()) {
frame->page()->triggerAction(QWebEnginePage::Reload);
}
emit pagesChanged();
@ -165,8 +167,8 @@ void SpeedDial::removePage(const Page &page)
m_webPages.removeAll(page);
m_regenerateScript = true;
foreach (QWebFrame* frame, cleanFrames()) {
frame->page()->triggerAction(QWebPage::Reload);
foreach (QWebEngineFrame* frame, cleanFrames()) {
frame->page()->triggerAction(QWebEnginePage::Reload);
}
emit pagesChanged();
@ -361,7 +363,7 @@ void SpeedDial::thumbnailCreated(const QPixmap &pixmap)
m_regenerateScript = true;
cleanFrames();
foreach (QWebFrame* frame, cleanFrames()) {
foreach (QWebEngineFrame* frame, cleanFrames()) {
frame->evaluateJavaScript(QString("setImageToUrl('%1', '%2');").arg(escapeUrl(url), escapeTitle(fileName)));
if (loadTitle) {
frame->evaluateJavaScript(QString("setTitleToUrl('%1', '%2');").arg(escapeUrl(url), escapeTitle(title)));
@ -413,3 +415,5 @@ QString SpeedDial::generateAllPages()
return allPages;
}
#endif

View File

@ -18,13 +18,15 @@
#ifndef SPEEDDIAL_H
#define SPEEDDIAL_H
#if QTWEBENGINE_DISABLED
#include <QObject>
#include <QPointer>
#include "qzcommon.h"
class QUrl;
class QWebFrame;
class QWebEngineFrame;
class QPixmap;
class AutoSaver;
@ -52,7 +54,7 @@ public:
Page pageForUrl(const QUrl &url);
QUrl urlForShortcut(int key);
void addWebFrame(QWebFrame* frame);
void addWebFrame(QWebEngineFrame* frame);
void addPage(const QUrl &url, const QString &title);
void removePage(const Page &page);
@ -88,7 +90,7 @@ private:
QString escapeTitle(QString string) const;
QString escapeUrl(QString url) const;
QList<QWebFrame*> cleanFrames();
QList<QWebEngineFrame*> cleanFrames();
QString generateAllPages();
QString m_initialScript;
@ -107,4 +109,6 @@ private:
bool m_regenerateScript;
};
#endif
#endif // SPEEDDIAL_H

View File

@ -55,7 +55,6 @@ PopupLocationBar::PopupLocationBar(QWidget* parent)
m_siteIcon->setFixedSize(26, 26);
m_bookmarkIcon = new BookmarksIcon(this);
m_rssIcon = new RssIcon(this);
m_autofillIcon = new AutoFillIcon(this);
m_loadingAnimation = new QLabel(this);
@ -69,7 +68,6 @@ PopupLocationBar::PopupLocationBar(QWidget* parent)
addWidget(m_siteIcon, LineEdit::LeftSide);
addWidget(m_autofillIcon, LineEdit::RightSide);
addWidget(m_bookmarkIcon, LineEdit::RightSide);
addWidget(m_rssIcon, LineEdit::RightSide);
addWidget(m_loadingAnimation, LineEdit::RightSide);
addWidget(rightSpacer, LineEdit::RightSide);
setLeftMargin(20);
@ -78,7 +76,6 @@ PopupLocationBar::PopupLocationBar(QWidget* parent)
setReadOnly(true);
// Hide icons by default
m_rssIcon->hide();
m_autofillIcon->hide();
}
@ -87,7 +84,6 @@ void PopupLocationBar::setView(PopupWebView* view)
m_view = view;
m_bookmarkIcon->setWebView(m_view);
m_rssIcon->setWebView(m_view);
m_autofillIcon->setWebView(m_view);
connect(m_view, SIGNAL(rssChanged(bool)), this, SLOT(showRSSIcon(bool)));
@ -133,7 +129,5 @@ void PopupLocationBar::showSiteIcon()
void PopupLocationBar::showRSSIcon(bool state)
{
m_rssIcon->setVisible(state);
updateTextMargins();
}

View File

@ -24,7 +24,6 @@
#include <QStatusBar>
#include <QStyle>
#include <QWebFrame>
PopupStatusBarMessage::PopupStatusBarMessage(PopupWindow* window)
: m_popupWindow(window)
@ -43,18 +42,22 @@ void PopupStatusBarMessage::showMessage(const QString &message)
else {
#endif
PopupWebView* view = m_popupWindow->webView();
QWebFrame* mainFrame = view->page()->mainFrame();
#if QTWEBENGINE_DISABLED
QWebEngineFrame* mainFrame = view->page()->mainFrame();
#endif
int horizontalScrollSize = 0;
int verticalScrollSize = 0;
const int scrollbarSize = m_popupWindow->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
#if QTWEBENGINE_DISABLED
if (mainFrame->scrollBarMaximum(Qt::Horizontal)) {
horizontalScrollSize = scrollbarSize;
}
if (mainFrame->scrollBarMaximum(Qt::Vertical)) {
verticalScrollSize = scrollbarSize;
}
#endif
m_statusBarText->setText(message);
m_statusBarText->setMaximumWidth(view->width() - verticalScrollSize);

View File

@ -31,7 +31,7 @@
//
// Got an idea how to determine it from kWebKitPart.
PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, BrowserWindow* window)
PopupWebPage::PopupWebPage(QWebEnginePage::WebWindowType type, BrowserWindow* window)
: WebPage()
, m_window(window)
, m_type(type)
@ -43,9 +43,11 @@ PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, BrowserWindow* window)
, m_progress(0)
{
connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
#if QTWEBENGINE_DISABLED
connect(this, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(slotMenuBarVisibilityChangeRequested(bool)));
connect(this, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(slotToolBarVisibilityChangeRequested(bool)));
connect(this, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(slotStatusBarVisibilityChangeRequested(bool)));
#endif
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));

View File

@ -45,7 +45,7 @@ private slots:
private:
BrowserWindow* m_window;
QWebPage::WebWindowType m_type;
QWebEnginePage::WebWindowType m_type;
bool m_createNewWindow;
bool m_menuBarVisible;

View File

@ -25,7 +25,6 @@
#include "enhancedmenu.h"
#include "loadrequest.h"
#include <QWebFrame>
#include <QContextMenuEvent>
PopupWebView::PopupWebView(QWidget* parent)
@ -94,13 +93,16 @@ void PopupWebView::closeView()
void PopupWebView::inspectElement()
{
triggerPageAction(QWebPage::InspectElement);
#if QTWEBENGINE_DISABLED
triggerPageAction(QWebEnginePage::InspectElement);
#endif
}
void PopupWebView::contextMenuEvent(QContextMenuEvent* event)
{
m_menu->clear();
#if QTWEBENGINE_DISABLED
const QWebHitTestResult hitTest = page()->mainFrame()->hitTestContent(event->pos());
createContextMenu(m_menu, hitTest, event->pos());
@ -115,6 +117,7 @@ void PopupWebView::contextMenuEvent(QContextMenuEvent* event)
m_menu->popup(p);
return;
}
#endif
WebView::contextMenuEvent(event);
}

View File

@ -28,7 +28,6 @@
#include <QVBoxLayout>
#include <QStatusBar>
#include <QWebFrame>
#include <QCloseEvent>
#include <QMenuBar>
@ -67,14 +66,14 @@ PopupWindow::PopupWindow(PopupWebView* view)
m_menuBar->addMenu(menuFile);
m_menuEdit = new QMenu(tr("Edit"));
m_menuEdit->addAction(m_view->pageAction(QWebPage::Undo));
m_menuEdit->addAction(m_view->pageAction(QWebPage::Redo));
m_menuEdit->addAction(m_view->pageAction(QWebEnginePage::Undo));
m_menuEdit->addAction(m_view->pageAction(QWebEnginePage::Redo));
m_menuEdit->addSeparator();
m_menuEdit->addAction(m_view->pageAction(QWebPage::Cut));
m_menuEdit->addAction(m_view->pageAction(QWebPage::Copy));
m_menuEdit->addAction(m_view->pageAction(QWebPage::Paste));
m_menuEdit->addAction(m_view->pageAction(QWebEnginePage::Cut));
m_menuEdit->addAction(m_view->pageAction(QWebEnginePage::Copy));
m_menuEdit->addAction(m_view->pageAction(QWebEnginePage::Paste));
m_menuEdit->addSeparator();
m_menuEdit->addAction(m_view->pageAction(QWebPage::SelectAll));
m_menuEdit->addAction(m_view->pageAction(QWebEnginePage::SelectAll));
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
m_menuBar->addMenu(m_menuEdit);
@ -125,9 +124,11 @@ PopupWindow::PopupWindow(PopupWebView* view)
titleChanged();
QUrl urlToShow = m_view->url();
#if QTWEBENGINE_DISABLED
if (urlToShow.isEmpty()) {
urlToShow = m_view->page()->mainFrame()->requestedUrl();
}
#endif
m_locationBar->showUrl(urlToShow);
@ -212,8 +213,10 @@ void PopupWindow::closeEvent(QCloseEvent* event)
void PopupWindow::savePageScreen()
{
#if QTWEBENGINE_DISABLED
PageScreen* pageScreen = new PageScreen(m_view, this);
pageScreen->show();
#endif
}
void PopupWindow::searchOnPage()

View File

@ -21,7 +21,7 @@
#include "mainapplication.h"
#include "settings.h"
#include <QWebPage> // QTWEBKIT_VERSION_CHECK macro
#include <QWebEnginePage> // QTWEBKIT_VERSION_CHECK macro
#include <QFileDialog>
JsOptions::JsOptions(QWidget* parent)

View File

@ -364,18 +364,19 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
//FONTS
settings.beginGroup("Browser-Fonts");
QWebSettings* webSettings = QWebSettings::globalSettings();
ui->fontStandard->setCurrentFont(QFont(settings.value("StandardFont", webSettings->fontFamily(QWebSettings::StandardFont)).toString()));
ui->fontCursive->setCurrentFont(QFont(settings.value("CursiveFont", webSettings->fontFamily(QWebSettings::CursiveFont)).toString()));
ui->fontFantasy->setCurrentFont(QFont(settings.value("FantasyFont", webSettings->fontFamily(QWebSettings::FantasyFont)).toString()));
ui->fontFixed->setCurrentFont(QFont(settings.value("FixedFont", webSettings->fontFamily(QWebSettings::FixedFont)).toString()));
ui->fontSansSerif->setCurrentFont(QFont(settings.value("SansSerifFont", webSettings->fontFamily(QWebSettings::SansSerifFont)).toString()));
ui->fontSerif->setCurrentFont(QFont(settings.value("SerifFont", webSettings->fontFamily(QWebSettings::SerifFont)).toString()));
ui->sizeDefault->setValue(settings.value("DefaultFontSize", webSettings->fontSize(QWebSettings::DefaultFontSize)).toInt());
ui->sizeFixed->setValue(settings.value("FixedFontSize", webSettings->fontSize(QWebSettings::DefaultFixedFontSize)).toInt());
ui->sizeMinimum->setValue(settings.value("MinimumFontSize", webSettings->fontSize(QWebSettings::MinimumFontSize)).toInt());
ui->sizeMinimumLogical->setValue(settings.value("MinimumLogicalFontSize", webSettings->fontSize(QWebSettings::MinimumLogicalFontSize)).toInt());
#if QTWEBENGINE_DISABLED
QWebEngineSettings* webSettings = QWebEngineSettings::globalSettings();
ui->fontStandard->setCurrentFont(QFont(settings.value("StandardFont", webSettings->fontFamily(QWebEngineSettings::StandardFont)).toString()));
ui->fontCursive->setCurrentFont(QFont(settings.value("CursiveFont", webSettings->fontFamily(QWebEngineSettings::CursiveFont)).toString()));
ui->fontFantasy->setCurrentFont(QFont(settings.value("FantasyFont", webSettings->fontFamily(QWebEngineSettings::FantasyFont)).toString()));
ui->fontFixed->setCurrentFont(QFont(settings.value("FixedFont", webSettings->fontFamily(QWebEngineSettings::FixedFont)).toString()));
ui->fontSansSerif->setCurrentFont(QFont(settings.value("SansSerifFont", webSettings->fontFamily(QWebEngineSettings::SansSerifFont)).toString()));
ui->fontSerif->setCurrentFont(QFont(settings.value("SerifFont", webSettings->fontFamily(QWebEngineSettings::SerifFont)).toString()));
ui->sizeDefault->setValue(settings.value("DefaultFontSize", webSettings->fontSize(QWebEngineSettings::DefaultFontSize)).toInt());
ui->sizeFixed->setValue(settings.value("FixedFontSize", webSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize)).toInt());
ui->sizeMinimum->setValue(settings.value("MinimumFontSize", webSettings->fontSize(QWebEngineSettings::MinimumFontSize)).toInt());
ui->sizeMinimumLogical->setValue(settings.value("MinimumLogicalFontSize", webSettings->fontSize(QWebEngineSettings::MinimumLogicalFontSize)).toInt());
#endif
settings.endGroup();
//KEYBOARD SHORTCUTS
@ -780,7 +781,9 @@ void Preferences::changeCachePathClicked()
void Preferences::reloadPacFileClicked()
{
#if QTWEBENGINE_DISABLED
mApp->networkManager()->proxyFactory()->pacManager()->downloadPacFile();
#endif
}
void Preferences::showPassManager(bool state)
@ -1110,7 +1113,9 @@ void Preferences::saveSettings()
mApp->history()->loadSettings();
mApp->reloadSettings();
mApp->plugins()->c2f_saveSettings();
#if QTWEBENGINE_DISABLED
mApp->networkManager()->loadSettings();
#endif
mApp->desktopNotifications()->loadSettings();
mApp->autoFill()->loadSettings();
}

View File

@ -56,8 +56,10 @@ SSLManager::SSLManager(QWidget* parent)
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
// Settings
#if QTWEBENGINE_DISABLED
ui->disableWeakCiphers->setChecked(mApp->networkManager()->isDisablingWeakCiphers());
ui->ignoreAll->setChecked(mApp->networkManager()->isIgnoringAllWarnings());
#endif
}
void SSLManager::addPath()
@ -98,6 +100,7 @@ void SSLManager::refreshCAList()
void SSLManager::refreshLocalList()
{
#if QTWEBENGINE_DISABLED
ui->localList->setUpdatesEnabled(false);
ui->localList->clear();
m_localCerts = mApp->networkManager()->getLocalCertificates();
@ -111,13 +114,16 @@ void SSLManager::refreshLocalList()
ui->localList->setCurrentRow(0);
ui->localList->setUpdatesEnabled(true);
#endif
}
void SSLManager::refreshPaths()
{
#if QTWEBENGINE_DISABLED
foreach (const QString &path, mApp->networkManager()->certificatePaths()) {
ui->pathList->addItem(path);
}
#endif
}
void SSLManager::showCaCertInfo()
@ -133,6 +139,7 @@ void SSLManager::showCaCertInfo()
void SSLManager::addLocalCertificate()
{
#if QTWEBENGINE_DISABLED
const QString path = QzTools::getOpenFileName("SSLManager-AddLocalCert", this, tr("Import certificate..."), QDir::homePath(), "*.crt");
if (path.isEmpty()) {
@ -147,6 +154,7 @@ void SSLManager::addLocalCertificate()
mApp->networkManager()->addLocalCertificate(list.at(0));
refreshLocalList();
#endif
}
void SSLManager::showLocalCertInfo()
@ -179,6 +187,7 @@ void SSLManager::showCertificateInfo(const QSslCertificate &cert)
void SSLManager::deleteCertificate()
{
#if QTWEBENGINE_DISABLED
QListWidgetItem* item = ui->localList->currentItem();
if (!item) {
return;
@ -188,20 +197,26 @@ void SSLManager::deleteCertificate()
m_localCerts.removeOne(cert);
mApp->networkManager()->removeLocalCertificate(cert);
refreshLocalList();
#endif
}
void SSLManager::ignoreAll(bool state)
{
#if QTWEBENGINE_DISABLED
mApp->networkManager()->setIgnoreAllWarnings(state);
#endif
}
void SSLManager::disableWeakCiphers(bool state)
{
#if QTWEBENGINE_DISABLED
mApp->networkManager()->setDisableWeakCiphers(state);
#endif
}
void SSLManager::closeEvent(QCloseEvent* e)
{
#if QTWEBENGINE_DISABLED
QStringList paths;
for (int i = 0; i < ui->pathList->count(); i++) {
QListWidgetItem* item = ui->pathList->item(i);
@ -214,6 +229,7 @@ void SSLManager::closeEvent(QCloseEvent* e)
mApp->networkManager()->setCertificatePaths(paths);
mApp->networkManager()->saveSettings();
#endif
QWidget::closeEvent(e);
}

View File

@ -20,6 +20,8 @@
#include <QMouseEvent>
#if QTWEBENGINE_DISABLED
RssIcon::RssIcon(QWidget* parent)
: ClickableLabel(parent)
, m_view(0)
@ -60,3 +62,5 @@ void RssIcon::mousePressEvent(QMouseEvent* ev)
// Prevent propagating to LocationBar
ev->accept();
}
#endif

View File

@ -21,6 +21,8 @@
#include "qzcommon.h"
#include "clickablelabel.h"
#if QTWEBENGINE_DISABLED
class WebView;
class QUPZILLA_EXPORT RssIcon : public ClickableLabel
@ -41,4 +43,6 @@ private:
WebView* m_view;
};
#endif
#endif // RSSICON_H

View File

@ -32,12 +32,14 @@
#include <QLabel>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QWebSettings>
#include <QWebEngineSettings>
#include <QMessageBox>
#include <QNetworkReply>
#include <QBuffer>
#include <QSqlQuery>
#if QTWEBENGINE_DISABLED
RSSManager::RSSManager(BrowserWindow* window, QWidget* parent)
: QWidget(parent)
, ui(new Ui::RSSManager)
@ -423,3 +425,5 @@ RSSManager::~RSSManager()
{
delete ui;
}
#endif

View File

@ -30,6 +30,8 @@
#include <QToolButton>
#include <QInputDialog>
#if QTWEBENGINE_DISABLED
namespace Ui
{
class RSSManager;
@ -77,4 +79,6 @@ private:
QPointer<BrowserWindow> m_window;
};
#endif
#endif // RSSMANAGER_H

View File

@ -30,6 +30,8 @@
#include <QClipboard>
#include <QFile>
#if QTWEBENGINE_DISABLED
RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView* parent)
: AnimatedWidget(AnimatedWidget::Down, 300, parent)
, ui(new Ui::RSSNotification)
@ -185,3 +187,5 @@ RSSNotification::~RSSNotification()
{
delete ui;
}
#endif

View File

@ -25,6 +25,8 @@
#include "qzcommon.h"
#include "animatedwidget.h"
#if QTWEBENGINE_DISABLED
class WebView;
namespace Ui
@ -65,4 +67,6 @@ private:
QVector<RssApp> m_rssApps;
};
#endif
#endif // RSSNOTIFICATION_H

View File

@ -23,9 +23,11 @@
#include "rssmanager.h"
#include "rssnotification.h"
#if QTWEBENGINE_DISABLED
#include <QToolTip>
#include <QPushButton>
#include <QWebFrame>
#include <QWebEngineFrame>
#include <QSqlQuery>
RSSWidget::RSSWidget(WebView* view, QWidget* parent)
@ -35,7 +37,7 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
{
ui->setupUi(this);
QWebFrame* frame = m_view->page()->mainFrame();
QWebEngineFrame* frame = m_view->page()->mainFrame();
QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");
// Make sure RSS feeds fit into a window, in case there is a lot of feeds from one page
@ -133,3 +135,5 @@ RSSWidget::~RSSWidget()
{
delete ui;
}
#endif

View File

@ -18,6 +18,8 @@
#ifndef RSSWIDGET_H
#define RSSWIDGET_H
#if QTWEBENGINE_DISABLED
#include <QMenu>
#include "qzcommon.h"
@ -47,4 +49,6 @@ private:
WebView* m_view;
};
#endif
#endif // RSSWIDGET_H

View File

@ -50,7 +50,9 @@ void TabIcon::setWebTab(WebTab* tab)
connect(m_tab->webView(), SIGNAL(loadStarted()), this, SLOT(showLoadingAnimation()));
connect(m_tab->webView(), SIGNAL(loadFinished(bool)), this, SLOT(hideLoadingAnimation()));
#if QTWEBENGINE_DISABLED
connect(m_tab->webView(), SIGNAL(iconChanged()), this, SLOT(showIcon()));
#endif
showIcon();
}

View File

@ -37,8 +37,7 @@
#include <QMimeData>
#include <QStackedWidget>
#include <QMouseEvent>
#include <QWebHistory>
#include <QWebFrame>
#include <QWebEngineHistory>
#include <QClipboard>
AddTabButton::AddTabButton(TabWidget* tabWidget, TabBar* tabBar)
@ -388,9 +387,10 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
m_window->locationBar()->setFocus();
}
#if QTWEBENGINE_DISABLED
if (openFlags & Qz::NT_NotSelectedTab) {
WebTab* currentWebTab = weTab();
// Workarounding invalid QWebPage::viewportSize() until QWebView is shown
// Workarounding invalid QWebEnginePage::viewportSize() until QWebEngineView is shown
// Fixes invalid scrolling to anchor(#) links
if (currentWebTab && currentWebTab->webView()) {
TabbedWebView* currentView = currentWebTab->webView();
@ -398,6 +398,7 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
webTab->webView()->page()->setViewportSize(currentView->page()->viewportSize());
}
}
#endif
// Make sure user notice opening new background tabs
if (!(openFlags & Qz::NT_SelectedTab)) {

View File

@ -20,8 +20,8 @@
#include "qztools.h"
#include "mainapplication.h"
#include <QWebHistory>
#include <QWebSettings>
#include <QWebEngineHistory>
#include <QWebEngineSettings>
ClosedTabsManager::ClosedTabsManager()
{

View File

@ -20,7 +20,6 @@
#include "settings.h"
#include "webview.h"
#include <QWebFrame>
HTML5PermissionsManager::HTML5PermissionsManager(QObject* parent)
: QObject(parent)
@ -28,8 +27,8 @@ HTML5PermissionsManager::HTML5PermissionsManager(QObject* parent)
loadSettings();
}
#if QTWEBKIT_FROM_2_2
void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebFrame* frame, const QWebPage::Feature &feature)
#if QTWEBENGINE_DISABLED
void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebEngineFrame* frame, const QWebEnginePage::Feature &feature)
{
if (!frame || !page) {
return;
@ -39,14 +38,14 @@ void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebFrame* frame
WebView* view = qobject_cast<WebView*>(page->view());
switch (feature) {
case QWebPage::Notifications:
case QWebEnginePage::Notifications:
if (m_notificationsGranted.contains(host)) {
page->setFeaturePermission(frame, feature, QWebPage::PermissionGrantedByUser);
page->setFeaturePermission(frame, feature, QWebEnginePage::PermissionGrantedByUser);
return;
}
if (m_notificationsDenied.contains(host)) {
page->setFeaturePermission(frame, feature, QWebPage::PermissionDeniedByUser);
page->setFeaturePermission(frame, feature, QWebEnginePage::PermissionDeniedByUser);
return;
}
@ -57,14 +56,14 @@ void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebFrame* frame
break;
case QWebPage::Geolocation:
case QWebEnginePage::Geolocation:
if (m_geolocationGranted.contains(host)) {
page->setFeaturePermission(frame, feature, QWebPage::PermissionGrantedByUser);
page->setFeaturePermission(frame, feature, QWebEnginePage::PermissionGrantedByUser);
return;
}
if (m_geolocationDenied.contains(host)) {
page->setFeaturePermission(frame, feature, QWebPage::PermissionDeniedByUser);
page->setFeaturePermission(frame, feature, QWebEnginePage::PermissionDeniedByUser);
return;
}
@ -81,16 +80,16 @@ void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebFrame* frame
}
}
void HTML5PermissionsManager::rememberPermissions(const QString &host, const QWebPage::Feature &feature,
const QWebPage::PermissionPolicy &policy)
void HTML5PermissionsManager::rememberPermissions(const QString &host, const QWebEnginePage::Feature &feature,
const QWebEnginePage::PermissionPolicy &policy)
{
if (host.isEmpty()) {
return;
}
switch (feature) {
case QWebPage::Notifications:
if (policy == QWebPage::PermissionGrantedByUser) {
case QWebEnginePage::Notifications:
if (policy == QWebEnginePage::PermissionGrantedByUser) {
m_notificationsGranted.append(host);
}
else {
@ -98,8 +97,8 @@ void HTML5PermissionsManager::rememberPermissions(const QString &host, const QWe
}
break;
case QWebPage::Geolocation:
if (policy == QWebPage::PermissionGrantedByUser) {
case QWebEnginePage::Geolocation:
if (policy == QWebEnginePage::PermissionGrantedByUser) {
m_geolocationGranted.append(host);
}
else {
@ -141,3 +140,4 @@ void HTML5PermissionsManager::saveSettings()
void HTML5PermissionsManager::showSettingsDialog()
{
}

View File

@ -32,10 +32,10 @@ class QUPZILLA_EXPORT HTML5PermissionsManager : public QObject
public:
explicit HTML5PermissionsManager(QObject* parent);
#if QTWEBKIT_FROM_2_2
void requestPermissions(WebPage* page, QWebFrame* frame, const QWebPage::Feature &feature);
void rememberPermissions(const QString &host, const QWebPage::Feature &feature,
const QWebPage::PermissionPolicy &policy);
#if QTWEBENGINE_DISABLED
void requestPermissions(WebPage* page, QWebEngineFrame* frame, const QWebEnginePage::Feature &feature);
void rememberPermissions(const QString &host, const QWebEnginePage::Feature &feature,
const QWebEnginePage::PermissionPolicy &policy);
#endif
void loadSettings();

View File

@ -21,10 +21,11 @@
#include "mainapplication.h"
#include "iconprovider.h"
#include <QWebFrame>
#if QTWEBENGINE_DISABLED
#include <QWebEngineFrame>
#ifdef USE_QTWEBKIT_2_2
HTML5PermissionsNotification::HTML5PermissionsNotification(const QString &host, QWebFrame* frame, const QWebPage::Feature &feature)
HTML5PermissionsNotification::HTML5PermissionsNotification(const QString &host, QWebEngineFrame* frame, const QWebEnginePage::Feature &feature)
: AnimatedWidget(AnimatedWidget::Down, 300, 0)
, ui(new Ui::HTML5PermissionsNotification)
, m_host(host)
@ -39,11 +40,11 @@ HTML5PermissionsNotification::HTML5PermissionsNotification(const QString &host,
QString message;
QString site = m_host.isEmpty() ? tr("this site") : QString("<b>%1</b>").arg(m_host);
if (feature == QWebPage::Notifications) {
if (feature == QWebEnginePage::Notifications) {
ui->iconLabel->setPixmap(QPixmap(":icons/other/notification.png"));
message = tr("Allow %1 to show desktop notifications?").arg(site);
}
else if (feature == QWebPage::Geolocation) {
else if (feature == QWebEnginePage::Geolocation) {
ui->iconLabel->setPixmap(QPixmap(":icons/other/geolocation.png"));
message = tr("Allow %1 to locate your position?").arg(site);
}
@ -63,11 +64,11 @@ void HTML5PermissionsNotification::grantPermissions()
return;
}
QWebPage* page = m_frame->page();
page->setFeaturePermission(m_frame, m_feature, QWebPage::PermissionGrantedByUser);
QWebEnginePage* page = m_frame->page();
page->setFeaturePermission(m_frame, m_feature, QWebEnginePage::PermissionGrantedByUser);
if (ui->remember->isChecked()) {
mApp->html5PermissionsManager()->rememberPermissions(m_host, m_feature, QWebPage::PermissionGrantedByUser);
mApp->html5PermissionsManager()->rememberPermissions(m_host, m_feature, QWebEnginePage::PermissionGrantedByUser);
}
hide();
@ -79,11 +80,11 @@ void HTML5PermissionsNotification::denyPermissions()
return;
}
QWebPage* page = m_frame->page();
page->setFeaturePermission(m_frame, m_feature, QWebPage::PermissionDeniedByUser);
QWebEnginePage* page = m_frame->page();
page->setFeaturePermission(m_frame, m_feature, QWebEnginePage::PermissionDeniedByUser);
if (ui->remember->isChecked()) {
mApp->html5PermissionsManager()->rememberPermissions(m_host, m_feature, QWebPage::PermissionDeniedByUser);
mApp->html5PermissionsManager()->rememberPermissions(m_host, m_feature, QWebEnginePage::PermissionDeniedByUser);
}
hide();
@ -94,3 +95,5 @@ HTML5PermissionsNotification::~HTML5PermissionsNotification()
delete ui;
}
#endif // USE_QTWEBKIT_2_2
#endif

View File

@ -34,7 +34,7 @@ class HTML5PermissionsNotification : public AnimatedWidget
#ifdef USE_QTWEBKIT_2_2
public:
explicit HTML5PermissionsNotification(const QString &host, QWebFrame* frame, const QWebPage::Feature &feature);
explicit HTML5PermissionsNotification(const QString &host, QWebEngineFrame* frame, const QWebEnginePage::Feature &feature);
~HTML5PermissionsNotification();
private slots:
@ -45,8 +45,8 @@ private:
Ui::HTML5PermissionsNotification* ui;
QString m_host;
QWebFrame* m_frame;
QWebPage::Feature m_feature;
QWebEngineFrame* m_frame;
QWebEnginePage::Feature m_feature;
#endif
};

View File

@ -19,8 +19,10 @@
#include "mainapplication.h"
#include "networkmanagerproxy.h"
#include <QWebPage>
#include <QWebFrame>
#if QTWEBENGINE_DISABLED
#include <QWebEnginePage>
#include <QWebEngineFrame>
#include <QPainter>
CleanPluginFactory::CleanPluginFactory(QObject* parent)
@ -45,7 +47,7 @@ QObject* CleanPluginFactory::create(const QString &mimeType, const QUrl &url, co
PageThumbnailer::PageThumbnailer(QObject* parent)
: QObject(parent)
, m_page(new QWebPage(this))
, m_page(new QWebEnginePage(this))
, m_size(QSize(450, 253))
, m_loadTitle(false)
{
@ -129,7 +131,7 @@ void PageThumbnailer::createThumbnail(bool status)
QPainter painter(&pixmap);
painter.scale(scalingFactor, scalingFactor);
m_page->mainFrame()->render(&painter, QWebFrame::ContentsLayer);
m_page->mainFrame()->render(&painter, QWebEngineFrame::ContentsLayer);
painter.end();
emit thumbnailCreated(pixmap.scaled(m_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
@ -139,3 +141,5 @@ PageThumbnailer::~PageThumbnailer()
{
m_page->deleteLater();
}
#endif

View File

@ -18,6 +18,8 @@
#ifndef PAGETHUMBNAILER_H
#define PAGETHUMBNAILER_H
#if QTWEBENGINE_DISABLED
#include <QObject>
#include <QSize>
#include <QUrl>
@ -25,7 +27,7 @@
#include "qzcommon.h"
class QWebPage;
class QWebEnginePage;
class QPixmap;
class QUPZILLA_EXPORT CleanPluginFactory : public QWebPluginFactory
@ -67,7 +69,7 @@ private slots:
void createThumbnail(bool status);
private:
QWebPage* m_page;
QWebEnginePage* m_page;
QSize m_size;
QUrl m_url;
@ -75,4 +77,6 @@ private:
bool m_loadTitle;
};
#endif
#endif // PAGETHUMBNAILER_H

View File

@ -39,7 +39,6 @@
#include <QSysInfo>
#include <QProcess>
#include <QMessageBox>
#include <QWebFrame>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
@ -216,9 +215,13 @@ QString QzTools::escapeSqlString(QString urlString)
return urlString;
}
QUrl QzTools::frameUrl(QWebFrame* frame)
QUrl QzTools::frameUrl(QWebEngineFrame* frame)
{
#if QTWEBENGINE_DISABLED
return frame->url().isEmpty() ? frame->baseUrl() : frame->url();
#else
return QUrl();
#endif
}
QString QzTools::ensureUniqueFilename(const QString &name, const QString &appendFormat)

View File

@ -24,7 +24,7 @@
class QSslCertificate;
class QFontMetrics;
class QWebFrame;
class QWebEngineFrame;
class QPixmap;
class QIcon;
class QWidget;
@ -49,7 +49,7 @@ public:
static QString urlEncodeQueryString(const QUrl &url);
static QString fromPunycode(const QString &str);
static QString escapeSqlString(QString urlString);
static QUrl frameUrl(QWebFrame* frame);
static QUrl frameUrl(QWebEngineFrame *frame);
static QString ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
static QString getFileNameFromUrl(const QUrl &url);

View File

@ -40,7 +40,11 @@ int ExternalJsObject::IsSearchProviderInstalled(const QString &engineURL)
QObject* ExternalJsObject::speedDial() const
{
#if QTWEBENGINE_DISABLED
return m_onSpeedDial ? mApp->plugins()->speedDial() : 0;
#else
return 0;
#endif
}
void ExternalJsObject::setOnSpeedDial(bool on)

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "loadrequest.h"
#include <QWebView>
#include <QWebEngineView>
LoadRequest::LoadRequest()
: m_operation(GetOperation)

View File

@ -19,6 +19,8 @@
#include "toolbutton.h"
#include "iconprovider.h"
#if QTWEBENGINE_DISABLED
#include <QTimer>
WebInspector::WebInspector(QWidget* parent)
@ -68,3 +70,5 @@ void WebInspector::resizeEvent(QResizeEvent* event)
QTimer::singleShot(0, this, SLOT(updateCloseButton()));
}
#endif

View File

@ -18,6 +18,7 @@
#ifndef WEBINSPECTORDOCKWIDGET_H
#define WEBINSPECTORDOCKWIDGET_H
#if QTWEBENGINE_DISABLED
#include <QWebInspector>
#include "qzcommon.h"
@ -42,5 +43,6 @@ private:
ToolButton* m_closeButton;
bool m_blockHideEvent;
};
#endif
#endif // WEBINSPECTORDOCKWIDGET_H

View File

@ -50,16 +50,19 @@
#include <QPushButton>
#endif
#include <QAuthenticator>
#include <QDir>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMouseEvent>
#include <QWebHistory>
#include <QWebEngineHistory>
#include <QTimer>
#include <QNetworkReply>
#include <QDesktopServices>
#include <QMessageBox>
#include <QFileDialog>
#include <QWebFrame>
#include <QWebSecurityOrigin>
#include <QCheckBox>
QString WebPage::s_lastUploadLocation = QDir::homePath();
QUrl WebPage::s_lastUnsupportedUrl;
@ -67,7 +70,7 @@ QTime WebPage::s_lastUnsupportedUrlTime;
QList<WebPage*> WebPage::s_livingPages;
WebPage::WebPage(QObject* parent)
: QWebPage(parent)
: QWebEnginePage(parent)
, m_view(0)
, m_fileWatcher(0)
, m_runningLoop(0)
@ -76,7 +79,8 @@ WebPage::WebPage(QObject* parent)
, m_secureStatus(false)
, m_adjustingScheduled(false)
{
m_javaScriptEnabled = QWebSettings::globalSettings()->testAttribute(QWebSettings::JavascriptEnabled);
#if QTWEBENGINE_DISABLED
m_javaScriptEnabled = QWebEngineSettings::globalSettings()->testAttribute(QWebEngineSettings::JavascriptEnabled);
m_networkProxy = new NetworkManagerProxy(this);
m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager());
@ -113,6 +117,8 @@ WebPage::WebPage(QObject* parent)
#elif QTWEBKIT_FROM_2_2
connect(this, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin*,quint64)),
this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*,quint64)));
#endif
#endif
s_livingPages.append(this);
@ -129,14 +135,11 @@ WebPage::~WebPage()
s_livingPages.removeOne(this);
#if QTWEBENGINE_DISABLED
// Page's network manager will be deleted and then set to null
// Fixes issue with network manager being used after deleted in destructor
setNetworkAccessManager(0);
}
QUrl WebPage::url() const
{
return mainFrame()->url();
#endif
}
void WebPage::setWebView(TabbedWebView* view)
@ -177,7 +180,11 @@ void WebPage::scheduleAdjustPage()
bool WebPage::loadingError() const
{
#if QTWEBENGINE_DISABLED
return !mainFrame()->findFirstElement("span[id=\"qupzilla-error-page\"]").isNull();
#else
return false;
#endif
}
void WebPage::addRejectedCerts(const QList<QSslCertificate> &certs)
@ -206,11 +213,13 @@ bool WebPage::containsRejectedCerts(const QList<QSslCertificate> &certs)
return matches == certs.count();
}
#if QTWEBENGINE_DISABLED
QWebElement WebPage::activeElement() const
{
QRect activeRect = inputMethodQuery(Qt::ImMicroFocus).toRect();
return mainFrame()->hitTestContent(activeRect.center()).element();
}
#endif
bool WebPage::isRunningLoop()
{
@ -224,10 +233,12 @@ bool WebPage::isLoading() const
void WebPage::urlChanged(const QUrl &url)
{
#if QTWEBENGINE_DISABLED
// Make sure JavaScript is enabled for qupzilla pages regardless of user settings
if (url.scheme() == QLatin1String("qupzilla")) {
settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
}
#endif
if (isLoading()) {
m_adBlockedEntries.clear();
@ -253,8 +264,8 @@ void WebPage::finished()
if (m_adjustingScheduled) {
m_adjustingScheduled = false;
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() + 1);
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() - 1);
setZoomFactor(zoomFactor() + 1);
setZoomFactor(zoomFactor() - 1);
}
// File scheme watcher
@ -284,11 +295,12 @@ void WebPage::finished()
void WebPage::watchedFileChanged(const QString &file)
{
if (url().toLocalFile() == file) {
triggerAction(QWebPage::Reload);
triggerAction(QWebEnginePage::Reload);
}
}
void WebPage::printFrame(QWebFrame* frame)
#if QTWEBENGINE_DISABLED
void WebPage::printFrame(QWebEngineFrame* frame)
{
WebView* webView = qobject_cast<WebView*>(view());
if (!webView) {
@ -297,22 +309,25 @@ void WebPage::printFrame(QWebFrame* frame)
webView->printPage(frame);
}
#endif
void WebPage::addJavaScriptObject()
{
#if QTWEBENGINE_DISABLED
// Make sure all other sites have JavaScript set by user preferences
// (JavaScript is enabled in WebPage::urlChanged)
if (url().scheme() != QLatin1String("qupzilla")) {
settings()->setAttribute(QWebSettings::JavascriptEnabled, m_javaScriptEnabled);
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, m_javaScriptEnabled);
}
ExternalJsObject* jsObject = new ExternalJsObject(this);
mainFrame()->addToJavaScriptWindowObject("external", jsObject);
addToJavaScriptWindowObject("external", jsObject);
if (url().toString() == QLatin1String("qupzilla:speeddial")) {
jsObject->setOnSpeedDial(true);
mApp->plugins()->speedDial()->addWebFrame(mainFrame());
}
#endif
}
void WebPage::handleUnsupportedContent(QNetworkReply* reply)
@ -327,6 +342,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
case QNetworkReply::NoError:
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
QString requestUrl = reply->request().url().toString(QUrl::RemoveFragment | QUrl::RemoveQuery);
#if QTWEBENGINE_DISABLED
if (requestUrl.endsWith(QLatin1String(".swf"))) {
const QWebElement docElement = mainFrame()->documentElement();
const QWebElement object = docElement.findFirst(QString("object[src=\"%1\"]").arg(requestUrl));
@ -340,6 +356,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
}
DownloadManager* dManager = mApp->downloadManager();
dManager->handleUnsupportedContent(reply, this);
#endif
return;
}
// Falling unsupported content with invalid ContentTypeHeader to be handled as UnknownProtocol
@ -352,7 +369,9 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
if (url.scheme() == QLatin1String("ftp")) {
DownloadManager* dManager = mApp->downloadManager();
#if QTWEBENGINE_DISABLED
dManager->handleUnsupportedContent(reply, this);
#endif
return;
}
@ -457,6 +476,7 @@ void WebPage::windowCloseRequested()
webView->closeView();
}
#if QTWEBENGINE_DISABLED
void WebPage::frameCreated(QWebFrame* frame)
{
connect(frame, SIGNAL(initialLayoutCompleted()), this, SLOT(frameInitialLayoutCompleted()));
@ -471,8 +491,144 @@ void WebPage::frameInitialLayoutCompleted()
// Autofill
m_passwordEntries = mApp->autoFill()->completeFrame(frame);
}
#endif
void WebPage::dbQuotaExceeded(QWebFrame* frame)
void WebPage::authentication(const QUrl &requestUrl, QAuthenticator* auth)
{
QDialog* dialog = new QDialog();
dialog->setWindowTitle(tr("Authorisation required"));
QFormLayout* formLa = new QFormLayout(dialog);
QLabel* label = new QLabel(dialog);
QLabel* userLab = new QLabel(dialog);
QLabel* passLab = new QLabel(dialog);
userLab->setText(tr("Username: "));
passLab->setText(tr("Password: "));
QLineEdit* user = new QLineEdit(dialog);
QLineEdit* pass = new QLineEdit(dialog);
pass->setEchoMode(QLineEdit::Password);
QCheckBox* save = new QCheckBox(dialog);
save->setText(tr("Save username and password on this site"));
QDialogButtonBox* box = new QDialogButtonBox(dialog);
box->addButton(QDialogButtonBox::Ok);
box->addButton(QDialogButtonBox::Cancel);
connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
label->setText(tr("A username and password are being requested by %1. "
"The site says: \"%2\"").arg(requestUrl.host(), QzTools::escape(auth->realm())));
formLa->addRow(label);
formLa->addRow(userLab, user);
formLa->addRow(passLab, pass);
formLa->addRow(save);
formLa->addWidget(box);
AutoFill* fill = mApp->autoFill();
QString storedUser;
QString storedPassword;
bool shouldUpdateEntry = false;
if (fill->isStored(requestUrl)) {
const QVector<PasswordEntry> &data = fill->getFormData(requestUrl);
if (!data.isEmpty()) {
save->setChecked(true);
shouldUpdateEntry = true;
storedUser = data.first().username;
storedPassword = data.first().password;
user->setText(storedUser);
pass->setText(storedPassword);
}
}
// Try to set the originating WebTab as a current tab
TabbedWebView* tabView = qobject_cast<TabbedWebView*>(view());
if (tabView) {
tabView->setAsCurrentTab();
}
// Do not save when private browsing is enabled
if (mApp->isPrivate()) {
save->setVisible(false);
}
if (dialog->exec() != QDialog::Accepted) {
return;
}
auth->setUser(user->text());
auth->setPassword(pass->text());
if (save->isChecked()) {
if (shouldUpdateEntry) {
if (storedUser != user->text() || storedPassword != pass->text()) {
fill->updateEntry(requestUrl, user->text(), pass->text());
}
}
else {
fill->addEntry(requestUrl, user->text(), pass->text());
}
}
}
void WebPage::proxyAuthentication(const QUrl &requestUrl, QAuthenticator* auth, const QString &proxyHost)
{
Q_UNUSED(requestUrl)
QVector<PasswordEntry> passwords = mApp->autoFill()->getFormData(QUrl(proxyHost));
if (!passwords.isEmpty()) {
auth->setUser(passwords.at(0).username);
auth->setPassword(passwords.at(0).password);
return;
}
QDialog* dialog = new QDialog();
dialog->setWindowTitle(tr("Proxy authorisation required"));
QFormLayout* formLa = new QFormLayout(dialog);
QLabel* label = new QLabel(dialog);
QLabel* userLab = new QLabel(dialog);
QLabel* passLab = new QLabel(dialog);
userLab->setText(tr("Username: "));
passLab->setText(tr("Password: "));
QLineEdit* user = new QLineEdit(dialog);
QLineEdit* pass = new QLineEdit(dialog);
pass->setEchoMode(QLineEdit::Password);
QCheckBox* save = new QCheckBox(dialog);
save->setText(tr("Remember username and password for this proxy."));
QDialogButtonBox* box = new QDialogButtonBox(dialog);
box->addButton(QDialogButtonBox::Ok);
box->addButton(QDialogButtonBox::Cancel);
connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
label->setText(tr("A username and password are being requested by proxy %1. ").arg(proxyHost));
formLa->addRow(label);
formLa->addRow(userLab, user);
formLa->addRow(passLab, pass);
formLa->addRow(save);
formLa->addWidget(box);
if (dialog->exec() != QDialog::Accepted) {
return;
}
if (save->isChecked()) {
mApp->autoFill()->addEntry(QUrl(proxyHost), user->text(), pass->text());
}
auth->setUser(user->text());
auth->setPassword(pass->text());
}
#if QTWEBENGINE_DISABLED
void WebPage::dbQuotaExceeded(QWebEngineFrame* frame)
{
if (!frame) {
return;
@ -483,6 +639,7 @@ void WebPage::dbQuotaExceeded(QWebFrame* frame)
frame->securityOrigin().setDatabaseQuota(oldQuota * 2);
}
#endif
void WebPage::doWebSearch(const QString &text)
{
@ -504,7 +661,7 @@ void WebPage::appCacheQuotaExceeded(QWebSecurityOrigin* origin, quint64 original
origin->setApplicationCacheQuota(originalQuota * 2);
}
void WebPage::featurePermissionRequested(QWebFrame* frame, const QWebPage::Feature &feature)
void WebPage::featurePermissionRequested(QWebEngineFrame* frame, const QWebEnginePage::Feature &feature)
{
mApp->html5PermissionsManager()->requestPermissions(this, frame, feature);
}
@ -513,7 +670,7 @@ void WebPage::featurePermissionRequested(QWebFrame* frame, const QWebPage::Featu
bool WebPage::event(QEvent* event)
{
if (event->type() == QEvent::Leave) {
// QWebPagePrivate::leaveEvent():
// QWebEnginePagePrivate::leaveEvent():
// Fake a mouse move event just outside of the widget, since all
// the interesting mouse-out behavior like invalidating scrollbars
// is handled by the WebKit event handler's mouseMoved function.
@ -548,10 +705,10 @@ bool WebPage::event(QEvent* event)
}
QMouseEvent fakeEvent(QEvent::MouseMove, mousePos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
return QWebPage::event(&fakeEvent);
return QWebEnginePage::event(&fakeEvent);
}
return QWebPage::event(event);
return QWebEnginePage::event(event);
}
void WebPage::setSSLCertificate(const QSslCertificate &cert)
@ -569,12 +726,13 @@ QSslCertificate WebPage::sslCertificate()
return QSslCertificate();
}
bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type)
#if QTWEBENGINE_DISABLED
bool WebPage::acceptNavigationRequest(QWebEngineFrame* frame, const QNetworkRequest &request, NavigationType type)
{
m_lastRequestType = type;
m_lastRequestUrl = request.url();
if (type == QWebPage::NavigationTypeFormResubmitted) {
if (type == QWebEnginePage::NavigationTypeFormResubmitted) {
// Don't show this dialog if app is still starting
if (!view() || !view()->isVisible()) {
return false;
@ -588,9 +746,10 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
}
}
bool accept = QWebPage::acceptNavigationRequest(frame, request, type);
bool accept = QWebEnginePage::acceptNavigationRequest(frame, request, type);
return accept;
}
#endif
void WebPage::populateNetworkRequest(QNetworkRequest &request)
{
@ -599,15 +758,17 @@ void WebPage::populateNetworkRequest(QNetworkRequest &request)
QVariant variant = QVariant::fromValue((void*) pagePointer);
request.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100), variant);
#if QTWEBENGINE_DISABLED
if (m_lastRequestUrl == request.url()) {
request.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 101), m_lastRequestType);
if (m_lastRequestType == NavigationTypeLinkClicked) {
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
}
}
#endif
}
QWebPage* WebPage::createWindow(QWebPage::WebWindowType type)
QWebEnginePage* WebPage::createWindow(QWebEnginePage::WebWindowType type)
{
if (m_view) {
return new PopupWebPage(type, m_view->browserWindow());
@ -631,7 +792,7 @@ QObject* WebPage::createPlugin(const QString &classid, const QUrl &url,
return new RecoveryWidget(m_view, m_view->browserWindow());
}
else {
mainFrame()->load(QUrl("qupzilla:start"));
load(QUrl("qupzilla:start"));
}
return 0;
@ -665,6 +826,7 @@ QVector<PasswordEntry> WebPage::autoFillData() const
void WebPage::cleanBlockedObjects()
{
#if QTWEBENGINE_DISABLED
AdBlockManager* manager = AdBlockManager::instance();
if (!manager->isEnabled()) {
return;
@ -718,14 +880,16 @@ void WebPage::cleanBlockedObjects()
if (view() && !view()->isVisible() && !url().fragment().isEmpty()) {
mainFrame()->scrollToAnchor(url().fragment());
}
#endif
}
QString WebPage::userAgentForUrl(const QUrl &url) const
{
QString userAgent = mApp->userAgentManager()->userAgentForUrl(url);
#if QTWEBENGINE_DISABLED
if (userAgent.isEmpty()) {
userAgent = QWebPage::userAgentForUrl(url);
userAgent = QWebEnginePage::userAgentForUrl(url);
#ifdef Q_OS_MAC
#ifdef __i386__ || __x86_64__
userAgent.replace(QLatin1String("PPC Mac OS X"), QLatin1String("Intel Mac OS X"));
@ -733,9 +897,11 @@ QString WebPage::userAgentForUrl(const QUrl &url) const
#endif
}
#endif
return userAgent;
}
#if QTWEBENGINE_DISABLED
bool WebPage::supportsExtension(Extension extension) const
{
Q_UNUSED(extension)
@ -746,11 +912,11 @@ bool WebPage::supportsExtension(Extension extension) const
bool WebPage::extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output)
{
if (extension == ChooseMultipleFilesExtension) {
const QWebPage::ChooseMultipleFilesExtensionOption* exOption = static_cast<const QWebPage::ChooseMultipleFilesExtensionOption*>(option);
QWebPage::ChooseMultipleFilesExtensionReturn* exReturn = static_cast<QWebPage::ChooseMultipleFilesExtensionReturn*>(output);
const QWebEnginePage::ChooseMultipleFilesExtensionOption* exOption = static_cast<const QWebEnginePage::ChooseMultipleFilesExtensionOption*>(option);
QWebEnginePage::ChooseMultipleFilesExtensionReturn* exReturn = static_cast<QWebEnginePage::ChooseMultipleFilesExtensionReturn*>(output);
if (!exOption || !exReturn) {
return QWebPage::extension(extension, option, output);
return QWebEnginePage::extension(extension, option, output);
}
QString suggestedFileName;
@ -762,21 +928,21 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
return true;
}
const ErrorPageExtensionOption* exOption = static_cast<const QWebPage::ErrorPageExtensionOption*>(option);
ErrorPageExtensionReturn* exReturn = static_cast<QWebPage::ErrorPageExtensionReturn*>(output);
const ErrorPageExtensionOption* exOption = static_cast<const QWebEnginePage::ErrorPageExtensionOption*>(option);
ErrorPageExtensionReturn* exReturn = static_cast<QWebEnginePage::ErrorPageExtensionReturn*>(output);
if (!exOption || !exReturn) {
return QWebPage::extension(extension, option, output);
return QWebEnginePage::extension(extension, option, output);
}
WebPage* erPage = qobject_cast<WebPage*>(exOption->frame->page());
if (!erPage) {
return QWebPage::extension(extension, option, output);
return QWebEnginePage::extension(extension, option, output);
}
QString errorString;
if (exOption->domain == QWebPage::QtNetwork) {
if (exOption->domain == QWebEnginePage::QtNetwork) {
switch (exOption->error) {
case QNetworkReply::ConnectionRefusedError:
errorString = tr("Server refused the connection");
@ -881,7 +1047,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
return false;
}
}
else if (exOption->domain == QWebPage::Http) {
else if (exOption->domain == QWebEnginePage::Http) {
// 200 status code = OK
// It shouldn't be reported as an error, but sometimes it is ...
if (exOption->error == 200) {
@ -889,7 +1055,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
}
errorString = tr("Error code %1").arg(exOption->error);
}
else if (exOption->domain == QWebPage::WebKit) {
else if (exOption->domain == QWebEnginePage::WebKit) {
return false; // Downloads
}
@ -918,11 +1084,12 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
exReturn->content = QString(errString + "<span id=\"qupzilla-error-page\"></span>").toUtf8();
return true;
}
#endif
bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg, const QString &defaultValue, QString* result)
bool WebPage::javaScriptPrompt(QUrl securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
{
#ifndef NONBLOCK_JS_DIALOGS
return QWebPage::javaScriptPrompt(originatingFrame, msg, defaultValue, result);
return QWebEnginePage::javaScriptPrompt(securityOrigin, msg, defaultValue, result);
#else
if (m_runningLoop) {
return false;
@ -963,10 +1130,10 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
#endif
}
bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
bool WebPage::javaScriptConfirm(QUrl securityOrigin, const QString &msg)
{
#ifndef NONBLOCK_JS_DIALOGS
return QWebPage::javaScriptConfirm(originatingFrame, msg);
return QWebEnginePage::javaScriptConfirm(securityOrigin, msg);
#else
if (m_runningLoop) {
return false;
@ -1003,9 +1170,9 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
#endif
}
void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
void WebPage::javaScriptAlert(QUrl securityOrigin, const QString &msg)
{
Q_UNUSED(originatingFrame)
Q_UNUSED(securityOrigin)
if (m_blockAlerts || m_runningLoop) {
return;
@ -1058,11 +1225,14 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
void WebPage::setJavaScriptEnabled(bool enabled)
{
settings()->setAttribute(QWebSettings::JavascriptEnabled, enabled);
#if QTWEBENGINE_DISABLED
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, enabled);
m_javaScriptEnabled = enabled;
#endif
}
QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)
#if QTWEBENGINE_DISABLED
QString WebPage::chooseFile(QWebEngineFrame* originatingFrame, const QString &oldFile)
{
QString suggFileName;
@ -1073,7 +1243,7 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)
suggFileName = oldFile;
}
const QString fileName = QzTools::getOpenFileName("WebPage-ChooseFile", originatingFrame->page()->view(), tr("Choose file..."), suggFileName);
const QString fileName = QzTools::getOpenFileName("WebPage-ChooseFile", view(), tr("Choose file..."), suggFileName);
if (!fileName.isEmpty()) {
s_lastUploadLocation = fileName;
@ -1089,6 +1259,7 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)
return fileName;
}
#endif
bool WebPage::isPointerSafeToUse(WebPage* page)
{

View File

@ -18,7 +18,7 @@
#ifndef WEBPAGE_H
#define WEBPAGE_H
#include <QWebPage>
#include <QWebEnginePage>
#include <QSslCertificate>
#include <QVector>
@ -35,7 +35,7 @@ class SpeedDial;
class NetworkManagerProxy;
class DelayedFileWatcher;
class QUPZILLA_EXPORT WebPage : public QWebPage
class QUPZILLA_EXPORT WebPage : public QWebEnginePage
{
Q_OBJECT
public:
@ -51,17 +51,15 @@ public:
WebPage(QObject* parent = 0);
~WebPage();
QUrl url() const;
void setWebView(TabbedWebView* view);
void populateNetworkRequest(QNetworkRequest &request);
void setSSLCertificate(const QSslCertificate &cert);
QSslCertificate sslCertificate();
bool javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg, const QString &defaultValue, QString* result);
bool javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg);
void javaScriptAlert(QWebFrame* originatingFrame, const QString &msg);
bool javaScriptPrompt(QUrl securityOrigin, const QString &msg, const QString &defaultValue, QString* result);
bool javaScriptConfirm(QUrl securityOrigin, const QString &msg);
void javaScriptAlert(QUrl securityOrigin, const QString &msg);
void setJavaScriptEnabled(bool enabled);
@ -80,7 +78,9 @@ public:
void addRejectedCerts(const QList<QSslCertificate> &certs);
bool containsRejectedCerts(const QList<QSslCertificate> &certs);
#if QTWEBENGINE_DISABLED
QWebElement activeElement() const;
#endif
QString userAgentForUrl(const QUrl &url) const;
static bool isPointerSafeToUse(WebPage* page);
@ -100,14 +100,18 @@ private slots:
void addJavaScriptObject();
void watchedFileChanged(const QString &file);
void printFrame(QWebFrame* frame);
void downloadRequested(const QNetworkRequest &request);
void windowCloseRequested();
void authentication(const QUrl &requestUrl, QAuthenticator* auth);
void proxyAuthentication(const QUrl &requestUrl, QAuthenticator* auth, const QString &proxyHost);
#if QTWEBENGINE_DISABLED
void frameCreated(QWebFrame* frame);
void frameInitialLayoutCompleted();
void dbQuotaExceeded(QWebEngineFrame* frame);
void printFrame(QWebEngineFrame* frame);
#endif
void dbQuotaExceeded(QWebFrame* frame);
void doWebSearch(const QString &text);
#ifdef USE_QTWEBKIT_2_2
@ -117,14 +121,16 @@ private slots:
protected:
bool event(QEvent* event);
QWebPage* createWindow(QWebPage::WebWindowType type);
QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type);
QObject* createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
private:
#if QTWEBENGINE_DISABLED
bool supportsExtension(Extension extension) const;
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);
#endif
void handleUnknownProtocol(const QUrl &url);
void desktopServicesOpen(const QUrl &url);
@ -144,7 +150,6 @@ private:
QVector<AdBlockedEntry> m_adBlockedEntries;
QVector<PasswordEntry> m_passwordEntries;
QWebPage::NavigationType m_lastRequestType;
QUrl m_lastRequestUrl;
int m_loadProgress;

View File

@ -22,6 +22,7 @@
#include "adblockmanager.h"
#include "webpage.h"
#if QTWEBENGINE_DISABLED
#include <QNetworkRequest>
WebPluginFactory::WebPluginFactory(WebPage* page)
@ -97,3 +98,5 @@ QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
// plugins.append(plugin);
// return plugins;
}
#endif

View File

@ -18,6 +18,7 @@
#ifndef WEB_PLUGIN_FACTORY_H
#define WEB_PLUGIN_FACTORY_H
#if QTWEBENGINE_DISABLED
#include <QWebPluginFactory>
#include "qzcommon.h"
@ -35,4 +36,5 @@ public:
private:
WebPage* m_page;
};
#endif
#endif // WEB_PLUGIN_FACTORY_H

View File

@ -45,8 +45,7 @@
#include <QTimer>
#include <QDesktopServices>
#include <QNetworkRequest>
#include <QWebHistory>
#include <QWebFrame>
#include <QWebEngineHistory>
#include <QClipboard>
#include <QTouchEvent>
#include <QPrintPreviewDialog>
@ -54,10 +53,12 @@
bool WebView::s_forceContextMenuOnMouseRelease = false;
WebView::WebView(QWidget* parent)
: QWebView(parent)
: QWebEngineView(parent)
, m_isLoading(false)
, m_progress(0)
#if QTWEBENGINE_DISABLED
, m_clickedFrame(0)
#endif
, m_page(0)
, m_disableTouchMocking(false)
, m_isReloading(false)
@ -67,8 +68,10 @@ WebView::WebView(QWidget* parent)
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished()));
connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged()));
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(slotUrlChanged(QUrl)));
#if QTWEBENGINE_DISABLED
connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged()));
#endif
m_zoomLevels = zoomLevels();
m_currentZoomLevel = m_zoomLevels.indexOf(100);
@ -82,7 +85,7 @@ WebView::WebView(QWidget* parent)
WebView::~WebView()
{
delete m_page;
//delete m_page;
}
QIcon WebView::icon() const
@ -99,9 +102,11 @@ QIcon WebView::icon() const
return IconProvider::standardIcon(QStyle::SP_ComputerIcon);
}
if (!QWebView::icon().isNull()) {
return QWebView::icon();
#if QTWEBENGINE_DISABLED
if (!QWebEngineView::icon().isNull()) {
return QWebEngineView::icon();
}
#endif
if (!m_siteIcon.isNull() && m_siteIconUrl.host() == url().host()) {
return m_siteIcon;
@ -112,7 +117,7 @@ QIcon WebView::icon() const
QString WebView::title() const
{
QString title = QWebView::title();
QString title = QWebEngineView::title();
if (title.isEmpty()) {
title = url().toString(QUrl::RemoveFragment);
@ -127,7 +132,7 @@ QString WebView::title() const
bool WebView::isTitleEmpty() const
{
return QWebView::title().isEmpty();
return QWebEngineView::title().isEmpty();
}
QUrl WebView::url() const
@ -146,16 +151,18 @@ WebPage* WebView::page() const
return m_page;
}
void WebView::setPage(QWebPage* page)
void WebView::setPage(QWebEnginePage* page)
{
if (m_page == page) {
return;
}
QWebView::setPage(page);
QWebEngineView::setPage(page);
m_page = qobject_cast<WebPage*>(page);
connect(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)), this, SLOT(frameStateChanged()));
#if QTWEBENGINE_DISABLED
connect(m_page, SIGNAL(saveFrameStateRequested(QWebEngineFrame*,QWebHistoryItem*)), this, SLOT(frameStateChanged()));
#endif
connect(m_page, SIGNAL(privacyChanged(bool)), this, SIGNAL(privacyChanged(bool)));
// Set default zoom level
@ -166,11 +173,13 @@ void WebView::setPage(QWebPage* page)
mApp->plugins()->emitWebPageCreated(m_page);
#if QTWEBENGINE_DISABLED
// Set white background by default.
// Fixes issue with dark themes. See #602
QPalette pal = palette();
pal.setBrush(QPalette::Base, Qt::white);
page->setPalette(pal);
#endif
}
void WebView::load(const LoadRequest &request)
@ -182,9 +191,9 @@ void WebView::load(const LoadRequest &request)
// Is the javascript source percent encoded or not?
// Looking for % character in source should work in most cases
if (scriptSource.contains(QL1C('%')))
page()->mainFrame()->evaluateJavaScript(QUrl::fromPercentEncoding(scriptSource.toUtf8()));
page()->runJavaScript(QUrl::fromPercentEncoding(scriptSource.toUtf8()));
else
page()->mainFrame()->evaluateJavaScript(scriptSource);
page()->runJavaScript(scriptSource);
return;
}
@ -235,11 +244,13 @@ bool WebView::hasRss() const
return m_hasRss;
}
#if QTWEBENGINE_DISABLED
QWebElement WebView::activeElement() const
{
QRect activeRect = inputMethodQuery(Qt::ImMicroFocus).toRect();
return page()->mainFrame()->hitTestContent(activeRect.center()).element();
}
#endif
int WebView::zoomLevel() const
{
@ -254,11 +265,13 @@ void WebView::setZoomLevel(int level)
bool WebView::onBeforeUnload()
{
#if QTWEBENGINE_DISABLED
const QString res = page()->mainFrame()->evaluateJavaScript("window.onbeforeunload(new Event(\"beforeunload\"))").toString();
if (!res.isEmpty()) {
return page()->javaScriptConfirm(page()->mainFrame(), res);
}
#endif
return true;
}
@ -364,32 +377,32 @@ void WebView::zoomReset()
void WebView::editUndo()
{
triggerPageAction(QWebPage::Undo);
triggerPageAction(QWebEnginePage::Undo);
}
void WebView::editRedo()
{
triggerPageAction(QWebPage::Redo);
triggerPageAction(QWebEnginePage::Redo);
}
void WebView::editCut()
{
triggerPageAction(QWebPage::Cut);
triggerPageAction(QWebEnginePage::Cut);
}
void WebView::editCopy()
{
triggerPageAction(QWebPage::Copy);
triggerPageAction(QWebEnginePage::Copy);
}
void WebView::editPaste()
{
triggerPageAction(QWebPage::Paste);
triggerPageAction(QWebEnginePage::Paste);
}
void WebView::editSelectAll()
{
triggerPageAction(QWebPage::SelectAll);
triggerPageAction(QWebEnginePage::SelectAll);
}
void WebView::editDelete()
@ -402,40 +415,44 @@ void WebView::reload()
{
m_isReloading = true;
if (LocationBar::convertUrlToText(QWebView::url()).isEmpty() && !m_aboutToLoadUrl.isEmpty()) {
if (LocationBar::convertUrlToText(QWebEngineView::url()).isEmpty() && !m_aboutToLoadUrl.isEmpty()) {
load(m_aboutToLoadUrl);
return;
}
QWebView::reload();
QWebEngineView::reload();
}
void WebView::reloadBypassCache()
{
triggerPageAction(QWebPage::ReloadAndBypassCache);
triggerPageAction(QWebEnginePage::ReloadAndBypassCache);
}
void WebView::back()
{
QWebHistory* history = page()->history();
QWebEngineHistory* history = page()->history();
if (history->canGoBack()) {
history->back();
emit urlChanged(url());
#if QTWEBENGINE_DISABLED
emit iconChanged();
#endif
}
}
void WebView::forward()
{
QWebHistory* history = page()->history();
QWebEngineHistory* history = page()->history();
if (history->canGoForward()) {
history->forward();
emit urlChanged(url());
#if QTWEBENGINE_DISABLED
emit iconChanged();
#endif
}
}
@ -472,7 +489,7 @@ void WebView::slotLoadFinished()
void WebView::frameStateChanged()
{
// QWebFrame::baseUrl() is not updated yet, so we are invoking 0 second timer
// QWebEngineFrame::baseUrl() is not updated yet, so we are invoking 0 second timer
QTimer::singleShot(0, this, SLOT(emitChangedUrl()));
}
@ -483,16 +500,18 @@ void WebView::emitChangedUrl()
void WebView::checkRss()
{
#if QTWEBENGINE_DISABLED
if (m_rssChecked) {
return;
}
m_rssChecked = true;
QWebFrame* frame = page()->mainFrame();
QWebEngineFrame* frame = page()->mainFrame();
const QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");
m_hasRss = links.count() != 0;
emit rssChanged(m_hasRss);
#endif
}
void WebView::slotIconChanged()
@ -599,7 +618,9 @@ void WebView::downloadUrlToDisk()
void WebView::copyImageToClipboard()
{
triggerPageAction(QWebPage::CopyImageToClipboard);
#if QTWEBENGINE_DISABLED
triggerPageAction(QWebEnginePage::CopyImageToClipboard);
#endif
}
void WebView::openActionUrl()
@ -609,7 +630,8 @@ void WebView::openActionUrl()
}
}
void WebView::showSource(QWebFrame* frame, const QString &selectedHtml)
#if QTWEBENGINE_DISABLED
void WebView::showSource(QWebEngineFrame* frame, const QString &selectedHtml)
{
if (!frame) {
frame = page()->mainFrame();
@ -619,11 +641,14 @@ void WebView::showSource(QWebFrame* frame, const QString &selectedHtml)
QzTools::centerWidgetToParent(source, this);
source->show();
}
#endif
void WebView::showSiteInfo()
{
#if QTWEBENGINE_DISABLED
SiteInfo* s = new SiteInfo(this, this);
s->show();
#endif
}
void WebView::searchSelectedText()
@ -733,22 +758,26 @@ void WebView::userDefinedOpenUrlInBgTab(const QUrl &url)
void WebView::loadClickedFrame()
{
#if QTWEBENGINE_DISABLED
QUrl frameUrl = m_clickedFrame->baseUrl();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
load(frameUrl);
#endif
}
void WebView::loadClickedFrameInNewTab(bool invert)
{
#if QTWEBENGINE_DISABLED
QUrl frameUrl = m_clickedFrame->baseUrl();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
userDefinedOpenUrlInNewTab(frameUrl, invert);
#endif
}
void WebView::loadClickedFrameInBgTab()
@ -758,50 +787,63 @@ void WebView::loadClickedFrameInBgTab()
void WebView::reloadClickedFrame()
{
#if QTWEBENGINE_DISABLED
QUrl frameUrl = m_clickedFrame->baseUrl();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
m_clickedFrame->load(frameUrl);
#endif
}
void WebView::printClickedFrame()
{
#if QTWEBENGINE_DISABLED
printPage(m_clickedFrame);
#endif
}
void WebView::clickedFrameZoomIn()
{
#if QTWEBENGINE_DISABLED
qreal zFactor = m_clickedFrame->zoomFactor() + 0.1;
if (zFactor > 2.5) {
zFactor = 2.5;
}
m_clickedFrame->setZoomFactor(zFactor);
#endif
}
void WebView::clickedFrameZoomOut()
{
#if QTWEBENGINE_DISABLED
qreal zFactor = m_clickedFrame->zoomFactor() - 0.1;
if (zFactor < 0.5) {
zFactor = 0.5;
}
m_clickedFrame->setZoomFactor(zFactor);
#endif
}
void WebView::clickedFrameZoomReset()
{
#if QTWEBENGINE_DISABLED
m_clickedFrame->setZoomFactor(zoomFactor());
#endif
}
void WebView::showClickedFrameSource()
{
#if QTWEBENGINE_DISABLED
showSource(m_clickedFrame);
#endif
}
void WebView::printPage(QWebFrame* frame)
#if QTWEBENGINE_DISABLED
void WebView::printPage(QWebEngineFrame* frame)
{
QPrintPreviewDialog* dialog = new QPrintPreviewDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
@ -816,12 +858,14 @@ void WebView::printPage(QWebFrame* frame)
dialog->open();
}
#endif
QUrl WebView::lastUrl()
{
return m_lastUrl;
}
#if QTWEBENGINE_DISABLED
bool WebView::isMediaElement(const QWebElement &element)
{
return (element.tagName().toLower() == QLatin1String("video")
@ -921,7 +965,7 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
++i;
}
if (menu->actions().last() == pageAction(QWebPage::InspectElement)) {
if (menu->actions().last() == pageAction(QWebEnginePage::InspectElement)) {
// We have own Inspect Element action
menu->actions().last()->setVisible(false);
}
@ -953,7 +997,7 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
{
QWebFrame* frameAtPos = page()->frameAt(pos);
QWebEngineFrame* frameAtPos = page()->frameAt(pos);
QAction* action = menu->addAction(tr("&Back"), this, SLOT(back()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack));
@ -1045,8 +1089,8 @@ void WebView::createLinkContextMenu(QMenu* menu, const QWebHitTestResult &hitTes
menu->addSeparator();
if (!selectedText().isEmpty()) {
pageAction(QWebPage::Copy)->setIcon(QIcon::fromTheme("edit-copy"));
menu->addAction(pageAction(QWebPage::Copy));
pageAction(QWebEnginePage::Copy)->setIcon(QIcon::fromTheme("edit-copy"));
menu->addAction(pageAction(QWebEnginePage::Copy));
}
}
@ -1066,8 +1110,8 @@ void WebView::createImageContextMenu(QMenu* menu, const QWebHitTestResult &hitTe
menu->addSeparator();
if (!selectedText().isEmpty()) {
pageAction(QWebPage::Copy)->setIcon(QIcon::fromTheme("edit-copy"));
menu->addAction(pageAction(QWebPage::Copy));
pageAction(QWebEnginePage::Copy)->setIcon(QIcon::fromTheme("edit-copy"));
menu->addAction(pageAction(QWebEnginePage::Copy));
}
}
@ -1078,8 +1122,8 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
QString selectedText = page()->selectedText();
menu->addSeparator();
if (!menu->actions().contains(pageAction(QWebPage::Copy))) {
menu->addAction(pageAction(QWebPage::Copy));
if (!menu->actions().contains(pageAction(QWebEnginePage::Copy))) {
menu->addAction(pageAction(QWebEnginePage::Copy));
}
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send text..."), this, SLOT(sendLinkByMail()))->setData(selectedText);
menu->addSeparator();
@ -1186,74 +1230,77 @@ void WebView::muteMedia()
m_clickedElement.evaluateJavaScript("this.muted = true");
}
}
#endif
void WebView::addSpeedDial()
{
page()->mainFrame()->evaluateJavaScript("addSpeedDial()");
page()->runJavaScript("addSpeedDial()");
}
void WebView::configureSpeedDial()
{
page()->mainFrame()->evaluateJavaScript("configureSpeedDial()");
page()->runJavaScript("configureSpeedDial()");
}
void WebView::reloadAllSpeedDials()
{
page()->mainFrame()->evaluateJavaScript("reloadAll()");
page()->runJavaScript("reloadAll()");
}
void WebView::initializeActions()
{
QAction* undoAction = pageAction(QWebPage::Undo);
QAction* undoAction = pageAction(QWebEnginePage::Undo);
undoAction->setText(tr("&Undo"));
undoAction->setShortcut(QKeySequence("Ctrl+Z"));
undoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
undoAction->setIcon(QIcon::fromTheme(QSL("edit-undo")));
QAction* redoAction = pageAction(QWebPage::Redo);
QAction* redoAction = pageAction(QWebEnginePage::Redo);
redoAction->setText(tr("&Redo"));
redoAction->setShortcut(QKeySequence("Ctrl+Shift+Z"));
redoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
redoAction->setIcon(QIcon::fromTheme(QSL("edit-redo")));
QAction* cutAction = pageAction(QWebPage::Cut);
QAction* cutAction = pageAction(QWebEnginePage::Cut);
cutAction->setText(tr("&Cut"));
cutAction->setShortcut(QKeySequence("Ctrl+X"));
cutAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
cutAction->setIcon(QIcon::fromTheme(QSL("edit-cut")));
QAction* copyAction = pageAction(QWebPage::Copy);
QAction* copyAction = pageAction(QWebEnginePage::Copy);
copyAction->setText(tr("&Copy"));
copyAction->setShortcut(QKeySequence("Ctrl+C"));
copyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
copyAction->setIcon(QIcon::fromTheme(QSL("edit-copy")));
QAction* pasteAction = pageAction(QWebPage::Paste);
QAction* pasteAction = pageAction(QWebEnginePage::Paste);
pasteAction->setText(tr("&Paste"));
pasteAction->setShortcut(QKeySequence("Ctrl+V"));
pasteAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
pasteAction->setIcon(QIcon::fromTheme(QSL("edit-paste")));
QAction* selectAllAction = pageAction(QWebPage::SelectAll);
QAction* selectAllAction = pageAction(QWebEnginePage::SelectAll);
selectAllAction->setText(tr("Select All"));
selectAllAction->setShortcut(QKeySequence("Ctrl+A"));
selectAllAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
selectAllAction->setIcon(QIcon::fromTheme(QSL("edit-select-all")));
QAction* reloadAction = pageAction(QWebPage::Reload);
QAction* reloadAction = pageAction(QWebEnginePage::Reload);
reloadAction->setText(tr("&Reload"));
reloadAction->setIcon(QIcon::fromTheme(QSL("view-refresh")));
QAction* stopAction = pageAction(QWebPage::Stop);
QAction* stopAction = pageAction(QWebEnginePage::Stop);
stopAction->setText(tr("S&top"));
stopAction->setIcon(QIcon::fromTheme(QSL("process-stop")));
pageAction(QWebPage::SetTextDirectionDefault)->setText(tr("Default"));
pageAction(QWebPage::SetTextDirectionLeftToRight)->setText(tr("Left to Right"));
pageAction(QWebPage::SetTextDirectionRightToLeft)->setText(tr("Right to Left"));
pageAction(QWebPage::ToggleBold)->setText(tr("Bold"));
pageAction(QWebPage::ToggleItalic)->setText(tr("Italic"));
pageAction(QWebPage::ToggleUnderline)->setText(tr("Underline"));
#if QTWEBENGINE_DISABLED
pageAction(QWebEnginePage::SetTextDirectionDefault)->setText(tr("Default"));
pageAction(QWebEnginePage::SetTextDirectionLeftToRight)->setText(tr("Left to Right"));
pageAction(QWebEnginePage::SetTextDirectionRightToLeft)->setText(tr("Right to Left"));
pageAction(QWebEnginePage::ToggleBold)->setText(tr("Bold"));
pageAction(QWebEnginePage::ToggleItalic)->setText(tr("Italic"));
pageAction(QWebEnginePage::ToggleUnderline)->setText(tr("Underline"));
#endif
// Make action shortcuts available for webview
addAction(undoAction);
@ -1277,7 +1324,7 @@ void WebView::wheelEvent(QWheelEvent* event)
return;
}
QWebView::wheelEvent(event);
QWebEngineView::wheelEvent(event);
}
void WebView::mousePressEvent(QMouseEvent* event)
@ -1298,19 +1345,22 @@ void WebView::mousePressEvent(QMouseEvent* event)
break;
case Qt::MiddleButton: {
QWebFrame* frame = page()->frameAt(event->pos());
#if QTWEBENGINE_DISABLED
QWebEngineFrame* frame = page()->frameAt(event->pos());
if (frame) {
m_clickedUrl = frame->hitTestContent(event->pos()).linkUrl();
if (!m_clickedUrl.isEmpty()) {
return;
}
}
#endif
break;
}
case Qt::LeftButton: {
QWebFrame* frame = page()->frameAt(event->pos());
#if QTWEBENGINE_DISABLED
QWebEngineFrame* frame = page()->frameAt(event->pos());
if (frame) {
const QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (event->modifiers() & Qt::ControlModifier && isUrlValid(link)) {
@ -1319,13 +1369,14 @@ void WebView::mousePressEvent(QMouseEvent* event)
return;
}
}
#endif
}
default:
break;
}
QWebView::mousePressEvent(event);
QWebEngineView::mousePressEvent(event);
}
void WebView::mouseReleaseEvent(QMouseEvent* event)
@ -1336,7 +1387,8 @@ void WebView::mouseReleaseEvent(QMouseEvent* event)
switch (event->button()) {
case Qt::MiddleButton: {
QWebFrame* frame = page()->frameAt(event->pos());
#if QTWEBENGINE_DISABLED
QWebEngineFrame* frame = page()->frameAt(event->pos());
if (frame) {
const QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (m_clickedUrl == link && isUrlValid(link)) {
@ -1345,6 +1397,7 @@ void WebView::mouseReleaseEvent(QMouseEvent* event)
return;
}
}
#endif
break;
}
@ -1359,7 +1412,7 @@ void WebView::mouseReleaseEvent(QMouseEvent* event)
break;
}
QWebView::mouseReleaseEvent(event);
QWebEngineView::mouseReleaseEvent(event);
}
void WebView::mouseMoveEvent(QMouseEvent* event)
@ -1368,7 +1421,7 @@ void WebView::mouseMoveEvent(QMouseEvent* event)
return;
}
QWebView::mouseMoveEvent(event);
QWebEngineView::mouseMoveEvent(event);
}
void WebView::keyPressEvent(QKeyEvent* event)
@ -1386,6 +1439,7 @@ void WebView::keyPressEvent(QKeyEvent* event)
// event->spontaneous() check guards recursive calling of keyPressEvent
// Events created from app have spontaneous() == false
#if QTWEBENGINE_DISABLED
if (event->spontaneous() && (eventKey == Qt::Key_Left || eventKey == Qt::Key_Right)) {
const QWebElement elementHasCursor = activeElement();
if (!elementHasCursor.isNull()) {
@ -1455,7 +1509,7 @@ void WebView::keyPressEvent(QKeyEvent* event)
case Qt::Key_Down:
if (event->modifiers() & Qt::ShiftModifier) {
triggerPageAction(QWebPage::SelectNextLine);
triggerPageAction(QWebEnginePage::SelectNextLine);
event->accept();
return;
}
@ -1464,10 +1518,10 @@ void WebView::keyPressEvent(QKeyEvent* event)
case Qt::Key_Left:
if (event->modifiers() & Qt::ShiftModifier) {
if (event->modifiers() == Qt::ShiftModifier) {
triggerPageAction(QWebPage::SelectPreviousChar);
triggerPageAction(QWebEnginePage::SelectPreviousChar);
}
else if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
triggerPageAction(QWebPage::SelectPreviousWord);
triggerPageAction(QWebEnginePage::SelectPreviousWord);
}
event->accept();
return;
@ -1477,10 +1531,10 @@ void WebView::keyPressEvent(QKeyEvent* event)
case Qt::Key_Right:
if (event->modifiers() & Qt::ShiftModifier) {
if (event->modifiers() == Qt::ShiftModifier) {
triggerPageAction(QWebPage::SelectNextChar);
triggerPageAction(QWebEnginePage::SelectNextChar);
}
else if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
triggerPageAction(QWebPage::SelectNextWord);
triggerPageAction(QWebEnginePage::SelectNextWord);
}
event->accept();
return;
@ -1490,10 +1544,10 @@ void WebView::keyPressEvent(QKeyEvent* event)
case Qt::Key_Home:
if (event->modifiers() & Qt::ShiftModifier) {
if (event->modifiers() == Qt::ShiftModifier) {
triggerPageAction(QWebPage::SelectStartOfLine);
triggerPageAction(QWebEnginePage::SelectStartOfLine);
}
else if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
triggerPageAction(QWebPage::SelectStartOfDocument);
triggerPageAction(QWebEnginePage::SelectStartOfDocument);
}
event->accept();
return;
@ -1503,10 +1557,10 @@ void WebView::keyPressEvent(QKeyEvent* event)
case Qt::Key_End:
if (event->modifiers() & Qt::ShiftModifier) {
if (event->modifiers() == Qt::ShiftModifier) {
triggerPageAction(QWebPage::SelectEndOfLine);
triggerPageAction(QWebEnginePage::SelectEndOfLine);
}
else if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
triggerPageAction(QWebPage::SelectEndOfDocument);
triggerPageAction(QWebEnginePage::SelectEndOfDocument);
}
event->accept();
return;
@ -1515,12 +1569,12 @@ void WebView::keyPressEvent(QKeyEvent* event)
case Qt::Key_Insert:
if (event->modifiers() == Qt::ControlModifier) {
triggerPageAction(QWebPage::Copy);
triggerPageAction(QWebEnginePage::Copy);
event->accept();
return;
}
if (event->modifiers() == Qt::ShiftModifier) {
triggerPageAction(QWebPage::Paste);
triggerPageAction(QWebEnginePage::Paste);
event->accept();
return;
}
@ -1529,8 +1583,9 @@ void WebView::keyPressEvent(QKeyEvent* event)
default:
break;
}
#endif
QWebView::keyPressEvent(event);
QWebEngineView::keyPressEvent(event);
}
void WebView::keyReleaseEvent(QKeyEvent* event)
@ -1539,23 +1594,29 @@ void WebView::keyReleaseEvent(QKeyEvent* event)
return;
}
QWebView::keyReleaseEvent(event);
QWebEngineView::keyReleaseEvent(event);
}
void WebView::resizeEvent(QResizeEvent* event)
{
QWebView::resizeEvent(event);
QWebEngineView::resizeEvent(event);
#if QTWEBENGINE_DISABLED
emit viewportResized(page()->viewportSize());
#endif
}
void WebView::loadRequest(const LoadRequest &req)
{
m_aboutToLoadUrl = req.url();
#if QTWEBENGINE_DISABLED
if (req.operation() == LoadRequest::GetOperation)
QWebView::load(req.networkRequest());
QWebEngineView::load(req.networkRequest());
else
QWebView::load(req.networkRequest(), QNetworkAccessManager::PostOperation, req.data());
QWebEngineView::load(req.networkRequest(), QNetworkAccessManager::PostOperation, req.data());
#else
QWebEngineView::load(req.url());
#endif
}
bool WebView::eventFilter(QObject* obj, QEvent* event)
@ -1568,6 +1629,7 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)
}
}
#if QTWEBENGINE_DISABLED
// This hack is no longer needed with QtWebKit 2.3 (bundled in Qt 5)
#if QTWEBKIT_TO_2_3
// This function was taken and modified from QTestBrowser to fix bug #33 with flightradar24.com
@ -1588,6 +1650,7 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)
if (ev->type() == QEvent::MouseMove && !(ev->buttons() & Qt::LeftButton)) {
return false;
}
#endif
if (ev->type() == QEvent::MouseButtonPress && !(ev->buttons() & Qt::LeftButton)) {
return false;
@ -1634,5 +1697,5 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)
return false;
}
#endif
return QWebView::eventFilter(obj, event);
return QWebEngineView::eventFilter(obj, event);
}

View File

@ -18,8 +18,11 @@
#ifndef WEBVIEW_H
#define WEBVIEW_H
#include <QWebView>
#include <QIcon>
#include <QWebEngineView>
#if QTWEBENGINE_DISABLED
#include <QWebElement>
#endif
#include "qzcommon.h"
#include "loadrequest.h"
@ -27,7 +30,7 @@
class WebPage;
class LoadRequest;
class QUPZILLA_EXPORT WebView : public QWebView
class QUPZILLA_EXPORT WebView : public QWebEngineView
{
Q_OBJECT
public:
@ -41,7 +44,7 @@ public:
bool isTitleEmpty() const;
WebPage* page() const;
void setPage(QWebPage* page);
void setPage(QWebEnginePage* page);
void load(const LoadRequest &request);
bool loadingError() const;
@ -51,7 +54,9 @@ public:
void fakeLoadingProgress(int progress);
bool hasRss() const;
#if QTWEBENGINE_DISABLED
QWebElement activeElement() const;
#endif
// Set zoom level (0 - 17)
int zoomLevel() const;
@ -100,7 +105,9 @@ public slots:
void back();
void forward();
void printPage(QWebFrame* frame = 0);
#if QTWEBENGINE_DISABLED
void printPage(QWebEngineFrame* frame = 0);
#endif
void sendPageByMail();
void savePageAs();
@ -124,7 +131,9 @@ protected slots:
void downloadUrlToDisk();
void copyImageToClipboard();
void openActionUrl();
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
#if QTWEBENGINE_DISABLED
void showSource(QWebEngineFrame* frame = 0, const QString &selectedHtml = QString());
#endif
void showSiteInfo();
void searchSelectedText();
void searchSelectedTextInBackgroundTab();
@ -136,7 +145,9 @@ protected slots:
void userDefinedOpenUrlInNewTab(const QUrl &url = QUrl(), bool invert = false);
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
#if QTWEBENGINE_DISABLED
void createSearchEngine();
#endif
// Clicked frame actions
void loadClickedFrame();
@ -162,6 +173,7 @@ protected:
void applyZoom();
QUrl lastUrl();
#if QTWEBENGINE_DISABLED
bool isMediaElement(const QWebElement &element);
void checkForForm(QMenu* menu, const QWebElement &element);
@ -171,10 +183,13 @@ protected:
void createImageContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
void createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
void createMediaContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
#endif
private slots:
#if QTWEBENGINE_DISABLED
void pauseMedia();
void muteMedia();
#endif
void frameStateChanged();
void emitChangedUrl();
void checkRss();
@ -196,8 +211,10 @@ private:
QUrl m_aboutToLoadUrl;
QUrl m_lastUrl;
#if QTWEBENGINE_DISABLED
QWebElement m_clickedElement;
QWebFrame* m_clickedFrame;
QWebEngineFrame* m_clickedFrame;
#endif
QUrl m_clickedUrl;
WebPage* m_page;

Some files were not shown because too many files have changed in this diff Show More