-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browser,ui): port to Qt WebEngine (#1125)
- Loading branch information
Showing
24 changed files
with
492 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/* Dark mode (see #466). */ | ||
/* TODO: Check if we need -webkit-filter for old Qt WebKit. */ | ||
|
||
html { | ||
-webkit-filter: invert() hue-rotate(180deg) contrast(70%); | ||
filter: invert() hue-rotate(180deg) contrast(70%); | ||
background-color: #262626 !important; | ||
filter: invert(1) hue-rotate(180deg) contrast(70%) !important; | ||
} | ||
|
||
html img { | ||
-webkit-filter: invert() hue-rotate(180deg) contrast(120%); | ||
filter: invert() hue-rotate(180deg) contrast(120%); | ||
filter: invert(1) hue-rotate(180deg) contrast(120%) !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
add_library(Browser STATIC | ||
searchtoolbar.cpp | ||
urlrequestinterceptor.cpp | ||
webbridge.cpp | ||
webcontrol.cpp | ||
webpage.cpp | ||
webview.cpp | ||
) | ||
|
||
target_link_libraries(Browser) | ||
|
||
find_package(Qt5 COMPONENTS WebKitWidgets REQUIRED) | ||
target_link_libraries(Browser Qt5::WebKitWidgets) | ||
find_package(Qt5 COMPONENTS WebEngineWidgets WebChannel REQUIRED) | ||
target_link_libraries(Browser Qt5::WebEngineWidgets Qt5::WebChannel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2020 Oleg Shparber | ||
** Copyright (C) 2019 Kay Gawlik | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "urlrequestinterceptor.h" | ||
|
||
#include <core/application.h> | ||
#include <core/networkaccessmanager.h> | ||
#include <core/settings.h> | ||
|
||
using namespace Zeal::Browser; | ||
|
||
UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) | ||
: QWebEngineUrlRequestInterceptor(parent) | ||
{ | ||
} | ||
|
||
void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) | ||
{ | ||
QUrl requestUrl = info.requestUrl(); | ||
QUrl firstPartyUrl = info.firstPartyUrl(); | ||
|
||
if (!firstPartyUrl.isValid()) { | ||
return; | ||
} | ||
|
||
bool firstPartyUrlLocal = Core::NetworkAccessManager::isLocalUrl(firstPartyUrl); | ||
bool requestUrlLocal = Core::NetworkAccessManager::isLocalUrl(requestUrl); | ||
|
||
if (firstPartyUrlLocal && requestUrlLocal) { | ||
return; | ||
} | ||
|
||
if (firstPartyUrlLocal != requestUrlLocal) { | ||
blockRequest(info); | ||
return; | ||
} | ||
|
||
Core::Settings::ExternalLinkPolicy linkPolicy = Core::Application::instance()->settings()->externalLinkPolicy; | ||
switch (info.resourceType()) { | ||
case QWebEngineUrlRequestInfo::ResourceTypeMainFrame: | ||
if (linkPolicy != Core::Settings::ExternalLinkPolicy::Open | ||
&& linkPolicy != Core::Settings::ExternalLinkPolicy::Ask) { | ||
blockRequest(info); | ||
} | ||
break; | ||
case QWebEngineUrlRequestInfo::ResourceTypeSubFrame: | ||
if (linkPolicy != Core::Settings::ExternalLinkPolicy::Open) { | ||
blockRequest(info); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void UrlRequestInterceptor::blockRequest(QWebEngineUrlRequestInfo &info) | ||
{ | ||
info.block(true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2020 Oleg Shparber | ||
** Copyright (C) 2019 Kay Gawlik | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef ZEAL_BROWSER_URLREQUESTINTERCEPTOR_H | ||
#define ZEAL_BROWSER_URLREQUESTINTERCEPTOR_H | ||
|
||
#include <QWebEngineUrlRequestInterceptor> | ||
|
||
namespace Zeal { | ||
namespace Browser { | ||
|
||
class UrlRequestInterceptor final : public QWebEngineUrlRequestInterceptor | ||
{ | ||
Q_OBJECT | ||
Q_DISABLE_COPY(UrlRequestInterceptor) | ||
public: | ||
UrlRequestInterceptor(QObject *parent = nullptr); | ||
void interceptRequest(QWebEngineUrlRequestInfo &info) override; | ||
|
||
private: | ||
void blockRequest(QWebEngineUrlRequestInfo &info); | ||
}; | ||
|
||
} // namespace Browser | ||
} // namespace Zeal | ||
|
||
#endif // ZEAL_BROWSER_URLREQUESTINTERCEPTOR_H |
Oops, something went wrong.
5360da3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the commit mean we don't need webkit anymore?
5360da3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is soooo ... good. With this change, I don't need to patch CMakeslist.txt to make zealdoc compilable in macOS.
5360da3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you make qt5-webkit as an backend option as you said in this PR? If you won't, I will remove the patch for head from brew formula and also remove my personal maintained qt5-webkit formula.
5360da3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markwu even if we add Qt WebKit back, that doesn't mean it will be required. If you want, you can only support Qt WebEngine.
I am not sure if Qt WebKit will make a comeback any time soon, its development is just too slow.
5360da3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trollixx It sounds good. Thanks.