Skip to content

Commit

Permalink
CrashReporter: Port CrashReporter to GML Compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
mrunix00 committed Dec 26, 2023
1 parent f2e4380 commit 99224b9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
7 changes: 2 additions & 5 deletions Userland/Applications/CrashReporter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ serenity_component(
TARGETS CrashReporter
)

stringify_gml(CrashReporterWindow.gml CrashReporterWindowGML.h crash_reporter_window_gml)
compile_gml(CrashReporterWindow.gml CrashReporterWindowGML.cpp)


set(SOURCES
CrashReporterWindowGML.cpp
main.cpp
)

set(GENERATED_SOURCES
CrashReporterWindowGML.h
)

serenity_app(CrashReporter ICON app-crash-reporter)
target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@GUI::Widget {
@CrashReporter::MainWidget {
fill_with_background_color: true
layout: @GUI::VerticalBoxLayout {
margins: [4]
Expand Down
24 changes: 24 additions & 0 deletions Userland/Applications/CrashReporter/MainWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <LibGUI/Widget.h>

namespace CrashReporter {

class MainWidget final : public GUI::Widget {
C_OBJECT(MainWidget)

public:
static ErrorOr<NonnullRefPtr<MainWidget>> try_create();
virtual ~MainWidget() override = default;

private:
MainWidget() = default;
};

}
8 changes: 5 additions & 3 deletions Userland/Applications/CrashReporter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "MainWidget.h"
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <AK/Types.h>
#include <AK/URL.h>
#include <Applications/CrashReporter/CrashReporterWindowGML.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibCoredump/Backtrace.h>
Expand Down Expand Up @@ -208,8 +208,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
unlink_coredump(coredump_path);
};

auto widget = window->set_main_widget<GUI::Widget>();
TRY(widget->load_from_gml(crash_reporter_window_gml));
// auto widget = window->set_main_widget<GUI::Widget>();
// TRY(widget->load_from_gml(crash_reporter_window_gml));
auto widget = TRY(CrashReporter::MainWidget::try_create());
window->set_main_widget(widget);

auto& icon_image_widget = *widget->find_descendant_of_type_named<GUI::ImageWidget>("icon");
icon_image_widget.set_bitmap(GUI::FileIconProvider::icon_for_executable(executable_path).bitmap_for_size(32));
Expand Down

0 comments on commit 99224b9

Please sign in to comment.