Fix find-in-files and go-to-line dialog (partially)
This commit is contained in:
parent
f148e8eede
commit
e74876028e
|
@ -44,7 +44,7 @@ void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
|
||||||
|
|
||||||
line->set_text(itos(text_editor->cursor_get_line()));
|
line->set_text(itos(text_editor->cursor_get_line()));
|
||||||
line->select_all();
|
line->select_all();
|
||||||
popup_centered(Size2(180, 80));
|
popup_centered(Size2(180, 80) * EDSCALE);
|
||||||
line->grab_focus();
|
line->grab_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,16 +65,20 @@ void GotoLineDialog::ok_pressed() {
|
||||||
GotoLineDialog::GotoLineDialog() {
|
GotoLineDialog::GotoLineDialog() {
|
||||||
|
|
||||||
set_title(TTR("Go to Line"));
|
set_title(TTR("Go to Line"));
|
||||||
|
|
||||||
|
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||||
|
vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE);
|
||||||
|
vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE);
|
||||||
|
vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE);
|
||||||
|
vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE);
|
||||||
|
add_child(vbc);
|
||||||
|
|
||||||
Label *l = memnew(Label);
|
Label *l = memnew(Label);
|
||||||
l->set_text(TTR("Line Number:"));
|
l->set_text(TTR("Line Number:"));
|
||||||
l->set_position(Point2(5, 5));
|
vbc->add_child(l);
|
||||||
add_child(l);
|
|
||||||
|
|
||||||
line = memnew(LineEdit);
|
line = memnew(LineEdit);
|
||||||
line->set_anchor(MARGIN_RIGHT, ANCHOR_END);
|
vbc->add_child(line);
|
||||||
line->set_begin(Point2(15, 22));
|
|
||||||
line->set_end(Point2(-15, 35));
|
|
||||||
add_child(line);
|
|
||||||
register_text_enter(line);
|
register_text_enter(line);
|
||||||
text_editor = NULL;
|
text_editor = NULL;
|
||||||
|
|
||||||
|
|
|
@ -406,11 +406,8 @@ FindInFilesDialog::FindInFilesDialog() {
|
||||||
HBoxContainer *hbc = memnew(HBoxContainer);
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
||||||
hbc->set_alignment(HBoxContainer::ALIGN_CENTER);
|
hbc->set_alignment(HBoxContainer::ALIGN_CENTER);
|
||||||
|
|
||||||
_find_button = memnew(Button);
|
_find_button = add_button(TTR("Find..."), false, "find");
|
||||||
_find_button->set_text(TTR("Find..."));
|
|
||||||
_find_button->connect("pressed", this, "_on_find_button_pressed");
|
|
||||||
_find_button->set_disabled(true);
|
_find_button->set_disabled(true);
|
||||||
hbc->add_child(_find_button);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Control *placeholder = memnew(Control);
|
Control *placeholder = memnew(Control);
|
||||||
|
@ -418,11 +415,8 @@ FindInFilesDialog::FindInFilesDialog() {
|
||||||
hbc->add_child(placeholder);
|
hbc->add_child(placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
_replace_button = memnew(Button);
|
_replace_button = add_button(TTR("Replace..."), false, "replace");
|
||||||
_replace_button->set_text(TTR("Replace..."));
|
|
||||||
_replace_button->connect("pressed", this, "_on_replace_button_pressed");
|
|
||||||
_replace_button->set_disabled(true);
|
_replace_button->set_disabled(true);
|
||||||
hbc->add_child(_replace_button);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Control *placeholder = memnew(Control);
|
Control *placeholder = memnew(Control);
|
||||||
|
@ -430,10 +424,8 @@ FindInFilesDialog::FindInFilesDialog() {
|
||||||
hbc->add_child(placeholder);
|
hbc->add_child(placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Button *cancel_button = memnew(Button);
|
Button *cancel_button = get_ok();
|
||||||
cancel_button->set_text(TTR("Cancel"));
|
cancel_button->set_text(TTR("Cancel"));
|
||||||
cancel_button->connect("pressed", this, "hide");
|
|
||||||
hbc->add_child(cancel_button);
|
|
||||||
|
|
||||||
vbc->add_child(hbc);
|
vbc->add_child(hbc);
|
||||||
}
|
}
|
||||||
|
@ -487,14 +479,14 @@ void FindInFilesDialog::_on_folder_button_pressed() {
|
||||||
_folder_dialog->popup_centered_ratio();
|
_folder_dialog->popup_centered_ratio();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindInFilesDialog::_on_find_button_pressed() {
|
void FindInFilesDialog::custom_action(const String &p_action) {
|
||||||
emit_signal(SIGNAL_FIND_REQUESTED);
|
if (p_action == "find") {
|
||||||
hide();
|
emit_signal(SIGNAL_FIND_REQUESTED);
|
||||||
}
|
hide();
|
||||||
|
} else if (p_action == "replace") {
|
||||||
void FindInFilesDialog::_on_replace_button_pressed() {
|
emit_signal(SIGNAL_REPLACE_REQUESTED);
|
||||||
emit_signal(SIGNAL_REPLACE_REQUESTED);
|
hide();
|
||||||
hide();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindInFilesDialog::_on_search_text_modified(String text) {
|
void FindInFilesDialog::_on_search_text_modified(String text) {
|
||||||
|
@ -509,7 +501,7 @@ void FindInFilesDialog::_on_search_text_modified(String text) {
|
||||||
void FindInFilesDialog::_on_search_text_entered(String text) {
|
void FindInFilesDialog::_on_search_text_entered(String text) {
|
||||||
// This allows to trigger a global search without leaving the keyboard
|
// This allows to trigger a global search without leaving the keyboard
|
||||||
if (!_find_button->is_disabled())
|
if (!_find_button->is_disabled())
|
||||||
_on_find_button_pressed();
|
custom_action("find");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindInFilesDialog::_on_folder_selected(String path) {
|
void FindInFilesDialog::_on_folder_selected(String path) {
|
||||||
|
@ -522,8 +514,6 @@ void FindInFilesDialog::_on_folder_selected(String path) {
|
||||||
void FindInFilesDialog::_bind_methods() {
|
void FindInFilesDialog::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method("_on_folder_button_pressed", &FindInFilesDialog::_on_folder_button_pressed);
|
ClassDB::bind_method("_on_folder_button_pressed", &FindInFilesDialog::_on_folder_button_pressed);
|
||||||
ClassDB::bind_method("_on_find_button_pressed", &FindInFilesDialog::_on_find_button_pressed);
|
|
||||||
ClassDB::bind_method("_on_replace_button_pressed", &FindInFilesDialog::_on_replace_button_pressed);
|
|
||||||
ClassDB::bind_method("_on_folder_selected", &FindInFilesDialog::_on_folder_selected);
|
ClassDB::bind_method("_on_folder_selected", &FindInFilesDialog::_on_folder_selected);
|
||||||
ClassDB::bind_method("_on_search_text_modified", &FindInFilesDialog::_on_search_text_modified);
|
ClassDB::bind_method("_on_search_text_modified", &FindInFilesDialog::_on_search_text_modified);
|
||||||
ClassDB::bind_method("_on_search_text_entered", &FindInFilesDialog::_on_search_text_entered);
|
ClassDB::bind_method("_on_search_text_entered", &FindInFilesDialog::_on_search_text_entered);
|
||||||
|
|
|
@ -91,8 +91,8 @@ class CheckBox;
|
||||||
class FileDialog;
|
class FileDialog;
|
||||||
|
|
||||||
// Prompts search parameters
|
// Prompts search parameters
|
||||||
class FindInFilesDialog : public WindowDialog {
|
class FindInFilesDialog : public AcceptDialog {
|
||||||
GDCLASS(FindInFilesDialog, WindowDialog)
|
GDCLASS(FindInFilesDialog, AcceptDialog)
|
||||||
public:
|
public:
|
||||||
static const char *SIGNAL_FIND_REQUESTED;
|
static const char *SIGNAL_FIND_REQUESTED;
|
||||||
static const char *SIGNAL_REPLACE_REQUESTED;
|
static const char *SIGNAL_REPLACE_REQUESTED;
|
||||||
|
@ -111,11 +111,10 @@ protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
void custom_action(const String &p_action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _on_folder_button_pressed();
|
void _on_folder_button_pressed();
|
||||||
void _on_find_button_pressed();
|
|
||||||
void _on_replace_button_pressed();
|
|
||||||
void _on_folder_selected(String path);
|
void _on_folder_selected(String path);
|
||||||
void _on_search_text_modified(String text);
|
void _on_search_text_modified(String text);
|
||||||
void _on_search_text_entered(String text);
|
void _on_search_text_entered(String text);
|
||||||
|
|
Loading…
Reference in New Issue