From c242cd546d4c9a5c08426c81b52d79d2d40f3397 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 5 Jan 2022 02:34:45 +0200 Subject: [PATCH] Add a checkbox in Preferences for quit confirmation This has no effect if the project has unsaved changes. --- Translations/Translations.pot | 3 +++ src/Autoload/Global.gd | 1 + src/Main.gd | 5 ++++- src/Preferences/PreferencesDialog.gd | 6 ++++++ src/Preferences/PreferencesDialog.tscn | 25 ++++++++++++++++++++----- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Translations/Translations.pot b/Translations/Translations.pot index 2a0259fb5..c7b53bf49 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -1691,6 +1691,9 @@ msgstr "" msgid "Opens last opened project on startup" msgstr "" +msgid "Quit confirmation" +msgstr "" + msgid "Enable autosave" msgstr "" diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 09688ff37..d70e18aa1 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -34,6 +34,7 @@ var default_clear_color := Color.gray # Preferences var pressure_sensitivity_mode = PressureSensitivity.NONE var open_last_project := false +var quit_confirmation := false var smooth_zoom := true var shrink := 1.0 diff --git a/src/Main.gd b/src/Main.gd index 43aacbaaf..a50ff8cad 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -440,7 +440,10 @@ func _can_draw_true() -> void: func show_quit_dialog() -> void: if !quit_dialog.visible: if !Global.current_project.has_changed: - quit_dialog.call_deferred("popup_centered") + if Global.quit_confirmation: + quit_dialog.call_deferred("popup_centered") + else: + _on_QuitDialog_confirmed() else: Global.quit_and_save_dialog.call_deferred("popup_centered") diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index 261b3af7d..87d91fb20 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -8,6 +8,12 @@ var preferences = [ "pressed", Global.open_last_project ], + [ + "quit_confirmation", + "Startup/StartupContainer/QuitConfirmation", + "pressed", + Global.quit_confirmation + ], ["shrink", "Interface/ShrinkContainer/ShrinkHSlider", "value", Global.shrink], ["dim_on_popup", "Interface/DimPopup/CheckBox", "pressed", Global.dim_on_popup], [ diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index bd680e0b5..8880c1865 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -51,18 +51,19 @@ size_flags_horizontal = 3 [node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/ScrollContainer"] margin_right = 498.0 -margin_bottom = 24.0 +margin_bottom = 52.0 size_flags_horizontal = 3 [node name="Startup" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"] margin_right = 498.0 -margin_bottom = 24.0 +margin_bottom = 52.0 -[node name="StartupContainer" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup"] +[node name="StartupContainer" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup"] margin_right = 498.0 -margin_bottom = 24.0 +margin_bottom = 52.0 +columns = 3 -[node name="Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/StartupContainer"] +[node name="OpenLastProjectLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/StartupContainer"] margin_top = 5.0 margin_right = 180.0 margin_bottom = 19.0 @@ -76,6 +77,20 @@ hint_tooltip = "Opens last opened project on startup" mouse_default_cursor_shape = 2 text = "On" +[node name="QuitConfirmationLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/StartupContainer"] +margin_left = 235.0 +margin_top = 5.0 +margin_right = 348.0 +margin_bottom = 19.0 +text = "Quit confirmation" + +[node name="QuitConfirmation" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/StartupContainer"] +margin_top = 28.0 +margin_right = 180.0 +margin_bottom = 52.0 +mouse_default_cursor_shape = 2 +text = "On" + [node name="PressureSentivity" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup"] visible = false margin_top = 28.0