1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 18:35:18 +00:00
serenity/Userland/DevTools/GMLPlayground/MainWidget.h
Sam Atkins ca3e0288e9 GMLPlayground: Keep a RefPtr to the "Save As..." action
Previously, the Save action held a reference to the local variable for
the Save As action, which goes out of scope at the end of
`initialize_menubar()`. This meant that if you tried to Save a new
file, it would instead crash and yeet your work into the abyss.
2023-07-19 19:36:17 +01:00

55 lines
1.7 KiB
C++

/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Julius Heijmen <julius.heijmen@gmail.com>
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2023, Karol Kosek <krkk@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibFileSystemAccessClient/Client.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
class MainWidget final : public GUI::Widget {
C_OBJECT_ABSTRACT(MainWidget)
public:
static ErrorOr<NonnullRefPtr<MainWidget>> try_create(GUI::Icon const&);
ErrorOr<void> initialize_menubar(GUI::Window&);
GUI::Window::CloseRequestDecision request_close();
void load_file(FileSystemAccessClient::File);
void update_title();
GUI::TextEditor& editor() const { return *m_editor; }
private:
MainWidget();
virtual void drag_enter_event(GUI::DragEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
RefPtr<GUI::Action> m_save_action;
RefPtr<GUI::Action> m_save_as_action;
RefPtr<GUI::TextEditor> m_editor;
RefPtr<GUI::Toolbar> m_toolbar;
RefPtr<GUI::Splitter> m_splitter;
RefPtr<GUI::Statusbar> m_statusbar;
RefPtr<GUI::Frame> m_preview_frame_widget;
RefPtr<GUI::Window> m_preview_window;
RefPtr<GUI::Widget> m_preview_window_widget;
GUI::Widget* m_preview;
GUI::ActionGroup m_views_group;
RefPtr<GUI::Action> m_view_frame_action;
RefPtr<GUI::Action> m_view_window_action;
GUI::Icon m_icon;
DeprecatedString m_file_path;
};