// 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 // the same card as a peer's - see qml/peer/PeerCard.qml - because clicking your own // face asks the same question as clicking somebody else's and deserves the same // answer in the same shape. What differs is that there is no reachability to report // about yourself and the two actions write. The name and handle are read straight off // AppSettings rather than passed in: threading two strings through a popup only to // have them go stale is worse than the coupling. QQC2.Popup { id: root signal editProfileRequested() // the window owns the one message strip, this card only asks for it. signal notifyRequested(string text) readonly property string handle: appSettings.username || "" readonly property string shownName: appSettings.displayName && appSettings.displayName.length > 0 ? appSettings.displayName : root.handle 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.CloseOnPressOutsideParent padding: 0 // above the row, because the account row is the last thing in the column - // but below it when there is no room above: a card that hangs off the top // of the window is a card cut in half, and an avatar the message timeline // opens this from can sit at the window's very top. function openAt(item) { if (!item) return root.parent = item root.x = 0 const above = item.mapToItem(null, 0, 0).y root.y = above >= root.height + Kirigami.Units.smallSpacing ? -root.height - Kirigami.Units.smallSpacing : 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 } // Copying goes through an off-screen editor because QML has no clipboard object // without a C++ helper - the same trick the conversation uses. TextEdit { id: clipboardHelper visible: false function copyText(str) { text = str selectAll() copy() } } contentItem: ColumnLayout { spacing: 0 ProfileHeader { Layout.fillWidth: true compact: true topCornerRadius: Kirigami.Units.cornerRadius // Your own reachability is that the process is running. showPresence: false displayName: root.shownName handle: root.handle statusEmoji: appSettings.statusEmoji statusText: appSettings.statusText // The face belongs to the active transport: Matrix has a remote // URL, Telegram exposes ownAvatarUrl, LAN uses the local picture. avatarSource: appSettings.connectionMode === 1 && matrixManager.loggedIn ? matrixManager.avatarUrl : (appSettings.connectionMode === 2 && typeof telegramRooms !== "undefined" && telegramRooms.ownAvatarUrl.length > 0 ? telegramRooms.ownAvatarUrl : FsUtils.toSourceUrl(appSettings.avatarPath)) bannerSource: appSettings.bannerPath badgeSource: appSettings.nameBadgePath } Kirigami.Separator { Layout.fillWidth: true Layout.leftMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing } RowLayout { Layout.fillWidth: true Layout.margins: Kirigami.Units.largeSpacing spacing: Kirigami.Units.smallSpacing QQC2.Button { Layout.fillWidth: true icon.name: "document-edit" text: i18nc("@action:button open the profile section of the settings", "Edit profile") onClicked: { root.editProfileRequested() root.close() } } // the handle is how somebody else starts a conversation with you. QQC2.Button { Layout.fillWidth: true icon.name: "edit-copy" enabled: root.handle.length > 0 text: i18nc("@action:button put your own handle on the clipboard", "Copy handle") onClicked: { // the same single-at-sign rule the header draws with: a // Matrix id carries its own @, and a copy must say the // id once, not twice. clipboardHelper.copyText(i18nc("@info a handle, %1 is the user name", "@%1", root.handle.startsWith("@") ? root.handle.substring(1) : root.handle)) root.notifyRequested(i18nc("@info:status", "Handle copied to the clipboard")) root.close() } } } } }