From 3dd16ba072a859a0353e8fb6f5231a3e29be2f2b Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 9 Jul 2019 22:48:59 -0400 Subject: [PATCH] Add avatar tooltips --- src/qml/Base/HAvatar.qml | 23 +++++++++++++++++++++++ src/qml/Base/HRoomAvatar.qml | 7 +++++-- src/qml/Base/HUserAvatar.qml | 7 +++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/qml/Base/HAvatar.qml b/src/qml/Base/HAvatar.qml index a29cfb7e..5c738423 100644 --- a/src/qml/Base/HAvatar.qml +++ b/src/qml/Base/HAvatar.qml @@ -2,17 +2,23 @@ // This file is part of harmonyqml, licensed under LGPLv3. import QtQuick 2.7 +import QtQuick.Controls 2.0 import "../Base" import "../utils.js" as Utils Rectangle { property string name: "" property var imageUrl: null + property var toolTipImageUrl: imageUrl property int dimension: theme.avatar.size property bool hidden: false onImageUrlChanged: if (imageUrl) { avatarImage.source = imageUrl } + onToolTipImageUrlChanged: if (imageUrl) { + avatarToolTipImage.source = toolTipImageUrl + } + width: dimension height: hidden ? 1 : dimension implicitWidth: dimension @@ -41,5 +47,22 @@ Rectangle { sourceSize.width: 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 + } + } } } diff --git a/src/qml/Base/HRoomAvatar.qml b/src/qml/Base/HRoomAvatar.qml index 2fc672ed..7ca5a087 100644 --- a/src/qml/Base/HRoomAvatar.qml +++ b/src/qml/Base/HRoomAvatar.qml @@ -15,6 +15,9 @@ HAvatar { imageUrl: roomInfo.avatarUrl ? - ("image://python/crop/" + roomInfo.avatarUrl) : - null + ("image://python/crop/" + roomInfo.avatarUrl) : null + + toolTipImageUrl: + roomInfo.avatarUrl ? + ("image://python/scale/" + roomInfo.avatarUrl) : null } diff --git a/src/qml/Base/HUserAvatar.qml b/src/qml/Base/HUserAvatar.qml index 08fc0ea8..f56cb715 100644 --- a/src/qml/Base/HUserAvatar.qml +++ b/src/qml/Base/HUserAvatar.qml @@ -13,8 +13,11 @@ HAvatar { imageUrl: userInfo.avatarUrl ? - ("image://python/crop/" + userInfo.avatarUrl) : - null + ("image://python/crop/" + userInfo.avatarUrl) : null + + toolTipImageUrl: + userInfo.avatarUrl ? + ("image://python/scale/" + userInfo.avatarUrl) : null //HImage { //id: status