How viplovek/flameshot works
Project type and purpose
• Flameshot is a cross-platform, Qt-based desktop screenshot tool with both graphical (GUI) and command-line (CLI) interfaces. It provides in-app screenshot editing, global and local hotkeys, D-Bus integration for Linux desktops, and image uploads (e.g., Imgur).
File structure
• Top-level “src” directory subdivides into:
• cli → command-line parser and commands
• config → configuration GUI, file parsing and resolution
• core → capture request handling, daemon, D-Bus adapter, global shortcuts
• widgets → Qt widget implementations for capture UI, panels, dialogs
• utils → file I/O, screenshot saving, upload requests, notifications
• CI/CD manifests in “.github/workflows” and build scripts (CMakeLists.txt).
Main architectural components
a. User Interface Layer (GUI)
• Interactive capture widget and sidebar panels under src/widgets and src/config
• Configuration window, about/info dialogs
b. Core Engine
• CaptureRequest API in src/core
• flameshotdaemon runs in background, registers D-Bus service
• GlobalShortcutFilter uses QHotkey for hotkey listening
c. CLI Layer
• src/cli parses commands (gui, full, screen, config) and invokes core engine
d. Tools Plugin Layer
• ToolFactory dynamically instantiates tools
e. Utility Services
• src/utils handles config file read/write, filesystem paths, HTTP upload requests, notifications
f. External Services
• Imgur REST API via utils/request and tools/imgupload
• D-Bus for inter-process communication on Linux
• Clipboard, file system, notifications via Qt platform abstractions
Relationships and flows
• GUI widgets send user actions to Core Engine (capture, annotate, save, upload).
• Core Engine emits events to Utils (save image, send HTTP requests, push system notifications).
• CLI invokes Core Engine directly or via D-Bus adapter.
• Tools plugin layer subscribes to user events from UI and mutates the capture image.
• Core Engine registers itself as a SingleApplication instance to enforce one instance.
• Packaging/static data and translations are loaded at runtime via Qt resource system (graphics.qrc).
Architectural patterns and technologies
• Layered architecture: UI → Core → Utils → External
• Plugin/factory pattern for annotation tools
• Observer pattern: Qt signals/slots for event propagation
• Qt5 framework, C++17, CMake build system
• CI/CD pipelines for cross-platform packaging