chore: format llm c files
C++ / fmt (pull_request) Failing after 4s
C++ / build (pull_request) Failing after 9s
JS/TS / lint (pull_request) Successful in 9s
JS/TS / fmt (pull_request) Successful in 16s
C++ / clang-tidy (pull_request) Failing after 43s
Python / static (pull_request) Failing after 57s
Rust / fmt (pull_request) Successful in 1m30s
Rust / build (pull_request) Successful in 2m5s
Rust / clippy (pull_request) Successful in 1m55s
Python / verify (pull_request) Successful in 2m23s

This commit is contained in:
2026-08-31 19:02:26 +02:00
parent dbb51ceadd
commit 52feb6006a
27 changed files with 741 additions and 1190 deletions
+6 -17
View File
@@ -13,27 +13,20 @@
namespace ZShell::llm {
// QML wrapper around JKQTMathText (JKQtPlotter's LaTeX renderer).
//
// Parses a display-math string and renders it into a transparent
// QImage at the given device pixel ratio, off the GUI thread (with a
// process-wide cache keyed on the full render state, so re-opening a
// chat does not re-render the same equations). QML displays the image
// (scaling it to the bubble width when needed) and falls back to the
// raw LaTeX when parsing fails.
class LlmMathText : public QObject {
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString latex READ latex WRITE setLatex NOTIFY changed)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
Q_PROPERTY(double fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY changed)
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY changed)
Q_PROPERTY(
double fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY
changed)
Q_PROPERTY(
qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio
NOTIFY changed)
Q_PROPERTY(QImage image READ image NOTIFY changed)
// data: URL of the rendered equation; usable directly as
// Image.source (a raw QImage is not).
Q_PROPERTY(QUrl imageUrl READ imageUrl NOTIFY changed)
// Logical (CSS pixel) size of the rendered equation.
Q_PROPERTY(qreal width READ width NOTIFY changed)
Q_PROPERTY(qreal height READ height NOTIFY changed)
Q_PROPERTY(bool ok READ ok NOTIFY changed)
@@ -61,8 +54,6 @@ class LlmMathText : public QObject {
private:
void reRender();
// Shared so an in-flight worker render keeps the renderer alive if
// this object (and its QML item) is destroyed mid-render.
std::shared_ptr<JKQTMathText> m_renderer;
QString m_latex;
QColor m_color;
@@ -73,8 +64,6 @@ class LlmMathText : public QObject {
qreal m_width = 0;
qreal m_height = 0;
bool m_ok = false;
// Bumps on every reRender; a delivery carrying an older id was
// superseded and is dropped.
int m_requestId = 0;
bool m_inFlight = false;
};