Problem Description
The QuickCaptureModal.qml file is currently a monolith containing ~2,300 lines of code. It implements:
- Core UI structures and layouts
- Visual components (toolbar, canvas, magnifying glass)
- Complex state management for annotations, select tools, and crop states
- Rendering pipelines (
onPaint routines for drawingCanvas and exportCanvas)
- Event capture and coordinates transformation logic (
drawMouseArea)
- Shortcut key routing and event mapping (
handleShortcutKey)
- File export/copy integration and processes orchestration
This massive consolidation makes it highly prone to regressions, hard to debug, and difficult for developers/agents to grasp without parsing the entire file structure.
Proposed Refactoring Strategies
- Extract Rendering Logic: Move drawStroke and related visual painters to a dedicated helper JS file or subclass (e.g.
StrokePainter.js), leaving only canvas orchestration in the QML file.
- Modularize Toolbar and Overlays: Move inner components like
textInputDialog, magnifier, and contrast/brightness samplers to separate component files under components/.
- State Management Extraction: Centralize state (such as the
strokes list, currentColor, strokeWidth, cropRect, and current tool properties) to reduce direct global bindings across the entire monolith.
- Input Handling Separation: Decouple key shortcut routing (
handleShortcutKey and handleTypingKey) and mouse drag/grab math from visual UI nodes.
Interim Reference
Until these actions are complete, developers and AI agents must refer to AIGUIDE.md to understand structure boundaries, coordinates mapping details, and common pitfalls.
Problem Description
The QuickCaptureModal.qml file is currently a monolith containing ~2,300 lines of code. It implements:
onPaintroutines fordrawingCanvasandexportCanvas)drawMouseArea)handleShortcutKey)This massive consolidation makes it highly prone to regressions, hard to debug, and difficult for developers/agents to grasp without parsing the entire file structure.
Proposed Refactoring Strategies
StrokePainter.js), leaving only canvas orchestration in the QML file.textInputDialog,magnifier, and contrast/brightness samplers to separate component files undercomponents/.strokeslist,currentColor,strokeWidth,cropRect, and current tool properties) to reduce direct global bindings across the entire monolith.handleShortcutKeyandhandleTypingKey) and mouse drag/grab math from visual UI nodes.Interim Reference
Until these actions are complete, developers and AI agents must refer to AIGUIDE.md to understand structure boundaries, coordinates mapping details, and common pitfalls.