Archived
1
Fork 0
This repository has been archived on 2025-04-27. You can view files and clone it, but cannot push or open issues or pull requests.
sukai/ui/Main.qml
Joshua Goins bdd63771bc Add a sidebar
It only has one action, but it's a start.
2024-12-16 16:20:57 -05:00

89 lines
No EOL
2.2 KiB
QML

// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
// 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: []
}
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;
}
}
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)
}
}
}
}