Skip to content

Commit

Permalink
feat: Click to copy UUIDs in the demo project (#78)
Browse files Browse the repository at this point in the history
Linkify UUIDs in the demo project output pane, so it's easy to copy UUID to the clipboard simply by clicking on it.
  • Loading branch information
limbonaut authored Jan 30, 2025
1 parent e93cc99 commit 07830ee
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions project/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
Expand All @@ -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"]
31 changes: 30 additions & 1 deletion project/output.gd
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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()

0 comments on commit 07830ee

Please sign in to comment.