mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Added option to open external protocols in system apps.
- so for example, links with apt: or tomahawk: protocol can be opened - it will ask user whether he wants to open link in external app and give option to remember the choice
This commit is contained in:
parent
48b7aed86b
commit
99722aa7aa
@ -18,9 +18,6 @@ win32 {
|
|||||||
DEFINES *= QT_NO_URL_CAST_FROM_STRING
|
DEFINES *= QT_NO_URL_CAST_FROM_STRING
|
||||||
DEFINES *= QT_USE_QSTRINGBUILDER
|
DEFINES *= QT_USE_QSTRINGBUILDER
|
||||||
|
|
||||||
##It won't compile on windows with this define. Some bug in qtsingleapp / qvector template
|
|
||||||
!win32: !CONFIG(debug, debug|release): DEFINES *= QT_NO_DEBUG_OUTPUT
|
|
||||||
|
|
||||||
CONFIG(debug, debug|release): DEFINES *= QUPZILLA_DEBUG_BUILD
|
CONFIG(debug, debug|release): DEFINES *= QUPZILLA_DEBUG_BUILD
|
||||||
|
|
||||||
d_no_system_datapath = $$(NO_SYSTEM_DATAPATH)
|
d_no_system_datapath = $$(NO_SYSTEM_DATAPATH)
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "webpage.h"
|
#include "webpage.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "locationbarsettings.h"
|
#include "locationbarsettings.h"
|
||||||
#include "webviewsettings.h"
|
#include "websettings.h"
|
||||||
#include "clearprivatedata.h"
|
#include "clearprivatedata.h"
|
||||||
#include "commandlineoptions.h"
|
#include "commandlineoptions.h"
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ void MainApplication::loadSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LocationBarSettings::loadSettings();
|
LocationBarSettings::loadSettings();
|
||||||
WebViewSettings::loadSettings();
|
WebSettings::loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainApplication::reloadSettings()
|
void MainApplication::reloadSettings()
|
||||||
|
@ -162,14 +162,14 @@ SOURCES += \
|
|||||||
popupwindow/popuplocationbar.cpp \
|
popupwindow/popuplocationbar.cpp \
|
||||||
webview/tabbedwebview.cpp \
|
webview/tabbedwebview.cpp \
|
||||||
webview/webview.cpp \
|
webview/webview.cpp \
|
||||||
webview/webviewsettings.cpp \
|
|
||||||
preferences/pluginlistdelegate.cpp \
|
preferences/pluginlistdelegate.cpp \
|
||||||
popupwindow/popupstatusbarmessage.cpp \
|
popupwindow/popupstatusbarmessage.cpp \
|
||||||
other/licenseviewer.cpp \
|
other/licenseviewer.cpp \
|
||||||
bookmarksimport/bookmarksimporticonfetcher.cpp \
|
bookmarksimport/bookmarksimporticonfetcher.cpp \
|
||||||
other/checkboxdialog.cpp \
|
other/checkboxdialog.cpp \
|
||||||
network/schemehandler.cpp \
|
network/schemehandler.cpp \
|
||||||
tools/plaineditwithlines.cpp
|
tools/plaineditwithlines.cpp \
|
||||||
|
webview/websettings.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
webview/tabpreview.h \
|
webview/tabpreview.h \
|
||||||
@ -303,7 +303,6 @@ HEADERS += \
|
|||||||
webview/tabbedwebview.h \
|
webview/tabbedwebview.h \
|
||||||
webview/webview.h \
|
webview/webview.h \
|
||||||
app/qz_namespace.h \
|
app/qz_namespace.h \
|
||||||
webview/webviewsettings.h \
|
|
||||||
preferences/pluginlistdelegate.h \
|
preferences/pluginlistdelegate.h \
|
||||||
popupwindow/popupstatusbarmessage.h \
|
popupwindow/popupstatusbarmessage.h \
|
||||||
other/licenseviewer.h \
|
other/licenseviewer.h \
|
||||||
@ -311,7 +310,8 @@ HEADERS += \
|
|||||||
other/checkboxdialog.h \
|
other/checkboxdialog.h \
|
||||||
network/schemehandler.h \
|
network/schemehandler.h \
|
||||||
tools/plaineditwithlines.h \
|
tools/plaineditwithlines.h \
|
||||||
sidebar/sidebarinterface.h
|
sidebar/sidebarinterface.h \
|
||||||
|
webview/websettings.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "networkmanagerproxy.h"
|
#include "networkmanagerproxy.h"
|
||||||
#include "adblockicon.h"
|
#include "adblockicon.h"
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
|
#include "websettings.h"
|
||||||
|
|
||||||
#ifdef NONBLOCK_JS_DIALOGS
|
#ifdef NONBLOCK_JS_DIALOGS
|
||||||
#include "ui_jsconfirm.h"
|
#include "ui_jsconfirm.h"
|
||||||
@ -282,6 +283,52 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebPage::handleUnknownProtocol(const QUrl &url)
|
||||||
|
{
|
||||||
|
const QString &protocol = url.scheme();
|
||||||
|
|
||||||
|
if (WebSettings::blockedProtocols.contains(protocol)) {
|
||||||
|
qDebug() << "WebPage::handleUnknownProtocol Protocol" << protocol << "is blocked!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WebSettings::autoOpenProtocols.contains(protocol)) {
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &text = tr("QupZilla cannot handle <b>%1:</b> links. The requested link "
|
||||||
|
"is <ul><li>%2</li></ul>Do you want QupZilla to try "
|
||||||
|
"open this link in system application?<br/>").arg(protocol, url.toString());
|
||||||
|
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, view());
|
||||||
|
dialog.setText(text);
|
||||||
|
dialog.setCheckBoxText(tr("Remember my choice for this protocol"));
|
||||||
|
dialog.setWindowTitle(tr("External Protocol Request"));
|
||||||
|
dialog.setIcon(IconProvider::standardIcon(QStyle::SP_MessageBoxQuestion));
|
||||||
|
|
||||||
|
switch (dialog.exec()) {
|
||||||
|
case QDialog::Accepted:
|
||||||
|
if (dialog.isChecked()) {
|
||||||
|
WebSettings::autoOpenProtocols.append(protocol);
|
||||||
|
WebSettings::saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QDialog::Rejected:
|
||||||
|
if (dialog.isChecked()) {
|
||||||
|
WebSettings::blockedProtocols.append(protocol);
|
||||||
|
WebSettings::saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebPage::downloadRequested(const QNetworkRequest &request)
|
void WebPage::downloadRequested(const QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
DownloadManager* dManager = mApp->downManager();
|
DownloadManager* dManager = mApp->downManager();
|
||||||
@ -531,6 +578,10 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
|
|||||||
case QNetworkReply::UnknownNetworkError:
|
case QNetworkReply::UnknownNetworkError:
|
||||||
errorString = exOption->errorString.isEmpty() ? tr("Unknown network error") : exOption->errorString;
|
errorString = exOption->errorString.isEmpty() ? tr("Unknown network error") : exOption->errorString;
|
||||||
break;
|
break;
|
||||||
|
case QNetworkReply::ProtocolUnknownError:
|
||||||
|
handleUnknownProtocol(exOption->url);
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
case QNetworkReply::ContentAccessDenied:
|
case QNetworkReply::ContentAccessDenied:
|
||||||
if (exOption->errorString.startsWith("AdBlockRule")) {
|
if (exOption->errorString.startsWith("AdBlockRule")) {
|
||||||
if (exOption->frame != erPage->mainFrame()) { //Content in <iframe>
|
if (exOption->frame != erPage->mainFrame()) { //Content in <iframe>
|
||||||
|
@ -102,11 +102,13 @@ protected:
|
|||||||
QWebPage* createWindow(QWebPage::WebWindowType type);
|
QWebPage* createWindow(QWebPage::WebWindowType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool supportsExtension(Extension extension) const;
|
bool supportsExtension(Extension extension) const;
|
||||||
virtual bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||||
bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type);
|
bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type);
|
||||||
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
||||||
|
|
||||||
|
void handleUnknownProtocol(const QUrl &url);
|
||||||
|
|
||||||
static QString m_lastUploadLocation;
|
static QString m_lastUploadLocation;
|
||||||
static QString m_userAgent;
|
static QString m_userAgent;
|
||||||
static QString m_fakeUserAgent;
|
static QString m_fakeUserAgent;
|
||||||
|
@ -15,17 +15,16 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "webviewsettings.h"
|
#include "websettings.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
int WebViewSettings::defaultZoom = 100;
|
int WebSettings::defaultZoom = 100;
|
||||||
bool WebViewSettings::loadTabsOnActivation = false;
|
bool WebSettings::loadTabsOnActivation = false;
|
||||||
|
|
||||||
WebViewSettings::WebViewSettings()
|
QStringList WebSettings::autoOpenProtocols;
|
||||||
{
|
QStringList WebSettings::blockedProtocols;
|
||||||
}
|
|
||||||
|
|
||||||
void WebViewSettings::loadSettings()
|
void WebSettings::loadSettings()
|
||||||
{
|
{
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("Web-Browser-Settings");
|
settings.beginGroup("Web-Browser-Settings");
|
||||||
@ -33,5 +32,19 @@ void WebViewSettings::loadSettings()
|
|||||||
defaultZoom = settings.value("DefaultZoom", 100).toInt();
|
defaultZoom = settings.value("DefaultZoom", 100).toInt();
|
||||||
loadTabsOnActivation = settings.value("LoadTabsOnActivation", false).toBool();
|
loadTabsOnActivation = settings.value("LoadTabsOnActivation", false).toBool();
|
||||||
|
|
||||||
|
autoOpenProtocols = settings.value("AutomaticallyOpenProtocols", QStringList()).toStringList();
|
||||||
|
blockedProtocols = settings.value("BlockOpeningProtocols", QStringList()).toStringList();
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebSettings::saveSettings()
|
||||||
|
{
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup("Web-Browser-Settings");
|
||||||
|
|
||||||
|
settings.setValue("AutomaticallyOpenProtocols", autoOpenProtocols);
|
||||||
|
settings.setValue("BlockOpeningProtocols", blockedProtocols);
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
@ -20,15 +20,21 @@
|
|||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
|
||||||
class WebViewSettings
|
#include <QStringList>
|
||||||
|
|
||||||
|
class WebSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WebViewSettings();
|
WebSettings();
|
||||||
|
|
||||||
static void loadSettings();
|
static void loadSettings();
|
||||||
|
static void saveSettings();
|
||||||
|
|
||||||
static int defaultZoom;
|
static int defaultZoom;
|
||||||
static bool loadTabsOnActivation;
|
static bool loadTabsOnActivation;
|
||||||
|
|
||||||
|
static QStringList autoOpenProtocols;
|
||||||
|
static QStringList blockedProtocols;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WEBVIEWSETTINGS_H
|
#endif // WEBVIEWSETTINGS_H
|
@ -23,7 +23,7 @@
|
|||||||
#include "tabwidget.h"
|
#include "tabwidget.h"
|
||||||
#include "locationbar.h"
|
#include "locationbar.h"
|
||||||
#include "globalfunctions.h"
|
#include "globalfunctions.h"
|
||||||
#include "webviewsettings.h"
|
#include "websettings.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWebHistory>
|
#include <QWebHistory>
|
||||||
@ -221,7 +221,7 @@ bool WebTab::isRestored() const
|
|||||||
|
|
||||||
void WebTab::restoreTab(const WebTab::SavedTab &tab)
|
void WebTab::restoreTab(const WebTab::SavedTab &tab)
|
||||||
{
|
{
|
||||||
if (WebViewSettings::loadTabsOnActivation) {
|
if (WebSettings::loadTabsOnActivation) {
|
||||||
m_savedTab = tab;
|
m_savedTab = tab;
|
||||||
int index = tabIndex();
|
int index = tabIndex();
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "browsinglibrary.h"
|
#include "browsinglibrary.h"
|
||||||
#include "bookmarksmanager.h"
|
#include "bookmarksmanager.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "webviewsettings.h"
|
#include "websettings.h"
|
||||||
#include "enhancedmenu.h"
|
#include "enhancedmenu.h"
|
||||||
#include "pluginproxy.h"
|
#include "pluginproxy.h"
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ void WebView::setPage(QWebPage* page)
|
|||||||
QWebView::setPage(page);
|
QWebView::setPage(page);
|
||||||
m_page = qobject_cast<WebPage*>(page);
|
m_page = qobject_cast<WebPage*>(page);
|
||||||
|
|
||||||
setZoom(WebViewSettings::defaultZoom);
|
setZoom(WebSettings::defaultZoom);
|
||||||
connect(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged()));
|
connect(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged()));
|
||||||
connect(m_page, SIGNAL(privacyChanged(bool)), this, SIGNAL(privacyChanged(bool)));
|
connect(m_page, SIGNAL(privacyChanged(bool)), this, SIGNAL(privacyChanged(bool)));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user