CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
image_controller_base.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <QObject>
11#include <memory>
12#include <QThread>
13#include <QUrl>
14
15#include "engine/photo_engine.h"
20
21namespace CaptureMoment::UI {
22class IOperationModel;
23
24namespace Controller {
36class ImageControllerBase : public QObject {
37 Q_OBJECT
38
40 Q_PROPERTY(int imageWidth READ imageWidth NOTIFY imageSizeChanged)
42 Q_PROPERTY(int imageHeight READ imageHeight NOTIFY imageSizeChanged)
43
51 Q_PROPERTY(CaptureMoment::UI::Display::DisplayManager* displayManager READ displayManager CONSTANT)
52
60 Q_PROPERTY(CaptureMoment::UI::Managers::OperationStateManager* operationStateManager READ operationStateManager CONSTANT)
61
62public:
67 explicit ImageControllerBase(QObject* parent = nullptr);
68
73
77 [[nodiscard]] int imageWidth() const noexcept { return m_image_width; }
78
82 [[nodiscard]] int imageHeight() const noexcept { return m_image_height; }
83
93 void registerModel(IOperationModel* model);
94
99
103 [[nodiscard]] CaptureMoment::UI::Managers::OperationStateManager* operationStateManager() { return m_operation_state_manager.get(); }
104
109
115 void doLoadImage(const QString& file_path);
116
124 void doApplyOperations(std::vector<Core::Operations::OperationDescriptor>&& operations);
125
131 Q_INVOKABLE void loadImageFromUrl(const QUrl& file_url);
132
133private :
137 QThread m_worker_thread;
138
139
150 std::shared_ptr<Core::Common::ImageRegion> m_source_image;
151
156 std::vector<IOperationModel*> m_registered_models;
157
161 std::unique_ptr<CaptureMoment::UI::Managers::OperationStateManager> m_operation_state_manager {nullptr};
162
163
167 std::unique_ptr<CaptureMoment::UI::Models::Manager::OperationModelManager> m_operation_model_manager {nullptr};
168
169public slots:
174 void loadImage(const QString& file_path);
175
185 void applyOperations(std::vector<Core::Operations::OperationDescriptor> operations);
186
192 void onImageLoadResult(bool success, const QString& error_msg);
193
199 void onOperationResult(bool success, const QString& error_msg);
200
201signals:
207 void imageLoaded(int width, int height);
208
213 void imageLoadFailed(QString error);
214
219
224 void operationFailed(QString error);
225
230
231protected:
235 std::shared_ptr<Core::Engine::PhotoEngine> m_engine;
236
240 std::unique_ptr<CaptureMoment::UI::Display::DisplayManager> m_display_manager {nullptr};
241
247
252
257};
258
259} // namespace Controller
260
261} // namespace CaptureMoment::UI
CaptureMoment::UI::Models::Manager::OperationModelManager * operationModelManager()
Get current operationModelManager instance.
std::unique_ptr< CaptureMoment::UI::Display::DisplayManager > m_display_manager
The unique displaymanager instance for managing display updates.
CaptureMoment::UI::Display::DisplayManager * displayManager()
Get current displayManager instance.
Q_INVOKABLE void loadImageFromUrl(const QUrl &file_url)
Loads an image from a QUrl (typically from QML FileDialog). Converts the QUrl to a native file path a...
void imageSizeChanged()
Emitted when image size changes.
void doApplyOperations(std::vector< Core::Operations::OperationDescriptor > &&operations)
Perform actual operations (runs on worker thread).
void applyOperations(std::vector< Core::Operations::OperationDescriptor > operations)
Apply operation with parameters (non-blocking) Note: This slot is designed to be called from QML or o...
void registerModel(IOperationModel *model)
Register an operation model for notifications.
void connectModelsToStateManager()
Connects the operationRequested signal from all created models to the OperationStateManager....
void onImageLoadResult(bool success, const QString &error_msg)
Internal: Handle load image result.
void onOperationResult(bool success, const QString &error_msg)
Internal: Handle operation result.
int imageHeight() const noexcept
Get current image height.
CaptureMoment::UI::Managers::OperationStateManager * operationStateManager
Exposes the OperationStateManager instance to QML.
std::shared_ptr< Core::Engine::PhotoEngine > m_engine
Core processing engine.
void operationCompleted()
Emitted when operation completes.
void loadImage(const QString &file_path)
Load image from file path (non-blocking)
CaptureMoment::UI::Managers::OperationStateManager * operationStateManager()
Get current operationStateManager instance.
void operationFailed(QString error)
Emitted when operation fails.
void imageLoadFailed(QString error)
Emitted when image load fails.
void doLoadImage(const QString &file_path)
Perform actual image load (runs on worker thread). This method contains the common logic for loading ...
CaptureMoment::UI::Display::DisplayManager * displayManager
Exposes the DisplayManager instance to QML.
void imageLoaded(int width, int height)
Emitted when image loaded successfully.
Central manager for image display, zoom, pan, and viewport coordination.
Pure interface for operation models.
Manages the state of active image operations.
Manages the creation, storage, and QML registration of operation model instances.
Manages image display with downsampling (with OIIO), zoom, and pan.
Manages the state of active image operations.
Declaration of PhotoEngine class.
CaptureMoment — footer