1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
27th April 2017).
End User License Agreement: www.juce.com/juce-5-licence
Privacy Policy: www.juce.com/juce-5-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#pragma once
//==============================================================================
class ApplicationUsageDataWindowComponent : public Component
{
public:
ApplicationUsageDataWindowComponent (bool showCheckbox)
{
addAndMakeVisible (headerLabel);
headerLabel.setText ("Application Usage Analytics", dontSendNotification);
headerLabel.setFont (Font (20.0f, Font::FontStyleFlags::bold));
headerLabel.setJustificationType (Justification::centred);
auto textToShow = String ("We use analytics services to understand how developers use our software in order for JUCE to improve its software and services. ");
if (! showCheckbox)
textToShow += String (" Analytics can be disabled with an Indie or Pro license. ");
textToShow += String ("For more information, please read the JUCE EULA and Privacy policy:");
addAndMakeVisible (bodyLabel);
bodyLabel.setText (textToShow, dontSendNotification);
bodyLabel.setFont (Font (14.0f));
bodyLabel.setJustificationType (Justification::centredLeft);
addAndMakeVisible (juceEULALink);
juceEULALink.setButtonText ("JUCE EULA");
juceEULALink.setFont (Font (14.0f), false);
juceEULALink.setURL (URL ("https://juce.com/juce-5-license"));
addAndMakeVisible (privacyPolicyLink);
privacyPolicyLink.setButtonText ("Privacy Policy");
privacyPolicyLink.setFont (Font (14.0f), false);
privacyPolicyLink.setURL (URL ("https://juce.com/juce-5-privacy-policy"));
addAndMakeVisible (okButton);
if (showCheckbox)
{
shareApplicationUsageDataToggle.reset (new ToggleButton());
addAndMakeVisible (shareApplicationUsageDataToggle.get());
auto* controller = ProjucerApplication::getApp().licenseController.get();
if (controller != nullptr && controller->getState().applicationUsageDataState == LicenseState::ApplicationUsageData::enabled)
shareApplicationUsageDataToggle->setToggleState (true, dontSendNotification);
else
shareApplicationUsageDataToggle->setToggleState (false, dontSendNotification);
addAndMakeVisible (shareApplicationUsageDataLabel);
shareApplicationUsageDataLabel.setFont (Font (14.0f));
shareApplicationUsageDataLabel.setMinimumHorizontalScale (1.0f);
}
else
{
addAndMakeVisible (upgradeLicenseButton);
upgradeLicenseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
upgradeLicenseButton.onClick = []
{
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
controller->chooseNewLicense();
};
}
}
~ApplicationUsageDataWindowComponent()
{
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
{
auto newApplicationUsageDataState = LicenseState::ApplicationUsageData::enabled;
if (shareApplicationUsageDataToggle != nullptr && ! shareApplicationUsageDataToggle->getToggleState())
newApplicationUsageDataState = LicenseState::ApplicationUsageData::disabled;
controller->setApplicationUsageDataState (newApplicationUsageDataState);
}
}
void resized() override
{
auto bounds = getLocalBounds().reduced (20);
headerLabel.setBounds (bounds.removeFromTop (40));
bodyLabel.setBounds (bounds.removeFromTop (75));
bounds.removeFromTop (10);
auto linkBounds = bounds.removeFromTop (20);
juceEULALink.setBounds (linkBounds.removeFromLeft (linkBounds.getWidth() / 2).reduced (2));
privacyPolicyLink.setBounds (linkBounds.reduced (2));
if (shareApplicationUsageDataToggle != nullptr)
{
bounds.removeFromTop (10);
auto toggleBounds = bounds.removeFromTop (40);
shareApplicationUsageDataToggle->setBounds (toggleBounds.removeFromLeft (40).reduced (5));
shareApplicationUsageDataLabel.setBounds (toggleBounds);
}
bounds.removeFromTop (10);
auto buttonW = 125;
auto buttonH = 40;
if (upgradeLicenseButton.isShowing())
{
auto left = bounds.removeFromLeft (bounds.getWidth() / 2);
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
{
g.fillAll (findColour (backgroundColourId));
}
private:
Label headerLabel, bodyLabel;
HyperlinkButton juceEULALink, privacyPolicyLink;
Label shareApplicationUsageDataLabel { {}, "Help JUCE to improve its software and services by sharing my application usage data" };
std::unique_ptr<ToggleButton> shareApplicationUsageDataToggle;
TextButton okButton { "OK" }, upgradeLicenseButton { "Upgrade License" };
void lookAndFeelChanged() override
{
upgradeLicenseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationUsageDataWindowComponent)
};
|