소스 검색

PasswordInputDialog: Port to GML compilation

Aryan Baburajan 1 년 전
부모
커밋
ddbed25bb5

+ 2 - 2
Userland/Libraries/LibGUI/CMakeLists.txt

@@ -6,7 +6,7 @@ stringify_gml(EmojiInputDialog.gml EmojiInputDialogGML.h emoji_input_dialog_gml)
 stringify_gml(FontPickerDialog.gml FontPickerDialogGML.h font_picker_dialog_gml)
 stringify_gml(FontPickerDialog.gml FontPickerDialogGML.h font_picker_dialog_gml)
 stringify_gml(FilePickerDialog.gml FilePickerDialogGML.h file_picker_dialog_gml)
 stringify_gml(FilePickerDialog.gml FilePickerDialogGML.h file_picker_dialog_gml)
 stringify_gml(IncrementalSearchBanner.gml IncrementalSearchBannerGML.h incremental_search_banner_gml)
 stringify_gml(IncrementalSearchBanner.gml IncrementalSearchBannerGML.h incremental_search_banner_gml)
-stringify_gml(PasswordInputDialog.gml PasswordInputDialogGML.h password_input_dialog_gml)
+compile_gml(PasswordInputDialog.gml PasswordInputDialogGML.cpp)
 
 
 set(SOURCES
 set(SOURCES
     AboutDialog.cpp
     AboutDialog.cpp
@@ -92,6 +92,7 @@ set(SOURCES
     OpacitySlider.cpp
     OpacitySlider.cpp
     Painter.cpp
     Painter.cpp
     PasswordInputDialog.cpp
     PasswordInputDialog.cpp
+    PasswordInputDialogGML.cpp
     PathBreadcrumbbar.cpp
     PathBreadcrumbbar.cpp
     PersistentModelIndex.cpp
     PersistentModelIndex.cpp
     Process.cpp
     Process.cpp
@@ -152,7 +153,6 @@ set(GENERATED_SOURCES
     FilePickerDialogGML.h
     FilePickerDialogGML.h
     FontPickerDialogGML.h
     FontPickerDialogGML.h
     IncrementalSearchBannerGML.h
     IncrementalSearchBannerGML.h
-    PasswordInputDialogGML.h
 )
 )
 
 
 serenity_lib(LibGUI gui)
 serenity_lib(LibGUI gui)

+ 3 - 3
Userland/Libraries/LibGUI/PasswordInputDialog.cpp

@@ -9,7 +9,7 @@
 #include <LibGUI/ImageWidget.h>
 #include <LibGUI/ImageWidget.h>
 #include <LibGUI/Label.h>
 #include <LibGUI/Label.h>
 #include <LibGUI/PasswordInputDialog.h>
 #include <LibGUI/PasswordInputDialog.h>
-#include <LibGUI/PasswordInputDialogGML.h>
+#include <LibGUI/PasswordInputDialogWidget.h>
 #include <LibGUI/TextBox.h>
 #include <LibGUI/TextBox.h>
 
 
 namespace GUI {
 namespace GUI {
@@ -23,8 +23,8 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, ByteString title
     resize(340, 122);
     resize(340, 122);
     set_title(move(title));
     set_title(move(title));
 
 
-    auto widget = set_main_widget<Widget>();
-    widget->load_from_gml(password_input_dialog_gml).release_value_but_fixme_should_propagate_errors();
+    auto widget = PasswordInputDialogWidget::try_create().release_value_but_fixme_should_propagate_errors();
+    set_main_widget(widget);
 
 
     auto& key_icon = *widget->find_descendant_of_type_named<GUI::ImageWidget>("key_icon");
     auto& key_icon = *widget->find_descendant_of_type_named<GUI::ImageWidget>("key_icon");
 
 

+ 1 - 1
Userland/Libraries/LibGUI/PasswordInputDialog.gml

@@ -1,4 +1,4 @@
-@GUI::Widget {
+@GUI::PasswordInputDialogWidget {
     fill_with_background_color: true
     fill_with_background_color: true
     layout: @GUI::HorizontalBoxLayout {
     layout: @GUI::HorizontalBoxLayout {
         margins: [8]
         margins: [8]

+ 2 - 0
Userland/Libraries/LibGUI/PasswordInputDialog.h

@@ -15,6 +15,8 @@ class PasswordInputDialog : public Dialog {
     C_OBJECT(PasswordInputDialog);
     C_OBJECT(PasswordInputDialog);
 
 
 public:
 public:
+    ErrorOr<NonnullRefPtr<GUI::Widget>> try_create();
+
     virtual ~PasswordInputDialog() override = default;
     virtual ~PasswordInputDialog() override = default;
 
 
     static ExecResult show(Window* parent_window, ByteString& text_value, ByteString title, ByteString server, ByteString username);
     static ExecResult show(Window* parent_window, ByteString& text_value, ByteString title, ByteString server, ByteString username);

+ 24 - 0
Userland/Libraries/LibGUI/PasswordInputDialogWidget.h

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2024, Aryan Baburajan <aryanbaburajan2007@gmail.com>.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibGUI/Frame.h>
+
+namespace GUI {
+
+class PasswordInputDialogWidget : public GUI::Widget {
+    C_OBJECT_ABSTRACT(PasswordInputDialogWidget)
+
+public:
+    static ErrorOr<NonnullRefPtr<PasswordInputDialogWidget>> try_create();
+    virtual ~PasswordInputDialogWidget() override = default;
+
+private:
+    PasswordInputDialogWidget() = default;
+};
+
+}