# lethudu70/win11-context-menu-swapper architecture

> Architecture diagram of the GitHub repository lethudu70/win11-context-menu-swapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lethudu70/win11-context-menu-swapper
- Repository: https://github.com/lethudu70/win11-context-menu-swapper

## Overview

Context Menu Swapper V4 is a Windows desktop utility for switching between the classic context menu and Windows’ default behavior. The main workflow runs from the Qt window through registry inspection, backup, verified changes, and persistent undo; users can optionally restart Explorer afterward. Separate branches provide Windows-system detection, experimental elevated HKLM operations, and targeted cleanup and diagnostic export. Relationships involving omitted window handlers are shown only where README documentation supports them or are left unverified.

Main entry points: [`V4/src/window.cpp`](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp) (Qt window), [`V4/src/registry.cpp`](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp) (Registry state and undo), [`V4/src/main.cpp`](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/main.cpp) (Application entry), [`V4/src/machine.cpp`](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/machine.cpp) (HKLM elevation helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop interface"]
  node_app["Application entry<br/>[main.cpp]"]
  node_window["Qt window<br/>[window.cpp]"]
  node_preferences["Language and themes<br/>[window.cpp]"]
end

subgraph group_registry["Registry operations"]
  node_registry_api["Registry state and undo<br/>[registry.cpp]"]
  node_backup["Undo backups<br/>[registry.cpp]"]
  node_system_info["Windows detection<br/>[registry.cpp]"]
end

subgraph group_machine["Machine integration"]
  node_machine_helper["HKLM elevation helper<br/>[machine.cpp]"]
end

subgraph group_maintenance["User data maintenance"]
  node_cache_cleanup["JSON cleanup<br/>[cache.cpp]"]
  node_diagnostics["Diagnostic export<br/>[window.cpp]"]
end

node_user(("User"))
node_windows_registry[("Windows registry")]
node_uac(("Windows UAC"))
node_explorer["Windows Explorer"]
node_user_files[("User profile files")]

node_user -->|"chooses mode"| node_window
node_app -->|"creates"| node_registry_api
node_app -->|"opens"| node_window
node_window -.->|"reads and changes"| node_registry_api
node_registry_api -->|"reads and writes"| node_windows_registry
node_registry_api -->|"saves and restores"| node_backup
node_app -->|"detects system"| node_system_info
node_window -.->|"requests elevation"| node_machine_helper
node_machine_helper -->|"launches elevated"| node_uac
node_app -->|"dispatches action"| node_machine_helper
node_machine_helper -->|"runs HKLM change"| node_registry_api
node_window -.->|"restarts on request"| node_explorer
node_window -.->|"requests cleanup"| node_cache_cleanup
node_cache_cleanup -->|"removes or archives"| node_user_files
node_window -.->|"exports diagnostics"| node_diagnostics
node_window -.->|"sets language and theme"| node_preferences
node_preferences -.->|"stores preferences"| node_user_files

click node_app "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/main.cpp"
click node_window "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp"
click node_registry_api "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp"
click node_backup "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp"
click node_system_info "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp"
click node_machine_helper "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/machine.cpp"
click node_cache_cleanup "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/cache.cpp"
click node_diagnostics "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp"
click node_preferences "https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_window,node_preferences,node_user toneBlue
class node_registry_api,node_backup,node_system_info,node_windows_registry,node_user_files toneAmber
class node_machine_helper toneMint
class node_cache_cleanup,node_diagnostics toneRose
class node_uac,node_explorer toneIndigo
```

## Components

### Desktop interface

- [Application entry](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/main.cpp): `V4/src/main.cpp`
- [Qt window](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp): `V4/src/window.cpp`
- [Language and themes](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp): `V4/src/window.cpp`

### Registry operations

- [Registry state and undo](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp): `V4/src/registry.cpp`
- [Undo backups](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp): `V4/src/registry.cpp`
- [Windows detection](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/registry.cpp): `V4/src/registry.cpp`

### Machine integration

- [HKLM elevation helper](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/machine.cpp): `V4/src/machine.cpp`

### User data maintenance

- [JSON cleanup](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/cache.cpp): `V4/src/cache.cpp`
- [Diagnostic export](https://github.com/lethudu70/win11-context-menu-swapper/blob/main/V4/src/window.cpp): `V4/src/window.cpp`

### Other components

- **User**
- **Windows registry**
- **Windows UAC**
- **Windows Explorer**
- **User profile files**

## Connections

- User → Qt window: chooses mode (evidence: `README.md`)
- Application entry → Registry state and undo: creates (evidence: `V4/src/main.cpp`)
- Application entry → Qt window: opens (evidence: `V4/src/main.cpp`)
- Qt window → Registry state and undo: reads and changes
- Registry state and undo → Windows registry: reads and writes (evidence: `V4/src/registry.cpp`)
- Registry state and undo → Undo backups: saves and restores (evidence: `README.md`)
- Application entry → Windows detection: detects system (evidence: `V4/src/main.cpp`)
- Qt window → HKLM elevation helper: requests elevation
- HKLM elevation helper → Windows UAC: launches elevated (evidence: `V4/src/machine.cpp`)
- Application entry → HKLM elevation helper: dispatches action (evidence: `V4/src/main.cpp`)
- HKLM elevation helper → Registry state and undo: runs HKLM change (evidence: `V4/src/machine.cpp`)
- Qt window → Windows Explorer: restarts on request
- Qt window → JSON cleanup: requests cleanup
- JSON cleanup → User profile files: removes or archives (evidence: `V4/src/cache.cpp`)
- Qt window → Diagnostic export: exports diagnostics (evidence: `V4/src/window.cpp`)
- Qt window → Language and themes: sets language and theme (evidence: `V4/src/window.cpp`)
- Language and themes → User profile files: stores preferences (evidence: `README.md`)
