// SPDX-FileCopyrightText: 2023 James Graham // SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL import QtQuick import QtQuick.Layouts import org.kde.kirigami as Kirigami import koutnet.app // The rounded block behind a message, after NeoChat's Bubble.qml. The block is // sized by its content (up to the ceiling the timeline gives it) rather than // stretched over the row, so a short message is a short block and own messages // can sit at the trailing edge. With the setting off there is no background and // no padding, leaving the flat timeline exactly as it was. Item { id: root property bool isOwn: false property bool showHighlight: false property int bubbleRadius: Kirigami.Units.cornerRadius property real contentScale: 1 // Everything written inside the bubble lands in the layout, not loose in // the Item: the layout is what gives the block its natural width. default property alias content: contentColumn.data readonly property real pad: appSettings.messageBubbles ? Math.round(Kirigami.Units.largeSpacing * root.contentScale) : 0 // NeoChat's Bubble gives the horizontal sides an extra smallSpacing over // the vertical ones; keep that so the two read the same at a glance. readonly property real sidePad: root.pad + (appSettings.messageBubbles ? Kirigami.Units.smallSpacing : 0) implicitWidth: contentColumn.implicitWidth + root.sidePad * 2 implicitHeight: contentColumn.implicitHeight + root.pad * 2 Kirigami.ShadowedRectangle { anchors.fill: parent visible: appSettings.messageBubbles // The scheme's view background, the way NeoChat's Bubble does it - not a // wash read off the wallpaper, which turned the blocks muddy on a busy // picture. Own messages get a light touch of the accent on top. Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false color: root.showHighlight ? Kirigami.ColorUtils.tintWithAlpha(AppPalette.background, ThemePalette.accent, 0.20) : (root.isOwn ? Kirigami.ColorUtils.tintWithAlpha(AppPalette.background, ThemePalette.accent, 0.15) : AppPalette.background) radius: root.bubbleRadius shadow.size: Kirigami.Units.smallSpacing shadow.color: Qt.rgba(AppPalette.text.r, AppPalette.text.g, AppPalette.text.b, 0.10) Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration } } } ColumnLayout { id: contentColumn anchors.fill: parent anchors.leftMargin: root.sidePad anchors.rightMargin: root.sidePad anchors.topMargin: root.pad anchors.bottomMargin: root.pad spacing: Math.round(Kirigami.Units.smallSpacing * root.contentScale / 2) } }