// 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 left edge of the conversation column, laid out after NeoChat's // SpaceDrawer: home and personal messages at the top, the connection modes in // the middle, create and browse at the bottom. It was modes only until the // drawer shape was wanted, and it is this rail that took the shape - the panel // beside it is the conversation list and stays where it is. // // The modes are applied through the same path the settings page uses, so a // switch here lands wherever the settings say. QQC2.Control { id: root property int currentMode: 0 // the chat list model, so the mode buttons can show their unread count property var chats: null signal modeSelected(int mode) signal homeRequested() signal personalMessagesRequested() signal createRequested() signal browseRequested() // Home shows every conversation whatever transport it came in on, and the // personal messages row is the conversation with oneself. Both are answers // to "what is in front of me", not connection modes, so they are said here // rather than smuggled into the modes list. property bool showingHome: false property bool showingPersonalMessages: false // Width comes from the square buttons plus the column's own insets; // hardcoding it is how the rail ends up half a pixel off the separator. implicitWidth: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.gridUnit * 2 padding: 0 // the values are persisted, so the order here is the enum's, not a nicer one. // // two buttons and not five: self-hosted, somebody else's and the // maintainer's deployment were one protocol at three addresses, picking an // address belongs in a text field on the settings page, and the relay // mode that came after them is gone. readonly property var modes: [ { mode: 0, name: i18nc("@item connection mode, peers found on the local network or over a VPN adapter", "Local network or VPN"), icon: "network-workgroup", reason: i18nc("@info:tooltip why a connection mode cannot be used", "no local interface is up") }, { mode: 1, name: i18nc("@item connection mode, a Matrix homeserver at whatever address is configured", "Matrix"), icon: "network-server", reason: i18nc("@info:tooltip why a connection mode cannot be used", "not built yet") }, { mode: 2, name: i18nc("@item transport, Telegram account", "Telegram"), icon: "network-server", reason: "" } ] contentItem: QQC2.ScrollView { id: railScroll // two buttons never need a scrollbar, and this rail has no room for // one; the view is here so a third mode does not fall off the bottom. QQC2.ScrollBar.vertical.policy: QQC2.ScrollBar.AlwaysOff QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff // do not bind contentWidth to availableWidth, it makes a loop with the Control width ColumnLayout { id: railColumn width: railScroll.width spacing: 0 // the seam between the groups. Inset like NeoChat's, so it reads as a // break in the column rather than as a rule across the panel. component RailSeparator: Kirigami.Separator { Layout.leftMargin: Kirigami.Units.smallSpacing Layout.rightMargin: Kirigami.Units.smallSpacing Layout.preferredWidth: railColumn.width - Kirigami.Units.smallSpacing * 2 Layout.preferredHeight: 1 } ModeButton { id: homeButton Layout.fillWidth: true Layout.preferredHeight: width mode: -1 modeName: i18nc("@action:button show every conversation", "Home") icon.name: "go-home-symbolic" current: root.showingHome unread: 0 onPicked: root.homeRequested() } ModeButton { id: personalButton Layout.fillWidth: true Layout.preferredHeight: width mode: -2 modeName: i18nc("@action:button open the conversation with yourself", "Personal messages") icon.name: "system-users-symbolic" current: root.showingPersonalMessages unread: 0 onPicked: root.personalMessagesRequested() } RailSeparator {} Repeater { model: root.modes delegate: ModeButton { required property var modelData Layout.fillWidth: true Layout.preferredHeight: width mode: modelData.mode modeName: modelData.name icon.name: modelData.icon current: root.currentMode === modelData.mode unavailableReason: networkManager.modeAvailable(modelData.mode) ? "" : modelData.reason unread: root.chats ? root.chats.unreadForGroup(modelData.mode) : 0 onPicked: root.modeSelected(modelData.mode) } } RailSeparator {} ModeButton { id: createButton Layout.fillWidth: true Layout.preferredHeight: width mode: -3 modeName: i18nc("@action:button start a new conversation", "Create") icon.name: "list-add-symbolic" current: false unread: 0 onPicked: root.createRequested() } ModeButton { id: browseButton Layout.fillWidth: true Layout.preferredHeight: width mode: -4 modeName: i18nc("@action:button look for someone or something to talk to", "Browse") icon.name: "compass-symbolic" current: false unread: 0 onPicked: root.browseRequested() } Item { Layout.fillHeight: true } } } }