ProjectTemplate.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2021, Nick Vella <nick@nxk.io>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. #include <AK/ByteString.h>
  9. #include <AK/LexicalPath.h>
  10. #include <AK/RefCounted.h>
  11. #include <AK/Weakable.h>
  12. #include <LibGUI/Icon.h>
  13. namespace HackStudio {
  14. class ProjectTemplate : public RefCounted<ProjectTemplate> {
  15. public:
  16. static ByteString templates_path() { return "/res/devel/templates"; }
  17. static RefPtr<ProjectTemplate> load_from_manifest(ByteString const& manifest_path);
  18. explicit ProjectTemplate(ByteString const& id, ByteString const& name, ByteString const& description, const GUI::Icon& icon, int priority);
  19. ErrorOr<void> create_project(ByteString const& name, ByteString const& path);
  20. ByteString const& id() const { return m_id; }
  21. ByteString const& name() const { return m_name; }
  22. ByteString const& description() const { return m_description; }
  23. const GUI::Icon& icon() const { return m_icon; }
  24. ByteString const content_path() const
  25. {
  26. return LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", templates_path(), m_id));
  27. }
  28. int priority() const { return m_priority; }
  29. private:
  30. ByteString m_id;
  31. ByteString m_name;
  32. ByteString m_description;
  33. GUI::Icon m_icon;
  34. int m_priority { 0 };
  35. };
  36. }