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
This commit is contained in:
Khushboo Mehta 2021-08-17 19:03:03 +02:00 committed by Iuri Matias
parent b2051ebe87
commit 27ff37e166
6 changed files with 71 additions and 38 deletions

@ -1 +1 @@
Subproject commit d24c2e6208062e27c4bd16915ab6b14aec05138b
Subproject commit d16719adda061e0d33bf8c7959776b5f3773a775

View File

@ -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)
}

View File

@ -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

View File

@ -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
}
}
}

View File

@ -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"))
}
}

View File

@ -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 {