// SPDX-FileCopyrightText: 2024 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick import QtQuick.Layouts import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import com.redstrate.sukai import com.redstrate.sukai.models Kirigami.ApplicationWindow { id: root pageStack.defaultColumnWidth: root.width function startupAccountCheck(): void { if (AccountManager.hasAccounts) { decideDefaultPage(); } else { pageStack.push(Qt.createComponent("qrc:/qt/qml/com/redstrate/sukai/ui/WelcomePage.qml")); } } function decideDefaultPage(): void { homeAction.trigger(); } globalDrawer: Sidebar { id: drawer enabled: AccountManager.hasAccounts && AccountManager.isReady actions: [homeAction] bottomActions: [settingsAction] } property Kirigami.Action homeAction: Kirigami.Action { icon.name: "go-home-symbolic" text: i18nc("@action:button", "Home") checkable: true onTriggered: { pageStack.clear(); pageStack.push(homeTimeline.createObject(root)); checked = true; } } property Kirigami.Action settingsAction: Kirigami.Action { icon.name: "configure-symbolic" text: i18nc("@action:button", "Settings") checkable: true onTriggered: Qt.createComponent("qrc:/qt/qml/com/redstrate/sukai/ui/SettingsPage.qml").createObject(root).open(); } Component.onCompleted: { if (AccountManager.isReady) { startupAccountCheck(); } } Connections { target: AccountManager function onAccountSelected(): void { root.decideDefaultPage(); } function onAccountsReady(): void { root.startupAccountCheck(); } } Connections { target: Navigation function onOpenProfile(did: string, handle: string): void { pageStack.push(Qt.createComponent("qrc:/qt/qml/com/redstrate/sukai/ui/ProfilePage.qml"), { did, handle }); } function onOpenThread(uri: string): void { pageStack.push(Qt.createComponent("qrc:/qt/qml/com/redstrate/sukai/ui/ThreadPage.qml"), { uri }); } } Component { id: homeTimeline TimelinePage { id: timelinePage model: TimelineModel { Component.onCompleted: load(AccountManager.selectedAccount) } } } }