Esempio n. 1
0
void FindInFilesPanel::_on_finished() {

	_status_label->set_text(TTR("Search complete"));
	update_replace_buttons();
	set_progress_visible(false);
	_cancel_button->set_disabled(true);
}
Esempio n. 2
0
void FindInFilesPanel::stop_search() {

	_finder->stop();

	_status_label->set_text("");
	update_replace_buttons();
	set_progress_visible(false);
	_cancel_button->set_disabled(true);
}
Esempio n. 3
0
void FindInFilesPanel::start_search() {

	_results_display->clear();
	_status_label->set_text(TTR("Searching..."));
	_search_text_label->set_text(_finder->get_search_text());

	set_process(true);
	set_progress_visible(true);

	_finder->start();

	update_replace_buttons();
	_cancel_button->set_disabled(false);
}
Esempio n. 4
0
FindInFilesPanel::FindInFilesPanel() {

	_finder = memnew(FindInFiles);
	_finder->connect(FindInFiles::SIGNAL_RESULT_FOUND, this, "_on_result_found");
	_finder->connect(FindInFiles::SIGNAL_FINISHED, this, "_on_finished");
	add_child(_finder);

	VBoxContainer *vbc = memnew(VBoxContainer);
	vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
	vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
	vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
	vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
	add_child(vbc);

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		Label *find_label = memnew(Label);
		find_label->set_text(TTR("Find: "));
		hbc->add_child(find_label);

		_search_text_label = memnew(Label);
		_search_text_label->add_font_override("font", get_font("source", "EditorFonts"));
		hbc->add_child(_search_text_label);

		_progress_bar = memnew(ProgressBar);
		_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(_progress_bar);
		set_progress_visible(false);

		_status_label = memnew(Label);
		hbc->add_child(_status_label);

		_cancel_button = memnew(Button);
		_cancel_button->set_text(TTR("Cancel"));
		_cancel_button->connect("pressed", this, "_on_cancel_button_clicked");
		_cancel_button->set_disabled(true);
		hbc->add_child(_cancel_button);

		vbc->add_child(hbc);
	}

	// In the future, this should be replaced by a more specific list container,
	// which can highlight text regions and change opacity for enabled/disabled states
	_results_display = memnew(ItemList);
	_results_display->add_font_override("font", get_font("source", "EditorFonts"));
	_results_display->set_v_size_flags(SIZE_EXPAND_FILL);
	_results_display->connect("item_selected", this, "_on_result_selected");
	vbc->add_child(_results_display);

	{
		_replace_container = memnew(HBoxContainer);

		Label *replace_label = memnew(Label);
		replace_label->set_text(TTR("Replace: "));
		_replace_container->add_child(replace_label);

		_replace_line_edit = memnew(LineEdit);
		_replace_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
		_replace_line_edit->connect("text_changed", this, "_on_replace_text_changed");
		_replace_container->add_child(_replace_line_edit);

		_replace_all_button = memnew(Button);
		_replace_all_button->set_text(TTR("Replace all (no undo)"));
		_replace_all_button->connect("pressed", this, "_on_replace_all_clicked");
		_replace_container->add_child(_replace_all_button);

		_replace_container->hide();

		vbc->add_child(_replace_container);
	}
}
Esempio n. 5
0
FindInFilesPanel::FindInFilesPanel() {

	_finder = memnew(FindInFiles);
	_finder->connect(FindInFiles::SIGNAL_RESULT_FOUND, this, "_on_result_found");
	_finder->connect(FindInFiles::SIGNAL_FINISHED, this, "_on_finished");
	add_child(_finder);

	VBoxContainer *vbc = memnew(VBoxContainer);
	vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
	vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
	vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
	vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
	add_child(vbc);

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		Label *find_label = memnew(Label);
		find_label->set_text(TTR("Find: "));
		hbc->add_child(find_label);

		_search_text_label = memnew(Label);
		_search_text_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
		hbc->add_child(_search_text_label);

		_progress_bar = memnew(ProgressBar);
		_progress_bar->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(_progress_bar);
		set_progress_visible(false);

		_status_label = memnew(Label);
		hbc->add_child(_status_label);

		_cancel_button = memnew(Button);
		_cancel_button->set_text(TTR("Cancel"));
		_cancel_button->connect("pressed", this, "_on_cancel_button_clicked");
		_cancel_button->hide();
		hbc->add_child(_cancel_button);

		vbc->add_child(hbc);
	}

	_results_display = memnew(Tree);
	_results_display->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
	_results_display->set_v_size_flags(SIZE_EXPAND_FILL);
	_results_display->connect("item_selected", this, "_on_result_selected");
	_results_display->connect("item_edited", this, "_on_item_edited");
	_results_display->set_hide_root(true);
	_results_display->set_select_mode(Tree::SELECT_ROW);
	_results_display->create_item(); // Root
	vbc->add_child(_results_display);

	_with_replace = false;

	{
		_replace_container = memnew(HBoxContainer);

		Label *replace_label = memnew(Label);
		replace_label->set_text(TTR("Replace: "));
		_replace_container->add_child(replace_label);

		_replace_line_edit = memnew(LineEdit);
		_replace_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
		_replace_line_edit->connect("text_changed", this, "_on_replace_text_changed");
		_replace_container->add_child(_replace_line_edit);

		_replace_all_button = memnew(Button);
		_replace_all_button->set_text(TTR("Replace all (no undo)"));
		_replace_all_button->connect("pressed", this, "_on_replace_all_clicked");
		_replace_container->add_child(_replace_all_button);

		_replace_container->hide();

		vbc->add_child(_replace_container);
	}
}