mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-07 10:59:49 +00:00
[0.x] Allow user to move Palettes to Trash/Recycle Bin instead of deleting them permanently (#918)
* backport #914 move palettes to bin instead of deleting them permanently * update backport to use dialog
This commit is contained in:
parent
be093f3490
commit
7416ed375c
|
@ -211,14 +211,17 @@ func current_palette_edit(name: String, comment: String, width: int, height: int
|
||||||
palettes[palette_path] = current_palette
|
palettes[palette_path] = current_palette
|
||||||
|
|
||||||
|
|
||||||
func _delete_palette(path: String) -> void:
|
func _delete_palette(path: String, permanent := true) -> void:
|
||||||
|
if permanent:
|
||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
dir.remove(path)
|
dir.remove(path)
|
||||||
|
else:
|
||||||
|
OS.move_to_trash(path)
|
||||||
palettes.erase(path)
|
palettes.erase(path)
|
||||||
|
|
||||||
|
|
||||||
func current_palete_delete() -> void:
|
func current_palete_delete(permanent := true) -> void:
|
||||||
_delete_palette(current_palette.resource_path)
|
_delete_palette(current_palette.resource_path, permanent)
|
||||||
|
|
||||||
if palettes.size() > 0:
|
if palettes.size() > 0:
|
||||||
select_palette(palettes.keys()[0])
|
select_palette(palettes.keys()[0])
|
||||||
|
|
|
@ -5,6 +5,7 @@ signal saved(name, comment, width, height)
|
||||||
signal deleted
|
signal deleted
|
||||||
|
|
||||||
const DELETE_ACTION := "delete"
|
const DELETE_ACTION := "delete"
|
||||||
|
const BIN_ACTION := "trash"
|
||||||
|
|
||||||
# Keeps original size of edited palette
|
# Keeps original size of edited palette
|
||||||
var origin_width := 0
|
var origin_width := 0
|
||||||
|
@ -20,11 +21,14 @@ onready var path_input := $VBoxContainer/PaletteMetadata/Path
|
||||||
|
|
||||||
onready var size_reduced_warning := $VBoxContainer/SizeReducedWarning
|
onready var size_reduced_warning := $VBoxContainer/SizeReducedWarning
|
||||||
onready var already_exists_warning := $VBoxContainer/AlreadyExistsWarning
|
onready var already_exists_warning := $VBoxContainer/AlreadyExistsWarning
|
||||||
|
onready var delete_confirmation := $DeleteConfirmation
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# Add delete button to edit palette dialog
|
# Add delete button to edit palette dialog
|
||||||
add_button(tr("Delete"), false, DELETE_ACTION)
|
add_button(tr("Delete"), false, DELETE_ACTION)
|
||||||
|
delete_confirmation.get_ok().text = tr("Delete Permanently")
|
||||||
|
delete_confirmation.add_button(tr("Move to Trash"), false, BIN_ACTION)
|
||||||
|
|
||||||
|
|
||||||
func open(current_palette: Palette) -> void:
|
func open(current_palette: Palette) -> void:
|
||||||
|
@ -78,8 +82,20 @@ func _on_EditPaletteDialog_confirmed() -> void:
|
||||||
|
|
||||||
func _on_EditPaletteDialog_custom_action(action: String) -> void:
|
func _on_EditPaletteDialog_custom_action(action: String) -> void:
|
||||||
if action == DELETE_ACTION:
|
if action == DELETE_ACTION:
|
||||||
|
delete_confirmation.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_delete_confirmation_confirmed() -> void:
|
||||||
|
emit_signal("deleted", true)
|
||||||
|
delete_confirmation.hide()
|
||||||
|
hide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_delete_confirmation_custom_action(action: String) -> void:
|
||||||
|
if action == BIN_ACTION:
|
||||||
|
emit_signal("deleted", false)
|
||||||
|
delete_confirmation.hide()
|
||||||
hide()
|
hide()
|
||||||
emit_signal("deleted")
|
|
||||||
|
|
||||||
|
|
||||||
func _on_size_value_changed(_value):
|
func _on_size_value_changed(_value):
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
[node name="EditPaletteDialog" type="ConfirmationDialog"]
|
[node name="EditPaletteDialog" type="ConfirmationDialog"]
|
||||||
margin_right = 409.0
|
margin_right = 409.0
|
||||||
margin_bottom = 535.0
|
margin_bottom = 535.0
|
||||||
|
rect_min_size = Vector2( 170, 59.5 )
|
||||||
window_title = "Edit Palette"
|
window_title = "Edit Palette"
|
||||||
resizable = true
|
resizable = true
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -25,7 +26,7 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="PaletteMetadata" type="GridContainer" parent="VBoxContainer"]
|
[node name="PaletteMetadata" type="GridContainer" parent="VBoxContainer"]
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 188.0
|
margin_bottom = 213.0
|
||||||
columns = 2
|
columns = 2
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -46,9 +47,9 @@ rect_min_size = Vector2( 0, 24 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="CommentLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
[node name="CommentLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_top = 46.0
|
margin_top = 58.0
|
||||||
margin_right = 67.0
|
margin_right = 67.0
|
||||||
margin_bottom = 60.0
|
margin_bottom = 72.0
|
||||||
rect_min_size = Vector2( 50, 0 )
|
rect_min_size = Vector2( 50, 0 )
|
||||||
text = "Comment:"
|
text = "Comment:"
|
||||||
|
|
||||||
|
@ -56,21 +57,21 @@ text = "Comment:"
|
||||||
margin_left = 71.0
|
margin_left = 71.0
|
||||||
margin_top = 28.0
|
margin_top = 28.0
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 78.0
|
margin_bottom = 103.0
|
||||||
rect_min_size = Vector2( 0, 75 )
|
rect_min_size = Vector2( 0, 75 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="WidthLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
[node name="WidthLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_top = 87.0
|
margin_top = 112.0
|
||||||
margin_right = 67.0
|
margin_right = 67.0
|
||||||
margin_bottom = 101.0
|
margin_bottom = 126.0
|
||||||
text = "Width:"
|
text = "Width:"
|
||||||
|
|
||||||
[node name="Width" type="SpinBox" parent="VBoxContainer/PaletteMetadata"]
|
[node name="Width" type="SpinBox" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_left = 71.0
|
margin_left = 71.0
|
||||||
margin_top = 82.0
|
margin_top = 107.0
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 106.0
|
margin_bottom = 131.0
|
||||||
rect_min_size = Vector2( 0, 24 )
|
rect_min_size = Vector2( 0, 24 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
min_value = 1.0
|
min_value = 1.0
|
||||||
|
@ -79,16 +80,16 @@ value = 1.0
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
[node name="HeightLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
[node name="HeightLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_top = 115.0
|
margin_top = 140.0
|
||||||
margin_right = 67.0
|
margin_right = 67.0
|
||||||
margin_bottom = 129.0
|
margin_bottom = 154.0
|
||||||
text = "Height:"
|
text = "Height:"
|
||||||
|
|
||||||
[node name="Height" type="SpinBox" parent="VBoxContainer/PaletteMetadata"]
|
[node name="Height" type="SpinBox" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_left = 71.0
|
margin_left = 71.0
|
||||||
margin_top = 110.0
|
margin_top = 135.0
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 134.0
|
margin_bottom = 159.0
|
||||||
rect_min_size = Vector2( 0, 24 )
|
rect_min_size = Vector2( 0, 24 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
min_value = 1.0
|
min_value = 1.0
|
||||||
|
@ -97,25 +98,25 @@ value = 1.0
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
[node name="PathLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
[node name="PathLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_top = 156.0
|
margin_top = 181.0
|
||||||
margin_right = 67.0
|
margin_right = 67.0
|
||||||
margin_bottom = 170.0
|
margin_bottom = 195.0
|
||||||
text = "Path:"
|
text = "Path:"
|
||||||
|
|
||||||
[node name="Path" type="TextEdit" parent="VBoxContainer/PaletteMetadata"]
|
[node name="Path" type="TextEdit" parent="VBoxContainer/PaletteMetadata"]
|
||||||
margin_left = 71.0
|
margin_left = 71.0
|
||||||
margin_top = 138.0
|
margin_top = 163.0
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 188.0
|
margin_bottom = 213.0
|
||||||
rect_min_size = Vector2( 0, 50 )
|
rect_min_size = Vector2( 0, 50 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
readonly = true
|
readonly = true
|
||||||
wrap_enabled = true
|
wrap_enabled = true
|
||||||
|
|
||||||
[node name="SizeReducedWarning" type="Label" parent="VBoxContainer"]
|
[node name="SizeReducedWarning" type="Label" parent="VBoxContainer"]
|
||||||
margin_top = 192.0
|
margin_top = 217.0
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 223.0
|
margin_bottom = 248.0
|
||||||
custom_colors/font_color = Color( 1, 0.603922, 0.603922, 1 )
|
custom_colors/font_color = Color( 1, 0.603922, 0.603922, 1 )
|
||||||
text = "Reducing palette size will reset positions of colors. Colors that don't fit in new palette size will be lost!"
|
text = "Reducing palette size will reset positions of colors. Colors that don't fit in new palette size will be lost!"
|
||||||
align = 1
|
align = 1
|
||||||
|
@ -126,9 +127,9 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="AlreadyExistsWarning" type="Label" parent="VBoxContainer"]
|
[node name="AlreadyExistsWarning" type="Label" parent="VBoxContainer"]
|
||||||
margin_top = 227.0
|
margin_top = 252.0
|
||||||
margin_right = 393.0
|
margin_right = 393.0
|
||||||
margin_bottom = 241.0
|
margin_bottom = 266.0
|
||||||
custom_colors/font_color = Color( 1, 0.603922, 0.603922, 1 )
|
custom_colors/font_color = Color( 1, 0.603922, 0.603922, 1 )
|
||||||
text = "Palette with the same name and path already exists!"
|
text = "Palette with the same name and path already exists!"
|
||||||
align = 1
|
align = 1
|
||||||
|
@ -138,9 +139,27 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="DeleteConfirmation" type="ConfirmationDialog" parent="."]
|
||||||
|
margin_right = 170.0
|
||||||
|
margin_bottom = 60.0
|
||||||
|
rect_min_size = Vector2( 170, 59.5 )
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="DeleteConfirmation"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = 8.0
|
||||||
|
margin_top = 8.0
|
||||||
|
margin_right = -8.0
|
||||||
|
margin_bottom = -36.0
|
||||||
|
text = "Delete Palette?"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
[connection signal="confirmed" from="." to="." method="_on_EditPaletteDialog_confirmed"]
|
[connection signal="confirmed" from="." to="." method="_on_EditPaletteDialog_confirmed"]
|
||||||
[connection signal="custom_action" from="." to="." method="_on_EditPaletteDialog_custom_action"]
|
[connection signal="custom_action" from="." to="." method="_on_EditPaletteDialog_custom_action"]
|
||||||
[connection signal="popup_hide" from="." to="." method="_on_EditPaletteDialog_popup_hide"]
|
[connection signal="popup_hide" from="." to="." method="_on_EditPaletteDialog_popup_hide"]
|
||||||
[connection signal="text_changed" from="VBoxContainer/PaletteMetadata/Name" to="." method="_on_Name_text_changed"]
|
[connection signal="text_changed" from="VBoxContainer/PaletteMetadata/Name" to="." method="_on_Name_text_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/PaletteMetadata/Width" to="." method="_on_size_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/PaletteMetadata/Width" to="." method="_on_size_value_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/PaletteMetadata/Height" to="." method="_on_size_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/PaletteMetadata/Height" to="." method="_on_size_value_changed"]
|
||||||
|
[connection signal="confirmed" from="DeleteConfirmation" to="." method="_on_delete_confirmation_confirmed"]
|
||||||
|
[connection signal="custom_action" from="DeleteConfirmation" to="." method="_on_delete_confirmation_custom_action"]
|
||||||
|
|
|
@ -204,8 +204,8 @@ func _on_HiddenColorPickerButton_popup_closed():
|
||||||
Palettes.current_palette_set_color(edited_swatch_index, edited_swatch_color)
|
Palettes.current_palette_set_color(edited_swatch_index, edited_swatch_color)
|
||||||
|
|
||||||
|
|
||||||
func _on_EditPaletteDialog_deleted() -> void:
|
func _on_EditPaletteDialog_deleted(permanent: bool) -> void:
|
||||||
Palettes.current_palete_delete()
|
Palettes.current_palete_delete(permanent)
|
||||||
setup_palettes_selector()
|
setup_palettes_selector()
|
||||||
redraw_current_palette()
|
redraw_current_palette()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue