// 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 first-run tour, modelled on the welcome tour of a certain desktop // environment: the same window size, the same page turn - each step is a page // pushed onto the stack, so changing the index slides it across rather than // swapping the contents - and the same footer, with Skip and Back on one side, // a page indicator that can be clicked, and Next and Finish on the other. // // A window of its own rather than a layer over the main one, because the main // window is not what is being introduced and a tour that covers it hides the // thing it points at. What it can change is small on purpose: the appearance // page is the same one the settings show, so a choice made here and one made // later are the same setting. // // Nothing here is required. Every step can be skipped and the last can be // reached without touching a control, because a tour that gates the // application behind itself is a form with a mascot. Kirigami.ApplicationWindow { id: root // The main window listens for the first and drops the tour; a login asked // for here is the same one the settings page asks for, so it is handed back // rather than done twice. signal finished() signal matrixLoginRequested() // A separate window is a separate theme chain, so the scheme is bound again. Kirigami.Theme.inherit: false title: i18nc("@title:window", "Welcome to KOutNet") // The tour is a window of its own and these are its default size - enough // room for the whole last step, picture and dark box together, without a // scroll. Not a "X by Y grid units", because the grid unit varies with the // font and the size was asked for as 661 by 695. width: 661 height: 695 minimumWidth: Kirigami.Units.gridUnit * 20 minimumHeight: Kirigami.Units.gridUnit * 30 readonly property bool inLayer: pageStack.layers.depth > 1 readonly property bool atStart: pageStack.currentIndex === 0 readonly property bool atEnd: pageStack.currentIndex === pageStack.depth - 1 // One page across, not two side by side: the default column width is the // whole window, so the page row never widens to a second column. pageStack.globalToolBar.showNavigationButtons: Kirigami.ApplicationHeaderStyle.NoNavigationButtons pageStack.defaultColumnWidth: width // The pages are pushed rather than declared as children, so that the page // row sees each as its own column and slides between them. function pushPage(page) { if (pageStack.currentIndex === -1) pageStack.push(page) else pageStack.insertPage(pageStack.depth, page) } function goBack() { pageStack.currentIndex -= 1 } function goForward() { pageStack.currentIndex += 1 } Component { id: welcomePageComponent; WizardWelcomePage {} } Component { id: networkPageComponent; WizardNetworkPage {} } Component { id: powerfulPageComponent; WizardPowerfulPage { onMatrixLoginRequested: root.matrixLoginRequested() } } Component { id: enjoyPageComponent; WizardEnjoyPage {} } Component.onCompleted: { pushPage(welcomePageComponent.createObject(null)) pushPage(networkPageComponent.createObject(null)) pushPage(powerfulPageComponent.createObject(null)) pushPage(enjoyPageComponent.createObject(null)) } // The mouse's own back and forward buttons, as the original tour has them. MouseArea { anchors.fill: parent acceptedButtons: Qt.BackButton | Qt.ForwardButton onPressed: (mouse) => { if (mouse.button === Qt.BackButton) root.goBack() else if (mouse.button === Qt.ForwardButton) root.goForward() } } footer: QQC2.ToolBar { position: QQC2.ToolBar.Footer contentItem: RowLayout { spacing: Kirigami.Units.smallSpacing // Skip at the very start, Back after that: one button, because the // first step has nothing behind it to go back to. QQC2.Button { Layout.alignment: Qt.AlignLeft action: Kirigami.Action { text: root.atStart ? i18nc("@action:button leave the first-run tour", "Skip") : i18nc("@action:button", "Back") icon.name: root.atStart ? "dialog-cancel-symbolic" : "go-previous-symbolic" shortcut: Qt.application.layoutDirection === Qt.LeftToRight ? "Left" : "Right" onTriggered: root.atStart ? root.finished() : root.goBack() } } Item { Layout.fillWidth: true } QQC2.PageIndicator { count: pageStack.depth currentIndex: pageStack.currentIndex onCurrentIndexChanged: pageStack.currentIndex = currentIndex interactive: true } Item { Layout.fillWidth: true } QQC2.Button { Layout.alignment: Qt.AlignRight // The arrow points the way it goes. LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.LeftToRight ? !root.atEnd : root.atEnd action: Kirigami.Action { text: root.atEnd ? i18nc("@action:button finish the first-run tour", "Finish") : i18nc("@action:button", "Next") icon.name: root.atEnd ? "dialog-ok-apply-symbolic" : "go-next-symbolic" shortcut: Qt.application.layoutDirection === Qt.LeftToRight ? "Right" : "Left" onTriggered: root.atEnd ? root.finished() : root.goForward() } } } } }