mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
ThemeEditor: Open the FilePicker at the location in the path input
The kernel panic no longer occurs, so we can do this now. :^)
This commit is contained in:
parent
e05d5df6aa
commit
91230ff28d
1 changed files with 8 additions and 2 deletions
|
@ -256,11 +256,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
path_input.set_text(startup_preview_palette.path(Gfx::PathRole::TitleButtonIcons));
|
path_input.set_text(startup_preview_palette.path(Gfx::PathRole::TitleButtonIcons));
|
||||||
|
|
||||||
path_picker_button.on_click = [&](auto) {
|
path_picker_button.on_click = [&](auto) {
|
||||||
// FIXME: Open at the path_input location. Right now that's panicking the kernel though! :^(
|
|
||||||
auto role = path_combo_box.model()->index(path_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_path_role();
|
auto role = path_combo_box.model()->index(path_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_path_role();
|
||||||
bool open_folder = (role == Gfx::PathRole::TitleButtonIcons);
|
bool open_folder = (role == Gfx::PathRole::TitleButtonIcons);
|
||||||
auto window_title = String::formatted(open_folder ? "Select {} folder" : "Select {} file", path_combo_box.text());
|
auto window_title = String::formatted(open_folder ? "Select {} folder" : "Select {} file", path_combo_box.text());
|
||||||
auto result = GUI::FilePicker::get_open_filepath(window, window_title, "/res/icons", open_folder);
|
auto target_path = path_input.text();
|
||||||
|
if (Core::File::exists(target_path)) {
|
||||||
|
if (!Core::File::is_directory(target_path))
|
||||||
|
target_path = LexicalPath::dirname(target_path);
|
||||||
|
} else {
|
||||||
|
target_path = "/res/icons";
|
||||||
|
}
|
||||||
|
auto result = GUI::FilePicker::get_open_filepath(window, window_title, target_path, open_folder);
|
||||||
if (!result.has_value())
|
if (!result.has_value())
|
||||||
return;
|
return;
|
||||||
path_input.set_text(*result);
|
path_input.set_text(*result);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue