You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-06 17:25:19 +00:00
Make it possible to copy the Godot version identifier by clicking it
This closes #24317.
(cherry picked from commit 1ceb603de8)
This commit is contained in:
committed by
Rémi Verschelde
parent
ca465ef54d
commit
018ca6b1c4
@@ -37,6 +37,9 @@
|
||||
#include "core/version.h"
|
||||
#include "core/version_hash.gen.h"
|
||||
|
||||
// The metadata key used to store and retrieve the version text to copy to the clipboard.
|
||||
static const String META_TEXT_TO_COPY = "text_to_copy";
|
||||
|
||||
void EditorAbout::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
@@ -62,8 +65,12 @@ void EditorAbout::_license_tree_selected() {
|
||||
_tpl_text->set_text(selected->get_metadata(0));
|
||||
}
|
||||
|
||||
void EditorAbout::_bind_methods() {
|
||||
void EditorAbout::_version_button_pressed() {
|
||||
OS::get_singleton()->set_clipboard(version_btn->get_meta(META_TEXT_TO_COPY));
|
||||
}
|
||||
|
||||
void EditorAbout::_bind_methods() {
|
||||
ClassDB::bind_method("_version_button_pressed", &EditorAbout::_version_button_pressed);
|
||||
ClassDB::bind_method(D_METHOD("_license_tree_selected"), &EditorAbout::_license_tree_selected);
|
||||
}
|
||||
|
||||
@@ -130,16 +137,32 @@ EditorAbout::EditorAbout() {
|
||||
_logo = memnew(TextureRect);
|
||||
hbc->add_child(_logo);
|
||||
|
||||
VBoxContainer *version_info_vbc = memnew(VBoxContainer);
|
||||
|
||||
// Add a dummy control node for spacing.
|
||||
Control *v_spacer = memnew(Control);
|
||||
version_info_vbc->add_child(v_spacer);
|
||||
|
||||
version_btn = memnew(LinkButton);
|
||||
String hash = String(VERSION_HASH);
|
||||
if (hash.length() != 0)
|
||||
if (hash.length() != 0) {
|
||||
hash = "." + hash.left(9);
|
||||
}
|
||||
version_btn->set_text(VERSION_FULL_NAME + hash);
|
||||
// Set the text to copy in metadata as it slightly differs from the button's text.
|
||||
version_btn->set_meta(META_TEXT_TO_COPY, "v" VERSION_FULL_BUILD + hash);
|
||||
version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
|
||||
version_btn->set_tooltip(TTR("Click to copy."));
|
||||
version_btn->connect("pressed", this, "_version_button_pressed");
|
||||
version_info_vbc->add_child(version_btn);
|
||||
|
||||
Label *about_text = memnew(Label);
|
||||
about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
|
||||
about_text->set_text(VERSION_FULL_NAME + hash +
|
||||
String::utf8("\n\xc2\xa9 2007-2021 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2021 ") +
|
||||
about_text->set_text(String::utf8("\xc2\xa9 2007-2021 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2021 ") +
|
||||
TTR("Godot Engine contributors") + "\n");
|
||||
hbc->add_child(about_text);
|
||||
version_info_vbc->add_child(about_text);
|
||||
|
||||
hbc->add_child(version_info_vbc);
|
||||
|
||||
TabContainer *tc = memnew(TabContainer);
|
||||
tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE);
|
||||
|
||||
Reference in New Issue
Block a user