Some refactor
This commit is contained in:
37 files changed
+1599
-981
No files matched your search
+62
-52
@@ -17,49 +17,51 @@ ApplicationWindow {
|
||||
source: "qrc:/Asteria/src/assets/MaterialIconsOutlined-Regular.otf"
|
||||
}
|
||||
|
||||
property bool sidebarOpen: appState.sidebarOpen
|
||||
onSidebarOpenChanged: appState.sidebarOpen = sidebarOpen
|
||||
property bool sidebarOpen: uiState.sidebarOpen
|
||||
onSidebarOpenChanged: uiState.sidebarOpen = sidebarOpen
|
||||
property string currentPage: "starter"
|
||||
property bool barsVisible: true
|
||||
// Set to true on the first book open at startup so we restore the last page.
|
||||
property bool _startupRestore: false
|
||||
|
||||
onCurrentPageChanged: appState.lastPage = currentPage
|
||||
onCurrentPageChanged: uiState.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
|
||||
width = uiState.windowWidth
|
||||
height = uiState.windowHeight
|
||||
if (uiState.windowX >= 0 && uiState.windowY >= 0) {
|
||||
x = uiState.windowX
|
||||
y = uiState.windowY
|
||||
}
|
||||
if (uiState.themeName !== "")
|
||||
ThemeManager.currentThemeName = uiState.themeName
|
||||
|
||||
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: appState
|
||||
target: uiState
|
||||
function onThemeNameChanged() {
|
||||
ThemeManager.currentThemeName = appState.themeName
|
||||
ThemeManager.currentThemeName = uiState.themeName
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: geometrySaveTimer
|
||||
interval: 500
|
||||
interval: 250
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
appState.windowWidth = window.width
|
||||
appState.windowHeight = window.height
|
||||
appState.windowX = window.x
|
||||
appState.windowY = window.y
|
||||
uiState.windowWidth = window.width
|
||||
uiState.windowHeight = window.height
|
||||
uiState.windowX = window.x
|
||||
uiState.windowY = window.y
|
||||
}
|
||||
}
|
||||
|
||||
onWidthChanged: geometrySaveTimer.restart()
|
||||
onWidthChanged: geometrySaveTimer.restart()
|
||||
onHeightChanged: geometrySaveTimer.restart()
|
||||
onXChanged: geometrySaveTimer.restart()
|
||||
onYChanged: geometrySaveTimer.restart()
|
||||
onXChanged: geometrySaveTimer.restart()
|
||||
onYChanged: geometrySaveTimer.restart()
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
@@ -73,10 +75,10 @@ ApplicationWindow {
|
||||
window.currentPage = page
|
||||
}
|
||||
onOpenFile: {
|
||||
bookController.browseAndOpen()
|
||||
book.browseAndOpen()
|
||||
}
|
||||
onCloseBook: {
|
||||
bookController.closeBook()
|
||||
book.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +123,7 @@ ApplicationWindow {
|
||||
|
||||
BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
running: bookController.loading || readingModel.measuring
|
||||
running: book.loading || readingModel.measuring
|
||||
visible: running
|
||||
z: 10
|
||||
}
|
||||
@@ -141,6 +143,32 @@ ApplicationWindow {
|
||||
z: 3000
|
||||
}
|
||||
|
||||
// Navigate once measurement (and position restoration) is done
|
||||
Connections {
|
||||
target: readingModel
|
||||
function onRestoreReady(chunkIndex, intraOffset) {
|
||||
if (!book.hasBook) return
|
||||
if (window._startupRestore) {
|
||||
window._startupRestore = false
|
||||
var savedPage = uiState.lastPage
|
||||
if (savedPage === "library" || savedPage === "settings")
|
||||
window.currentPage = savedPage
|
||||
else
|
||||
window.currentPage = "reader"
|
||||
} else {
|
||||
window.currentPage = "reader"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: book
|
||||
function onBookChanged() {
|
||||
if (!book.hasBook && window.currentPage === "reader")
|
||||
window.currentPage = "starter"
|
||||
}
|
||||
}
|
||||
|
||||
// Global keyboard shortcuts - work regardless of focus
|
||||
Shortcut {
|
||||
sequence: "F"
|
||||
@@ -188,7 +216,6 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fallback shortcuts using alternative key names
|
||||
Shortcut {
|
||||
sequence: "Prior"
|
||||
context: Qt.ApplicationShortcut
|
||||
@@ -217,31 +244,6 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: bookController
|
||||
function onBookReady() {
|
||||
if (bookController.startupRestore) {
|
||||
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"
|
||||
}
|
||||
function onNoSavedBook() {
|
||||
window.sidebarOpen = true
|
||||
var savedPage = appState.lastPage
|
||||
if (savedPage === "library" || savedPage === "settings")
|
||||
window.currentPage = savedPage
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
repeat: false
|
||||
@@ -250,7 +252,15 @@ ApplicationWindow {
|
||||
onTriggered: {
|
||||
window.opacity = 1
|
||||
readerPage.pageView.updateContentWidth()
|
||||
bookController.uiReady()
|
||||
if (uiState.lastFilePath !== "") {
|
||||
window._startupRestore = true
|
||||
book.openFromPath(uiState.lastFilePath)
|
||||
} else {
|
||||
var savedPage = uiState.lastPage
|
||||
if (savedPage === "library" || savedPage === "settings")
|
||||
window.currentPage = savedPage
|
||||
window.sidebarOpen = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user