#pragma once #include #include #include #include #include #include "backend/IImageLoader.h" // Runs chunk height measurement off the GUI thread and reports the results // back on it. Owns the image loader used to resolve embedded images and the // lifetime of the in-flight measurement. class MeasurementController : public QObject { Q_OBJECT public: explicit MeasurementController(QObject *parent = nullptr); ~MeasurementController() override; void setImageLoader(std::unique_ptr loader); // isNew is passed through untouched to heightsReady so the owner knows // whether this measurement should trigger a position restore. void start(const QStringList &htmls, int contentWidth, int fontSize, qreal lineSpacing, bool isNew); bool measuring() const; signals: void measuringChanged(); void heightsReady(QVector heights, bool isNew); private: std::unique_ptr m_imageLoader; bool m_measuring = false; QFuture m_future; };