Warning, /network/tokodon/src/content/ui/Components/UserCard.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Shubham Arora <shubhamarora@protonmail.com>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Layouts
0006 import QtQuick.Controls 2 as QQC2
0007 import org.kde.kirigami 2 as Kirigami
0008 import org.kde.tokodon
0009 import org.kde.tokodon.private
0010 import '..'
0011 import '../StatusDelegate'
0012 
0013 Kirigami.AbstractCard {
0014     id: root
0015 
0016     required property var userIdentity
0017 
0018     property bool isBackgroundAvailable: !userIdentity.backgroundUrl.toString().trim().endsWith("/headers/original/missing.png")
0019 
0020     HoverHandler {
0021         cursorShape: Qt.PointingHandCursor
0022     }
0023 
0024     leftPadding: 0
0025     rightPadding: 0
0026     topPadding: 0
0027 
0028     showClickFeedback: true
0029 
0030     contentItem: Item {
0031         implicitHeight: userInfo.implicitHeight
0032         anchors {
0033             leftMargin: Kirigami.Units.mediumSpacing
0034             rightMargin: Kirigami.Units.mediumSpacing
0035             topMargin: Kirigami.Units.mediumSpacing
0036         }
0037 
0038         ColumnLayout {
0039             id: userInfo
0040             InlineIdentityInfo {
0041                 secondary: false
0042                 identity: root.userIdentity
0043                 Layout.bottomMargin: Kirigami.Units.smallSpacing
0044             }
0045 
0046             QQC2.TextArea {
0047                 id: bio
0048                 visible: root.userIdentity.bio && root.userIdentity.bio.length > 0
0049                 font: Config.defaultFont
0050                 width: root.width - Kirigami.Units.largeSpacing * 2
0051                 text:  "<style>
0052                             a {
0053                             color: " + Kirigami.Theme.linkColor + ";
0054                             text-decoration: none;
0055                             }
0056                             </style>" + root.userIdentity.bio
0057                 textFormat: TextEdit.RichText
0058                 readOnly: true
0059                 background: null
0060                 wrapMode: TextEdit.Wrap
0061                 selectByMouse: !Kirigami.Settings.isMobile
0062                 onLinkActivated: {
0063                     // Tag has a complete url in the form of https://domain.tld/tags/tag
0064                     const [, , hostname, ...pathSegments] = link.split('/');
0065                     const path = '/' + pathSegments.join('/');
0066                     const tag = path.indexOf("/tags/") !== -1 ? path.substring(path.indexOf("/tags/") + 6)
0067                         : link.startsWith('hashtag:/') ? link.substring(9)
0068                             : '';
0069                         tag.length > 0 ? pageStack.push(tagModelComponent, { hashtag: tag }): Qt.openUrlExternally(link);
0070 
0071                 }
0072                 color: Kirigami.Theme.textColor
0073                 onHoveredLinkChanged: if (hoveredLink.length > 0) {
0074                     applicationWindow().hoverLinkIndicator.text = hoveredLink;
0075                 } else {
0076                     applicationWindow().hoverLinkIndicator.text = "";
0077                 }
0078 
0079                 MouseArea {
0080                     anchors.fill: parent
0081                     acceptedButtons: Qt.NoButton // don't eat clicks on the Text
0082                     cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
0083                 }
0084             }
0085         }
0086     }
0087 
0088     onClicked: {
0089         Navigation.openAccount(root.userIdentity.id)
0090     }
0091 }