1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-07 10:59:49 +00:00

Add a confirmation dialog when deleting a layout

This commit is contained in:
Manolis Papadeas 2022-03-18 04:21:38 +02:00
parent 9128b455e6
commit 9411f37a47
3 changed files with 21 additions and 7 deletions

View file

@ -196,6 +196,9 @@ msgstr ""
msgid "Edit Layout" msgid "Edit Layout"
msgstr "" msgstr ""
msgid "Are you sure you want to delete this layout?"
msgstr ""
msgid "Auto" msgid "Auto"
msgstr "" msgstr ""

View file

@ -8,6 +8,7 @@ onready var edit_layout: Button = find_node("EditLayout")
onready var delete_layout: Button = find_node("DeleteLayout") onready var delete_layout: Button = find_node("DeleteLayout")
onready var layout_settings: ConfirmationDialog = $LayoutSettings onready var layout_settings: ConfirmationDialog = $LayoutSettings
onready var layout_name: LineEdit = $LayoutSettings/LayoutName onready var layout_name: LineEdit = $LayoutSettings/LayoutName
onready var delete_confirmation: ConfirmationDialog = $DeleteConfirmation
func _on_ManageLayouts_about_to_show() -> void: func _on_ManageLayouts_about_to_show() -> void:
@ -50,13 +51,7 @@ func _on_EditLayout_pressed() -> void:
func _on_DeleteLayout_pressed() -> void: func _on_DeleteLayout_pressed() -> void:
delete_layout_file(layout_list.get_item_text(layout_selected) + ".tres") delete_confirmation.popup_centered()
Global.top_menu_container.layouts.remove(layout_selected)
layout_list.remove_item(layout_selected)
Global.top_menu_container.populate_layouts_submenu()
layout_selected = -1
edit_layout.disabled = true
delete_layout.disabled = true
func _on_LayoutSettings_confirmed() -> void: func _on_LayoutSettings_confirmed() -> void:
@ -88,3 +83,13 @@ func _on_LayoutSettings_confirmed() -> void:
func delete_layout_file(file_name: String) -> void: func delete_layout_file(file_name: String) -> void:
var dir := Directory.new() var dir := Directory.new()
dir.remove("user://layouts/".plus_file(file_name)) dir.remove("user://layouts/".plus_file(file_name))
func _on_DeleteConfirmation_confirmed() -> void:
delete_layout_file(layout_list.get_item_text(layout_selected) + ".tres")
Global.top_menu_container.layouts.remove(layout_selected)
layout_list.remove_item(layout_selected)
Global.top_menu_container.populate_layouts_submenu()
layout_selected = -1
edit_layout.disabled = true
delete_layout.disabled = true

View file

@ -83,6 +83,11 @@ margin_bottom = 50.5
size_flags_horizontal = 3 size_flags_horizontal = 3
placeholder_text = "Insert name" placeholder_text = "Insert name"
[node name="DeleteConfirmation" type="ConfirmationDialog" parent="."]
margin_right = 200.0
margin_bottom = 70.0
dialog_text = "Are you sure you want to delete this layout?"
[connection signal="about_to_show" from="." to="." method="_on_ManageLayouts_about_to_show"] [connection signal="about_to_show" from="." to="." method="_on_ManageLayouts_about_to_show"]
[connection signal="popup_hide" from="." to="." method="_on_ManageLayouts_popup_hide"] [connection signal="popup_hide" from="." to="." method="_on_ManageLayouts_popup_hide"]
[connection signal="item_activated" from="VBoxContainer/SavedLayouts" to="." method="_on_SavedLayouts_item_activated"] [connection signal="item_activated" from="VBoxContainer/SavedLayouts" to="." method="_on_SavedLayouts_item_activated"]
@ -92,3 +97,4 @@ placeholder_text = "Insert name"
[connection signal="pressed" from="VBoxContainer/ButtonsContainer/EditLayout" to="." method="_on_EditLayout_pressed"] [connection signal="pressed" from="VBoxContainer/ButtonsContainer/EditLayout" to="." method="_on_EditLayout_pressed"]
[connection signal="pressed" from="VBoxContainer/ButtonsContainer/DeleteLayout" to="." method="_on_DeleteLayout_pressed"] [connection signal="pressed" from="VBoxContainer/ButtonsContainer/DeleteLayout" to="." method="_on_DeleteLayout_pressed"]
[connection signal="confirmed" from="LayoutSettings" to="." method="_on_LayoutSettings_confirmed"] [connection signal="confirmed" from="LayoutSettings" to="." method="_on_LayoutSettings_confirmed"]
[connection signal="confirmed" from="DeleteConfirmation" to="." method="_on_DeleteConfirmation_confirmed"]