Add usability updates to the build tool (#1846)

This commit is contained in:
Veronica Berglyd Olsen
2024-05-01 22:18:15 +02:00
committed by GitHub
3 changed files with 14 additions and 9 deletions
+4 -3
View File
@@ -44,9 +44,7 @@ from novelwriter.core.item import NWItem
from novelwriter.enum import nwBuildFmt
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.extensions.simpleprogress import NProgressSimple
from novelwriter.types import (
QtAlignCenter, QtDialogClose, QtRoleAction, QtRoleReject, QtUserRole
)
from novelwriter.types import QtAlignCenter, QtDialogClose, QtRoleAction, QtRoleReject, QtUserRole
logger = logging.getLogger(__name__)
@@ -328,6 +326,9 @@ class GuiManuscriptBuild(QDialog):
):
return False
# Make sure editor content is saved before we start
SHARED.mainGui.saveDocument()
docBuild = NWBuildDocument(SHARED.project, self._build)
docBuild.queueAll()
+9 -5
View File
@@ -342,6 +342,9 @@ class GuiManuscript(QDialog):
if not (build := self._getSelectedBuild()):
return
# Make sure editor content is saved before we start
SHARED.mainGui.saveDocument()
docBuild = NWBuildDocument(SHARED.project, build)
docBuild.setPreviewMode(True)
docBuild.queueAll()
@@ -749,6 +752,7 @@ class _PreviewWidget(QTextBrowser):
self._docTime = 0
self._buildName = ""
self._scrollPos = 0
# Document Setup
dPalette = self.palette()
@@ -845,6 +849,7 @@ class _PreviewWidget(QTextBrowser):
self.buildProgress.setValue(0)
self.buildProgress.setCentreText(None)
self.buildProgress.setVisible(True)
self._scrollPos = self.verticalScrollBar().value()
self.setPlaceholderText("")
self.clear()
return
@@ -857,7 +862,6 @@ class _PreviewWidget(QTextBrowser):
def setContent(self, data: dict) -> None:
"""Set the content of the preview widget."""
sPos = self.verticalScrollBar().value()
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
self.buildProgress.setCentreText(self.tr("Processing ..."))
@@ -874,7 +878,6 @@ class _PreviewWidget(QTextBrowser):
cursor = self.textCursor()
cursor.insertText("\t")
self.verticalScrollBar().setValue(sPos)
self._docTime = checkInt(data.get("time"), 0)
self._updateBuildAge()
@@ -885,7 +888,7 @@ class _PreviewWidget(QTextBrowser):
self.buildProgress.setCentreText(self.tr("Done"))
QApplication.restoreOverrideCursor()
QApplication.processEvents()
QTimer.singleShot(300, self._hideProgress)
QTimer.singleShot(300, self._postUpdate)
return
@@ -940,9 +943,10 @@ class _PreviewWidget(QTextBrowser):
return
@pyqtSlot()
def _hideProgress(self) -> None:
"""Clean up the build progress bar."""
def _postUpdate(self) -> None:
"""Run tasks after content update."""
self.buildProgress.setVisible(False)
self.verticalScrollBar().setValue(self._scrollPos)
return
##
+1 -1
View File
@@ -270,7 +270,7 @@ def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
assert manus.docPreview.document().defaultTextOption().alignment() == QtAlignAbsolute
# Tests are too fast to trigger this one, so we trigger it manually to ensure it isn't failing
manus.docPreview._hideProgress()
manus.docPreview._postUpdate()
# Builds
# ======