Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to move Palettes to Trash/Recycle Bin instead of deleting them permanently #914

Merged
merged 7 commits into from Oct 11, 2023
2 changes: 1 addition & 1 deletion src/Autoload/Palettes.gd
Expand Up @@ -214,7 +214,7 @@ func current_palette_edit(palette_name: String, comment: String, width: int, hei


func _delete_palette(path: String) -> void:
DirAccess.open(path).remove(path)
OS.move_to_trash(path)
palettes.erase(path)


Expand Down
14 changes: 11 additions & 3 deletions src/Palette/CreatePaletteDialog.tscn
Expand Up @@ -3,16 +3,18 @@
[ext_resource type="Script" path="res://src/Palette/CreatePaletteDialog.gd" id="1"]

[node name="CreatePaletteDialog" type="ConfirmationDialog"]
title = "Create a new palette"
size = Vector2i(325, 437)
script = ExtResource("1")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = -1
anchor_left = 0.000793701
anchor_right = 0.000793701
offset_left = 7.76189
offset_left = 7.74205
offset_top = 8.0
offset_right = 291.762
offset_bottom = 401.0
offset_right = 316.742
offset_bottom = 388.0

[node name="PaletteMetadata" type="GridContainer" parent="VBoxContainer"]
layout_mode = 2
Expand Down Expand Up @@ -118,12 +120,18 @@ layout_mode = 2
size_flags_vertical = 7
theme_override_colors/font_color = Color(1, 0.603922, 0.603922, 1)
text = "Palette with the same name and path already exists!"
horizontal_alignment = 1
vertical_alignment = 2
autowrap_mode = 3

[node name="EnterNameWarning" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 7
theme_override_colors/font_color = Color(1, 0.603922, 0.603922, 1)
text = "Palette name is required!"
horizontal_alignment = 1
vertical_alignment = 2
autowrap_mode = 3

[connection signal="confirmed" from="." to="." method="_on_CreatePaletteDialog_confirmed"]
[connection signal="visibility_changed" from="." to="." method="_on_CreatePaletteDialog_visibility_changed"]
Expand Down
4 changes: 2 additions & 2 deletions src/Palette/EditPaletteDialog.gd
Expand Up @@ -16,7 +16,7 @@ var old_name := ""
@onready var comment_input := $VBoxContainer/PaletteMetadata/Comment
@onready var width_input := $VBoxContainer/PaletteMetadata/Width
@onready var height_input := $VBoxContainer/PaletteMetadata/Height
@onready var path_input := $VBoxContainer/PaletteMetadata/Path3D
@onready var path_input := $VBoxContainer/PaletteMetadata/Path

@onready var size_reduced_warning := $VBoxContainer/SizeReducedWarning
@onready var already_exists_warning := $VBoxContainer/AlreadyExistsWarning
Expand Down Expand Up @@ -79,7 +79,7 @@ func _on_EditPaletteDialog_confirmed() -> void:
func _on_EditPaletteDialog_custom_action(action: String) -> void:
if action == DELETE_ACTION:
hide()
deleted.emit(deleted)
emit_signal("deleted")
Variable-ind marked this conversation as resolved.
Show resolved Hide resolved


func _on_size_value_changed(_value):
Expand Down
17 changes: 14 additions & 3 deletions src/Palette/EditPaletteDialog.tscn
Expand Up @@ -3,6 +3,8 @@
[ext_resource type="Script" path="res://src/Palette/EditPaletteDialog.gd" id="1"]

[node name="EditPaletteDialog" type="ConfirmationDialog"]
title = "Edit Palette"
size = Vector2i(409, 535)
script = ExtResource("1")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
Expand All @@ -12,10 +14,11 @@ anchor_bottom = 1.0
offset_left = 8.0
offset_top = 8.0
offset_right = -8.0
offset_bottom = -36.0
offset_bottom = -49.0

[node name="PaletteMetadata" type="GridContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
columns = 2

[node name="NameLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
Expand All @@ -31,12 +34,14 @@ size_flags_horizontal = 3
[node name="CommentLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
custom_minimum_size = Vector2(50, 0)
layout_mode = 2
size_flags_vertical = 0
text = "Comment:"

[node name="Comment" type="TextEdit" parent="VBoxContainer/PaletteMetadata"]
custom_minimum_size = Vector2(0, 75)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="WidthLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
layout_mode = 2
Expand Down Expand Up @@ -64,9 +69,9 @@ value = 1.0

[node name="PathLabel" type="Label" parent="VBoxContainer/PaletteMetadata"]
layout_mode = 2
text = "Path3D:"
text = "Path:"

[node name="Path3D" type="TextEdit" parent="VBoxContainer/PaletteMetadata"]
[node name="Path" type="TextEdit" parent="VBoxContainer/PaletteMetadata"]
custom_minimum_size = Vector2(0, 50)
layout_mode = 2
size_flags_horizontal = 3
Expand All @@ -75,11 +80,17 @@ size_flags_horizontal = 3
layout_mode = 2
theme_override_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!"
horizontal_alignment = 1
vertical_alignment = 2
autowrap_mode = 3

[node name="AlreadyExistsWarning" type="Label" parent="VBoxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.603922, 0.603922, 1)
text = "Palette with the same name and path already exists!"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 3

[connection signal="confirmed" from="." to="." method="_on_EditPaletteDialog_confirmed"]
[connection signal="custom_action" from="." to="." method="_on_EditPaletteDialog_custom_action"]
Expand Down
6 changes: 3 additions & 3 deletions src/UI/ReferenceImages/ReferenceImageButton.gd
Expand Up @@ -7,11 +7,11 @@ var _ignore_spinbox_changes := false

func _ready():
if OS.get_name() == "Web":
$Interior/PathHeader/Path3D.visible = false
$Interior/PathHeader/Path.visible = false
$Interior/PathHeader/PathHTML.text = element.image_path
else:
$Interior/PathHeader/PathHTML.visible = false
$Interior/PathHeader/Path3D.text = element.image_path
$Interior/PathHeader/Path.text = element.image_path

if !element.texture:
$Interior/PreviewAndOptions/PreviewPanel/Warning.text = "Image not found!"
Expand Down Expand Up @@ -79,7 +79,7 @@ func _on_Opacity_value_changed(value: float):


func _on_Path_pressed() -> void:
OS.shell_open($Interior/PathHeader/Path3D.text.get_base_dir())
OS.shell_open($Interior/PathHeader/Path.text.get_base_dir())


func _on_Silhouette_toggled(button_pressed: bool) -> void:
Expand Down
4 changes: 2 additions & 2 deletions src/UI/ReferenceImages/ReferenceImageButton.tscn
Expand Up @@ -19,7 +19,7 @@ layout_mode = 2
layout_mode = 2
theme_override_constants/separation = 0

[node name="Path3D" type="LinkButton" parent="Interior/PathHeader"]
[node name="Path" type="LinkButton" parent="Interior/PathHeader"]
modulate = Color(0.552941, 1, 0.298039, 1)
layout_mode = 2
size_flags_horizontal = 3
Expand Down Expand Up @@ -117,7 +117,7 @@ layout_mode = 2
theme_override_colors/font_color = Color(1, 0.266667, 0.266667, 1)
text = "Remove"

[connection signal="pressed" from="Interior/PathHeader/Path3D" to="." method="_on_Path_pressed"]
[connection signal="pressed" from="Interior/PathHeader/Path" to="." method="_on_Path_pressed"]
[connection signal="value_changed" from="Interior/PreviewAndOptions/Options/Position/X" to="." method="_on_X_value_changed"]
[connection signal="value_changed" from="Interior/PreviewAndOptions/Options/Position/Y" to="." method="_on_Y_value_changed"]
[connection signal="value_changed" from="Interior/PreviewAndOptions/Options/Scale" to="." method="_on_Scale_value_changed"]
Expand Down