7.5 KiB
Asset Processor GUI Refactor Plan
This document outlines the plan to refactor the Asset Processor GUI based on user requirements.
Goals
- Improve File Visibility: Display all files found within an asset in the preview list, including those that don't match the preset, are moved to 'Extra', or have errors, along with their status.
- Integrate Preset Editor: Move the preset editing functionality from the separate dialog into a collapsible panel within the main window.
Goal 1: Improve File Visibility in Preview List
Problem: The current preview (PredictionHandler calling AssetProcessor.predict_output_structure) only shows files that successfully match a map type rule and get a predicted output name. It doesn't show files that are ignored, moved to 'Extra', or encounter errors during classification.
Solution: Leverage the more comprehensive classification logic already present in AssetProcessor._inventory_and_classify_files for the GUI preview.
Plan Steps:
- Modify
asset_processor.py:- Create a new method in
AssetProcessor, perhaps namedget_detailed_file_predictions(). - This new method will perform the core steps of
_setup_workspace(),_extract_input(), and_inventory_and_classify_files(). - It will then iterate through all categories in
self.classified_files('maps', 'models', 'extra', 'ignored'). - For each file, it will determine a 'status' (e.g., "Mapped", "Model", "Extra", "Ignored", "Error") and attempt to predict the output name (similar to
predict_output_structurefor maps, maybe just the original name for others). - It will return a more detailed list of dictionaries, each containing:
{'original_path': str, 'predicted_name': str | None, 'status': str, 'details': str | None}. - Crucially, this method will not perform the actual processing (
_process_maps,_merge_maps, etc.) or file moving, only the classification and prediction. It should also include cleanup (_cleanup_workspace).
- Create a new method in
- Modify
gui/prediction_handler.py:- Update
PredictionHandler.run_predictionto call the newAssetProcessor.get_detailed_file_predictions()method instead ofpredict_output_structure(). - Adapt the code that processes the results to handle the new dictionary format (including the 'status' and 'details' fields).
- Emit this enhanced list via the
prediction_results_readysignal.
- Update
- Modify
gui/main_window.py:- In
setup_ui, add a new column toself.preview_tablefor "Status". Adjust column count and header labels. - In
on_prediction_results_ready, populate the new "Status" column using the data received fromPredictionHandler. - Consider adding tooltips to the status column to show the 'details' (e.g., the reason for being ignored or moved to extra).
- Optionally, use background colors or icons in the status column for better visual distinction.
- In
Goal 2: Integrate Preset Editor into Main Window
Problem: Preset editing requires opening a separate modal dialog, interrupting the main workflow.
Solution: Embed the preset editing controls directly into the main window within a collapsible panel.
Plan Steps:
- Modify
gui/main_window.py- UI Changes:- Remove the "Manage Presets" button (
self.manage_presets_button). - Add a collapsible panel (potentially using a
QFramewith show/hide logic triggered by a button, or aQDockWidgetif more appropriate) to the left side of the main layout. - Inside this panel:
- Add the
QListWidgetfor displaying presets (self.preset_list). - Add the "New" and "Delete" buttons below the list. (The "Load" button becomes implicit - selecting a preset in the list loads it into the editor).
- Recreate the
QTabWidget(self.preset_editor_tabs) with the "General & Naming" and "Mapping & Rules" tabs. - Recreate all the widgets currently inside the
PresetEditorDialogtabs (QLineEdit, QTextEdit, QSpinBox, QListWidget+controls, QTableWidget+controls) within the corresponding tabs in the main window's panel. Give them appropriate instance names (e.g.,self.editor_preset_name,self.editor_supplier_name, etc.). - Add "Save" and "Save As..." buttons within the collapsible panel, likely at the bottom.
- Add the
- Remove the "Manage Presets" button (
- Modify
gui/main_window.py- Logic Integration:- Adapt the
populate_presetsmethod to populate the newself.preset_listin the panel. - Connect
self.preset_list.currentItemChangedto a new methodload_selected_preset_for_editing. This method will handle checking for unsaved changes in the editor panel and then load the selected preset's data into the editor widgets (similar toPresetEditorDialog.load_preset). - Implement
save_preset,save_preset_as,new_preset,delete_presetmethods directly withinMainWindow, adapting the logic fromPresetEditorDialog. These will interact with the editor widgets in the panel. - Implement
check_unsaved_changeslogic for the editor panel, prompting the user if they try to load/create/delete a preset or close the application with unsaved edits in the panel. - Connect the editor widgets' change signals (
textChanged,valueChanged,itemChanged, etc.) to amark_editor_unsavedmethod inMainWindow. - Ensure the main preset selection
QComboBox(self.preset_combo) is repopulated when presets are saved/deleted via the editor panel.
- Adapt the
- Cleanup:
- Delete the
gui/preset_editor_dialog.pyfile. - Remove imports and references to
PresetEditorDialogfromgui/main_window.py.
- Delete the
Visual Plan
Current Layout:
graph TD
subgraph "Current Main Window Layout"
A[Preset Combo + Manage Button] --> B(Drag & Drop Area);
B --> C{File Preview Table};
C --> D[Progress Bar];
D --> E[Options + Start/Cancel Buttons];
end
subgraph "Current Preset Editor (Separate Dialog)"
F[Preset List + Load/New/Delete] --> G{Tab Widget};
subgraph "Tab Widget"
G1[General & Naming Tab]
G2[Mapping & Rules Tab]
end
G --> H[Save / Save As / Close Buttons];
end
A -- Manage Button Click --> F;
style F fill:#f9f,stroke:#333,stroke-width:2px
style G fill:#f9f,stroke:#333,stroke-width:2px
style H fill:#f9f,stroke:#333,stroke-width:2px
Proposed Layout:
graph TD
subgraph "Proposed Main Window Layout"
direction LR
subgraph "Collapsible Preset Editor Panel (Left)"
P_List[Preset List] --> P_Buttons[New / Delete Buttons]
P_Buttons --> P_Tabs{Tab Widget}
subgraph "Editor Tabs"
P_Tab1[General & Naming]
P_Tab2[Mapping & Rules]
end
P_Tabs --> P_Save[Save / Save As Buttons]
end
subgraph "Main Area (Right)"
M_Preset[Preset Combo (for processing)] --> M_DragDrop(Drag & Drop Area)
M_DragDrop --> M_Preview{File Preview Table (with Status Column)}
M_Preview --> M_Progress[Progress Bar]
M_Progress --> M_Controls[Options + Start/Cancel Buttons]
end
P_List -- Selection Loads --> P_Tabs;
P_Save -- Updates --> P_List;
P_List -- Updates --> M_Preset;
style M_Preview fill:#ccf,stroke:#333,stroke-width:2px
style P_List fill:#cfc,stroke:#333,stroke-width:2px
style P_Tabs fill:#cfc,stroke:#333,stroke-width:2px
style P_Save fill:#cfc,stroke:#333,stroke-width:2px
end