You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Make it possible to copy the Godot version identifier by clicking it
This closes #24317.
This commit is contained in:
@@ -47,12 +47,14 @@
|
||||
#include "core/project_settings.h"
|
||||
#include "core/translation.h"
|
||||
#include "core/version.h"
|
||||
#include "core/version_hash.gen.h"
|
||||
#include "main/input_default.h"
|
||||
#include "main/main.h"
|
||||
#include "scene/gui/center_container.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/file_dialog.h"
|
||||
#include "scene/gui/link_button.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/panel.h"
|
||||
#include "scene/gui/panel_container.h"
|
||||
@@ -173,6 +175,9 @@
|
||||
|
||||
EditorNode *EditorNode::singleton = NULL;
|
||||
|
||||
// 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 EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames) {
|
||||
// Keep track of a list of "index sets," i.e. sets of indices
|
||||
// within disambiguated_scene_names which contain the same name.
|
||||
@@ -876,6 +881,10 @@ void EditorNode::_reload_project_settings() {
|
||||
void EditorNode::_vp_resized() {
|
||||
}
|
||||
|
||||
void EditorNode::_version_button_pressed() {
|
||||
OS::get_singleton()->set_clipboard(version_btn->get_meta(META_TEXT_TO_COPY));
|
||||
}
|
||||
|
||||
void EditorNode::_node_renamed() {
|
||||
if (get_inspector())
|
||||
get_inspector()->update_tree();
|
||||
@@ -5342,6 +5351,7 @@ void EditorNode::_bind_methods() {
|
||||
ClassDB::bind_method("_close_messages", &EditorNode::_close_messages);
|
||||
ClassDB::bind_method("_show_messages", &EditorNode::_show_messages);
|
||||
ClassDB::bind_method("_vp_resized", &EditorNode::_vp_resized);
|
||||
ClassDB::bind_method("_version_button_pressed", &EditorNode::_version_button_pressed);
|
||||
ClassDB::bind_method("_quick_opened", &EditorNode::_quick_opened);
|
||||
ClassDB::bind_method("_quick_run", &EditorNode::_quick_run);
|
||||
|
||||
@@ -6440,11 +6450,31 @@ EditorNode::EditorNode() {
|
||||
bottom_panel_hb_editors->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
bottom_panel_hb->add_child(bottom_panel_hb_editors);
|
||||
|
||||
version_label = memnew(Label);
|
||||
version_label->set_text(VERSION_FULL_CONFIG);
|
||||
VBoxContainer *version_info_vbc = memnew(VBoxContainer);
|
||||
bottom_panel_hb->add_child(version_info_vbc);
|
||||
|
||||
// Add a dummy control node for vertical spacing.
|
||||
Control *v_spacer = memnew(Control);
|
||||
version_info_vbc->add_child(v_spacer);
|
||||
|
||||
version_btn = memnew(LinkButton);
|
||||
version_btn->set_text(VERSION_FULL_CONFIG);
|
||||
String hash = String(VERSION_HASH);
|
||||
if (hash.length() != 0) {
|
||||
hash = "." + hash.left(9);
|
||||
}
|
||||
// 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);
|
||||
// Fade out the version label to be less prominent, but still readable
|
||||
version_label->set_self_modulate(Color(1, 1, 1, 0.6));
|
||||
bottom_panel_hb->add_child(version_label);
|
||||
version_btn->set_self_modulate(Color(1, 1, 1, 0.65));
|
||||
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);
|
||||
|
||||
// Add a dummy control node for horizontal spacing.
|
||||
Control *h_spacer = memnew(Control);
|
||||
bottom_panel_hb->add_child(h_spacer);
|
||||
|
||||
bottom_panel_raise = memnew(ToolButton);
|
||||
bottom_panel_raise->set_icon(gui_base->get_icon("ExpandBottomDock", "EditorIcons"));
|
||||
|
||||
Reference in New Issue
Block a user