settings.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include <QString>
  3. #include <QJsonDocument>
  4. ///
  5. /// @brief Provide util methods to work with SettingsManager class
  6. ///
  7. namespace settings {
  8. // all available settings sections
  9. enum type {
  10. BGEFFECT,
  11. FGEFFECT,
  12. BLACKBORDER,
  13. BOBLSERVER,
  14. COLOR,
  15. DEVICE,
  16. EFFECTS,
  17. NETFORWARD,
  18. SYSTEMCAPTURE,
  19. GENERAL,
  20. V4L2,
  21. AUDIO,
  22. JSONSERVER,
  23. LEDCONFIG,
  24. LEDS,
  25. LOGGER,
  26. SMOOTHING,
  27. WEBSERVER,
  28. INSTCAPTURE,
  29. NETWORK,
  30. FLATBUFSERVER,
  31. PROTOSERVER,
  32. INVALID
  33. };
  34. ///
  35. /// @brief Convert settings::type to string representation
  36. /// @param type The settings::type from enum
  37. /// @return The settings type as string
  38. ///
  39. inline QString typeToString(type type)
  40. {
  41. switch (type)
  42. {
  43. case BGEFFECT: return "backgroundEffect";
  44. case FGEFFECT: return "foregroundEffect";
  45. case BLACKBORDER: return "blackborderdetector";
  46. case BOBLSERVER: return "boblightServer";
  47. case COLOR: return "color";
  48. case DEVICE: return "device";
  49. case EFFECTS: return "effects";
  50. case NETFORWARD: return "forwarder";
  51. case SYSTEMCAPTURE: return "framegrabber";
  52. case GENERAL: return "general";
  53. case V4L2: return "grabberV4L2";
  54. case AUDIO: return "grabberAudio";
  55. case JSONSERVER: return "jsonServer";
  56. case LEDCONFIG: return "ledConfig";
  57. case LEDS: return "leds";
  58. case LOGGER: return "logger";
  59. case SMOOTHING: return "smoothing";
  60. case WEBSERVER: return "webConfig";
  61. case INSTCAPTURE: return "instCapture";
  62. case NETWORK: return "network";
  63. case FLATBUFSERVER: return "flatbufServer";
  64. case PROTOSERVER: return "protoServer";
  65. default: return "invalid";
  66. }
  67. }
  68. ///
  69. /// @brief Convert string to settings::type representation
  70. /// @param type The string to convert
  71. /// @return The settings type from enum
  72. ///
  73. inline type stringToType(const QString& type)
  74. {
  75. if (type == "backgroundEffect") return BGEFFECT;
  76. else if (type == "foregroundEffect") return FGEFFECT;
  77. else if (type == "blackborderdetector") return BLACKBORDER;
  78. else if (type == "boblightServer") return BOBLSERVER;
  79. else if (type == "color") return COLOR;
  80. else if (type == "device") return DEVICE;
  81. else if (type == "effects") return EFFECTS;
  82. else if (type == "forwarder") return NETFORWARD;
  83. else if (type == "framegrabber") return SYSTEMCAPTURE;
  84. else if (type == "general") return GENERAL;
  85. else if (type == "grabberV4L2") return V4L2;
  86. else if (type == "grabberAudio") return AUDIO;
  87. else if (type == "jsonServer") return JSONSERVER;
  88. else if (type == "ledConfig") return LEDCONFIG;
  89. else if (type == "leds") return LEDS;
  90. else if (type == "logger") return LOGGER;
  91. else if (type == "smoothing") return SMOOTHING;
  92. else if (type == "webConfig") return WEBSERVER;
  93. else if (type == "instCapture") return INSTCAPTURE;
  94. else if (type == "network") return NETWORK;
  95. else if (type == "flatbufServer") return FLATBUFSERVER;
  96. else if (type == "protoServer") return PROTOSERVER;
  97. else return INVALID;
  98. }
  99. }