diff --git a/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h index fbb41d02f6..df2db4a5dd 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h @@ -28,15 +28,10 @@ //============================================================================== -class AboutWindowComponent : public Component, - private Button::Listener +class AboutWindowComponent : public Component { public: AboutWindowComponent() - : titleLabel ("title", "PROJUCER"), - versionLabel ("version"), - copyrightLabel ("copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.")), - aboutButton ("About Us", URL ("https://juce.com")) { bool showPurchaseButton = false; @@ -67,8 +62,13 @@ public: if (showPurchaseButton) { - addAndMakeVisible (licenseButton = new TextButton ("Purchase License")); - licenseButton->addListener (this); + addAndMakeVisible (licenseButton); + + licenseButton.onClick = [] + { + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) + controller->chooseNewLicense(); + }; } } @@ -105,8 +105,8 @@ public: centreSlice.removeFromTop (10); - if (licenseButton != nullptr) - licenseButton->setBounds (centreSlice.removeFromTop (25).reduced (25, 0)); + if (licenseButton.isShowing()) + licenseButton.setBounds (centreSlice.removeFromTop (25).reduced (25, 0)); aboutButton.setBounds (centreSlice.removeFromBottom (20)); } @@ -123,12 +123,14 @@ public: } private: - Label titleLabel, versionLabel, copyrightLabel; - HyperlinkButton aboutButton; - ScopedPointer licenseButton; + Label titleLabel { "title", "PROJUCER" }, + versionLabel { "version" }, + copyrightLabel { "copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.") }; + + HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") }; + TextButton licenseButton { "Purchase License" }; - Rectangle huckleberryLogoBounds; - Rectangle juceLogoBounds; + Rectangle huckleberryLogoBounds, juceLogoBounds; ScopedPointer juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize) }; @@ -136,14 +138,5 @@ private: ScopedPointer huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg, BinaryData::huckleberry_icon_svgSize) }; - void buttonClicked (Button* b) override - { - if (b == licenseButton.get()) - { - if (auto* controller = ProjucerApplication::getApp().licenseController.get()) - controller->chooseNewLicense(); - } - } - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent) }; diff --git a/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h index c1683574cb..8ce432a89d 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h @@ -28,8 +28,7 @@ //============================================================================== -class ApplicationUsageDataWindowComponent : public Component, - private Button::Listener +class ApplicationUsageDataWindowComponent : public Component { public: ApplicationUsageDataWindowComponent (bool showCheckbox) @@ -62,29 +61,32 @@ public: privacyPolicyLink.setURL (URL ("https://juce.com/privacy-policy")); addAndMakeVisible (okButton); - okButton.setButtonText ("OK"); - okButton.addListener (this); if (showCheckbox) { - addAndMakeVisible (shareApplicationUsageDataToggle = new ToggleButton()); + addAndMakeVisible (shareApplicationUsageDataToggle); auto* controller = ProjucerApplication::getApp().licenseController.get(); if (controller != nullptr && controller->getState().applicationUsageDataState == LicenseState::ApplicationUsageData::disabled) - shareApplicationUsageDataToggle->setToggleState (false, dontSendNotification); + shareApplicationUsageDataToggle.setToggleState (false, dontSendNotification); else - shareApplicationUsageDataToggle->setToggleState (true, dontSendNotification); + shareApplicationUsageDataToggle.setToggleState (true, dontSendNotification); - addAndMakeVisible(shareApplicationUsageDataLabel = new Label ({}, "Help JUCE to improve its software and services by sharing my application usage data")); - shareApplicationUsageDataLabel->setFont (Font (14.0f)); - shareApplicationUsageDataLabel->setMinimumHorizontalScale (1.0f); + addAndMakeVisible (shareApplicationUsageDataLabel); + shareApplicationUsageDataLabel.setFont (Font (14.0f)); + shareApplicationUsageDataLabel.setMinimumHorizontalScale (1.0f); } else { - addAndMakeVisible (upgradeLicenseButton = new TextButton ("Upgrade License")); - upgradeLicenseButton->addListener (this); - upgradeLicenseButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId)); + addAndMakeVisible (upgradeLicenseButton); + upgradeLicenseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId)); + + upgradeLicenseButton.onClick = [] + { + if (auto* controller = ProjucerApplication::getApp().licenseController.get()) + controller->chooseNewLicense(); + }; } } @@ -94,7 +96,7 @@ public: { auto newApplicationUsageDataState = LicenseState::ApplicationUsageData::enabled; - if (shareApplicationUsageDataToggle != nullptr && ! shareApplicationUsageDataToggle->getToggleState()) + if (shareApplicationUsageDataToggle.isShowing() && ! shareApplicationUsageDataToggle.getToggleState()) newApplicationUsageDataState = LicenseState::ApplicationUsageData::disabled; controller->setApplicationUsageDataState (newApplicationUsageDataState); @@ -113,13 +115,13 @@ public: juceEULALink.setBounds (linkBounds.removeFromLeft (linkBounds.getWidth() / 2).reduced (2)); privacyPolicyLink.setBounds (linkBounds.reduced (2)); - if (shareApplicationUsageDataToggle != nullptr) + if (shareApplicationUsageDataToggle.isShowing()) { bounds.removeFromTop (10); auto toggleBounds = bounds.removeFromTop (40); - shareApplicationUsageDataToggle->setBounds (toggleBounds.removeFromLeft (40).reduced (5)); - shareApplicationUsageDataLabel->setBounds (toggleBounds); + shareApplicationUsageDataToggle.setBounds (toggleBounds.removeFromLeft (40).reduced (5)); + shareApplicationUsageDataLabel.setBounds (toggleBounds); } bounds.removeFromTop (10); @@ -127,16 +129,17 @@ public: auto buttonW = 125; auto buttonH = 40; - if (upgradeLicenseButton != nullptr) + if (upgradeLicenseButton.isShowing()) { auto left = bounds.removeFromLeft (bounds.getWidth() / 2); - upgradeLicenseButton->setSize (buttonW, buttonH); - upgradeLicenseButton->setCentrePosition (left.getCentreX(), left.getCentreY()); + upgradeLicenseButton.setSize (buttonW, buttonH); + upgradeLicenseButton.setCentrePosition (left.getCentreX(), left.getCentreY()); } okButton.setSize (buttonW, buttonH); okButton.setCentrePosition (bounds.getCentreX(), bounds.getCentreY()); + okButton.onClick = [] { ProjucerApplication::getApp().dismissApplicationUsageDataAgreementPopup(); }; } void paint (Graphics& g) override @@ -147,28 +150,13 @@ public: private: Label headerLabel, bodyLabel; HyperlinkButton juceEULALink, privacyPolicyLink; - ScopedPointer