Improve clicking link previews

First of all, clicking on them actually works - because we were missing
an import for RoomManager. Secondly, we use a dedicated TapHandler
since onLinkActivated sucks. We want to be able to click anywhere on the
preview to go to the website/room anyway.
This commit is contained in:
Joshua Goins
2024-11-09 18:00:34 -05:00
parent 07d3b80c3e
commit 6966159062

View File

@@ -8,6 +8,8 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.neochat
/**
* @brief A component to show a link preview from a message.
*/
@@ -95,7 +97,6 @@ QQC2.Control {
}
</style>
<a href=\"" + root.linkPreviewer.url + "\">" + (maximizeButton.checked ? root.linkPreviewer.title : titleTextMetrics.elidedText).replace("&ndash;", "—") + "</a>"
onLinkActivated: RoomManager.resolveResource(link, "join")
TextMetrics {
id: titleTextMetrics
@@ -120,6 +121,11 @@ QQC2.Control {
elide: Text.ElideRight
}
}
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: RoomManager.resolveResource(root.linkPreviewer.url, "join")
}
}
QQC2.Button {