obs-app.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 InitLocale();
  30. public:
  31. OBSApp(int &argc, char **argv);
  32. void OBSInit();
  33. inline QMainWindow *GetMainWindow() const {return mainWindow.get();}
  34. inline config_t GlobalConfig() const {return globalConfig;}
  35. inline const char *GetLocale() const
  36. {
  37. return locale.c_str();
  38. }
  39. inline const char *GetString(const char *lookupVal) const
  40. {
  41. return textLookup.GetString(lookupVal);
  42. }
  43. const char *InputAudioSource() const;
  44. const char *OutputAudioSource() const;
  45. const char *GetRenderModule() const;
  46. };
  47. inline OBSApp *App() {return static_cast<OBSApp*>(qApp);}
  48. inline config_t GetGlobalConfig() {return App()->GlobalConfig();}
  49. inline const char *Str(const char *lookup) {return App()->GetString(lookup);}
  50. #define QTStr(lookupVal) QString::fromUtf8(Str(lookupVal))