From 07830ee750e99b0ec6e457d52c2935742a49d448 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 30 Jan 2025 23:56:01 +0100 Subject: [PATCH] feat: Click to copy UUIDs in the demo project (#78) Linkify UUIDs in the demo project output pane, so it's easy to copy UUID to the clipboard simply by clicking on it. --- CHANGELOG.md | 1 + project/main.tscn | 26 ++++++++++++++++++++++++++ project/output.gd | 31 ++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0e333d..8dc3d721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - New `environment` property in `SentryOptions` and better auto-naming to prioritize development environments ([#66](https://github.com/getsentry/sentry-godot/pull/66)) - Configure the SDK via GDScript and filter events using event hooks `before_send` and `on_crash`. The new `SentryConfiguration` class can be extended in a script and assigned in options to configure the SDK during initialization. However, due to the way scripting is initialized in the Godot Engine, this comes with a trade-off: a slightly later initialization. If a configuration script is assigned, initialization must be delayed until ScriptServer is ready to load and run the user script. ([#60](https://github.com/getsentry/sentry-godot/pull/60)) - New `dist` property in `SentryOptions` ([#74](https://github.com/getsentry/sentry-godot/pull/74)) +- Click to copy UUIDs in the demo project ([#78](https://github.com/getsentry/sentry-godot/pull/78)) ### Dependencies diff --git a/project/main.tscn b/project/main.tscn index d9dfbf28..80d3a2f2 100644 --- a/project/main.tscn +++ b/project/main.tscn @@ -264,7 +264,10 @@ unique_name_in_owner = true custom_minimum_size = Vector2(0, 400) layout_mode = 2 size_flags_vertical = 3 +focus_mode = 2 +bbcode_enabled = true scroll_following = true +selection_enabled = true script = ExtResource("2_ibxrb") [node name="BG" type="Panel" parent="VBoxContainer/OutputPane/Output"] @@ -275,6 +278,28 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 + +[node name="MsgCopied" type="PanelContainer" parent="VBoxContainer/OutputPane/Output"] +unique_name_in_owner = true +custom_minimum_size = Vector2(190.651, 0) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -75.5 +offset_top = -20.0 +offset_right = 75.5 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="VBoxContainer/OutputPane/Output/MsgCopied"] +layout_mode = 2 +size_flags_horizontal = 4 +text = "Copied to clipboard" [connection signal="pressed" from="VBoxContainer/Columns/Column1/Breadcrumb/AddBreadcrumbButton" to="." method="_on_add_breadcrumb_button_pressed"] [connection signal="pressed" from="VBoxContainer/Columns/Column1/Tags/AddTagButton" to="." method="_on_add_tag_button_pressed"] @@ -284,3 +309,4 @@ grow_vertical = 2 [connection signal="pressed" from="VBoxContainer/Columns/Column2/GenerateErrors/GenNativeError" to="." method="_on_gen_native_error_pressed"] [connection signal="pressed" from="VBoxContainer/Columns/Column2/MessageEvent/CaptureButton" to="." method="_on_capture_button_pressed"] [connection signal="pressed" from="VBoxContainer/Columns/Column2/Crash2/CrashButton" to="." method="_on_crash_button_pressed"] +[connection signal="meta_clicked" from="VBoxContainer/OutputPane/Output" to="VBoxContainer/OutputPane/Output" method="_on_meta_clicked"] diff --git a/project/output.gd b/project/output.gd index 6a132a1f..213bc7a1 100644 --- a/project/output.gd +++ b/project/output.gd @@ -1,6 +1,10 @@ extends RichTextLabel var _log_file: FileAccess +var _regex: RegEx +var _tween: Tween + +@onready var msg_copied: PanelContainer = %MsgCopied func _init() -> void: @@ -15,8 +19,33 @@ func _init() -> void: tween.tween_interval(0.1) tween.tween_callback(_read_log) + _regex = RegEx.create_from_string(r"\b([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\b") + + +func _ready() -> void: + msg_copied.modulate = Color.TRANSPARENT + func _read_log() -> void: while _log_file.get_position() < _log_file.get_length(): var line: String = _log_file.get_line() + "\n" - text += line + text += _linkify_uuids(line) + + +func _linkify_uuids(line: String) -> String: + line = _regex.sub(line, r"[url]$1[/url]", true) + return line + + +func _pop_copied_toast(): + if _tween and _tween.is_valid(): + _tween.kill() + _tween = create_tween() + _tween.tween_property(msg_copied, "modulate", Color.WHITE, 0.1) + _tween.tween_interval(3.0) + _tween.tween_property(msg_copied, "modulate", Color.TRANSPARENT, 0.1) + + +func _on_meta_clicked(meta: Variant) -> void: + DisplayServer.clipboard_set(str(meta)) + _pop_copied_toast()