Skip to content

refactor: modularize monolithic QuickCaptureModal.qml #8

@hthienloc

Description

@hthienloc

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

  1. 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.
  2. Modularize Toolbar and Overlays: Move inner components like textInputDialog, magnifier, and contrast/brightness samplers to separate component files under components/.
  3. 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.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions