ProjectTemplate.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/LexicalPath.h>
  9. #include <AK/RefCounted.h>
  10. #include <AK/Result.h>
  11. #include <AK/String.h>
  12. #include <AK/Weakable.h>
  13. #include <LibGUI/Icon.h>
  14. namespace HackStudio {
  15. class ProjectTemplate : public RefCounted<ProjectTemplate> {
  16. public:
  17. static String templates_path() { return "/res/devel/templates"; }
  18. static RefPtr<ProjectTemplate> load_from_manifest(const String& manifest_path);
  19. explicit ProjectTemplate(const String& id, const String& name, const String& description, const GUI::Icon& icon, int priority);
  20. Result<void, String> create_project(const String& name, const String& path);
  21. const String& id() const { return m_id; }
  22. const String& name() const { return m_name; }
  23. const String& description() const { return m_description; }
  24. const GUI::Icon& icon() const { return m_icon; }
  25. const String content_path() const
  26. {
  27. return LexicalPath::canonicalized_path(String::formatted("{}/{}", templates_path(), m_id));
  28. }
  29. int priority() const { return m_priority; }
  30. private:
  31. String m_id;
  32. String m_name;
  33. String m_description;
  34. GUI::Icon m_icon;
  35. int m_priority { 0 };
  36. };
  37. }