Skip to content

Commit

Permalink
New Quick Open Dialog
Browse files Browse the repository at this point in the history
  - Updated list view with thumbnails, and separate file name.
  - Added a grid view which has larger icons.
  - Added toggle to filter out files from addons.
  - Store history for each opened resource type.

New Editor settings for Quick Open:
  - Startup display mode (grid or list):
      - Determined by the requested resource type.
      - Whatever was last used.
  - Toggle to filter out files from addons (for persistence).

Notes
  - The dialog is now created once in EditorNode, and globally available for other components.
  - A fixed number of result scenes are instantiated, and reused based on query.
  - Drop support for multiselect.
  • Loading branch information
stijn-h committed Oct 1, 2024
1 parent f4af820 commit c0f1b1d
Show file tree
Hide file tree
Showing 18 changed files with 1,271 additions and 463 deletions.
6 changes: 6 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,12 @@
If [code]true[/code], when saving a file, the editor will rename the old file to a different name, save a new file, then only remove the old file once the new file has been saved. This makes loss of data less likely to happen if the editor or operating system exits unexpectedly while saving (e.g. due to a crash or power outage).
[b]Note:[/b] On Windows, this feature can interact negatively with certain antivirus programs. In this case, you may have to set this to [code]false[/code] to prevent file locking issues.
</member>
<member name="filesystem/quick_open_dialog/default_display_mode" type="int" setter="" getter="">
If set to [code]Adaptive[/code], the dialog opens in list view or grid view depending on the requested type. If set to [code]Last Used[/code], the display mode will always open the way you last used it.
</member>
<member name="filesystem/quick_open_dialog/include_addons" type="bool" setter="" getter="">
If [code]true[/code], results will include files located in the [code]addons[/code] folder.
</member>
<member name="filesystem/tools/oidn/oidn_denoise_path" type="String" setter="" getter="">
The path to the directory containing the Open Image Denoise (OIDN) executable, used optionally for denoising lightmaps. It can be downloaded from [url=https://www.openimagedenoise.org/downloads.html]openimagedenoise.org[/url].
To enable this feature for your specific project, use [member ProjectSettings.rendering/lightmapping/denoising/denoiser].
Expand Down
36 changes: 12 additions & 24 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#include "editor/editor_paths.h"
#include "editor/editor_properties.h"
#include "editor/editor_property_name_processor.h"
#include "editor/editor_quick_open.h"
#include "editor/editor_resource_picker.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_run.h"
#include "editor/editor_run_native.h"
Expand All @@ -109,6 +109,7 @@
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/gui/editor_quick_open_dialog.h"
#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_scene_tabs.h"
#include "editor/gui/editor_title_bar.h"
Expand Down Expand Up @@ -2669,19 +2670,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {

} break;
case FILE_QUICK_OPEN: {
quick_open->popup_dialog("Resource", true);
quick_open->set_title(TTR("Quick Open..."));

quick_open_dialog->popup_dialog({ "Resource" }, callable_mp(this, &EditorNode::_quick_opened));
} break;
case FILE_QUICK_OPEN_SCENE: {
quick_open->popup_dialog("PackedScene", true);
quick_open->set_title(TTR("Quick Open Scene..."));

quick_open_dialog->popup_dialog({ "PackedScene" }, callable_mp(this, &EditorNode::_quick_opened));
} break;
case FILE_QUICK_OPEN_SCRIPT: {
quick_open->popup_dialog("Script", true);
quick_open->set_title(TTR("Quick Open Script..."));

quick_open_dialog->popup_dialog({ "Script" }, callable_mp(this, &EditorNode::_quick_opened));
} break;
case FILE_OPEN_PREV: {
if (previous_scenes.is_empty()) {
Expand Down Expand Up @@ -4599,17 +4594,11 @@ void EditorNode::_update_recent_scenes() {
recent_scenes->reset_size();
}

void EditorNode::_quick_opened() {
Vector<String> files = quick_open->get_selected_files();

bool open_scene_dialog = quick_open->get_base_type() == "PackedScene";
for (int i = 0; i < files.size(); i++) {
const String &res_path = files[i];
if (open_scene_dialog || ClassDB::is_parent_class(ResourceLoader::get_resource_type(res_path), "PackedScene")) {
open_request(res_path);
} else {
load_resource(res_path);
}
void EditorNode::_quick_opened(const String &p_file_path) {
if (ClassDB::is_parent_class(ResourceLoader::get_resource_type(p_file_path), "PackedScene")) {
open_request(p_file_path);
} else {
load_resource(p_file_path);
}
}

Expand Down Expand Up @@ -7848,9 +7837,8 @@ EditorNode::EditorNode() {
open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported));
gui_base->add_child(open_imported);

quick_open = memnew(EditorQuickOpen);
gui_base->add_child(quick_open);
quick_open->connect("quick_open", callable_mp(this, &EditorNode::_quick_opened));
quick_open_dialog = memnew(EditorQuickOpenDialog);
gui_base->add_child(quick_open_dialog);

_update_recent_scenes();

Expand Down
8 changes: 5 additions & 3 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class EditorLog;
class EditorMainScreen;
class EditorNativeShaderSourceVisualizer;
class EditorPluginList;
class EditorQuickOpen;
class EditorResourcePreview;
class EditorResourceConversionPlugin;
class EditorRunBar;
Expand All @@ -90,6 +89,7 @@ class EditorSelectionHistory;
class EditorSettingsDialog;
class EditorTitleBar;
class ExportTemplateManager;
class EditorQuickOpenDialog;
class FBXImporterManager;
class FileSystemDock;
class HistoryDock;
Expand Down Expand Up @@ -257,13 +257,13 @@ class EditorNode : public Node {
EditorSelectionHistory editor_history;

EditorCommandPalette *command_palette = nullptr;
EditorQuickOpenDialog *quick_open_dialog = nullptr;
EditorExport *editor_export = nullptr;
EditorLog *log = nullptr;
EditorNativeShaderSourceVisualizer *native_shader_source_visualizer = nullptr;
EditorPluginList *editor_plugins_force_input_forwarding = nullptr;
EditorPluginList *editor_plugins_force_over = nullptr;
EditorPluginList *editor_plugins_over = nullptr;
EditorQuickOpen *quick_open = nullptr;
EditorResourcePreview *resource_preview = nullptr;
EditorSelection *editor_selection = nullptr;
EditorSettingsDialog *editor_settings_dialog = nullptr;
Expand Down Expand Up @@ -572,7 +572,7 @@ class EditorNode : public Node {
void _inherit_request(String p_file);
void _instantiate_request(const Vector<String> &p_files);

void _quick_opened();
void _quick_opened(const String &p_file_path);
void _open_command_palette();

void _project_run_started();
Expand Down Expand Up @@ -913,6 +913,8 @@ class EditorNode : public Node {
Dictionary drag_resource(const Ref<Resource> &p_res, Control *p_from);
Dictionary drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from);

EditorQuickOpenDialog *get_quick_open_dialog() { return quick_open_dialog; }

void add_tool_menu_item(const String &p_name, const Callable &p_callback);
void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
void remove_tool_menu_item(const String &p_name);
Expand Down
Loading

0 comments on commit c0f1b1d

Please sign in to comment.