5.1 KiB
FEAT-GUI-NoDefaultPreset: Prevent Default Preset Selection in GUI
Objective
Modify the Graphical User Interface (GUI) to prevent any preset from being selected by default on application startup. Instead, the GUI should prompt the user to explicitly select a preset from the list before displaying the detailed file preview. This aims to avoid accidental processing with an unintended preset.
Problem Description
Currently, when the GUI application starts, a preset from the available list is automatically selected. This can lead to user confusion if they are not aware of this behavior and proceed to add assets and process them using a preset they did not intend to use. The preview table also populates automatically based on this default selection, which might not be desired until a conscious preset choice is made.
Failed Attempts
-
Attempt 1: Remove Default Selection Logic and Add Placeholder Text:
- Approach: Removed code that explicitly set a default selected item in the preset list during initialization. Added a
QLabelwith placeholder text ("Please select a preset...") to the preview area and attempted to usesetPlaceholderTexton theQTableView(this was incorrect asQTableViewdoes not have this method). Managed visibility of the placeholder label and table view. - Result: The
setPlaceholderTextcall failed with anAttributeError. Even after removing the erroneous line and adding a dedicatedQLabel, a preset was still being selected automatically in the list on startup, and the placeholder was not consistently shown. This suggested that simply populating theQListWidgetmight implicitly trigger a selection.
- Approach: Removed code that explicitly set a default selected item in the preset list during initialization. Added a
-
Attempt 2: Explicitly Clear Selection and Refine Visibility Logic:
- Approach: Added explicit calls (
setCurrentItem(None),clearSelection()) after populating the preset list to ensure no item was selected. Refined the visibility logic for the placeholder label and table view in_clear_editorand_load_selected_preset_for_editing. Added logging to track selection and visibility changes. - Result: Despite explicitly clearing the selection, testing indicated that a preset was still being selected on startup, and the placeholder was not consistently displayed. This reinforced the suspicion that the
QListWidget's behavior upon population was automatically triggering a selection and the associated signal.
- Approach: Added explicit calls (
Proposed Plan: Implement "-- Select a Preset --" Placeholder Item
This approach makes the "no selection" state an explicit, selectable item in the preset list, giving us more direct control over the initial state and subsequent behavior.
-
Modify
populate_presetsMethod:- Add a
QListWidgetItemwith the text "-- Select a Preset --" at the very beginning of the list (index 0) after clearing the list but before adding actual preset items. - Store a special, non-
Pathvalue (e.g.,Noneor a unique string like"__PLACEHOLDER__") in this placeholder item'sUserRoledata to distinguish it from real presets. - After adding all real preset items, explicitly set the current item to this placeholder item using
self.editor_preset_list.setCurrentRow(0).
- Add a
-
Modify
_load_selected_preset_for_editingMethod (Slot forcurrentItemChanged):- At the beginning of the method, check if the
current_itemis the placeholder item by examining itsUserRoledata. - If the placeholder item is selected:
- Call
self._clear_editor()to reset all editor fields. - Call
self.preview_model.clear_data()to ensure the preview table model is empty. - Explicitly set
self.preview_placeholder_label.setVisible(True)andself.preview_table_view.setVisible(False). - Return from the method without proceeding to load a preset or call
update_preview.
- Call
- If a real preset item is selected, proceed with the existing logic: get the
Pathfrom the item's data, call_load_preset_for_editing(preset_path), callself.update_preview(), setself.preview_placeholder_label.setVisible(False)andself.preview_table_view.setVisible(True).
- At the beginning of the method, check if the
-
Modify
start_processingMethod:- Before initiating the processing, check if the currently selected item in
editor_preset_listis the placeholder item. - If the placeholder item is selected, display a warning message to the user (e.g., "Please select a valid preset before processing.") using the status bar and return from the method.
- If a real preset is selected, proceed with the existing processing logic.
- Before initiating the processing, check if the currently selected item in
-
Modify
update_previewMethod:- Add a check at the beginning of the method. Get the
current_itemfromeditor_preset_list. If it is the placeholder item, clear the preview model (self.preview_model.clear_data()) and return immediately. This prevents the prediction handler from running when no valid preset is selected.
- Add a check at the beginning of the method. Get the
Next Steps
Implement the proposed plan by modifying the specified methods in gui/main_window.py. Test the GUI on startup and when selecting different items in the preset list to ensure the desired behavior is achieved.