CmEditorPrefs.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "CmEditorPrerequisites.h"
  3. #include "CmModule.h"
  4. #include <QtCore/QString>
  5. #include "3rdParty/pugixml/pugixml.hpp"
  6. namespace CamelotEditor
  7. {
  8. enum WindowDockState
  9. {
  10. WDS_LEFT,
  11. WDS_RIGHT,
  12. WDS_TOP,
  13. WDS_BOTTOM,
  14. WDS_CENTER,
  15. WDS_FLOATING
  16. };
  17. struct WindowLayoutDesc
  18. {
  19. WindowLayoutDesc()
  20. :width(0), height(0), left(0), top(0),
  21. screenIdx(-1), maximized(true), dockState(WDS_FLOATING),
  22. dockParentId(-1), activeWidget(0), id(0)
  23. {
  24. }
  25. UINT32 activeWidget;
  26. Vector<QString>::type childWidgetNames;
  27. INT32 id;
  28. UINT32 width;
  29. UINT32 height;
  30. UINT32 left;
  31. UINT32 top;
  32. UINT32 screenIdx;
  33. bool maximized;
  34. WindowDockState dockState;
  35. INT32 dockParentId;
  36. };
  37. class EditorPrefs : public CamelotFramework::Module<EditorPrefs>
  38. {
  39. public:
  40. UINT32 getNumRecentlyUsedProjects() const;
  41. const QString& getRecentlyUsedProjectPath(UINT32 idx) const;
  42. void addRecentlyUsedProjectPath(const QString& path);
  43. void removeRecentlyUsedProjectPath(UINT32 idx);
  44. void setLastUsedProjectDirectory(const QString& value);
  45. const QString& getLastUsedProjectDirectory() const;
  46. void setMainWindowLayout(const WindowLayoutDesc& desc);
  47. const WindowLayoutDesc& getMainWindowLayout() const;
  48. void setWindowLayouts(const Vector<WindowLayoutDesc>::type& descs);
  49. const Vector<WindowLayoutDesc>::type& getWindowLayouts() const;
  50. void save(const QString& path, bool overwrite = true) const;
  51. void load(const QString& path);
  52. private:
  53. Vector<QString>::type mRecentlyUsedProjects;
  54. QString mLastUsedProjectDirectory;
  55. WindowLayoutDesc mMainWindowLayout;
  56. Vector<WindowLayoutDesc>::type mWindowLayouts;
  57. void saveWindowLayout(pugi::xml_node parentNode, const WindowLayoutDesc& desc) const;
  58. WindowLayoutDesc loadWindowLayout(pugi::xml_node node) const;
  59. void clear();
  60. };
  61. EditorPrefs& gEditorPrefs();
  62. }