Conditionally compile the license activation code when the ENABLE_DRM flag is defined

This commit is contained in:
Martín Capello 2021-08-27 17:48:51 -03:00 committed by David Capello
parent 122769c836
commit 588d8027f4
2 changed files with 25 additions and 0 deletions

View File

@ -177,6 +177,13 @@ Export Warning
<<{0}
||&Yes||&No
END
enter_license_disabled = <<<END
Information
<<This copy of Aseprite does not support entering a license key.
<<Consider getting one from https://aseprite.org/download.
<<Activating Aseprite will give you access to automatic updates.
||&OK
END
[brush_slot_params]
brush = Brush:

View File

@ -7,6 +7,14 @@
#include "app/app.h"
#include "app/commands/command.h"
#include "app/context.h"
#include "ver/info.h"
#ifdef ENABLE_DRM
#include "drm/license_manager.h"
#else
#include "app/i18n/strings.h"
#include "ui/alert.h"
#endif
#include "enter_license.xml.h"
@ -26,16 +34,26 @@ EnterLicenseCommand::EnterLicenseCommand()
void EnterLicenseCommand::onExecute(Context* context)
{
#ifdef ENABLE_DRM
// Load the window widget
app::gen::EnterLicense window;
window.setSizeable(false);
window.licenseKey()->Change.connect([&window]() {
window.licenseKey()->setText(base::string_to_upper(window.licenseKey()->text()));
window.okButton()->setEnabled(window.licenseKey()->text().size() > 0);
});
window.okButton()->setEnabled(false);
window.okButton()->Click.connect([&window](ui::Event&) {
drm::LicenseManager::instance()->activate(window.licenseKey()->text(), get_app_name(), get_app_version());
window.closeWindow(nullptr);
});
// Open the window
window.openWindowInForeground();
#else
ui::Alert::show(Strings::alerts_enter_license_disabled());
#endif
}
Command* CommandFactory::createRegisterCommand()