Files

63 lines
1.7 KiB
C++

#pragma once
#include <QColor>
#include <QObject>
#include <QString>
#include <QtQml>
namespace ZShell::llm {
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(QString imageId READ imageId NOTIFY changed)
Q_PROPERTY(qreal width READ width NOTIFY changed)
Q_PROPERTY(qreal height READ height NOTIFY changed)
Q_PROPERTY(bool ok READ ok NOTIFY changed)
public:
explicit LlmMathText(QObject* parent = nullptr);
~LlmMathText() override;
[[nodiscard]] QString latex() const { return m_latex; }
void setLatex(const QString& value);
[[nodiscard]] QColor color() const { return m_color; }
void setColor(const QColor& value);
[[nodiscard]] double fontPointSize() const { return m_fontPointSize; }
void setFontPointSize(double value);
[[nodiscard]] qreal devicePixelRatio() const { return m_devicePixelRatio; }
void setDevicePixelRatio(qreal value);
[[nodiscard]] QString imageId() const { return m_imageId; }
[[nodiscard]] qreal width() const { return m_width; }
[[nodiscard]] qreal height() const { return m_height; }
[[nodiscard]] bool ok() const { return m_ok; }
Q_SIGNALS:
void changed();
private:
void reRender();
QString m_latex;
QColor m_color;
double m_fontPointSize = 12.0;
qreal m_devicePixelRatio = 1.0;
QString m_imageId;
qreal m_width = 0;
qreal m_height = 0;
bool m_ok = false;
int m_requestId = 0;
bool m_inFlight = false;
};
} // namespace ZShell::llm