diff --git a/src/app/browser/view.nim b/src/app/browser/view.nim index bc50c34f5d..1bce098095 100644 --- a/src/app/browser/view.nim +++ b/src/app/browser/view.nim @@ -27,7 +27,7 @@ QtObject: try: let bookmarksJSON = status_settings.getSetting[string](Setting.Bookmarks, "[]").parseJson for bookmark in bookmarksJSON: - bookmarks.add(Bookmark(url: bookmark["url"].getStr, name: bookmark["name"].getStr, image: "")) + bookmarks.add(Bookmark(url: bookmark["url"].getStr, name: bookmark["name"].getStr)) except: # Bad JSON. Just use the empty array discard @@ -43,7 +43,7 @@ QtObject: notify = bookmarksChanged proc addBookmark*(self: BrowserView, url: string, name: string) {.slot.} = - self.bookmarks.addBookmarkItemToList(Bookmark(url: url, name: name, image: "")) + self.bookmarks.addBookmarkItemToList(Bookmark(url: url, name: name)) discard status_settings.saveSetting(Setting.Bookmarks, $(%self.bookmarks.bookmarks)) self.bookmarksChanged() diff --git a/src/app/browser/views/bookmark_list.nim b/src/app/browser/views/bookmark_list.nim index ea61b35b8b..cab8b4ee42 100644 --- a/src/app/browser/views/bookmark_list.nim +++ b/src/app/browser/views/bookmark_list.nim @@ -5,13 +5,11 @@ import sequtils as sequtils type Bookmark* = ref object name*: string url*: string - image*: string type BookmarkRoles {.pure.} = enum - Name = UserRole + 1, + Name = UserRole + 1 Url = UserRole + 2 - Image = UserRole + 3 QtObject: type @@ -38,7 +36,6 @@ QtObject: case column: of "name": result = bookmark.name of "url": result = bookmark.url - of "image": result = bookmark.image method data(self: BookmarkList, index: QModelIndex, role: int): QVariant = if not index.isValid: @@ -52,13 +49,11 @@ QtObject: case bookmarkItemRole: of BookmarkRoles.Name: result = newQVariant(bookmarkItem.name) of BookmarkRoles.Url: result = newQVariant(bookmarkItem.url) - of BookmarkRoles.Image: result = newQVariant(bookmarkItem.image) method roleNames(self: BookmarkList): Table[int, string] = { BookmarkRoles.Name.int:"name", - BookmarkRoles.Url.int:"url", - BookmarkRoles.Image.int: "image", + BookmarkRoles.Url.int:"url" }.toTable proc addBookmarkItemToList*(self: BookmarkList, bookmark: Bookmark) = @@ -74,7 +69,7 @@ QtObject: proc modifyBookmarkItemFromList*(self: BookmarkList, index: int, url: string, name: string) = let topLeft = self.createIndex(index, index, nil) let bottomRight = self.createIndex(index, index, nil) - self.bookmarks[index] = Bookmark(url: url, name: name, image: "") + self.bookmarks[index] = Bookmark(url: url, name: name) self.dataChanged(topLeft, bottomRight, @[BookmarkRoles.Name.int, BookmarkRoles.Url.int]) proc setNewData*(self: BookmarkList, bookmarkList: seq[Bookmark]) = diff --git a/ui/app/AppLayouts/Browser/BrowserHeader.qml b/ui/app/AppLayouts/Browser/BrowserHeader.qml index e4c1e2ea1b..d6c87537d4 100644 --- a/ui/app/AppLayouts/Browser/BrowserHeader.qml +++ b/ui/app/AppLayouts/Browser/BrowserHeader.qml @@ -80,7 +80,7 @@ Rectangle { Connections { target: browserModel onBookmarksChanged: { - addressBar.currentFavorite = getCurrentFavorite() + addressBar.currentFavorite = getCurrentFavorite(currentWebView.url) } } diff --git a/ui/app/AppLayouts/Browser/BrowserLayout.qml b/ui/app/AppLayouts/Browser/BrowserLayout.qml index 281768a815..f83d2c6148 100644 --- a/ui/app/AppLayouts/Browser/BrowserLayout.qml +++ b/ui/app/AppLayouts/Browser/BrowserLayout.qml @@ -99,9 +99,15 @@ Rectangle { if (index === -1) { return null } + const currentFavicon = currentWebView.icon.toString().replace('image://favicon/', '') + if (!appSettings.bookmarkFavicons[url] || appSettings.bookmarkFavicons[url] !== currentFavicon) { + appSettings.bookmarkFavicons[url] = currentFavicon + } + return { url: url, - name: browserModel.bookmarks.rowData(index, 'name') + name: browserModel.bookmarks.rowData(index, 'name'), + image: appSettings.bookmarkFavicons[url] || "" } } @@ -658,6 +664,7 @@ Rectangle { id: bookmarkBtn text: name onClicked: currentWebView.url = url + source: appSettings.bookmarkFavicons[url] || "" onRightClicked: { favoriteMenu.url = url favoriteMenu.x = bookmarkList.x + bookmarkBtn.x + mouse.x diff --git a/ui/app/AppLayouts/Browser/FaviconImage.qml b/ui/app/AppLayouts/Browser/FaviconImage.qml index d1bfa0195c..58a77552a8 100644 --- a/ui/app/AppLayouts/Browser/FaviconImage.qml +++ b/ui/app/AppLayouts/Browser/FaviconImage.qml @@ -10,5 +10,5 @@ Image { height: 24 sourceSize: Qt.size(width, height) // TODO find a better default favicon - source: faviconImage.currentTab && !!faviconImage.currentTab.icon.toString() ? faviconImage.currentTab.icon : "../../img/globe.svg" + source: faviconImage.currentTab && !!faviconImage.currentTab.icon.toString() ? faviconImage.currentTab.icon : "../../img/compassActive.svg" } diff --git a/ui/app/AppLayouts/Browser/components/BookmarkButton.qml b/ui/app/AppLayouts/Browser/components/BookmarkButton.qml index 0450f8fff3..ecbc0c0bf7 100644 --- a/ui/app/AppLayouts/Browser/components/BookmarkButton.qml +++ b/ui/app/AppLayouts/Browser/components/BookmarkButton.qml @@ -4,7 +4,7 @@ import "../../../../shared/status" import "../../../../imports" Item { - property url source: "../../../img/globe.svg" + property url source property string text signal clicked(mouse: var) signal rightClicked(mouse: var) @@ -15,7 +15,7 @@ Item { SVGImage { id: bookmarkImage - source: root.source + source: !!root.source && !!root.source.toString() ? root.source :"../../../img/compassActive.svg" anchors.horizontalCenter: parent.horizontalCenter width: 48 height: 48 diff --git a/ui/main.qml b/ui/main.qml index 8789029822..0809583fba 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -112,6 +112,7 @@ ApplicationWindow { property int fontSize: Constants.fontSizeM // Browser settings + property var bookmarkFavicons: ({}) property bool autoLoadImages: true property bool javaScriptEnabled: true property bool errorPageEnabled: true