This document outlines the structure and data flow of the TextToQR macOS app.
-
QRCodeGeneratorApp (SwiftUI App)
- Entry point. Creates a single
WindowGroupand embedsContentViewwith a fixed size.
- Entry point. Creates a single
-
ContentView (SwiftUI View)
- Split layout: left sidebar for folder tree, right pane for editor + preview.
- Manages input text, generated
NSImage?, selected root folder, and selected file URL. - Triggers QR generation live on text change (no Render button).
- Provides Save/New actions to persist QR texts to files.
-
QRCodeGenerator (Utility struct)
getQRImageUsingNew(qrcode:)guard-returnsnilon empty input, otherwise produces anNSImageby:- creating a CI QR code (
CIQRCodeGenerator), - scaling to ~300×300 via
CGAffineTransform, - converting
CIImage→NSImageviaNSCIImageRep.
- creating a CI QR code (
generateQRCode(from:quality:)accepts a string and correction level (e.g.,L/M/Q/H).
-
NSImageView (SwiftUI View)
- Renders an optional
NSImageusing SwiftUI’sImage(nsImage:). - Shows a placeholder message when
nil.
- Renders an optional
-
FileManagement (Utilities)
FileNodetree structure to represent folders and files.FileScannerbuilds the tree from a root URL and reads/writes text files with extensions:txt,qr,qrtext.
App initializes its managed Application Support root → sidebar lists folders/files → selecting a file loads its text → @State qrInputtext updates → onChange regenerates QR → Save/New write to disk → sidebar refreshes.
- Scaling: The CI filter emits a small image. The current approach scales via an affine transform for simplicity. For the sharpest edges, consider rendering to a
CGImageusing aCIContextwith no interpolation and drawing into an exact pixel buffer size. - Error correction: Default is
H(high). Making this adjustable is straightforward via a UI control bound togenerateQRCode’squalityparameter. - Naming:
NSImageView(SwiftUI) can be mistaken for AppKit’s class. Consider renaming toQRImageViewto avoid confusion.
The earlier README proposed image export/copy, adjustable QR size/correction level, improved validation/empty states, and sharper scaling. These are ideas, not implemented capabilities or verified bugs; discuss scope before starting.