fix(desktop/browser): Fix add bookmark button

This button needs special case when it is not a real bookmark
This commit is contained in:
Anthony Laibe 2021-11-12 13:37:05 +01:00
parent fb687383b6
commit da4d895131
4 changed files with 20 additions and 8 deletions

View File

@ -35,6 +35,11 @@ RowLayout {
acceptedButtons: Qt.LeftButton | Qt.RightButton
z: 51
onClicked: function (mouse) {
const isAddBookmarkButton = url === Constants.newBookmark
if (mouse.button === Qt.RightButton && isAddBookmarkButton) {
return
}
if (mouse.button === Qt.RightButton) {
favoriteMenu.url = url
favoriteMenu.x = favoriteBtn.x + mouse.x
@ -42,13 +47,18 @@ RowLayout {
favoriteMenu.open()
return
}
if (!url.toString()) {
if (isAddBookmarkButton) {
addFavoriteModal.toolbarMode = true
addFavoriteModal.ogUrl = browserHeader.currentFavorite ? browserHeader.currentFavorite.url : currentWebView.url
addFavoriteModal.ogName = browserHeader.currentFavorite ? browserHeader.currentFavorite.name : currentWebView.title
addFavoriteModal.open()
} else {
return
}
currentWebView.url = determineRealURL(url)
}
}
}
}
}
}

View File

@ -159,9 +159,9 @@ ModalPopup {
onClicked: {
if (!popup.modifiyModal) {
// remove "add favorite" button at the end, add new bookmark, add "add favorite" button back
BookmarksStore.deleteBookmark(" ")
BookmarksStore.deleteBookmark(Constants.newBookmark)
BookmarksStore.addBookmark(urlInput.input.text, nameInput.input.text)
BookmarksStore.addBookmark(" ", qsTr("Add Favorite"))
BookmarksStore.addBookmark(Constants.newBookmark, qsTr("Add Favorite"))
} else if (popup.ogName !== nameInput.input.text || popup.ogUrl !== urlInput.input.text) {
BookmarksStore.updateBookmark(popup.ogUrl, urlInput.input.text, nameInput.input.text)
}

View File

@ -183,9 +183,9 @@ WebEngineView {
model: BookmarksStore.bookmarksModel
Component.onCompleted: {
// Add fav button at the end of the grid
var index = BookmarksStore.getBookmarkIndexByUrl(" ")
if (index !== -1) { BookmarksStore.deleteBookmark(" ") }
BookmarksStore.addBookmark(" ", qsTr("Add Favorite"))
var index = BookmarksStore.getBookmarkIndexByUrl(Constants.newBookmark)
if (index !== -1) { BookmarksStore.deleteBookmark(Constants.newBookmark) }
BookmarksStore.addBookmark(Constants.newBookmark, qsTr("Add Favorite"))
}
}
}

View File

@ -176,6 +176,8 @@ QtObject {
//% "(edited)"
readonly property string editLabel: ` <span class="isEdited">` + qsTrId("-edited-") + `</span>`
readonly property string newBookmark: " "
readonly property var ensState: {
//% "Username already taken :("
"taken": qsTrId("ens-username-taken"),