// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard import koutnet.app // The LAN half of the protocols tab: the peers this machine trusts on the // network it is already on, and the button that makes the running layer use // them. Written to the same shape as the Matrix half for the same reason. // // An Item rather than a Page for the reason the Matrix half gives: the settings // page above draws the background and holds the padding. Item { id: root // handed in so the cards line up with the rest of the settings. property real formWidth: Kirigami.Units.gridUnit * 30 // The settings page that holds this tab hears the button and writes its own // setting, so asking for the save is a question rather than a call. signal saved() QQC2.ScrollView { id: lanScroll anchors.fill: parent contentWidth: availableWidth ColumnLayout { // the form column and nothing else, for the reason the profile tab gives width: Math.min(lanScroll.availableWidth, root.formWidth + Kirigami.Units.gridUnit * 2) spacing: 0 ThemedFormHeader { maximumWidth: root.formWidth title: i18nc("@title:group the local-network side of the connection", "LAN / VPN") } ThemedFormCard { maximumWidth: root.formWidth FormCard.FormTextFieldDelegate { id: staticPeersField label: i18nc("@label:textbox", "Static peers") placeholderText: i18nc("@info:placeholder a list of addresses", "10.0.0.5, 192.168.2.14") text: appSettings.staticPeers.join(", ") onEditingFinished: { const parts = staticPeersField.text.split(RegExp("[,\\s;]+")) appSettings.staticPeers = parts.filter(p => p.length > 0) } } FormCard.FormDelegateSeparator { above: staticPeersField; below: applyDelegate } // AppSettings only persists; the running NetworkManager is told separately, // and switching peers is a transport change, so it waits for the button. FormCard.FormButtonDelegate { id: applyDelegate text: i18nc("@action:button apply the connection settings to the running network layer", "Apply connection settings") icon.name: "dialog-ok-apply" onClicked: { networkManager.setStaticPeers(appSettings.staticPeers) networkManager.setConnectionMode(appSettings.connectionMode) root.saved() } } } } } }