// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL import QtQuick import org.kde.kirigami as Kirigami import koutnet.app // The line between the conversation list and the conversation, which is also // what the width of the list is dragged with. // // A child of the page whose right edge it marks, and so positioned in that // page's own coordinates. It used to be parented to the window and placed with // mapToItem(root.contentItem, ...).width, which looks equivalent and is not: // mapToItem is a call, not a property, so the binding tracking it saw only the // page's width. The page row animates its pages when the window crosses the // wide/narrow threshold, and the binding captured a coordinate from the middle of // that slide and then never ran again. The handle froze off the edge of the // window - at -132px or wherever the fold happened to be caught - and stayed // there through every later resize, which is what broke the interface. Here the // only thing the position depends on is the page's own width. // // It asks for the width rather than holding it: the window owns the setting and // the minimum, and a component that kept its own copy would be a second answer // to the same question. Item { id: handle // The page whose right edge this marks. The handle is parented to it, so it // is told which page that is rather than to work out where it is. property Item page: null // The width the list is at now, and the width to make it. property real currentWidth: 0 signal widthRequested(real width) // The width the drag started from. The translation is measured from where // the handle was grabbed, so the whole drag is this plus that: no running // total to drift, and no dependence on which part of it was held. property real widthAtGrab: 0 readonly property bool available: page !== null && page.width > 0 z: 500 x: handle.available ? handle.page.width - width / 2 : 0 y: 0 // Wider than the line it draws: asking for a single pixel to be dragged is // asking for a different kind of window manager. width: Kirigami.Units.smallSpacing * 3 height: handle.available ? handle.page.height : 0 Rectangle { anchors.horizontalCenter: parent.horizontalCenter width: 1 height: parent.height // A hairline, so it reads as the edge of a column and not as a rule drawn // through the window. color: ThemePalette.accent opacity: resizeDrag.active ? 0.8 : (chatListHover.hovered ? 0.5 : 0.25) Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.OutCubic } } } HoverHandler { id: chatListHover cursorShape: Qt.SizeHorCursor } DragHandler { id: resizeDrag // The handle follows the column, so it must not be moved by the drag as // well: two writers for one x is a handle that fights its page. target: null cursorShape: Qt.SizeHorCursor yAxis.enabled: false // Without this the drag is refused wherever a child of the window already // wants the pointer, and the handle is a sliver between two pages that // both want it. grabPermissions: PointerHandler.CanTakeOverFromAnything onActiveChanged: if (active) handle.widthAtGrab = handle.currentWidth onTranslationChanged: if (active) handle.widthRequested(handle.widthAtGrab + translation.x) } // A drag is not the only way to move a column, and a handle that can only be // seen cannot be moved by anyone using a keyboard. activeFocusOnTab: true Accessible.role: Accessible.Separator Accessible.name: i18nc("@info:whatsthis", "Width of the conversation list") Keys.onPressed: function (event) { const step = event.key === Qt.Key_Left ? -1 : (event.key === Qt.Key_Right ? 1 : 0) if (step === 0) return handle.widthRequested(handle.currentWidth + step * Kirigami.Units.gridUnit) event.accepted = true } }