The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
4.3KB

  1. #include "../JuceLibraryCode/JuceHeader.h"
  2. #include "GoogleAnalyticsDestination.h"
  3. #include "MainComponent.h"
  4. //==============================================================================
  5. class AnalyticsCollectionApplication : public JUCEApplication
  6. {
  7. public:
  8. //==============================================================================
  9. AnalyticsCollectionApplication() {}
  10. const String getApplicationName() override { return ProjectInfo::projectName; }
  11. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  12. bool moreThanOneInstanceAllowed() override { return true; }
  13. //==============================================================================
  14. void initialise (const String&) override
  15. {
  16. // Add an analytics identifier for the user. Make sure you don't collect
  17. // identifiable information accidentally if you haven't asked for permission!
  18. Analytics::getInstance()->setUserId ("AnonUser1234");
  19. // Add any other constant user information.
  20. StringPairArray userData;
  21. userData.set ("group", "beta");
  22. Analytics::getInstance()->setUserProperties (userData);
  23. // Add any analytics destinations we want to use to the Analytics singleton.
  24. Analytics::getInstance()->addDestination (new GoogleAnalyticsDestination());
  25. Analytics::getInstance()->logEvent ("startup", {});
  26. mainWindow = new MainWindow (getApplicationName());
  27. }
  28. void shutdown() override
  29. {
  30. Analytics::getInstance()->logEvent ("shutdown", {});
  31. // Add your application's shutdown code here..
  32. mainWindow = nullptr; // (deletes our window)
  33. }
  34. //==============================================================================
  35. void systemRequestedQuit() override
  36. {
  37. // This is called when the app is being asked to quit: you can ignore this
  38. // request and let the app carry on running, or call quit() to allow the app to close.
  39. quit();
  40. }
  41. void anotherInstanceStarted (const String&) override
  42. {
  43. // When another instance of the app is launched while this one is running,
  44. // this method is invoked, and the commandLine parameter tells you what
  45. // the other instance's command-line arguments were.
  46. }
  47. //==============================================================================
  48. /*
  49. This class implements the desktop window that contains an instance of
  50. our MainContentComponent class.
  51. */
  52. class MainWindow : public DocumentWindow
  53. {
  54. public:
  55. MainWindow (String name) : DocumentWindow (name,
  56. Desktop::getInstance().getDefaultLookAndFeel()
  57. .findColour (ResizableWindow::backgroundColourId),
  58. DocumentWindow::allButtons)
  59. {
  60. setUsingNativeTitleBar (true);
  61. setContentOwned (new MainContentComponent(), true);
  62. centreWithSize (getWidth(), getHeight());
  63. setVisible (true);
  64. }
  65. void closeButtonPressed() override
  66. {
  67. // This is called when the user tries to close this window. Here, we'll just
  68. // ask the app to quit when this happens, but you can change this to do
  69. // whatever you need.
  70. JUCEApplication::getInstance()->systemRequestedQuit();
  71. }
  72. /* Note: Be careful if you override any DocumentWindow methods - the base
  73. class uses a lot of them, so by overriding you might break its functionality.
  74. It's best to do all your work in your content component instead, but if
  75. you really have to override any DocumentWindow methods, make sure your
  76. subclass also calls the superclass's method.
  77. */
  78. private:
  79. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  80. };
  81. private:
  82. ScopedPointer<MainWindow> mainWindow;
  83. };
  84. //==============================================================================
  85. // This macro generates the main() routine that launches the app.
  86. START_JUCE_APPLICATION (AnalyticsCollectionApplication)