obs-app.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <QApplication>
  16. #include <util/util.hpp>
  17. #include <string>
  18. #include <memory>
  19. #include "window-main.hpp"
  20. class OBSApp : public QApplication {
  21. Q_OBJECT
  22. private:
  23. std::string locale;
  24. ConfigFile globalConfig;
  25. TextLookup textLookup;
  26. std::unique_ptr<OBSMainWindow> mainWindow;
  27. bool InitGlobalConfig();
  28. bool InitGlobalConfigDefaults();
  29. bool InitConfigDefaults();
  30. bool InitLocale();
  31. void GetFPSCommon(uint32_t &num, uint32_t &den) const;
  32. void GetFPSInteger(uint32_t &num, uint32_t &den) const;
  33. void GetFPSFraction(uint32_t &num, uint32_t &den) const;
  34. void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const;
  35. public:
  36. OBSApp(int &argc, char **argv);
  37. void OBSInit();
  38. inline QMainWindow *GetMainWindow() const {return mainWindow.get();}
  39. inline config_t GlobalConfig() const {return globalConfig;}
  40. inline const char *GetLocale() const
  41. {
  42. return locale.c_str();
  43. }
  44. inline const char *GetString(const char *lookupVal) const
  45. {
  46. return textLookup.GetString(lookupVal);
  47. }
  48. void GetConfigFPS(uint32_t &num, uint32_t &den) const;
  49. const char *GetRenderModule() const;
  50. };
  51. inline OBSApp *App() {return static_cast<OBSApp*>(qApp);}
  52. inline config_t GetGlobalConfig() {return App()->GlobalConfig();}
  53. inline const char *Str(const char *lookup) {return App()->GetString(lookup);}
  54. #define QTStr(lookupVal) QString::fromUtf8(Str(lookupVal))