status-desktop/storybook/main.qml

180 lines
4.2 KiB
QML

import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import Qt.labs.settings 1.0
import StatusQ.Core.Theme 0.1
import Storybook 1.0
ApplicationWindow {
id: root
width: 1450
height: 840
visible: true
property string currentPage
font.pixelSize: 13
HotReloader {
id: reloader
loader: viewLoader
enabled: hotReloaderControls.enabled
onReloaded: hotReloaderControls.notifyReload()
}
ListModel {
id: pagesModel
ListElement {
title: "ProfileDialogView"
section: "Views"
}
ListElement {
title: "CommunitiesPortalLayout"
section: "Views"
}
ListElement {
title: "LoginView"
section: "Views"
}
ListElement {
title: "AboutView"
section: "Views"
}
ListElement {
title: "CommunityProfilePopupInviteFriendsPanel"
section: "Panels"
}
ListElement {
title: "CommunityProfilePopupInviteMessagePanel"
section: "Panels"
}
ListElement {
title: "StatusCommunityCard"
section: "Panels"
}
ListElement {
title: "InviteFriendsToCommunityPopup"
section: "Popups"
}
ListElement {
title: "CreateChannelPopup"
section: "Popups"
}
ListElement {
title: "LanguageCurrencySettings"
section: "Settings"
}
ListElement {
title: "BrowserSettings"
section: "Settings"
}
ListElement {
title: "UserListPanel"
}
ListElement {
title: "ProfileFetchingView"
}
ListElement {
title: "MembersSelector"
}
}
SplitView {
anchors.fill: parent
ColumnLayout {
SplitView.preferredWidth: 240
CheckBox {
id: loadAsyncCheckBox
Layout.fillWidth: true
text: "Load asynchronously"
}
CheckBox {
id: darkModeCheckBox
Layout.fillWidth: true
text: "Dark mode"
StatusLightTheme { id: lightTheme }
StatusDarkTheme { id: darkTheme }
Binding {
target: Theme
property: "palette"
value: darkModeCheckBox.checked ? darkTheme : lightTheme
}
}
HotReloaderControls {
id: hotReloaderControls
Layout.fillWidth: true
onForceReloadClicked: reloader.forceReload()
}
Pane {
Layout.fillWidth: true
Layout.fillHeight: true
FilteredPagesList {
anchors.fill: parent
currentPage: root.currentPage
model: pagesModel
onPageSelected: root.currentPage = page
}
}
}
Item {
SplitView.fillWidth: true
Loader {
id: viewLoader
anchors.fill: parent
clip: true
source: `pages/${root.currentPage}Page.qml`
asynchronous: loadAsyncCheckBox.checked
visible: status === Loader.Ready
// force reload when `asynchronous` changes
onAsynchronousChanged: {
active = false
active = true
}
}
BusyIndicator {
anchors.centerIn: parent
visible: viewLoader.status === Loader.Loading
}
Label {
anchors.centerIn: parent
visible: viewLoader.status === Loader.Error
text: "Loading page failed"
}
}
}
Settings {
property alias currentPage: root.currentPage
property alias loadAsynchronously: loadAsyncCheckBox.checked
property alias darkMode: darkModeCheckBox.checked
property alias hotReloading: hotReloaderControls.enabled
}
}