From 3ab05dbbb92f70f19f4ff14809d576220e0a9147 Mon Sep 17 00:00:00 2001 From: Aryan Baburajan Date: Sat, 30 Mar 2024 12:07:02 +0530 Subject: [PATCH] FilePickerDialog: Port to GML compilation --- Userland/Libraries/LibGUI/CMakeLists.txt | 4 ++-- Userland/Libraries/LibGUI/FilePicker.cpp | 6 ++--- .../Libraries/LibGUI/FilePickerDialog.gml | 3 +-- .../Libraries/LibGUI/FilePickerDialogWidget.h | 24 +++++++++++++++++++ 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 Userland/Libraries/LibGUI/FilePickerDialogWidget.h diff --git a/Userland/Libraries/LibGUI/CMakeLists.txt b/Userland/Libraries/LibGUI/CMakeLists.txt index 8c4fe1d157f..033925ea09b 100644 --- a/Userland/Libraries/LibGUI/CMakeLists.txt +++ b/Userland/Libraries/LibGUI/CMakeLists.txt @@ -4,7 +4,7 @@ compile_gml(AboutDialog.gml AboutDialogGML.cpp) stringify_gml(DatePickerDialog.gml DatePickerDialogGML.h date_picker_dialog_gml) stringify_gml(EmojiInputDialog.gml EmojiInputDialogGML.h emoji_input_dialog_gml) stringify_gml(FontPickerDialog.gml FontPickerDialogGML.h font_picker_dialog_gml) -stringify_gml(FilePickerDialog.gml FilePickerDialogGML.h file_picker_dialog_gml) +compile_gml(FilePickerDialog.gml FilePickerDialogGML.cpp) stringify_gml(IncrementalSearchBanner.gml IncrementalSearchBannerGML.h incremental_search_banner_gml) compile_gml(PasswordInputDialog.gml PasswordInputDialogGML.cpp) @@ -50,6 +50,7 @@ set(SOURCES Event.cpp FileIconProvider.cpp FilePicker.cpp + FilePickerDialogGML.cpp FileSystemModel.cpp FilteringProxyModel.cpp FontPicker.cpp @@ -150,7 +151,6 @@ set(GENERATED_SOURCES ../../Services/WindowServer/WindowServerEndpoint.h DatePickerDialogGML.h EmojiInputDialogGML.h - FilePickerDialogGML.h FontPickerDialogGML.h IncrementalSearchBannerGML.h ) diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index 13441156e9a..d6b37fab352 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -99,8 +99,8 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St } resize(560, 320); - auto widget = set_main_widget(); - widget->load_from_gml(file_picker_dialog_gml).release_value_but_fixme_should_propagate_errors(); + auto widget = GUI::FilePickerDialogWidget::try_create().release_value_but_fixme_should_propagate_errors(); + set_main_widget(widget); auto& toolbar = *widget->find_descendant_of_type_named("toolbar"); diff --git a/Userland/Libraries/LibGUI/FilePickerDialog.gml b/Userland/Libraries/LibGUI/FilePickerDialog.gml index 79760da794d..9c600e25798 100644 --- a/Userland/Libraries/LibGUI/FilePickerDialog.gml +++ b/Userland/Libraries/LibGUI/FilePickerDialog.gml @@ -1,4 +1,4 @@ -@GUI::Widget { +@GUI::FilePickerDialogWidget { fill_with_background_color: true layout: @GUI::HorizontalBoxLayout { margins: [4] @@ -83,7 +83,6 @@ @GUI::ComboBox { name: "allowed_file_type_filters_combo" - model_only: true } @GUI::DialogButton { diff --git a/Userland/Libraries/LibGUI/FilePickerDialogWidget.h b/Userland/Libraries/LibGUI/FilePickerDialogWidget.h new file mode 100644 index 00000000000..b9df009bd0b --- /dev/null +++ b/Userland/Libraries/LibGUI/FilePickerDialogWidget.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024, Aryan Baburajan . + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace GUI { + +class FilePickerDialogWidget : public GUI::Widget { + C_OBJECT_ABSTRACT(FilePickerDialogWidget) + +public: + static ErrorOr> try_create(); + virtual ~FilePickerDialogWidget() override = default; + +private: + FilePickerDialogWidget() = default; +}; + +}