import QtQuick import QtQuick.Controls import Asteria import QtQml ApplicationWindow { id: window width: 1024 height: 768 visible: true title: "Asteria" color: ThemeManager.currentTheme.backgroundDeepest FontLoader { id: materialIcons source: "qrc:/Asteria/src/assets/MaterialIconsOutlined-Regular.otf" } property bool sidebarOpen: appState.sidebarOpen onSidebarOpenChanged: appState.sidebarOpen = sidebarOpen property string currentPage: "starter" property bool _restoringState: false property bool barsVisible: true 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 } // Initialize theme from AppState if (appState.themeName !== "") { ThemeManager.currentThemeName = appState.themeName } if (appState.lastFilePath !== "") { window._restoringState = true bookController.openBook(appState.lastFileUrl()) } else { window.sidebarOpen = true var savedPage = appState.lastPage if (savedPage === "library" || savedPage === "settings") window.currentPage = savedPage } } Connections { target: appState function onThemeNameChanged() { ThemeManager.currentThemeName = appState.themeName } } 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 } onOpenFile: { bookController.browseAndOpen() } onCloseBook: { bookController.closeBook() } } Column { width: parent.width - sidebar.width height: parent.height Header { id: header width: parent.width sidebarOpen: window.sidebarOpen currentPage: window.currentPage barsVisible: window.currentPage !== "reader" || window.barsVisible onMenuClicked: window.sidebarOpen = true } Item { id: contentArea width: parent.width height: parent.height - header.height - (footerLoader.active ? ThemeManager.currentTheme.footerHeight : 0) StarterPage { anchors.fill: parent visible: window.currentPage === "starter" } ReaderPage { id: 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" && window.barsVisible sourceComponent: Footer {} } } } ErrorPopup { anchors.fill: parent z: 3000 } // Global keyboard shortcuts - work regardless of focus Shortcut { sequence: "F" context: Qt.ApplicationShortcut onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen } Shortcut { sequence: "F11" context: Qt.ApplicationShortcut onActivated: window.visibility = (window.visibility === Window.FullScreen) ? Window.Windowed : Window.FullScreen } Shortcut { sequence: "Up" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage?.pageView) { readerPage.pageView.handleScrollUp(); } } } Shortcut { sequence: "Down" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage?.pageView) { readerPage.pageView.handleScrollDown(); } } } Shortcut { sequence: "PgUp" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage?.pageView) { readerPage.pageView.handlePageUp(); } } } Shortcut { sequence: "PgDown" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage?.pageView) { readerPage.pageView.handlePageDown(); } } } // Fallback shortcuts using alternative key names Shortcut { sequence: "Prior" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage?.pageView) { readerPage.pageView.handlePageUp(); } } } Shortcut { sequence: "Next" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage?.pageView) { readerPage.pageView.handlePageDown(); } } } Shortcut { sequence: "Space" context: Qt.ApplicationShortcut onActivated: { if (currentPage === "reader" && readerPage) { readerPage.pageView.handlePageDown(); } } } Connections { target: bookController function onBookReady() { if (window._restoringState) { window._restoringState = false var savedPage = appState.lastPage if (savedPage === "library" || savedPage === "settings") window.currentPage = savedPage else window.currentPage = "reader" } else { window.currentPage = "reader" } } function onBookChanged() { if (!bookController.hasBook && window.currentPage === "reader") window.currentPage = "starter" } } }