139 lines
3.8 KiB
QML
139 lines
3.8 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import Asteria
|
|
|
|
ApplicationWindow {
|
|
id: window
|
|
width: 1024
|
|
height: 768
|
|
visible: true
|
|
title: "Asteria"
|
|
color: Theme.backgroundDeepest
|
|
|
|
FontLoader {
|
|
id: materialIcons
|
|
source: "qrc:/Asteria/src/assets/MaterialIconsOutlined-Regular.otf"
|
|
}
|
|
|
|
property bool sidebarOpen: false
|
|
property string currentPage: "starter"
|
|
property string pageFlipMode: appState.pageFlipMode
|
|
|
|
onCurrentPageChanged: appState.lastPage = currentPage
|
|
|
|
Component.onCompleted: {
|
|
width = appState.windowWidth
|
|
height = appState.windowHeight
|
|
if (appState.windowX >= 0 && appState.windowY >= 0) {
|
|
x = appState.windowX
|
|
y = appState.windowY
|
|
}
|
|
if (appState.lastFilePath !== "")
|
|
bookController.openBook(appState.lastFileUrl())
|
|
var savedPage = appState.lastPage
|
|
if (savedPage === "library" || savedPage === "settings")
|
|
window.currentPage = savedPage
|
|
}
|
|
|
|
Timer {
|
|
id: geometrySaveTimer
|
|
interval: 500
|
|
repeat: false
|
|
onTriggered: {
|
|
appState.windowWidth = window.width
|
|
appState.windowHeight = window.height
|
|
appState.windowX = window.x
|
|
appState.windowY = window.y
|
|
}
|
|
}
|
|
|
|
onWidthChanged: geometrySaveTimer.restart()
|
|
onHeightChanged: geometrySaveTimer.restart()
|
|
onXChanged: geometrySaveTimer.restart()
|
|
onYChanged: geometrySaveTimer.restart()
|
|
|
|
Row {
|
|
anchors.fill: parent
|
|
|
|
SideBar {
|
|
id: sidebar
|
|
height: parent.height
|
|
sidebarOpen: window.sidebarOpen
|
|
onCloseDrawer: window.sidebarOpen = false
|
|
onNavigateTo: function(page) {
|
|
window.currentPage = page
|
|
window.sidebarOpen = false
|
|
}
|
|
onOpenFile: {
|
|
bookController.browseAndOpen()
|
|
}
|
|
onCloseBook: {
|
|
bookController.closeBook()
|
|
window.sidebarOpen = false
|
|
}
|
|
}
|
|
|
|
Column {
|
|
width: parent.width - sidebar.width
|
|
height: parent.height
|
|
|
|
Header {
|
|
id: header
|
|
width: parent.width
|
|
sidebarOpen: window.sidebarOpen
|
|
currentPage: window.currentPage
|
|
onMenuClicked: window.sidebarOpen = true
|
|
}
|
|
|
|
Item {
|
|
id: contentArea
|
|
width: parent.width
|
|
height: parent.height - header.height - (footerLoader.active ? Theme.footerHeight : 0)
|
|
|
|
StarterPage {
|
|
anchors.fill: parent
|
|
visible: window.currentPage === "starter"
|
|
}
|
|
|
|
ReaderPage {
|
|
anchors.fill: parent
|
|
visible: window.currentPage === "reader"
|
|
}
|
|
|
|
SettingsPage {
|
|
anchors.fill: parent
|
|
visible: window.currentPage === "settings"
|
|
}
|
|
|
|
LibraryPage {
|
|
anchors.fill: parent
|
|
visible: window.currentPage === "library"
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: footerLoader
|
|
width: parent.width
|
|
active: window.currentPage === "reader"
|
|
sourceComponent: Footer {}
|
|
}
|
|
}
|
|
}
|
|
|
|
ErrorPopup {
|
|
anchors.fill: parent
|
|
z: 3000
|
|
}
|
|
|
|
Connections {
|
|
target: bookController
|
|
function onBookReady() {
|
|
window.currentPage = "reader"
|
|
}
|
|
function onBookChanged() {
|
|
if (!bookController.hasBook && window.currentPage === "reader")
|
|
window.currentPage = "starter"
|
|
}
|
|
}
|
|
}
|