// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL import QtQuick import QtQuick.Layouts import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import koutnet.app // not the third column and not a page: clicking a face in a list is a question worth // one card, and PeerInfoPage is still where the fingerprint, the operating system and // the addresses live. The shape is qml/profile/ProfileHeader.qml at card size, and the // account card is the same component with your own identity in it, which is what makes // the two read as one design rather than two. The popup itself has no padding, because // the banner is full bleed and a padded popup cannot do that. No address on it: the // chat is keyed on one, but that is routing. QQC2.Popup { id: root // the map Main.qml builds: { ip, username, displayName, bio, os, e2e, // avatarLetter, isFavorites, online, lastSeen, statusEmoji, presence }. property var peer: null signal messageRequested(string chatId) signal callRequested(string chatId) signal detailsRequested(string chatId) readonly property string chatId: root.peer ? (root.peer.ip || "") : "" readonly property string shownName: root.peer ? ((root.peer.displayName && root.peer.displayName.length > 0) ? root.peer.displayName : (root.peer.username || "")) : "" readonly property string handle: root.peer ? (root.peer.username || "") : "" readonly property bool online: root.peer ? root.peer.online === true : false readonly property string statusEmoji: root.peer ? (root.peer.statusEmoji || "") : "" // The saved-messages chat, keyed on itself: a conversation with no other // end, so the questions about the other end are not asked of it. Set by // Main.qml's peerInfoFor(), which is the same table every card reads. readonly property bool isFavorites: root.peer ? root.peer.isFavorites === true : false // Fixed rather than grown from the content, so a peer with a long name gets an // elide instead of a card the width of the screen. implicitWidth: Kirigami.Units.gridUnit * 18 // See Main.qml: a popup is reparented into the overlay, which is its own chain. Kirigami.Theme.inherit: false modal: false dim: false focus: true closePolicy: QQC2.Popup.CloseOnEscape | QQC2.Popup.CloseOnPressOutside padding: 0 // Reparenting is what makes x and y mean "beside that item"; it also gives // CloseOnPressOutsideParent something sensible to measure against. function openAt(item, peerInfo) { if (!item) return root.peer = peerInfo root.parent = item root.x = 0 root.y = item.height + Kirigami.Units.smallSpacing root.open() } background: Kirigami.ShadowedRectangle { radius: Kirigami.Units.cornerRadius // the tone of the theme, and the border a little way from it towards the // text: one material with an edge, rather than a card in the scheme's own // grey sitting in a window that is not color: ThemePalette.surface border.width: 1 border.color: Kirigami.ColorUtils.linearInterpolation(ThemePalette.surface, ThemePalette.text, 0.2) shadow.size: Kirigami.Units.gridUnit shadow.color: Qt.rgba(0, 0, 0, 0.3) shadow.yOffset: 2 } contentItem: ColumnLayout { spacing: 0 ProfileHeader { Layout.fillWidth: true compact: true // the card's background is rounded and the banner is full bleed, so the // strip rounds its own top corners or it squares the card off. topCornerRadius: Kirigami.Units.cornerRadius displayName: root.shownName handle: root.handle online: root.online lastSeenSecs: root.peer ? (root.peer.lastSeen || 0) : 0 // the saved-messages chat has no other end whose presence could be // told: the line would say "offline" about the reader's own row. showPresence: !root.isFavorites statusEmoji: root.statusEmoji // the face this peer pushed over the TLS channel; initials stand in // until an avatar frame has arrived. avatarSource: root.peer ? (root.peer.avatar || "") : "" // the header picture, arrived as banner frames the same way. bannerSource: root.peer ? (root.peer.banner || "") : "" } Kirigami.Separator { Layout.fillWidth: true Layout.leftMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing } ProfileBlock { Layout.fillWidth: true Layout.leftMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing Layout.topMargin: Kirigami.Units.largeSpacing // A conversation with no other end has no session to describe: the // saved-messages row is the account talking to itself, and there // is nothing on the wire to say "no session" about. visible: root.peer !== null && !root.isFavorites label: i18nc("@label:textbox caption over whether the session is encrypted", "Session") RowLayout { Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Kirigami.Icon { Layout.alignment: Qt.AlignVCenter implicitWidth: Kirigami.Units.iconSizes.small implicitHeight: Kirigami.Units.iconSizes.small source: (root.peer && root.peer.e2e) ? "security-high" : "security-low" } QQC2.Label { Layout.fillWidth: true text: (root.peer && root.peer.e2e) ? i18nc("@info:status the session is end to end encrypted", "End to end encrypted") : i18nc("@info:status", "No session") textFormat: Text.PlainText elide: Text.ElideRight } } } RowLayout { Layout.fillWidth: true Layout.margins: Kirigami.Units.largeSpacing spacing: Kirigami.Units.smallSpacing QQC2.Button { Layout.fillWidth: true icon.name: "mail-message-new" // The saved-messages row opens with "Write" rather than // "Message": the conversation is with yourself, and the word // for going to it is the one the account row's own card uses. text: root.isFavorites ? i18nc("@action:button open the saved messages conversation", "Write") : i18nc("@action:button open the conversation with this peer", "Message") onClicked: { root.messageRequested(root.chatId) root.close() } } // A call has no other end to reach in the saved-messages chat, and // neither has a details column: the session block above is gone // with it, so the tool button that opens that column goes too. QQC2.Button { Layout.fillWidth: true icon.name: "call-start" visible: !root.isFavorites enabled: root.online text: i18nc("@action:button start a voice call with this peer", "Call") onClicked: { root.callRequested(root.chatId) root.close() } } QQC2.ToolButton { display: QQC2.AbstractButton.IconOnly icon.name: "documentinfo" visible: !root.isFavorites text: i18nc("@action:button show the full peer details column", "Details") QQC2.ToolTip.visible: hovered QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay QQC2.ToolTip.text: text onClicked: { root.detailsRequested(root.chatId) root.close() } } } } }