2020-12-29 17:10:22 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import StatusQ.Core 0.1
|
2023-08-18 11:12:46 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2021-10-20 08:44:04 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2020-12-29 17:10:22 +00:00
|
|
|
RowLayout {
|
|
|
|
id: favoritesBar
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
property alias bookmarkModel: bookmarkList.model
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
property var favoritesMenu
|
|
|
|
property var setAsCurrentWebUrl: function(url){}
|
|
|
|
property var addFavModal: function(){}
|
|
|
|
|
2020-12-29 17:10:22 +00:00
|
|
|
spacing: 0
|
2021-11-17 11:49:03 +00:00
|
|
|
height: 38
|
2020-12-29 17:10:22 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2020-12-29 17:10:22 +00:00
|
|
|
id: bookmarkList
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
orientation : ListView.Horizontal
|
2022-07-14 11:03:36 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2021-10-20 08:44:04 +00:00
|
|
|
delegate: StatusFlatButton {
|
2020-12-29 17:10:22 +00:00
|
|
|
id: favoriteBtn
|
|
|
|
height: 32
|
|
|
|
icon.source: imageUrl
|
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
2022-03-10 12:09:39 +00:00
|
|
|
// Limit long named tabs. StatusFlatButton is not well-behaved control
|
|
|
|
// implicitWidth doesn't work. Also avoid breaking visualization by escaping HTML
|
2023-08-18 11:12:46 +00:00
|
|
|
text: SQUtils.StringUtils.escapeHtml(Utils.elideIfTooLong(name, 40))
|
2020-12-29 17:10:22 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
z: 51
|
|
|
|
onClicked: function (mouse) {
|
2021-11-12 12:37:05 +00:00
|
|
|
const isAddBookmarkButton = url === Constants.newBookmark
|
|
|
|
if (mouse.button === Qt.RightButton && isAddBookmarkButton) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-29 17:10:22 +00:00
|
|
|
if (mouse.button === Qt.RightButton) {
|
2021-12-07 23:15:17 +00:00
|
|
|
favoritesMenu.url = url
|
|
|
|
favoritesMenu.x = favoriteBtn.x + mouse.x
|
|
|
|
favoritesMenu.y = Qt.binding(function () {return mouse.y + favoritesMenu.height})
|
|
|
|
favoritesMenu.open()
|
2020-12-29 17:10:22 +00:00
|
|
|
return
|
|
|
|
}
|
2021-11-12 12:37:05 +00:00
|
|
|
|
|
|
|
if (isAddBookmarkButton) {
|
2021-12-07 23:15:17 +00:00
|
|
|
addFavModal()
|
2021-11-12 12:37:05 +00:00
|
|
|
return
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
2021-11-12 12:37:05 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
setAsCurrentWebUrl(url)
|
2020-12-29 17:10:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|