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

74 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
2020-10-27 20:53:22 +00:00
import "../../../../shared"
import "../../../../shared/status"
import "../../../../imports"
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 :"../../../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
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
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
}
}