Adding loading screen for rendering LaTeX formula when threaded setting is enabled.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
27c9fe0473
commit
727dda2623
13 changed files with 168 additions and 34 deletions
|
@ -17,10 +17,10 @@
|
|||
*/
|
||||
|
||||
import QtQml
|
||||
import QtQuick.Controls
|
||||
import eu.ad5001.MixedMenu 1.1
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts 1.12
|
||||
import eu.ad5001.MixedMenu 1.1
|
||||
|
||||
// Auto loading all modules.
|
||||
import eu.ad5001.LogarithmPlotter.Common
|
||||
|
@ -158,21 +158,17 @@ ApplicationWindow {
|
|||
Overlay.ViewPositionChange {
|
||||
id: viewPositionChanger
|
||||
anchors.fill: parent
|
||||
canvas: parent
|
||||
settingsInstance: settings
|
||||
}
|
||||
|
||||
Overlay.PickLocation {
|
||||
id: positionPicker
|
||||
anchors.fill: parent
|
||||
canvas: parent
|
||||
}
|
||||
}
|
||||
|
||||
// Overlay.Loading {
|
||||
// id: loadingOverlay
|
||||
// anchors.fill: parent
|
||||
// canvas: parent
|
||||
// }
|
||||
Overlay.Loading {
|
||||
id: loadingOverlay
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
@ -56,7 +56,7 @@ ScrollView {
|
|||
property var editingRows: []
|
||||
model: Modules.Objects.currentObjects[objType]
|
||||
width: objectsListView.width
|
||||
implicitHeight: contentItem.childrenRect.height
|
||||
height: contentItem.childrenRect.height + 10
|
||||
visible: model != undefined && model.length > 0
|
||||
interactive: false
|
||||
|
||||
|
|
|
@ -17,3 +17,114 @@
|
|||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
|
||||
/*!
|
||||
\qmltype Loading
|
||||
\inqmlmodule eu.ad5001.LogarithmPlotter.Overlay
|
||||
\brief Overlay notifiying the user when a file is loading.
|
||||
|
||||
Provides an overlay over the canvas that is shown when the user loads a new file, both to lock the ViewPositionChange
|
||||
overlay and inform the user of what is loading and how much remains.
|
||||
|
||||
\sa Common, ViewPositionChange
|
||||
*/
|
||||
Item {
|
||||
id: loadingRoot
|
||||
opacity: 0
|
||||
visible: opacity !== 0
|
||||
clip: true
|
||||
|
||||
property int currentlyLoading: 0
|
||||
property int maxCurrentLoadingSteps: 0
|
||||
|
||||
Behavior on opacity { PropertyAnimation {} }
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: sysPalette.window
|
||||
opacity: 0.85
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 5
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
Text {
|
||||
id: loadingTitle
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
font.pixelSize: 20
|
||||
color: sysPalette.windowText
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: progress
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 300
|
||||
from: 0
|
||||
value: loadingRoot.maxCurrentLoadingSteps - loadingRoot.currentlyLoading
|
||||
to: loadingRoot.maxCurrentLoadingSteps
|
||||
}
|
||||
|
||||
Text {
|
||||
id: lastFinishedStep
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
color: sysPalette.windowText
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: picker
|
||||
anchors.fill: parent
|
||||
hoverEnabled: parent.visible
|
||||
cursorShape: Qt.ArrowCursor
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\qmlmethod void Loading::addedLoadingStep()
|
||||
Registers one new loading step that will eventually call \c finishedLoadingStep.
|
||||
*/
|
||||
function addedLoadingStep() {
|
||||
if(loadingRoot.maxCurrentLoadingSteps === 1) {
|
||||
// Only when several ones need to be loaded.
|
||||
const fileName = Modules.Settings.saveFilename.split('/').pop().split('\\').pop()
|
||||
loadingTitle.text = qsTr("Loading...")
|
||||
loadingRoot.opacity = 1
|
||||
}
|
||||
loadingRoot.currentlyLoading++
|
||||
loadingRoot.maxCurrentLoadingSteps++
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod void Loading::finishedLoadingStep()
|
||||
Marks a loading step as finished and displays the message to the user.
|
||||
*/
|
||||
function finishedLoadingStep(message) {
|
||||
loadingRoot.currentlyLoading--
|
||||
const current = loadingRoot.maxCurrentLoadingSteps - loadingRoot.currentlyLoading
|
||||
lastFinishedStep.text = `${message} (${current}/${loadingRoot.maxCurrentLoadingSteps})`
|
||||
if(loadingRoot.currentlyLoading === 0) {
|
||||
loadingRoot.maxCurrentLoadingSteps = 0
|
||||
loadingRoot.opacity = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component.onCompleted: function() {
|
||||
Modules.Latex.on("async-render-started", (e) => {
|
||||
addedLoadingStep()
|
||||
})
|
||||
Modules.Latex.on("async-render-finished", (e) => {
|
||||
const markup = e.markup.length > 20 ? e.markup.substring(0, 15)+"..." : e.markup
|
||||
finishedLoadingStep(qsTr("Finished rendering of %1").arg(markup))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,16 +57,6 @@ Item {
|
|||
*/
|
||||
signal endPositionChange(int deltaX, int deltaY)
|
||||
|
||||
/*!
|
||||
\qmlproperty var ViewPositionChangeOverlay::canvas
|
||||
LogGraphCanvas instance.
|
||||
*/
|
||||
property var canvas
|
||||
/*!
|
||||
\qmlproperty var ViewPositionChangeOverlay::settingsInstance
|
||||
Settings instance.
|
||||
*/
|
||||
property var settingsInstance
|
||||
/*!
|
||||
\qmlproperty int ViewPositionChangeOverlay::prevX
|
||||
The x coordinate (on the mousearea) at the last change of the canvas position.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module eu.ad5001.LogarithmPlotter.Overlay
|
||||
|
||||
Loading 1.0 Loading.qml
|
||||
PickLocation 1.0 PickLocation.qml
|
||||
ViewPositionChange 1.0 ViewPositionChange.qml
|
||||
|
|
|
@ -28,7 +28,7 @@ DEFAULT_SETTINGS = {
|
|||
"reset_redo_stack": True,
|
||||
"last_install_greet": "0",
|
||||
"enable_latex": which("latex") is not None and which("dvipng") is not None,
|
||||
"enable_latex_async": True,
|
||||
"enable_latex_threaded": True,
|
||||
"expression_editor": {
|
||||
"autoclose": True,
|
||||
"colorize": True,
|
||||
|
|
|
@ -22,9 +22,9 @@ from os import path
|
|||
from re import compile
|
||||
|
||||
CURRENT_PATH = path.dirname(path.realpath(__file__))
|
||||
SOURCEMAP_PATH = path.realpath(f"{CURRENT_PATH}/../qml/eu/ad5001/LogarithmPlotter/js/index.mjs.map")
|
||||
SOURCEMAP_PATH = path.realpath(f"{CURRENT_PATH}/../qml/eu/ad5001/LogarithmPlotter/Common/index.mjs.map")
|
||||
SOURCEMAP_INDEX = None
|
||||
INDEX_REG = compile(r"build\/runtime-pyside6\/LogarithmPlotter\/qml\/eu\/ad5001\/LogarithmPlotter\/js\/index.mjs:(\d+)")
|
||||
INDEX_REG = compile(r"build\/runtime-pyside6\/LogarithmPlotter\/qml\/eu\/ad5001\/LogarithmPlotter\/Common\/index.mjs:(\d+)")
|
||||
|
||||
|
||||
class LOG_COLORS:
|
||||
|
|
|
@ -91,7 +91,7 @@ class Latex(QObject):
|
|||
|
||||
@Property(bool)
|
||||
def supportsAsyncRender(self) -> bool:
|
||||
return config.getSetting("enable_latex_async")
|
||||
return config.getSetting("enable_latex_threaded")
|
||||
|
||||
@Slot(result=bool)
|
||||
def checkLatexInstallation(self) -> bool:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue