diff options
author | Nick Vella <nick@nxk.io> | 2021-02-13 21:22:48 +1100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-13 19:49:30 +0100 |
commit | b6715772234e3e55235b21fff05487e29727bfe8 (patch) | |
tree | 39a93db4d872f1de1c04985b11f78009fc02d3cd /Userland/DevTools/HackStudio/HackStudioWidget.cpp | |
parent | a6fdc17f3f0add00fd15a1223415e8dd04ceb6f8 (diff) | |
download | serenity-b6715772234e3e55235b21fff05487e29727bfe8.zip |
HackStudio: Project templates and New Project dialog
This commit adds a simple project template system to HackStudio,
as well as a pretty New Project dialog, inspired by early VS.NET
and MS Office.
Diffstat (limited to 'Userland/DevTools/HackStudio/HackStudioWidget.cpp')
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 06c62c4510..e492cc3647 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -31,6 +31,7 @@ #include "Debugger/DebugInfoWidget.h" #include "Debugger/Debugger.h" #include "Debugger/DisassemblyWidget.h" +#include "Dialogs/NewProjectDialog.h" #include "Editor.h" #include "EditorWrapper.h" #include "FindInFilesWidget.h" @@ -57,6 +58,7 @@ #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> +#include <LibGUI/Dialog.h> #include <LibGUI/EditingEngine.h> #include <LibGUI/FilePicker.h> #include <LibGUI/InputBox.h> @@ -130,6 +132,7 @@ HackStudioWidget::HackStudioWidget(const String& path_to_project) m_remove_current_editor_action = create_remove_current_editor_action(); m_open_action = create_open_action(); m_save_action = create_save_action(); + m_new_project_action = create_new_project_action(); create_action_tab(*m_right_hand_splitter); @@ -383,6 +386,18 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action() return delete_action; } +NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action() +{ + return GUI::Action::create("Create new project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GUI::Action&) { + auto dialog = NewProjectDialog::construct(window()); + dialog->set_icon(window()->icon()); + auto result = dialog->exec(); + + if (result == GUI::Dialog::ExecResult::ExecOK && dialog->created_project_path().has_value()) + open_project(dialog->created_project_path().value()); + }); +} + void HackStudioWidget::add_new_editor(GUI::Widget& parent) { auto wrapper = EditorWrapper::construct(); @@ -849,6 +864,7 @@ void HackStudioWidget::create_action_tab(GUI::Widget& parent) void HackStudioWidget::create_app_menubar(GUI::MenuBar& menubar) { auto& app_menu = menubar.add_menu("Hack Studio"); + app_menu.add_action(*m_new_project_action); app_menu.add_action(*m_open_action); app_menu.add_action(*m_save_action); app_menu.add_separator(); |