diff --git a/ui/app/AppLayouts/Browser/BrowserHeader.qml b/ui/app/AppLayouts/Browser/BrowserHeader.qml index 59f6a31562..4a79f1638f 100644 --- a/ui/app/AppLayouts/Browser/BrowserHeader.qml +++ b/ui/app/AppLayouts/Browser/BrowserHeader.qml @@ -15,12 +15,14 @@ Rectangle { id: root width: parent.width - height: 45 + height: barRow.height + favoritesBarLoader.height color: Style.current.background border.width: 0 RowLayout { - anchors.fill: parent + id: barRow + width: parent.width + height: 45 spacing: root.innerMargin Menu { @@ -219,6 +221,21 @@ Rectangle { padding: 6 } } + + Loader { + id: favoritesBarLoader + active: appSettings.showFavoritesBar + height: active ? item.height : 0 + anchors.top: barRow.bottom + anchors.left: parent.left + anchors.leftMargin: Style.current.smallPadding + anchors.right: parent.right + anchors.rightMargin: Style.current.smallPadding + + sourceComponent: Component { + FavoritesBar {} + } + } } diff --git a/ui/app/AppLayouts/Browser/BrowserLayout.qml b/ui/app/AppLayouts/Browser/BrowserLayout.qml index d5f28ac610..1460e3c059 100644 --- a/ui/app/AppLayouts/Browser/BrowserLayout.qml +++ b/ui/app/AppLayouts/Browser/BrowserLayout.qml @@ -650,46 +650,12 @@ Rectangle { anchors.topMargin: 60 } - Item { + FavoritesList { id: bookmarkListContainer anchors.horizontalCenter: emptyPageImage.horizontalCenter anchors.top: emptyPageImage.bottom anchors.topMargin: 30 width: parent.width - Style.current.bigPadding * 2 - - 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() - } - } - } - - BookmarkButton { - id: addBookmarkBtn - text: qsTr("Add favorite") - onClicked: { - addFavoriteModal.open() - } - anchors.left: bookmarkList.right - anchors.leftMargin: bookmarkList.spacing - } } } } diff --git a/ui/app/AppLayouts/Browser/FavoritesBar.qml b/ui/app/AppLayouts/Browser/FavoritesBar.qml new file mode 100644 index 0000000000..da6aa0c404 --- /dev/null +++ b/ui/app/AppLayouts/Browser/FavoritesBar.qml @@ -0,0 +1,51 @@ +import QtQuick 2.13 +import QtQuick.Layouts 1.13 +import "../../../shared" +import "../../../shared/status" +import "../../../imports" + +RowLayout { + id: favoritesBar + spacing: 0 + height: 38 + + ListView { + id: bookmarkList + model: browserModel.bookmarks + spacing: Style.current.halfPadding + orientation : ListView.Horizontal + height: parent.height + clip: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + width: parent.width + boundsBehavior: Flickable.StopAtBounds + delegate: StatusButton { + id: favoriteBtn + height: 32 + icon.source: imageUrl + disableColorOverlay: true + icon.width: 24 + icon.height: 24 + text: name + implicitHeight: 32 + type: "secondary" + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + z: 51 + onClicked: function (mouse) { + if (mouse.button === Qt.RightButton) { + favoriteMenu.url = url + favoriteMenu.x = favoriteBtn.x + mouse.x + favoriteMenu.y = Qt.binding(function () {return mouse.y + favoriteMenu.height}) + favoriteMenu.open() + return + } + + currentWebView.url = determineRealURL(url) + } + } + } + } +} diff --git a/ui/app/AppLayouts/Browser/FavoritesList.qml b/ui/app/AppLayouts/Browser/FavoritesList.qml new file mode 100644 index 0000000000..efaa44a31e --- /dev/null +++ b/ui/app/AppLayouts/Browser/FavoritesList.qml @@ -0,0 +1,43 @@ +import QtQuick 2.13 +import "../../../shared" +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() + } + } + } + + BookmarkButton { + id: addBookmarkBtn + text: qsTr("Add favorite") + onClicked: { + addFavoriteModal.open() + } + anchors.left: bookmarkList.right + anchors.leftMargin: bookmarkList.spacing + } +} diff --git a/ui/app/AppLayouts/Browser/components/BookmarkButton.qml b/ui/app/AppLayouts/Browser/components/BookmarkButton.qml index ecbc0c0bf7..ca9be00064 100644 --- a/ui/app/AppLayouts/Browser/components/BookmarkButton.qml +++ b/ui/app/AppLayouts/Browser/components/BookmarkButton.qml @@ -36,7 +36,7 @@ Item { cursorShape: Qt.PointingHandCursor acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { - if (mouse.button == Qt.RightButton) { + if (mouse.button === Qt.RightButton) { root.rightClicked(mouse) } else { root.clicked(mouse) diff --git a/ui/nim-status-client.pro b/ui/nim-status-client.pro index 489ab307ae..645e00bbca 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -132,6 +132,8 @@ DISTFILES += \ app/AppLayouts/Browser/DownloadElement.qml \ app/AppLayouts/Browser/FaviconImage.qml \ app/AppLayouts/Browser/FavoriteMenu.qml \ + app/AppLayouts/Browser/FavoritesBar.qml \ + app/AppLayouts/Browser/FavoritesList.qml \ app/AppLayouts/Browser/components/BookmarkButton.qml \ app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatCommandButton.qml \ app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatCommandModal.qml \ diff --git a/ui/shared/status/StatusButton.qml b/ui/shared/status/StatusButton.qml index d0967ce811..e679c1941e 100644 --- a/ui/shared/status/StatusButton.qml +++ b/ui/shared/status/StatusButton.qml @@ -12,6 +12,7 @@ Button { property color color: Style.current.buttonForegroundColor property color bgColor: Style.current.buttonBackgroundColor property color bgHoverColor: Qt.darker(control.bgColor, 1.1) + property bool disableColorOverlay: false property int iconRotation: 0 id: control @@ -43,9 +44,10 @@ Button { rotation: control.iconRotation ColorOverlay { + enabled: !control.disableColorOverlay anchors.fill: iconImg source: iconImg - color: buttonLabel.color + color: control.disableColorOverlay ? "transparent" : buttonLabel.color antialiasing: true smooth: true rotation: control.iconRotation