mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Fixed issue with infinite opening mailto: links in QupZilla
- when xdg-open tries to open mailto: links again in QupZilla
This commit is contained in:
parent
014ae5aff6
commit
14928e6bc6
@ -58,6 +58,7 @@ QString WebPage::s_lastUploadLocation = QDir::homePath();
|
|||||||
QString WebPage::s_userAgent;
|
QString WebPage::s_userAgent;
|
||||||
QString WebPage::s_fakeUserAgent;
|
QString WebPage::s_fakeUserAgent;
|
||||||
QUrl WebPage::s_lastUnsupportedUrl;
|
QUrl WebPage::s_lastUnsupportedUrl;
|
||||||
|
QTime WebPage::s_lastUnsupportedUrlTime;
|
||||||
QList<WebPage*> WebPage::s_livingPages;
|
QList<WebPage*> WebPage::s_livingPages;
|
||||||
|
|
||||||
WebPage::WebPage(QupZilla* mainClass)
|
WebPage::WebPage(QupZilla* mainClass)
|
||||||
@ -292,15 +293,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
|
|||||||
|
|
||||||
case QNetworkReply::ProtocolUnknownError: {
|
case QNetworkReply::ProtocolUnknownError: {
|
||||||
qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";
|
qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";
|
||||||
|
desktopServicesOpen(url);
|
||||||
// We will open last unsupported url only once
|
|
||||||
// (to prevent endless loop in case QDesktopServices::openUrl decide
|
|
||||||
// to open the url again in QupZilla )
|
|
||||||
|
|
||||||
if (s_lastUnsupportedUrl != url) {
|
|
||||||
s_lastUnsupportedUrl = url;
|
|
||||||
QDesktopServices::openUrl(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
return;
|
return;
|
||||||
@ -323,7 +316,7 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WebSettings::autoOpenProtocols.contains(protocol)) {
|
if (WebSettings::autoOpenProtocols.contains(protocol)) {
|
||||||
QDesktopServices::openUrl(url);
|
desktopServicesOpen(url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,6 +355,21 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebPage::desktopServicesOpen(const QUrl &url)
|
||||||
|
{
|
||||||
|
// Open same url only once in 2 secs
|
||||||
|
|
||||||
|
if (s_lastUnsupportedUrl != url || QTime::currentTime() > s_lastUnsupportedUrlTime.addSecs(2)) {
|
||||||
|
s_lastUnsupportedUrl = url;
|
||||||
|
s_lastUnsupportedUrlTime = QTime::currentTime();
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarning() << "WebPage::desktopServicesOpen Url" << url << "has already been opened!\n"
|
||||||
|
"Ignoring it to prevent infinite loop!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebPage::downloadRequested(const QNetworkRequest &request)
|
void WebPage::downloadRequested(const QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
DownloadManager* dManager = mApp->downManager();
|
DownloadManager* dManager = mApp->downManager();
|
||||||
@ -453,13 +461,13 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
|
|||||||
const QString &scheme = request.url().scheme();
|
const QString &scheme = request.url().scheme();
|
||||||
|
|
||||||
if (scheme == "mailto" || scheme == "ftp") {
|
if (scheme == "mailto" || scheme == "ftp") {
|
||||||
QDesktopServices::openUrl(request.url());
|
desktopServicesOpen(request.url());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == QWebPage::NavigationTypeFormResubmitted) {
|
if (type == QWebPage::NavigationTypeFormResubmitted) {
|
||||||
QString message = tr("To show this page, QupZilla must resend request which do it again \n"
|
QString message = tr("To show this page, QupZilla must resend request which do it again \n"
|
||||||
"(like searching on making an shoping, which has been already done.)");
|
"(like searching on making an shopping, which has been already done.)");
|
||||||
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
||||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -115,11 +115,13 @@ private:
|
|||||||
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
||||||
|
|
||||||
void handleUnknownProtocol(const QUrl &url);
|
void handleUnknownProtocol(const QUrl &url);
|
||||||
|
void desktopServicesOpen(const QUrl &url);
|
||||||
|
|
||||||
static QString s_lastUploadLocation;
|
static QString s_lastUploadLocation;
|
||||||
static QString s_userAgent;
|
static QString s_userAgent;
|
||||||
static QString s_fakeUserAgent;
|
static QString s_fakeUserAgent;
|
||||||
static QUrl s_lastUnsupportedUrl;
|
static QUrl s_lastUnsupportedUrl;
|
||||||
|
static QTime s_lastUnsupportedUrlTime;
|
||||||
static QList<WebPage*> s_livingPages;
|
static QList<WebPage*> s_livingPages;
|
||||||
|
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
Loading…
Reference in New Issue
Block a user