2025-04-29 18:26:13 +02:00

4.9 KiB

Asset Processor GUI Development Plan

This document outlines the plan for developing a Graphical User Interface (GUI) for the Asset Processor Tool.

I. Foundation & Framework Choice

  1. Choose GUI Framework: PySide6 (LGPL license, powerful features).
  2. Project Structure: Create gui/ directory. Core logic remains separate.
  3. Dependencies: Add PySide6 to requirements.txt.

II. Core GUI Layout & Basic Functionality

  1. Main Window: gui/main_window.py.
  2. Layout Elements:
    • Drag & Drop Area (QWidget subclass).
    • Preset Dropdown (QComboBox).
    • Preview Area (QListWidget).
    • Progress Bar (QProgressBar).
    • Control Buttons (QPushButton: Start, Cancel, Manage Presets).
    • Status Bar (QStatusBar).

III. Input Handling & Predictive Preview

  1. Connect Drag & Drop: Validate drops, add valid paths to Preview List.
  2. Refactor for Prediction: Create/refactor methods in AssetProcessor/Configuration to predict output names without full processing.
  3. Implement Preview Update: On preset change or file add, load config, call prediction logic, update Preview List items (e.g., "Input: ... -> Output: ...").
  4. Responsive Preview: Utilize PySide6 list widget efficiency (consider model/view for very large lists).

IV. Processing Integration & Progress Reporting

  1. Adapt Processing Logic: Refactor main.py's ProcessPoolExecutor loop into a callable function/class (gui/processing_handler.py).
  2. Background Execution: Run processing logic in a QThread to keep GUI responsive.
  3. Progress Updates (Signals & Slots):
    • Background thread emits signals: progress_update(current, total), file_status_update(path, status, msg), processing_finished(stats).
    • Main window connects slots to these signals to update UI elements (QProgressBar, QListWidget items, status bar).
  4. Completion/Error Handling: Re-enable controls, display summary stats, report errors on processing_finished.

V. Preset Management Interface (Sub-Task)

  1. New Window/Dialog: gui/preset_editor.py.
  2. Functionality: List, load, edit (tree view/form), create, save/save as presets (.json in presets/). Basic validation.

VI. Refinements & Additional Features (Ideas)

  1. Cancel Button: Implement cancellation signal to background thread/workers.
  2. Log Viewer: Add QTextEdit to display logging output.
  3. Output Directory Selection: Add browse button/field.
  4. Configuration Options: Expose key config.py settings.
  5. Clearer Error Display: Tooltips, status bar updates, or error panel.

VII. Packaging (Deployment)

  1. Tooling: PyInstaller or cx_Freeze.
  2. Configuration: Build scripts (.spec) to bundle code, dependencies, assets, and presets/.

High-Level Mermaid Diagram:

graph TD
    subgraph GUI Application (PySide6)
        A[Main Window] --> B(Drag & Drop Area);
        A --> C(Preset Dropdown);
        A --> D(Preview List Widget);
        A --> E(Progress Bar);
        A --> F(Start Button);
        A -- Contains --> SB(Status Bar);
        A --> CB(Cancel Button);
        A --> MB(Manage Presets Button);

        B -- fileDroppedSignal --> X(Handle Input Files);
        C -- currentIndexChangedSignal --> Y(Update Preview);
        X -- Adds paths --> D;
        X -- Triggers --> Y;

        Y -- Reads --> C;
        Y -- Uses --> J(Prediction Logic);
        Y -- Updates --> D;

        F -- clickedSignal --> Z(Start Processing);
        CB -- clickedSignal --> AA(Cancel Processing);
        MB -- clickedSignal --> L(Preset Editor Dialog);

        Z -- Starts --> BB(Processing Thread: QThread);
        AA -- Signals --> BB;

        BB -- progressSignal(curr, total) --> E;
        BB -- fileStatusSignal(path, status, msg) --> D;
        BB -- finishedSignal(stats) --> AB(Handle Processing Finished);
        AB -- Updates --> SB;
        AB -- Enables/Disables --> F;
        AB -- Enables/Disables --> CB;
        AB -- Enables/Disables --> C;
        AB -- Enables/Disables --> B;

        L -- Modifies --> H(Presets Dir: presets/*.json);
    end

    subgraph Backend Logic (Existing + Refactored)
        H -- Loaded by --> C;
        H -- Loaded/Saved by --> L;

        J -- Reads --> M(configuration.py / asset_processor.py);
        BB -- Runs --> K(Adapted main.py Logic);
        K -- Uses --> N(ProcessPoolExecutor);
        N -- Runs --> O(process_single_asset_wrapper);
        O -- Uses --> M;
        O -- Reports Status --> K;
        K -- Reports Progress --> BB;
    end

    classDef gui fill:#f9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef thread fill:#ffc,stroke:#333,stroke-width:1px;
    class A,B,C,D,E,F,CB,MB,L,SB,X,Y,Z,AA,AB gui;
    class H,J,K,M,N,O backend;
    class BB thread;

This plan provides a roadmap for the GUI development.