-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
508 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,28 @@ | ||
/* Dark mode (see #466). */ | ||
/* TODO: Check if we need -webkit-filter for old Qt WebKit. */ | ||
|
||
body { | ||
background-color: white !important; | ||
transition-duration: 0s !important; | ||
} | ||
|
||
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; | ||
} | ||
|
||
::-webkit-scrollbar { | ||
width: 15px; | ||
height: 15px; | ||
} | ||
::-webkit-scrollbar-track-piece { | ||
background-color: black; | ||
} | ||
::-webkit-scrollbar-thumb:vertical { | ||
height: 30px; | ||
background-color: #0A4C95; | ||
} |
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.