// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: BSD-2-Clause import QtQuick import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import koutnet.app // The emoji panel as the column of its own that Telegram puts down the right of // the conversation, rather than as a drop-down over it: the third section, whose // width comes off the conversation instead of lying on top of it // (ComposeControls::createTabbedPanel handing the panel its height, and // resizeForThirdSection giving the conversation less room; // TabbedPanel::moveHorizontally putting the panel's trailing edge on the compose // row's, and moveBottomRight its bottom on that row's top). // // EmojiPopup.qml is the same panel in the other shape, the drop-down a window // too narrow to give a column has to make do with - Telegram keeps both and puts // a toggle to the composer between them. // // It is a child reparented onto the page rather than one of the page's own // children on purpose. Those live in the page's content item, which stops above // the composer, and a column that came up short of the bottom of the window // would be the drop-down with extra steps. Rectangle { id: root signal picked(string emoji) // What the conversation gives up to make room, which is this column's width // and nothing while it is closed - so the page can hand the width over and // take it back without either side being asked to be told. readonly property real columnWidth: root.visible ? root.width : 0 // Telegram's own figures, on its 18 pixel grid unit: the 345 of // emojiPanWidth, the margins of emojiPanMargins and the corner of // emojiPanRadius, in chat_helpers/chat_helpers.style. The height is not one // of them - a column of the window's height is the point of this shape. readonly property real panelMargin: Kirigami.Units.gridUnit * 10 / 18 implicitWidth: Math.round(Kirigami.Units.gridUnit * 19.2) function close() { root.visible = false } function toggle() { root.visible = !root.visible } // A panel left showing somebody else's search would be a search of theirs. onVisibleChanged: if (root.visible) { picker.clearSearchField() picker.forceActiveFocus() } visible: false // the tone of the theme, like every other surface: a panel the wallpaper is // behind and a scheme grey covers it with is a panel of the wrong colour color: ThemePalette.surface radius: Kirigami.Units.gridUnit * 8 / 18 // The panel's own way back to the conversation: the composer's smiley is // only ever an opener, so the closing is said here. The cross itself // stands in the picker's search row (the picker builds it on request, so // the pop-up shape never grows one), where it can stand over nothing: the // row is the panel's furniture, and a cross over the categories or the // grid is a cross in the way. Styled like the room panel's cross, so the // two closers read as the same thing. EmojiPicker { id: picker anchors.fill: parent anchors.margins: root.panelMargin // the cross is this panel's, not the picker's showCloser: true onCloseRequested: root.close() // The panel stays up as it was, so that several emoji can be picked // without going back to the button between them; the caller gives the // field the focus back, which is where the next one is going. onChosen: (emoji) => root.picked(emoji) } }