Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

bring back favicons #141

Merged
merged 9 commits into from Feb 9, 2019
7 changes: 7 additions & 0 deletions src/app/favicon-fetcher.cpp
Expand Up @@ -83,6 +83,13 @@ void FaviconFetcher::setUrl(const QUrl& url)
return;
}

// QtWebEngine icons are provided as e.g. image://favicon/https://duckduckgo.com/favicon.ico
if ((url.scheme() == "image") && (url.host() == "favicon"))
{
setLocalUrl(url);
return;
}

QString id = url.toString(QUrl::None);

QString extension;
Expand Down
6 changes: 4 additions & 2 deletions src/app/webbrowser/Browser.qml
Expand Up @@ -220,7 +220,8 @@ BrowserView {
},
Actions.Bookmark {
enabled: currentWebview
onTriggered: internal.addBookmark(currentWebview.url, currentWebview.title, currentWebview.icon)
// QtWebEngine icons are provided as e.g. image://favicon/https://duckduckgo.com/favicon.ico
onTriggered: internal.addBookmark(currentWebview.url, currentWebview.title, (currentWebview.icon.toString().substring(0, 16) == "image://favicon/") ? currentWebview.icon.toString().substring(16) : currentWebview.icon)
},
Actions.NewTab {
onTriggered: internal.openUrlInNewTab("", true)
Expand Down Expand Up @@ -589,7 +590,8 @@ BrowserView {
onCloseTabRequested: internal.closeCurrentTab()
onToggleBookmark: {
if (isCurrentUrlBookmarked()) BookmarksModel.remove(tab.url)
else internal.addBookmark(tab.url, tab.title, tab.icon)
// QtWebEngine icons are provided as e.g. image://favicon/https://duckduckgo.com/favicon.ico
else internal.addBookmark(tab.url, tab.title, (tab.icon.toString().substring(0,16) == "image://favicon/") ? tab.icon.toString().substring(16) : tab.icon)
balcy marked this conversation as resolved.
Show resolved Hide resolved
}
onWebviewChanged: bookmarked = isCurrentUrlBookmarked()
Connections {
Expand Down
19 changes: 13 additions & 6 deletions src/app/webbrowser/TabComponent.qml
Expand Up @@ -323,7 +323,7 @@ Component {
}

onLoadingChanged: {
if (loadRequest.status == WebEngineLoadRequest.LoadSucceededStatus) {
if (loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus) {
chrome.findInPageMode = false
webviewInternal.titleSet = false
webviewInternal.title = title
Expand All @@ -333,17 +333,18 @@ Component {
return
}

if (loadRequest.status == WebEngineLoadRequest.LoadSucceededStatus) {
if (loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus) {
webviewInternal.storedUrl = loadRequest.url
HistoryModel.add(loadRequest.url, title, icon)
// note: at this point the icon is an empty string most times, not sure why (seems to be set after this event)
HistoryModel.add(loadRequest.url, title, (icon.toString().substring(0,16) == "image://favicon/") ? icon.toString().substring(16) : icon)
}

// If the page has started, stopped, redirected, errored
// then clear the cache for the history update
// Otherwise if no title change has occurred the next title
// change will be the url of the next page causing the
// history entry to be incorrect (pad.lv/1603835)
if (loadRequest.status == WebEngineLoadRequest.LoadFailedStatus) {
if (loadRequest.status === WebEngineLoadRequest.LoadFailedStatus) {
webviewInternal.titleSet = true
webviewInternal.storedUrl = ""
}
Expand All @@ -363,12 +364,18 @@ Component {
}
}
}
*/
onIconChanged: {

if (webviewimpl.incognito) {
return
}

if (webviewInternal.storedUrl.toString()) {
HistoryModel.update(webviewInternal.storedUrl, webviewInternal.title, icon)
HistoryModel.update(webviewInternal.storedUrl, webviewInternal.title, (icon.toString().substring(0,16) == "image://favicon/") ? icon.toString().substring(16) : icon)
}
}

/*
//onGeolocationPermissionRequested: requestGeolocationPermission(request)
*/
UniversalSuperBox marked this conversation as resolved.
Show resolved Hide resolved
property var certificateError
Expand Down