Files
asteria-qt/src/backend/reading/MeasurementController.h
T
2026-07-31 17:31:02 +02:00

38 lines
1.1 KiB
C++

#pragma once
#include <QFuture>
#include <QObject>
#include <QStringList>
#include <QVector>
#include <memory>
#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<IImageLoader> 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<int> heights, bool isNew);
private:
std::unique_ptr<IImageLoader> m_imageLoader;
bool m_measuring = false;
QFuture<void> m_future;
};