mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Add a confirmation dialog to confirm whether a user wants to enable an extension
For security purposes. Extensions can be dangerous, the user must know what they are doing. Better safe than sorry.
This commit is contained in:
parent
2613e02cd2
commit
10d3eac253
|
@ -1543,6 +1543,7 @@ msgstr ""
|
|||
msgid "Specifies the tablet driver being used on Windows. If you have Windows Ink enabled, select winink."
|
||||
msgstr ""
|
||||
|
||||
#. Found in the Preferences, under Extensions.
|
||||
msgid "Add Extension"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1558,6 +1559,18 @@ msgstr ""
|
|||
msgid "Open Folder"
|
||||
msgstr ""
|
||||
|
||||
#. Found in the Preferences, under Extensions. It is a button that, when clicked, opens up the extension explorer which allows users to download extensions from the Internet.
|
||||
msgid "Explore Online"
|
||||
msgstr ""
|
||||
|
||||
#. Found in the Preferences, under Extensions. This is the text of a confirmation dialog that appears when the user attempts to enable an extension.
|
||||
msgid "Are you sure you want to enable this extension? Make sure to only enable extensions from sources that you trust."
|
||||
msgstr ""
|
||||
|
||||
#. Found in the Preferences, under Extensions. This is the text of a confirmation dialog that appears when the user attempts to delete an extension.
|
||||
msgid "Are you sure you want to delete this extension?"
|
||||
msgstr ""
|
||||
|
||||
#. Hint tooltip of a button in the Global Tool Settings. "Dynamics" let users affect certain brush parameters, such as their size and alpha, based on the pressure of the tablet pen, the velocity of the mouse or the pen, and more in the future.
|
||||
msgid "Dynamics"
|
||||
msgstr ""
|
||||
|
|
|
@ -7,7 +7,8 @@ extends VBoxContainer
|
|||
@onready var extension_list := $InstalledExtensions as ItemList
|
||||
@onready var enable_button := $HBoxContainer/EnableButton as Button
|
||||
@onready var uninstall_button := $HBoxContainer/UninstallButton as Button
|
||||
@onready var delete_confirmation := %DeleteConfirmation as ConfirmationDialog
|
||||
@onready var enable_confirmation := %EnableExtensionConfirmation as ConfirmationDialog
|
||||
@onready var delete_confirmation := %DeleteExtensionConfirmation as ConfirmationDialog
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -70,17 +71,25 @@ func _on_AddExtensionButton_pressed() -> void:
|
|||
func _on_EnableButton_pressed() -> void:
|
||||
var file_name: String = extension_list.get_item_metadata(extensions.extension_selected)
|
||||
var extension: Extensions.Extension = extensions.extensions[file_name]
|
||||
extension.enabled = !extension.enabled
|
||||
# Don't allow disabling internal extensions through this button.
|
||||
if extension.internal and extension.enabled_once:
|
||||
preferences_dialog.preference_update(true)
|
||||
else:
|
||||
extensions.enable_extension(extension)
|
||||
|
||||
if extension.enabled:
|
||||
enable_button.text = "Disable"
|
||||
else:
|
||||
enable_button.text = "Enable"
|
||||
if extension.enabled: # If enabled, disable
|
||||
extension.enabled = false
|
||||
extensions.enable_extension(extension)
|
||||
enable_button.text = "Enable"
|
||||
else: # If disabled, ask for user confirmation to enable
|
||||
if enable_confirmation.confirmed.is_connected(
|
||||
_on_enable_extension_confirmation_confirmed
|
||||
):
|
||||
enable_confirmation.confirmed.disconnect(
|
||||
_on_enable_extension_confirmation_confirmed
|
||||
)
|
||||
enable_confirmation.confirmed.connect(
|
||||
_on_enable_extension_confirmation_confirmed.bind(extension)
|
||||
)
|
||||
enable_confirmation.popup_centered()
|
||||
|
||||
|
||||
func _on_UninstallButton_pressed() -> void:
|
||||
|
@ -103,5 +112,12 @@ func _on_delete_confirmation_custom_action(action: StringName) -> void:
|
|||
delete_confirmation.hide()
|
||||
|
||||
|
||||
func _on_enable_extension_confirmation_confirmed(extension: Extensions.Extension) -> void:
|
||||
extension.enabled = true
|
||||
extensions.enable_extension(extension)
|
||||
enable_button.text = "Disable"
|
||||
enable_confirmation.confirmed.disconnect(_on_enable_extension_confirmation_confirmed)
|
||||
|
||||
|
||||
func _on_delete_confirmation_confirmed() -> void:
|
||||
extensions.uninstall_extension(extension_list.get_item_metadata(extensions.extension_selected))
|
||||
|
|
|
@ -1366,22 +1366,20 @@ show_hidden_files = true
|
|||
[node name="Store" parent="." instance=ExtResource("8_jmnx8")]
|
||||
transient = true
|
||||
|
||||
[node name="DeleteConfirmation" type="ConfirmationDialog" parent="."]
|
||||
[node name="EnableExtensionConfirmation" type="ConfirmationDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
dialog_text = "Are you sure you want to enable this extension? Make sure to only enable extensions from sources that you trust."
|
||||
dialog_autowrap = true
|
||||
|
||||
[node name="DeleteExtensionConfirmation" type="ConfirmationDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2i(0, 36)
|
||||
size = Vector2i(500, 100)
|
||||
size = Vector2i(400, 100)
|
||||
exclusive = false
|
||||
popup_window = true
|
||||
ok_button_text = "Delete Permanently"
|
||||
|
||||
[node name="Label" type="Label" parent="DeleteConfirmation"]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 492.0
|
||||
offset_bottom = 51.0
|
||||
text = "Delete Extension?"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
dialog_text = "Are you sure you want to delete this extension?"
|
||||
dialog_autowrap = true
|
||||
|
||||
[connection signal="about_to_popup" from="." to="." method="_on_PreferencesDialog_about_to_show"]
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_PreferencesDialog_visibility_changed"]
|
||||
|
@ -1397,5 +1395,5 @@ vertical_alignment = 1
|
|||
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions/HBoxContainer/UninstallButton" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_UninstallButton_pressed"]
|
||||
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions/HBoxContainer/OpenFolderButton" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_OpenFolderButton_pressed"]
|
||||
[connection signal="files_selected" from="AddExtensionFileDialog" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_AddExtensionFileDialog_files_selected"]
|
||||
[connection signal="confirmed" from="DeleteConfirmation" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_delete_confirmation_confirmed"]
|
||||
[connection signal="custom_action" from="DeleteConfirmation" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_delete_confirmation_custom_action"]
|
||||
[connection signal="confirmed" from="DeleteExtensionConfirmation" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_delete_confirmation_confirmed"]
|
||||
[connection signal="custom_action" from="DeleteExtensionConfirmation" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_delete_confirmation_custom_action"]
|
||||
|
|
Loading…
Reference in a new issue