Camera roll previews queued free on file deletion

This commit is contained in:
Davide Di Staso committed 2025-10-11 12:40:39 +02:00
1 parent dbc3e0738f
commit 4957c7ab47
5 files changed
+165 -19

No files matched your search

+19 -13
View File
@@ -6,23 +6,29 @@ extends VBoxContainer
const SCREENSHOT_PREVIEW = preload("res://addons/screenshots/debugger/bottom_panel/screenshot_preview/screenshot_preview.tscn")
var roll_directory : String
func _ready() -> void:
%RollPanelContainer.add_theme_stylebox_override("panel", get_theme_stylebox("panel", "ItemListSecondary"))
%CameraRollIcon.texture = get_theme_icon("CameraTexture", "EditorIcons")
for filepath in local_data.settings.load_value("misc", "CameraRollPreviews", []):
var img = Image.new()
img = img.load_from_file(filepath)
if img == null:
continue
var s = SCREENSHOT_PREVIEW.instantiate()
s.texture = ImageTexture.create_from_image(img)
s.path = filepath
s.locale = ""
previews_container.add_child(s)
roll_directory = local_data.settings.load_value("misc", "PathLineEdit", "user://screenshots")
%DirectoryWatcher.add_scan_directory(roll_directory)
local_data.settings.value_changed.connect(_on_local_data_changed)
%DirectoryWatcher.files_deleted.connect(_on_files_deleted)
func _on_files_deleted(files: PackedStringArray) -> void:
for file in files:
for preview in previews_container.get_children():
if ProjectSettings.globalize_path(preview.path) == ProjectSettings.localize_path(file):
preview.queue_free()
func _on_local_data_changed(section: String, key: String, new_value) -> void:
if not key == "PathLineEdit":
return
local_data.settings.save("misc", "CameraRollPreviews", get_all_previews_paths())
%DirectoryWatcher.remove_scan_directory(roll_directory)
roll_directory = new_value
%DirectoryWatcher.add_scan_directory(roll_directory)
func add_preview(file_path: String, timestamp: String, locale: String) -> void:
var s = SCREENSHOT_PREVIEW.instantiate()