Unify editor version buttons
This commit is contained in:
@ -30,8 +30,6 @@
|
||||
|
||||
#include "editor_bottom_panel.h"
|
||||
|
||||
#include "core/os/time.h"
|
||||
#include "core/version.h"
|
||||
#include "editor/debugger/editor_debugger_node.h"
|
||||
#include "editor/editor_about.h"
|
||||
#include "editor/editor_command_palette.h"
|
||||
@ -39,13 +37,10 @@
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/engine_update_label.h"
|
||||
#include "editor/gui/editor_toaster.h"
|
||||
#include "editor/gui/editor_version_button.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/button.h"
|
||||
#include "scene/gui/link_button.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 EditorBottomPanel::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
@ -110,10 +105,6 @@ void EditorBottomPanel::_expand_button_toggled(bool p_pressed) {
|
||||
EditorNode::get_top_split()->set_visible(!p_pressed);
|
||||
}
|
||||
|
||||
void EditorBottomPanel::_version_button_pressed() {
|
||||
DisplayServer::get_singleton()->clipboard_set(version_btn->get_meta(META_TEXT_TO_COPY));
|
||||
}
|
||||
|
||||
bool EditorBottomPanel::_button_drag_hover(const Vector2 &, const Variant &, Button *p_button, Control *p_control) {
|
||||
if (!p_button->is_pressed()) {
|
||||
_switch_by_control(true, p_control);
|
||||
@ -262,25 +253,9 @@ EditorBottomPanel::EditorBottomPanel() {
|
||||
editor_toaster = memnew(EditorToaster);
|
||||
bottom_hbox->add_child(editor_toaster);
|
||||
|
||||
version_btn = memnew(LinkButton);
|
||||
version_btn->set_text(VERSION_FULL_CONFIG);
|
||||
String hash = String(VERSION_HASH);
|
||||
if (hash.length() != 0) {
|
||||
hash = " " + vformat("[%s]", 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);
|
||||
EditorVersionButton *version_btn = memnew(EditorVersionButton(EditorVersionButton::FORMAT_BASIC));
|
||||
// Fade out the version label to be less prominent, but still readable.
|
||||
version_btn->set_self_modulate(Color(1, 1, 1, 0.65));
|
||||
version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
|
||||
String build_date;
|
||||
if (VERSION_TIMESTAMP > 0) {
|
||||
build_date = Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC";
|
||||
} else {
|
||||
build_date = TTR("(unknown)");
|
||||
}
|
||||
version_btn->set_tooltip_text(vformat(TTR("Git commit date: %s\nClick to copy the version information."), build_date));
|
||||
version_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorBottomPanel::_version_button_pressed));
|
||||
version_btn->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
|
||||
bottom_hbox->add_child(version_btn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user