# lxqt/pcmanfm-qt architecture

> Architecture diagram of the GitHub repository lxqt/pcmanfm-qt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lxqt/pcmanfm-qt
- Repository: https://github.com/lxqt/pcmanfm-qt

## Overview

##### Project’s Core Purpose and Components
- PCManFM-Qt is a file manager with dual roles: it provides standard file management UI functionality and also can handle the desktop when invoked with specific options (like --desktop or --desktop-pref).
- The project is structured as a full-fledged desktop application primarily built with Qt and CMake. It also includes support for multilingual translations, integration with LXQt (via its configuration directories), and a clear separation between the file management core (pcmanfm module) and configuration/autostart elements.

##### Main Components to Capture
a. User Interface Layer:
– The core UI modules are in the “pcmanfm” directory (e.g., mainwindow.cpp, desktopwindow.cpp, various dialogs like preferencesdialog, autorundialog, etc.) that together build the file browsing and desktop management interface.
– Include the dialogs and views like “bulk-rename”, “preferences”, “desktop entry”, “connect server”, etc.
– Emphasize that this layer is built upon the Qt Framework.

b. Business Logic & File Management:
– The file operations and backend logic utilizing GLib for file system interactions. Indicate that this component handles file management workflows.
– Show integration and dependencies with “libfm-qt” (which depends on the Qt Framework, as noted) and GLib as a provider of low-level file system functions.

c. Configuration & Settings Component:
– The “config” directory and configuration files (e.g., settings.conf.in) that manage application settings, desktop preferences, etc.
– This module interacts with the business logic to load and apply user-specific configurations.

d. Translation & Localization:
– The “pcmanfm/translations” and “autostart/translations” directories hold numerous YAML and TS files to support various languages.
– Mark this component as a support module integrating with the UI for language localization.

e. Autostart & Desktop Handling:
– The “autostart” directory indicates installation scripts and desktop entry templates (e.g., lxqt-desktop.desktop.in) used when launching PCManFM-Qt as a desktop handler.
– This will show how the file manager adapts its behavior depending on the command-line options (like --desktop) to provide desktop environment integration.

f. Build & Deployment Infrastructure:
– The usage of CMake (with CMakeLists.txt in several directories) and Docker/CI configurations (e.g., .ci, .github directories).
– This module isn’t part of runtime architecture but is important for understanding how the project is built and configured.

##### Relationships and Interactions
– The UI layer communicates user actions (like opening directories or renaming files) directly to the business logic, which in turn interacts with GLib and libfm-qt for file operations.
– The configuration module supplies settings to both the UI and the business logic, ensuring that paths, preferences, and desktop-specific options are applied.
– The translation/localization component supplies language packs and localized text to the UI layer.
– An “autostart” module ensures that when running in desktop mode, appropriate desktop integration files and configurations are loaded.
- UI Layer ⇄ Business Logic/Backend
- Business Logic → GLib & libfm-qt (noting libfm-qt’s dependency on Qt)
- UI → Translation Module (for multilingual support)
- Configurations → Both UI and Business Logic

##### Architectural Patterns and Design Principles
– The application demonstrates a layered architecture:
- Presentation Layer (UI components built with Qt)
- Business Logic/Domain Layer (file management operations implemented using GLib, with a dependency on libfm-qt)
- Configuration & Integration Layer (settings, autostart, and LXQt integration).
– There is a modular separation evident in the source tree – isolating desktop handling, file operations, configuration, and translations into separate directories.
– Emphasize the use of CMake for configuration management and the integration with CI/CD scripts, which manage testing and building.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI_Main["Main Window (PCManFM)"]:::ui
        UI_Desktop["Desktop Window (PCManFM)"]:::ui
        UI_Dialog["Dialogs & Views"]:::ui
    end
    click UI_Main "https://github.com/lxqt/pcmanfm-qt/blob/master/pcmanfm/mainwindow.cpp"
    click UI_Desktop "https://github.com/lxqt/pcmanfm-qt/blob/master/pcmanfm/desktopwindow.cpp"
    click UI_Dialog "https://github.com/lxqt/pcmanfm-qt/blob/master/pcmanfm/mainwindow.cpp"

    %% Business Logic & File Management
    subgraph "Business Logic & File Management"
        BL_File["File Operations (Backend Logic)"]:::backend
    end
    click BL_File "https://github.com/lxqt/pcmanfm-qt/blob/master/pcmanfm/application.cpp"

    %% Configuration & Settings Component
    subgraph "Configuration & Settings"
        Config["Config Manager"]:::config
    end
    click Config "https://github.com/lxqt/pcmanfm-qt/blob/master/config/pcmanfm-qt/lxqt/settings.conf.in"

    %% Translation & Localization
    subgraph "Translation & Localization"
        Trans_UI["UI Translations"]:::translation
        Trans_Autostart["Autostart Translations"]:::translation
    end
    click Trans_UI "https://github.com/lxqt/pcmanfm-qt/tree/master/pcmanfm/translations"
    click Trans_Autostart "https://github.com/lxqt/pcmanfm-qt/tree/master/autostart/translations"

    %% Autostart & Desktop Handling
    subgraph "Autostart & Desktop Handling"
        Autostart["Desktop Autostart"]:::autostart
    end
    click Autostart "https://github.com/lxqt/pcmanfm-qt/blob/master/autostart/lxqt-desktop.desktop.in"

    %% Build & Deployment Infrastructure
    subgraph "Build & Deployment Infrastructure"
        Build_Root["CMake (Project Root)"]:::build
        Build_PCManFM["CMake (PCManFM)"]:::build
        Build_Config["CMake (Config)"]:::build
        Build_Autostart["CMake (Autostart)"]:::build
        CICD["CI/CD (.ci & .github)"]:::build
    end
    click Build_PCManFM "https://github.com/lxqt/pcmanfm-qt/blob/master/pcmanfm/CMakeLists.txt"
    click Build_Config "https://github.com/lxqt/pcmanfm-qt/blob/master/config/CMakeLists.txt"
    click Build_Autostart "https://github.com/lxqt/pcmanfm-qt/blob/master/autostart/CMakeLists.txt"
    click CICD "https://github.com/lxqt/pcmanfm-qt/blob/master/.ci"

    %% External Dependencies
    subgraph "External Dependencies"
        Qt["Qt Framework"]:::external
        GLib["GLib"]:::external
        Libfmqt["libfm-qt"]:::external
    end

    %% Relationships and Data Flow
    UI_Main -->|"sends commands"| BL_File
    UI_Desktop -->|"sends commands"| BL_File
    UI_Dialog -->|"sends commands"| BL_File

    Config -->|"applies settings to"| UI_Main
    Config -->|"applies settings to"| BL_File

    UI_Main -->|"fetches language"| Trans_UI
    UI_Dialog -->|"fetches language"| Trans_UI

    BL_File -->|"invokes"| GLib
    BL_File -->|"invokes"| Libfmqt
    Libfmqt -->|"dependsOn"| Qt

    UI_Main -->|"triggers desktop mode"| Autostart

    %% Build Infrastructure links (context for all modules)
    Build_Root --- UI_Main
    Build_Root --- BL_File
    Build_Root --- Config
    Build_Root --- Autostart

    %% Class Definitions for styling
    classDef ui fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef config fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef translation fill:#fff5cc,stroke:#333,stroke-width:2px;
    classDef autostart fill:#ffd9b3,stroke:#333,stroke-width:2px;
    classDef build fill:#d9ccff,stroke:#333,stroke-width:2px;
    classDef external fill:#ff9999,stroke:#333,stroke-width:2px;
```
