Browse Source

Projucer: Disable project saving when file modification warning is showing

tags/2021-05-28
ed 4 years ago
parent
commit
a3af3a5381
3 changed files with 30 additions and 13 deletions
  1. +14
    -5
      extras/Projucer/Source/Project/UI/jucer_HeaderComponent.cpp
  2. +13
    -7
      extras/Projucer/Source/Project/jucer_Project.cpp
  3. +3
    -1
      extras/Projucer/Source/Project/jucer_Project.h

+ 14
- 5
extras/Projucer/Source/Project/UI/jucer_HeaderComponent.cpp View File

@@ -277,13 +277,22 @@ void HeaderComponent::initialiseButtons()
{ {
if (project != nullptr) if (project != nullptr)
{ {
if (project->hasIncompatibleLicenseTypeAndSplashScreenSetting())
if (project->isSaveAndExportDisabled())
{ {
auto child = project->getProjectMessages().getChildWithName (ProjectMessages::Ids::warning)
.getChildWithName (ProjectMessages::Ids::incompatibleLicense);
auto setWarningVisible = [this] (const Identifier& identifier)
{
auto child = project->getProjectMessages().getChildWithName (ProjectMessages::Ids::warning)
.getChildWithName (identifier);
if (child.isValid())
child.setProperty (ProjectMessages::Ids::isVisible, true, nullptr);
};
if (project->hasIncompatibleLicenseTypeAndSplashScreenSetting())
setWarningVisible (ProjectMessages::Ids::incompatibleLicense);
if (child.isValid())
child.setProperty (ProjectMessages::Ids::isVisible, true, nullptr);
if (project->isFileModificationCheckPending())
setWarningVisible (ProjectMessages::Ids::jucerFileModified);
} }
else else
{ {


+ 13
- 7
extras/Projucer/Source/Project/jucer_Project.cpp View File

@@ -39,22 +39,22 @@ Project::ProjectFileModificationPoller::ProjectFileModificationPoller (Project&
void Project::ProjectFileModificationPoller::reset() void Project::ProjectFileModificationPoller::reset()
{ {
project.removeProjectMessage (ProjectMessages::Ids::jucerFileModified); project.removeProjectMessage (ProjectMessages::Ids::jucerFileModified);
showingWarning = false;
pending = false;
startTimer (250); startTimer (250);
} }
void Project::ProjectFileModificationPoller::timerCallback() void Project::ProjectFileModificationPoller::timerCallback()
{ {
if (project.updateCachedFileState() && ! showingWarning)
if (project.updateCachedFileState() && ! pending)
{ {
project.addProjectMessage (ProjectMessages::Ids::jucerFileModified, project.addProjectMessage (ProjectMessages::Ids::jucerFileModified,
{ { "Save current state", [this] { resaveProject(); } }, { { "Save current state", [this] { resaveProject(); } },
{ "Re-load from disk", [this] { reloadProjectFromDisk(); } },
{ "Ignore", [this] { reset(); } } });
{ "Re-load from disk", [this] { reloadProjectFromDisk(); } },
{ "Ignore", [this] { reset(); } } });
stopTimer(); stopTimer();
showingWarning = true;
pending = true;
} }
} }
@@ -79,8 +79,8 @@ void Project::ProjectFileModificationPoller::reloadProjectFromDisk()
void Project::ProjectFileModificationPoller::resaveProject() void Project::ProjectFileModificationPoller::resaveProject()
{ {
project.saveProject();
reset(); reset();
project.saveProject();
} }
//============================================================================== //==============================================================================
@@ -745,9 +745,15 @@ bool Project::hasIncompatibleLicenseTypeAndSplashScreenSetting() const
&& ! ProjucerApplication::getApp().getLicenseController().getCurrentState().canUnlockFullFeatures(); && ! ProjucerApplication::getApp().getLicenseController().getCurrentState().canUnlockFullFeatures();
} }
bool Project::isFileModificationCheckPending() const
{
return fileModificationPoller.isCheckPending();
}
bool Project::isSaveAndExportDisabled() const bool Project::isSaveAndExportDisabled() const
{ {
return ! ProjucerApplication::getApp().isRunningCommandLine && hasIncompatibleLicenseTypeAndSplashScreenSetting();
return ! ProjucerApplication::getApp().isRunningCommandLine
&& (hasIncompatibleLicenseTypeAndSplashScreenSetting() || isFileModificationCheckPending());
} }
void Project::updateLicenseWarning() void Project::updateLicenseWarning()


+ 3
- 1
extras/Projucer/Source/Project/jucer_Project.h View File

@@ -501,6 +501,7 @@ public:
//============================================================================== //==============================================================================
bool hasIncompatibleLicenseTypeAndSplashScreenSetting() const; bool hasIncompatibleLicenseTypeAndSplashScreenSetting() const;
bool isFileModificationCheckPending() const;
bool isSaveAndExportDisabled() const; bool isSaveAndExportDisabled() const;
private: private:
@@ -514,6 +515,7 @@ private:
struct ProjectFileModificationPoller : private Timer struct ProjectFileModificationPoller : private Timer
{ {
ProjectFileModificationPoller (Project& p); ProjectFileModificationPoller (Project& p);
bool isCheckPending() const noexcept { return pending; }
private: private:
void timerCallback() override; void timerCallback() override;
@@ -523,7 +525,7 @@ private:
void reloadProjectFromDisk(); void reloadProjectFromDisk();
Project& project; Project& project;
bool showingWarning = false;
bool pending = false;
}; };
//============================================================================== //==============================================================================


Loading…
Cancel
Save