🏗️ Qt::Desktop Architecture (QML Layer)¶
Overview¶
This section describes the QML user interface layer. It interacts with the Qt/C++ UI Core layer (ImageControllerBase, Operation Models, SerializerController) to provide the user experience for loading images, adjusting parameters, viewing results, and managing operation persistence.
🔗 Dependencies¶
* Qt Libraries: Qt6::Widget.¶
Key QML Components¶
QML Operation Widgets¶
- Role: Individual UI controls (e.g., sliders, checkboxes) for specific image adjustments (e.g., Brightness, Contrast).
- Interaction: Bind to C++ operation models (e.g.,
brightnessControl,contrastControl) obtained from the QML context. Trigger updates via model setters (e.g.,model.setValue(newVal)).
QML Panels¶
- Role: Organizational containers (e.g.,
TonePanel.qml) grouping related operation widgets together.
QML Display Area¶
- Role: Central area hosting the Qt Quick rendering item (e.g.,
QMLSGSImageItem.qml,QMLRHIImageItem.qml,QMLPaintedImageItem.qml) which displays the processed image received from theDisplayManager.
QML Context Integration¶
- Role: The QML layer receives C++ objects from
QmlContextSetup. - Objects Available:
controller: Instance ofImageControllerBase. Used forloadImage,applyOperations, accessingoperationStateManager, etc.serializerController: Instance ofSerializerController. Used forsaveOperations,loadOperations, listening tooperationsSaved,operationsLoaded, etc.- Operation Models (e.g.,
brightnessControl,contrastControl).
QML Interaction Flows¶
Image Adjustment Flow¶
- User Action: User drags a slider in a QML Operation Widget (e.g., Brightness).
- QML Binding: The slider's
valueChangedsignal updates the bound C++ model'svalueproperty (e.g.,brightnessControl.value = newValue). - C++ Model Signal: The C++
BaseAdjustmentModelemits itsvalueChangedsignal. - C++ Connection:
ImageControllerBasereceives the signal and triggers the processing pipeline (seeui_core_architecture.md).
Operation Persistence Flow¶
- User Action: User clicks a "Save Adjustments" or "Load Adjustments" button in QML.
- QML Call: QML calls a slot on the exposed
serializerControllerobject (e.g.,serializerController.saveOperations(controller.getCurrentImagePath(), controller.operationStateManager.getActiveOperations())orserializerController.loadOperations(controller.getCurrentImagePath())). - C++ Serialization:
SerializerControllerhandles the core serialization logic (seeui_core_architecture.md). - QML Feedback: QML listens to signals emitted by
serializerController(e.g.,onOperationsSaved,onOperationsLoadFailed) and updates the UI (e.g., shows success/error messages).
Main Flow (Combined UI + Core)¶
The primary flow involves QML triggering actions via controller or serializerController, which then propagate through the UI Core layer and eventually to the Core engine for processing or persistence.
🛠️ How to Contribute¶
Adding a New QML Operation Widget¶
- Create QML Component: Define a new QML file (e.g.,
VignetteOperation.qml). - Bind to Model: Use
Bindingor direct property binding to connect the QML control (slider, checkbox) to the corresponding C++ operation model property (e.g.,model: vignetteControl). - Register Model: Ensure the C++
VignetteModelis created and registered byOperationModelManagerand exposed to QML (seeui_core_architecture.md).
Adding a New QML Persistence Feature¶
- Create UI Elements: Add buttons, dialogs, or other QML components to trigger save/load actions.
- Call Serializer Controller: Use the
serializerControllerobject available in the QML context to callsaveOperationsorloadOperations. - Handle Signals: Listen to signals from
serializerControllerto provide user feedback.