status-desktop/ui/app/AppLayouts/Browser/controls/BookmarkButton.qml

77 lines
2.0 KiB
QML
Raw Normal View History

2020-10-27 20:53:22 +00:00
import QtQuick 2.13
import StatusQ.Components 0.1 as StatusQ
import StatusQ.Core.Theme 0.1
import shared 1.0
import shared.panels 1.0
import shared.status 1.0
import utils 1.0
2020-10-27 20:53:22 +00:00
Item {
property url webUrl
property url source
2020-10-27 20:53:22 +00:00
property string text
2020-10-29 20:07:52 +00:00
signal clicked(mouse: var)
signal rightClicked(mouse: var)
2020-10-27 20:53:22 +00:00
id: root
width: 74
height: 48 + Style.current.halfPadding
2020-10-27 20:53:22 +00:00
SVGImage {
id: bookmarkImage
width: 48
height: 48
anchors.horizontalCenter: parent.horizontalCenter
source: !!root.source && !!root.source.toString() ? root.source : Style.svg("compassActive")
visible: root.source && root.source.toString()
}
StatusQ.StatusRoundIcon {
id: addButton
anchors.horizontalCenter: parent.horizontalCenter
asset.name: "add"
asset.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
2020-10-27 20:53:22 +00:00
}
StyledText {
id: bookmarkName
text: root.text
width: 67
2020-10-27 20:53:22 +00:00
anchors.top: bookmarkImage.bottom
horizontalAlignment: Text.AlignHCenter
font.pixelSize: Style.current.additionalTextSize
2020-10-27 20:53:22 +00:00
wrapMode: Text.WordWrap
anchors.topMargin: Style.current.halfPadding
maximumLineCount: 2
elide: Text.ElideRight
textFormat: Text.PlainText
2020-10-27 20:53:22 +00:00
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
2020-10-29 20:07:52 +00:00
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton) {
2020-10-29 20:07:52 +00:00
root.rightClicked(mouse)
} else {
root.clicked(mouse)
}
}
2020-10-27 20:53:22 +00:00
}
}