Now custom controls can be added to the top bar of the plugin settings page.

This commit is contained in:
Relintai 2022-07-16 19:28:39 +02:00
parent 4faf01a1c1
commit fb02d16983
3 changed files with 31 additions and 16 deletions

View File

@ -30,25 +30,32 @@
#include "editor_plugin_settings.h"
#include "core/io/config_file.h"
#include "core/os/file_access.h"
#include "core/os/main_loop.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "core/class_db.h"
#include "core/error_list.h"
#include "core/error_macros.h"
#include "core/io/config_file.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/os/main_loop.h"
#include "core/os/memory.h"
#include "core/reference.h"
#include "core/variant.h"
#include "editor/plugin_config_dialog.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "scene/gui/button.h"
#include "scene/gui/control.h"
#include "scene/gui/label.h"
#include "scene/gui/tree.h"
#include "scene/main/node.h"
void EditorPluginSettings::add_control_to_top_bar(Control *p_control) {
_custom_top_bar_control_container->add_child(p_control);
}
void EditorPluginSettings::remove_control_from_top_bar(Control *p_control) {
_custom_top_bar_control_container->remove_child(p_control);
}
void EditorPluginSettings::_notification(int p_what) {
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
update_plugins();
@ -209,6 +216,8 @@ EditorPluginSettings::EditorPluginSettings() {
HBoxContainer *title_hb = memnew(HBoxContainer);
title_hb->add_child(memnew(Label(TTR("Installed Plugins:"))));
title_hb->add_spacer();
_custom_top_bar_control_container = memnew(HBoxContainer);
title_hb->add_child(_custom_top_bar_control_container);
create_plugin = memnew(Button(TTR("Create")));
create_plugin->connect("pressed", this, "_create_clicked");
title_hb->add_child(create_plugin);

View File

@ -36,14 +36,27 @@
#include "core/ustring.h"
#include "core/vector.h"
class Button;
class PluginConfigDialog;
class Tree;
class HBoxContainer;
class EditorPluginSettings : public VBoxContainer {
GDCLASS(EditorPluginSettings, VBoxContainer);
public:
void add_control_to_top_bar(Control *p_control);
void remove_control_from_top_bar(Control *p_control);
void update_plugins();
EditorPluginSettings();
protected:
void _notification(int p_what);
static void _bind_methods();
enum {
BUTTON_PLUGIN_EDIT
};
@ -54,21 +67,13 @@ class EditorPluginSettings : public VBoxContainer {
Tree *plugin_list;
bool updating;
HBoxContainer *_custom_top_bar_control_container;
void _plugin_activity_changed();
void _create_clicked();
void _cell_button_pressed(Object *p_item, int p_column, int p_id);
static Vector<String> _get_plugins(const String &p_dir);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void update_plugins();
EditorPluginSettings();
};
#endif // EDITORPLUGINSETTINGS_H

View File

@ -219,6 +219,7 @@ public:
void update_plugins();
EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; }
EditorPluginSettings *get_plugin_settings() { return plugin_settings; }
TabContainer *get_tabs();