From 27ff37e1665350ead7f44196a831dbe61b512b18 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Tue, 17 Aug 2021 19:03:03 +0200 Subject: [PATCH] fix(@desktop/browser): Favorite list get truncated when its too long Adapted the bookmark list to a grid view to accomodate items when the list gets long. Max column size is 7 and in case screen cannot show 7 columns it will flow to the next row. Also added ideinticon for a website with no icon Fixed the issue of DApps launching on all new tabs. fixes #2009 --- ui/StatusQ | 2 +- .../AppLayouts/Browser/AddFavoriteModal.qml | 3 + ui/app/AppLayouts/Browser/BrowserHeader.qml | 3 + ui/app/AppLayouts/Browser/BrowserLayout.qml | 8 ++- ui/app/AppLayouts/Browser/FavoritesList.qml | 58 +++++++++---------- .../Browser/components/BookmarkButton.qml | 35 +++++++++-- 6 files changed, 71 insertions(+), 38 deletions(-) diff --git a/ui/StatusQ b/ui/StatusQ index d24c2e6208..d16719adda 160000 --- a/ui/StatusQ +++ b/ui/StatusQ @@ -1 +1 @@ -Subproject commit d24c2e6208062e27c4bd16915ab6b14aec05138b +Subproject commit d16719adda061e0d33bf8c7959776b5f3773a775 diff --git a/ui/app/AppLayouts/Browser/AddFavoriteModal.qml b/ui/app/AppLayouts/Browser/AddFavoriteModal.qml index be5e7e02a8..0bbd6d66d2 100644 --- a/ui/app/AppLayouts/Browser/AddFavoriteModal.qml +++ b/ui/app/AppLayouts/Browser/AddFavoriteModal.qml @@ -147,7 +147,10 @@ ModalPopup { } if (!popup.modifiyModal) { + // remove "add favorite" button at the end, add new bookmark, add "add favorite" button back + browserModel.removeBookmark("") browserModel.addBookmark(urlInput.text, nameInput.text) + browserModel.addBookmark("", qsTr("Add Favorite")) } else if (popup.ogName !== nameInput.text || popup.ogUrl !== urlInput.text) { browserModel.modifyBookmark(popup.ogUrl, urlInput.text, nameInput.text) } diff --git a/ui/app/AppLayouts/Browser/BrowserHeader.qml b/ui/app/AppLayouts/Browser/BrowserHeader.qml index 5853e806ea..174d825e9c 100644 --- a/ui/app/AppLayouts/Browser/BrowserHeader.qml +++ b/ui/app/AppLayouts/Browser/BrowserHeader.qml @@ -161,7 +161,10 @@ Rectangle { anchors.rightMargin: Style.current.halfPadding onClicked: { if (!addressBar.currentFavorite) { + // remove "add favorite" button at the end, add new bookmark, add "add favorite" button back + browserModel.removeBookmark("") browserModel.addBookmark(currentWebView.url, currentWebView.title) + browserModel.addBookmark("", qsTr("Add Favorite")) } addFavoriteModal.modifiyModal = true diff --git a/ui/app/AppLayouts/Browser/BrowserLayout.qml b/ui/app/AppLayouts/Browser/BrowserLayout.qml index d379730685..5770edf90f 100644 --- a/ui/app/AppLayouts/Browser/BrowserLayout.qml +++ b/ui/app/AppLayouts/Browser/BrowserLayout.qml @@ -458,6 +458,10 @@ property Component sendTransactionModalComponent: SignTransactionModal {} return qsTrId("new-tab") }) + if (createAsStartPage) { + tab.item.url = "https://dap.ps" + } + tab.item.profile = profile; if (appSettings.browserHomepage !== "") { tab.item.url = appSettings.browserHomepage @@ -512,7 +516,6 @@ property Component sendTransactionModalComponent: SignTransactionModal {} anchors.top: parent.top anchors.topMargin: browserHeader.height focus: true - url: "https://dap.ps" webChannel: channel onLinkHovered: function(hoveredUrl) { if (hoveredUrl === "") @@ -673,7 +676,8 @@ property Component sendTransactionModalComponent: SignTransactionModal {} anchors.horizontalCenter: emptyPageImage.horizontalCenter anchors.top: emptyPageImage.bottom anchors.topMargin: 30 - width: parent.width - Style.current.bigPadding * 2 + width: (parent.width < 700) ? (Math.floor(parent.width/cellWidth)*cellWidth) : 700 + height: parent.height - emptyPageImage.height - 20 } } } diff --git a/ui/app/AppLayouts/Browser/FavoritesList.qml b/ui/app/AppLayouts/Browser/FavoritesList.qml index f0c230da51..33b9f1fa25 100644 --- a/ui/app/AppLayouts/Browser/FavoritesList.qml +++ b/ui/app/AppLayouts/Browser/FavoritesList.qml @@ -4,41 +4,37 @@ import "../../../shared/status" import "../../../imports" import "./components" -Item { - id: bookmarkListContainer - - ListView { - id: bookmarkList - model: browserModel.bookmarks - spacing: Style.current.padding - orientation : ListView.Horizontal - anchors.horizontalCenter: parent.horizontalCenter - anchors.horizontalCenterOffset: -(addBookmarkBtn.width + spacing) /2 - width: Math.min(childrenRect.width, parent.width - addBookmarkBtn.width - spacing) - delegate: BookmarkButton { - id: bookmarkBtn - text: name - onClicked: { - currentWebView.url = determineRealURL(url) - } - source: imageUrl - onRightClicked: { - favoriteMenu.url = url - favoriteMenu.x = bookmarkList.x + bookmarkBtn.x + mouse.x - favoriteMenu.y = Qt.binding(function () {return bookmarkListContainer.y + mouse.y + favoriteMenu.height}) - favoriteMenu.open() +GridView { + id: bookmarkGrid + cellWidth: 100 + cellHeight: 100 + model: browserModel.bookmarks + delegate: BookmarkButton { + id: bookmarkBtn + text: name + source: imageUrl + webUrl: determineRealURL(url) + onClicked: { + if (!webUrl.toString()) { + addFavoriteModal.open() + } else { + currentWebView.url = webUrl } } + onRightClicked: { + favoriteMenu.url = url + favoriteMenu.x = bookmarkGrid.x + bookmarkBtn.x + mouse.x + favoriteMenu.y = Qt.binding(function () {return bookmarkGrid.y + mouse.y + favoriteMenu.height}) + favoriteMenu.open() + } } - BookmarkButton { - id: addBookmarkBtn - //% "Add favorite" - text: qsTrId("add-favorite") - onClicked: { - addFavoriteModal.open() + Component.onCompleted: { + // Add fav button at the end of the grid + var index = browserModel.bookmarks.getBookmarkIndexByUrl("") + if (index !== -1) { + browserModel.removeBookmark("") } - anchors.left: bookmarkList.right - anchors.leftMargin: bookmarkList.spacing + browserModel.addBookmark("", qsTr("Add Favorite")) } } diff --git a/ui/app/AppLayouts/Browser/components/BookmarkButton.qml b/ui/app/AppLayouts/Browser/components/BookmarkButton.qml index ca9be00064..ec2cdee615 100644 --- a/ui/app/AppLayouts/Browser/components/BookmarkButton.qml +++ b/ui/app/AppLayouts/Browser/components/BookmarkButton.qml @@ -1,9 +1,14 @@ import QtQuick 2.13 + +import StatusQ.Components 0.1 as StatusQ +import StatusQ.Core.Theme 0.1 + import "../../../../shared" import "../../../../shared/status" import "../../../../imports" Item { + property url webUrl property url source property string text signal clicked(mouse: var) @@ -11,24 +16,46 @@ Item { id: root width: 74 - height: bookmarkImage.height + bookmarkName.height + Style.current.halfPadding + height: 48 + Style.current.halfPadding SVGImage { id: bookmarkImage - source: !!root.source && !!root.source.toString() ? root.source :"../../../img/compassActive.svg" - anchors.horizontalCenter: parent.horizontalCenter width: 48 height: 48 + anchors.horizontalCenter: parent.horizontalCenter + source: !!root.source && !!root.source.toString() ? root.source :"../../../img/compassActive.svg" + visible: root.source && root.source.toString() + } + + StatusQ.StatusRoundIcon { + id: addButton + anchors.horizontalCenter: parent.horizontalCenter + icon.name: "add" + icon.color: Theme.palette.baseColor1 + color: Theme.palette.baseColor2 + visible: !webUrl.toString() + } + + StatusQ.StatusLetterIdenticon { + id: identicon + anchors.horizontalCenter: parent.horizontalCenter + color: Theme.palette.baseColor2 + identiconText.text: text.charAt(0) + identiconText.color: Theme.palette.baseColor1 + visible: !bookmarkImage.visible && !addButton.visible } StyledText { id: bookmarkName text: root.text - width: parent.width + width: 67 anchors.top: bookmarkImage.bottom horizontalAlignment: Text.AlignHCenter + font.pixelSize: Style.current.additionalTextSize wrapMode: Text.WordWrap anchors.topMargin: Style.current.halfPadding + maximumLineCount: 2 + elide: Text.ElideRight } MouseArea {