Add avatar tooltips

This commit is contained in:
miruka 2019-07-09 22:48:59 -04:00
parent 9af9e88b0d
commit 3dd16ba072
3 changed files with 33 additions and 4 deletions

View File

@ -2,17 +2,23 @@
// This file is part of harmonyqml, licensed under LGPLv3. // This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.0
import "../Base" import "../Base"
import "../utils.js" as Utils import "../utils.js" as Utils
Rectangle { Rectangle {
property string name: "" property string name: ""
property var imageUrl: null property var imageUrl: null
property var toolTipImageUrl: imageUrl
property int dimension: theme.avatar.size property int dimension: theme.avatar.size
property bool hidden: false property bool hidden: false
onImageUrlChanged: if (imageUrl) { avatarImage.source = imageUrl } onImageUrlChanged: if (imageUrl) { avatarImage.source = imageUrl }
onToolTipImageUrlChanged: if (imageUrl) {
avatarToolTipImage.source = toolTipImageUrl
}
width: dimension width: dimension
height: hidden ? 1 : dimension height: hidden ? 1 : dimension
implicitWidth: dimension implicitWidth: dimension
@ -41,5 +47,22 @@ Rectangle {
sourceSize.width: dimension sourceSize.width: dimension
sourceSize.height: dimension sourceSize.height: dimension
MouseArea {
id: imageMouseArea
anchors.fill: parent
hoverEnabled: true
}
ToolTip {
visible: imageMouseArea.containsMouse
delay: Qt.styleHints.mousePressAndHoldInterval
HImage {
id: avatarToolTipImage
sourceSize.width: 128
sourceSize.height: 128
}
}
} }
} }

View File

@ -15,6 +15,9 @@ HAvatar {
imageUrl: imageUrl:
roomInfo.avatarUrl ? roomInfo.avatarUrl ?
("image://python/crop/" + roomInfo.avatarUrl) : ("image://python/crop/" + roomInfo.avatarUrl) : null
null
toolTipImageUrl:
roomInfo.avatarUrl ?
("image://python/scale/" + roomInfo.avatarUrl) : null
} }

View File

@ -13,8 +13,11 @@ HAvatar {
imageUrl: imageUrl:
userInfo.avatarUrl ? userInfo.avatarUrl ?
("image://python/crop/" + userInfo.avatarUrl) : ("image://python/crop/" + userInfo.avatarUrl) : null
null
toolTipImageUrl:
userInfo.avatarUrl ?
("image://python/scale/" + userInfo.avatarUrl) : null
//HImage { //HImage {
//id: status //id: status