Browse Source

Projucer: fixed an edge-case where the UI would misbehave if you're logged in but don't have a live-coding license

tags/2021-05-28
jules 9 years ago
parent
commit
81ff3a89b7
6 changed files with 71 additions and 41 deletions
  1. +8
    -8
      extras/Projucer/Source/Application/jucer_Application.cpp
  2. +4
    -4
      extras/Projucer/Source/Application/jucer_LoginForm.h
  3. +1
    -1
      extras/Projucer/Source/Application/jucer_Main.cpp
  4. +25
    -8
      extras/Projucer/Source/Application/jucer_ProjucerLicenses.h
  5. +30
    -18
      extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp
  6. +3
    -2
      extras/Projucer/Source/Project/jucer_ProjectContentComponent.h

+ 8
- 8
extras/Projucer/Source/Application/jucer_Application.cpp View File

@@ -511,11 +511,11 @@ void ProjucerApplication::getCommandInfo (CommandID commandID, ApplicationComman
break;
case CommandIDs::loginLogout:
result.setInfo (ProjucerLicences::getInstance()->isLoggedIn()
? String ("Sign out ") + ProjucerLicences::getInstance()->getLoginName()
result.setInfo (ProjucerLicenses::getInstance()->isLoggedIn()
? String ("Sign out ") + ProjucerLicenses::getInstance()->getLoginName()
: String ("Sign in..."),
"Log out of your JUCE account", CommandCategories::general, 0);
result.setActive (ProjucerLicences::getInstance()->isDLLPresent());
result.setActive (ProjucerLicenses::getInstance()->isDLLPresent());
break;
default:
@@ -711,7 +711,7 @@ void ProjucerApplication::hideLoginForm()
void ProjucerApplication::showLoginForm()
{
if (ProjucerLicences::getInstance()->isDLLPresent())
if (ProjucerLicenses::getInstance()->isDLLPresent())
{
jassert (MessageManager::getInstance()->isThisTheMessageThread());
@@ -739,7 +739,7 @@ void ProjucerApplication::showLoginForm()
void ProjucerApplication::showLoginFormAsyncIfNotTriedRecently()
{
if (ProjucerLicences::getInstance()->isDLLPresent())
if (ProjucerLicenses::getInstance()->isDLLPresent())
{
Time lastLoginAttempt (getGlobalProperties().getValue ("lastLoginAttemptTime").getIntValue() * (int64) 1000);
@@ -756,7 +756,7 @@ void ProjucerApplication::timerCallback()
{
stopTimer();
if (! ProjucerLicences::getInstance()->isLoggedIn())
if (! ProjucerLicenses::getInstance()->isLoggedIn())
showLoginForm();
}
@@ -770,7 +770,7 @@ void ProjucerApplication::updateAllBuildTabs()
//==============================================================================
void ProjucerApplication::loginOrLogout()
{
ProjucerLicences& status = *ProjucerLicences::getInstance();
ProjucerLicenses& status = *ProjucerLicenses::getInstance();
if (status.isLoggedIn())
status.logout();
@@ -783,7 +783,7 @@ void ProjucerApplication::loginOrLogout()
bool ProjucerApplication::checkEULA()
{
if (currentEULAHasBeenAcceptedPreviously()
|| ! ProjucerLicences::getInstance()->isDLLPresent())
|| ! ProjucerLicenses::getInstance()->isDLLPresent())
return true;
ScopedPointer<AlertWindow> eulaDialogue (new EULADialogue());


+ 4
- 4
extras/Projucer/Source/Application/jucer_LoginForm.h View File

@@ -27,9 +27,9 @@
class LoginForm : public Component,
public ButtonListener,
private ButtonListener,
private TextEditor::Listener,
private ProjucerLicences::LoginCallback
private ProjucerLicenses::LoginCallback
{
public:
LoginForm()
@@ -56,7 +56,7 @@ public:
initialiseTextField (userIDEditor, userIDLabel);
addAndMakeVisible (userIDEditor);
String userName = ProjucerLicences::getInstance()->getLoginName();
String userName = ProjucerLicenses::getInstance()->getLoginName();
userIDEditor.setText (userName.isEmpty() ? getLastUserName() : userName);
initialiseLabel (errorLabel, Font::plain, ProjucerDialogLookAndFeel::getErrorTextColour());
@@ -223,7 +223,7 @@ private:
errorLabel.setVisible (false);
spinner.setVisible (true);
ProjucerLicences::getInstance()->login (loginName, password, rememberLogin, this);
ProjucerLicenses::getInstance()->login (loginName, password, rememberLogin, this);
}
void registerButtonClicked()


+ 1
- 1
extras/Projucer/Source/Application/jucer_Main.cpp View File

@@ -48,7 +48,7 @@
#include "../LiveBuildEngine/projucer_CompileEngineServer.h"
#include "jucer_ProjucerLicenses.h"
juce_ImplementSingleton (ProjucerLicences);
juce_ImplementSingleton (ProjucerLicenses);
struct ProjucerAppClasses
{


+ 25
- 8
extras/Projucer/Source/Application/jucer_ProjucerLicenses.h View File

@@ -1,23 +1,40 @@
/*
==============================================================================
Copyright 2015 by Raw Material Software Ltd.
==============================================================================
*/
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2015 - ROLI Ltd.
Permission is granted to use this software under the terms of either:
a) the GPL v2 (or any later version)
b) the Affero GPL v3
Details of these licenses can be found at: www.gnu.org/licenses
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.juce.com for more information.
==============================================================================
*/
#ifndef PROJUCER_PROJUCERLICENSES_H_INCLUDED
#define PROJUCER_PROJUCERLICENSES_H_INCLUDED
//==============================================================================
struct ProjucerLicences : private DeletedAtShutdown
struct ProjucerLicenses : private DeletedAtShutdown
{
ProjucerLicences()
ProjucerLicenses()
{
dll.initialise (crashCallback, quitCallback, false);
}
juce_DeclareSingleton (ProjucerLicences, false);
juce_DeclareSingleton (ProjucerLicenses, false);
//==============================================================================
struct LoginCallback
@@ -103,7 +120,7 @@ private:
static void staticCallbackFunction (void* userInfo, const char* errorMessage, const char* username, const char* apiKey)
{
static_cast<ProjucerLicences*> (userInfo)->callbackFunction (errorMessage, username, apiKey);
static_cast<ProjucerLicenses*> (userInfo)->callbackFunction (errorMessage, username, apiKey);
}
static void crashCallback (const char*) {}


+ 30
- 18
extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp View File

@@ -354,9 +354,9 @@ struct BuildTabComponent : public ConcertinaPanel
struct ProjucerDisabledComp : public Component,
private Button::Listener
{
ProjucerDisabledComp (String message, bool canLogin, bool requirePurchase = false,
ProjucerDisabledComp (String message, bool loggedIn, bool canLogin, bool requirePurchase = false,
const String& loginName = String())
: isPurchaseButton (requirePurchase)
: isLoggedIn (loggedIn), isPurchaseButton (requirePurchase)
{
infoLabel.setColour (Label::textColourId, findColour (mainBackgroundColourId).contrasting (0.7f));
infoLabel.setJustificationType (Justification::centred);
@@ -404,7 +404,7 @@ struct ProjucerDisabledComp : public Component,
}
else if (btn == signOutButton.get())
{
ProjucerLicences::getInstance()->logout();
ProjucerLicenses::getInstance()->logout();
ProjucerApplication::getApp().updateAllBuildTabs();
}
}
@@ -412,7 +412,7 @@ struct ProjucerDisabledComp : public Component,
Label infoLabel { "info", String() };
TextButton loginButton { "Log-in..." };
ScopedPointer<TextButton> signOutButton;
bool isPurchaseButton;
bool isLoggedIn, isPurchaseButton;
};
struct EnableBuildComp : public Component
@@ -449,11 +449,11 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c
#if JUCE_WINDOWS
ignoreUnused (child);
return new ProjucerDisabledComp ("Windows support is still under development - "
"please check for updates at www.juce.com!", false);
"please check for updates at www.juce.com!", false, false);
#elif JUCE_LINUX
ignoreUnused (child);
return new ProjucerDisabledComp ("Linux support is still under development - "
"please check for updates at www.juce.com!", false);
"please check for updates at www.juce.com!", false, false);
#else
if (child != nullptr)
{
@@ -462,7 +462,7 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c
return new BuildTabComponent (child, new ProjucerAppClasses::ErrorListComp (child->errorList));
}
auto& unlockStatus = *ProjucerLicences::getInstance();
auto& unlockStatus = *ProjucerLicenses::getInstance();
if (unlockStatus.hasLiveCodingLicence()
&& project != nullptr
@@ -474,7 +474,7 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c
+ newLine
+ "Your account " + unlockStatus.getLoginName().quoted()
+ " does not have an asscociated JUCE Pro license:",
true, true, unlockStatus.getLoginName());
true, true, true, unlockStatus.getLoginName());
if (! unlockStatus.isDLLPresent())
return new ProjucerDisabledComp (String ("The live-building DLL is missing!") + newLine
@@ -482,10 +482,12 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c
+ "To enable the compiler, you'll need to install the missing DLL "
+ CompileEngineDLL::getDLLName().quoted() + newLine
+ newLine
+ "Visit the JUCE website/forum for more help on getting and installing the DLL!", false);
+ "Visit the JUCE website/forum for more help on getting and installing the DLL!",
false, false);
return new ProjucerDisabledComp ("The Projucer's live-build features are currently disabled!\n\n"
"To enable them, you'll need to log-in with your JUCE account details:", true, false);
"To enable them, you'll need to log-in with your JUCE account details:",
false, true, false);
#endif
}
@@ -494,14 +496,24 @@ BuildTabComponent* findBuildTab (const TabbedComponent& tabs)
return dynamic_cast<BuildTabComponent*> (tabs.getTabContentComponent (2));
}
bool ProjectContentComponent::isBuildTabShowing() const
bool ProjectContentComponent::isBuildTabEnabled() const
{
return findBuildTab (treeViewTabs) != nullptr;
}
bool ProjectContentComponent::isLoggedInTabShowing() const
bool ProjectContentComponent::isBuildTabSuitableForLoggedInUser() const
{
return isBuildTabShowing() || dynamic_cast<EnableBuildComp*> (treeViewTabs.getTabContentComponent (2)) != nullptr;
return isBuildTabEnabled()
|| isBuildTabLoggedInWithoutLicense()
|| dynamic_cast<EnableBuildComp*> (treeViewTabs.getTabContentComponent (2)) != nullptr;
}
bool ProjectContentComponent::isBuildTabLoggedInWithoutLicense() const
{
if (auto* c = dynamic_cast<ProjucerDisabledComp*> (treeViewTabs.getTabContentComponent (2)))
return c->isLoggedIn;
return false;
}
void ProjectContentComponent::createProjectTabs()
@@ -1355,16 +1367,16 @@ bool ProjectContentComponent::isBuildEnabled() const
{
return project != nullptr
&& ! LiveBuildProjectSettings::isBuildDisabled (*project)
&& ProjucerLicences::getInstance()->hasLiveCodingLicence()
&& ProjucerLicences::getInstance()->isLoggedIn();
&& ProjucerLicenses::getInstance()->hasLiveCodingLicence()
&& ProjucerLicenses::getInstance()->isLoggedIn();
}
void ProjectContentComponent::refreshTabsIfBuildStatusChanged()
{
if (project != nullptr
&& (treeViewTabs.getNumTabs() < 3
|| isBuildEnabled() != isBuildTabShowing()
|| ProjucerLicences::getInstance()->isLoggedIn() != isLoggedInTabShowing()))
|| isBuildEnabled() != isBuildTabEnabled()
|| ProjucerLicenses::getInstance()->isLoggedIn() != isBuildTabSuitableForLoggedInUser()))
rebuildProjectTabs();
}
@@ -1493,7 +1505,7 @@ void ProjectContentComponent::handleMissingSystemHeaders()
deleteProjectTabs();
createProjectTabs();
ProjucerDisabledComp* buildTab = new ProjucerDisabledComp (tabMessage, false);
ProjucerDisabledComp* buildTab = new ProjucerDisabledComp (tabMessage, false, false);
treeViewTabs.addTab ("Build", Colours::transparentBlack, buildTab, true);
showBuildTab();


+ 3
- 2
extras/Projucer/Source/Project/jucer_ProjectContentComponent.h View File

@@ -110,8 +110,7 @@ public:
void killChildProcess();
void cleanAll();
void handleMissingSystemHeaders();
bool isBuildTabShowing() const;
bool isLoggedInTabShowing() const;
bool isBuildTabEnabled() const;
void setBuildEnabled (bool);
bool isBuildEnabled() const;
bool areWarningsEnabled() const;
@@ -162,6 +161,8 @@ private:
void updateWarningState();
void launchApp();
void killApp();
bool isBuildTabSuitableForLoggedInUser() const;
bool isBuildTabLoggedInWithoutLicense() const;
ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();


Loading…
Cancel
Save