Skip to content

Commit

Permalink
add rename feature to Duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
BasilYes committed Feb 20, 2024
1 parent 9faf699 commit 0c03a5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extends ConfirmationDialog
@onready var _create_folder_failed_dialog = $CreateFolderFailedDialog
@onready var _file_dialog = $FileDialog
@onready var _randomize_name_button = %RandomizeNameButton
@onready var _rename_container: HBoxContainer = $VBoxContainer/HBoxContainer3
@onready var _rename_check_box: CheckBox = %RenameCheckBox

var _create_folder_failed_label: Label

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ unique_name_in_owner = true
layout_mode = 2
text = "Browse"

[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"]
visible = false
layout_mode = 2

[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3"]
layout_mode = 2
text = "Rename project"

[node name="RenameCheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2

[node name="MessageLabel" type="Label" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
Expand Down
8 changes: 8 additions & 0 deletions src/components/projects/projects.gd
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func _on_projects_list_item_duplicate_requested(project: Projects.Item) -> void:
return

_duplicate_project_dialog.title = "Duplicate Project: %s" % project.name
_duplicate_project_dialog._rename_container.visible = true
_duplicate_project_dialog._rename_check_box.button_pressed = Cache.smart_value(self, "rename_duple", true).ret(false)
_duplicate_project_dialog.get_ok_button().text = tr("Duplicate")

_duplicate_project_dialog.raise(project.name)
Expand Down Expand Up @@ -227,6 +229,12 @@ func _on_projects_list_item_duplicate_requested(project: Projects.Item) -> void:
return

var project_file_path = project_configs[0]
if _duplicate_project_dialog._rename_check_box.button_pressed:
var initial_settings = ConfigFile.new()
initial_settings.load(project_file_path._path)
initial_settings.set_value("application", "config/name", final_project_name)
initial_settings.save(project_file_path._path)
Cache.smart_value(self, "rename_duple", true).put(_duplicate_project_dialog._rename_check_box.button_pressed)
_duplicate_project_dialog.hide()
import(project_file_path.path)
pass,
Expand Down

0 comments on commit 0c03a5b

Please sign in to comment.