Add tooltips to buttons and room invite button

This commit is contained in:
miruka
2019-08-22 09:27:26 -04:00
parent 3082c64666
commit 627a186700
10 changed files with 75 additions and 31 deletions

View File

@@ -50,9 +50,7 @@ HRectangle {
fillMode: Image.PreserveAspectCrop
source: Qt.resolvedUrl(imageUrl)
HoverHandler {
id: hoverHandler
}
HoverHandler { id: hoverHandler }
HToolTip {
id: avatarToolTip
@@ -65,17 +63,10 @@ HRectangle {
height: width
delay: 1000
background: HRectangle {
id: background
border.color: "black"
border.width: 2
}
HImage {
id: avatarToolTipImage
anchors.centerIn: parent
sourceSize.width: parent.width - background.border.width * 2
sourceSize.height: parent.height - background.border.width * 2
sourceSize.width: parent.width
sourceSize.height: parent.height
width: sourceSize.width
height: sourceSize.width
fillMode: Image.PreserveAspectCrop

View File

@@ -21,6 +21,11 @@ Button {
property bool loading: false
property bool circle: false
property HToolTip toolTip: HToolTip {
id: toolTip
visible: text && hovered
}
background: HButtonBackground {
button: button

View File

@@ -5,9 +5,9 @@ MenuItem {
id: menuItem
spacing: theme.spacing
leftPadding: spacing
rightPadding: spacing
rightPadding: leftPadding
topPadding: spacing / 1.75
bottomPadding: spacing / 1.75
bottomPadding: topPadding
height: visible ? implicitHeight : 0

View File

@@ -2,12 +2,25 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
ToolTip {
// Be sure to have a width and height set, to prevent the tooltip from
// going out of the window's boundaries
id: toolTip
delay: 150
padding: 0
delay: theme.controls.toolTip.delay
padding: background.border.width
background: HRectangle {
id: background
color: theme.controls.toolTip.background
border.color: theme.controls.toolTip.border
border.width: theme.controls.toolTip.borderWidth
}
contentItem: HLabel {
color: theme.controls.toolTip.text
text: toolTip.text
leftPadding: theme.spacing / 1.5
rightPadding: leftPadding
topPadding: theme.spacing / 2
bottomPadding: topPadding
}
enter: Transition {
HNumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
@@ -21,6 +34,6 @@ ToolTip {
}
HoverHandler {
onHoveredChanged: if (!hovered) { toolTip.hide() }
onHoveredChanged: if (! hovered) toolTip.hide()
}
}