diff --git a/src/backend/ChunkMeasurer.cpp b/src/backend/ChunkMeasurer.cpp index 55c8e79..7d4c295 100644 --- a/src/backend/ChunkMeasurer.cpp +++ b/src/backend/ChunkMeasurer.cpp @@ -44,7 +44,7 @@ QVector ChunkMeasurer::measure(const QStringList &chunks, qreal textWidth) QVector heights(n, 0); QAtomicInt nextIdx(0); - const int threadCount = QThread::idealThreadCount(); + const int threadCount = 2; // Capture by value what each worker needs (no shared mutable state) auto worker = [&]() { diff --git a/src/qml/Main.qml b/src/qml/Main.qml index c117ca5..60f214f 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -23,6 +23,7 @@ ApplicationWindow { property bool barsVisible: true // Set to true on the first book open at startup so we restore the last page. property bool _startupRestore: false + property bool _bookInitializing: false onCurrentPageChanged: uiState.lastPage = currentPage @@ -46,6 +47,20 @@ ApplicationWindow { } } + Connections { + target: book + function onLoadingChanged() { + if (book.loading) window._bookInitializing = true + } + } + + Connections { + target: readingModel + function onMeasuringChanged() { + if (!readingModel.measuring) window._bookInitializing = false + } + } + Timer { id: geometrySaveTimer interval: 250 @@ -123,10 +138,12 @@ ApplicationWindow { BusyIndicator { anchors.centerIn: parent - running: book.loading || readingModel.measuring + running: window._bookInitializing visible: running z: 10 } + + } Loader { diff --git a/src/qml/components/Footer.qml b/src/qml/components/Footer.qml index 83a1ac9..257e0e2 100644 --- a/src/qml/components/Footer.qml +++ b/src/qml/components/Footer.qml @@ -13,6 +13,25 @@ Rectangle { anchors.top: parent.top } + // Measuring spinner + Text { + anchors.left: parent.left + anchors.leftMargin: 16 + anchors.verticalCenter: parent.verticalCenter + visible: typeof readingModel !== "undefined" && readingModel.measuring + text: "\ue863" + font.family: "Material Icons Outlined" + font.pixelSize: 14 + color: ThemeManager.currentTheme.dimText + + RotationAnimator on rotation { + from: 0; to: 360 + duration: 1200 + loops: Animation.Infinite + running: parent.visible + } + } + // Prev chapter button Button { id: prevBtn