/
ka_pie
/
PeakOff
Обзор
Документация
Войти
/
ka_pie
/
PeakOff
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/imageprocessor.h
134 строки
4 KB
Viktoria
final version of PeakOff
14 июл 2026, 11:13
14 июл 2026, 11:13
a838933
Код
Авторство
О чём код?
#include "processingworker.h" #ifndef IMAGEPROCESSOR_H #define IMAGEPROCESSOR_H #include <QObject> #include <QThread> #include <QMutex> #include <QImage> #include <QString> #include <memory> #include <QObject> #include <QString> #include <QColor> class PhotoModel; class HistoryModel; class ProcessingWorker; class ImageProcessor : public QObject { Q_OBJECT Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged) Q_PROPERTY(QString resultSource READ resultSource NOTIFY resultSourceChanged) Q_PROPERTY(QString processingTime READ processingTime NOTIFY processingTimeChanged) Q_PROPERTY(PhotoModel* photoModel READ photoModel WRITE setPhotoModel NOTIFY photoModelChanged) Q_PROPERTY(HistoryModel* historyModel READ historyModel WRITE setHistoryModel NOTIFY historyModelChanged) Q_PROPERTY(qreal styleStrength READ styleStrength WRITE setStyleStrength NOTIFY styleStrengthChanged) public: explicit ImageProcessor(QObject *parent = nullptr); ~ImageProcessor(); bool isBusy() const { return m_busy; } QString resultSource() const { return m_resultSource; } QString processingTime() const { return m_processingTime; } float styleStrength() const { return m_styleStrength; } void setStyleStrength(float strength); PhotoModel* photoModel() const { return m_photoModel; } void setPhotoModel(PhotoModel *model); HistoryModel* historyModel() const { return m_historyModel; } void setHistoryModel(HistoryModel *model); Q_INVOKABLE void cleanup(); Q_INVOKABLE void saveProjectData(QObject *projectHistoryObj, const QString &originalPhotoPath, const QString &projectName); Q_INVOKABLE void applyCorrection(int brightness, float contrast); Q_INVOKABLE void commitCorrectionStep(); Q_INVOKABLE void cancelCorrection(); Q_INVOKABLE void replaceBackground(const QString& hexColor); Q_INVOKABLE void applyManualMask(const QString& maskFileUrl, bool isEraser); Q_INVOKABLE void replaceBackgroundWithImage(const QString &imagePath); public slots: void applyEnhance(); void applyRemoveBackground(); void applyStyle(int styleIndex = 0); void undo(); void redo(); void resetToOriginal(); Q_INVOKABLE void applyHistoryStep(int index); Q_INVOKABLE void restoreSteps(const QVariantList &steps); Q_INVOKABLE void loadProjectFromJson(const QString &path); void processStep(const QString &operation, const QVariant ¶ms); void saveToGallery(); void cancelProcessing(); void startCompare(); void stopCompare(); void applyCrop(int x, int y, int width, int height); signals: void busyChanged(); void resultSourceChanged(); void processingTimeChanged(); void styleStrengthChanged(); void photoModelChanged(); void historyModelChanged(); void errorOccurred(const QString &message); void operationCompleted(const QString &operationName); void imageProcessed(); void historyApplied(); private slots: void onProcessingFinished(const QImage &result, const QString &operation); void onProcessingError(const QString &error); void onMetricsReady(const ProcessingMetrics &metrics); void onProgressChanged(int percent); void onCorrectionFinished(const QImage &result); private: void setBusy(bool busy); void setResult(const QImage &image); void updateResultSource(); void pushHistory(const QImage &image, const QString &operation); PhotoModel *m_photoModel = nullptr; HistoryModel *m_historyModel = nullptr; std::unique_ptr<ProcessingWorker> m_worker; std::unique_ptr<QThread> m_workerThread; bool m_busy = false; QString m_resultSource; QString m_processingTime; float m_styleStrength = 0.5f; QMutex m_mutex; bool m_cancelled = false; QImage m_currentResult; QImage m_compareOriginal; QImage m_lastBaseImage; cv::Mat m_currentImage; cv::Mat m_currentMask; cv::Mat m_resultImage; }; #endif