mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 11:42:47 +00:00
Create EnterLicense dialog
This commit is contained in:
parent
588d8027f4
commit
2639c36b2f
@ -1074,6 +1074,7 @@ default_new_layer_name = New Layer
|
|||||||
title = Enter License
|
title = Enter License
|
||||||
default_message = If you need a license key, go to
|
default_message = If you need a license key, go to
|
||||||
license_key = License Key
|
license_key = License Key
|
||||||
|
activating_message = Activating...
|
||||||
|
|
||||||
[tileset_selector]
|
[tileset_selector]
|
||||||
new_tileset = New Tileset
|
new_tileset = New Tileset
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!-- Aseprite -->
|
<!-- Aseprite -->
|
||||||
<!-- Copyright (c) 2021 Igara Studio S.A. -->
|
<!-- Copyright (c) 2021 Igara Studio S.A. -->
|
||||||
<gui>
|
<gui>
|
||||||
<window id="enter_license" text="@.title" expansive="false">
|
<window id="enter_license" text="@.title" expansive="true">
|
||||||
<box vertical="true">
|
<box vertical="true">
|
||||||
<hbox>
|
<hbox>
|
||||||
<label text="@.default_message" />
|
<label text="@.default_message" />
|
||||||
@ -9,6 +9,10 @@
|
|||||||
</hbox>
|
</hbox>
|
||||||
<separator text="@.license_key" left="true" horizontal="true" />
|
<separator text="@.license_key" left="true" horizontal="true" />
|
||||||
<entry id="license_key" cell_align="horizontal" magnet="true" maxsize="17" />
|
<entry id="license_key" cell_align="horizontal" magnet="true" maxsize="17" />
|
||||||
|
<hbox>
|
||||||
|
<image id="icon" icon="warning_box" visible="false" />
|
||||||
|
<label id="message" text="" expansive="true" minheight="40" />
|
||||||
|
</hbox>
|
||||||
<box horizontal="true">
|
<box horizontal="true">
|
||||||
<box horizontal="true" expansive="true" />
|
<box horizontal="true" expansive="true" />
|
||||||
<box horizontal="true" homogeneous="true">
|
<box horizontal="true" homogeneous="true">
|
||||||
|
@ -367,6 +367,7 @@ if(ENABLE_UI)
|
|||||||
ui/editor/state_with_wheel_behavior.cpp
|
ui/editor/state_with_wheel_behavior.cpp
|
||||||
ui/editor/transform_handles.cpp
|
ui/editor/transform_handles.cpp
|
||||||
ui/editor/zooming_state.cpp
|
ui/editor/zooming_state.cpp
|
||||||
|
ui/enter_license.cpp
|
||||||
ui/export_file_window.cpp
|
ui/export_file_window.cpp
|
||||||
ui/expr_entry.cpp
|
ui/expr_entry.cpp
|
||||||
ui/file_list.cpp
|
ui/file_list.cpp
|
||||||
|
@ -4,20 +4,16 @@
|
|||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
|
||||||
#include "app/app.h"
|
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/context.h"
|
#include "app/context.h"
|
||||||
#include "ver/info.h"
|
|
||||||
|
|
||||||
#ifdef ENABLE_DRM
|
#ifdef ENABLE_DRM
|
||||||
#include "drm/license_manager.h"
|
#include "app/ui/enter_license.h"
|
||||||
#else
|
#else
|
||||||
#include "app/i18n/strings.h"
|
#include "app/i18n/strings.h"
|
||||||
#include "ui/alert.h"
|
#include "ui/alert.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "enter_license.xml.h"
|
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class EnterLicenseCommand : public Command {
|
class EnterLicenseCommand : public Command {
|
||||||
@ -36,19 +32,7 @@ void EnterLicenseCommand::onExecute(Context* context)
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_DRM
|
#ifdef ENABLE_DRM
|
||||||
// Load the window widget
|
// Load the window widget
|
||||||
app::gen::EnterLicense window;
|
app::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
|
// Open the window
|
||||||
window.openWindowInForeground();
|
window.openWindowInForeground();
|
||||||
#else
|
#else
|
||||||
|
74
src/app/ui/enter_license.cpp
Normal file
74
src/app/ui/enter_license.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// Aseprite
|
||||||
|
// Copyright (C) 2021 Igara Studio S.A.
|
||||||
|
//
|
||||||
|
// This program is distributed under the terms of
|
||||||
|
// the End-User License Agreement for Aseprite.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "app/i18n/strings.h"
|
||||||
|
#include "enter_license.h"
|
||||||
|
#include "enter_license.xml.h"
|
||||||
|
#include "ui/message.h"
|
||||||
|
#include "ui/style.h"
|
||||||
|
#include "ui/system.h"
|
||||||
|
#include "ver/info.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
EnterLicense::EnterLicense() : m_timer(500, this), m_activationInProgress(false)
|
||||||
|
{
|
||||||
|
for (auto& layer : message()->style()->layers()) {
|
||||||
|
layer.setAlign(layer.align() | ui::WORDWRAP);
|
||||||
|
}
|
||||||
|
setSizeable(false);
|
||||||
|
licenseKey()->Change.connect([this]() {
|
||||||
|
licenseKey()->setText(base::string_to_upper(licenseKey()->text()));
|
||||||
|
okButton()->setEnabled(licenseKey()->text().size() > 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
okButton()->setEnabled(false);
|
||||||
|
okButton()->Click.connect([this](ui::Event&) {
|
||||||
|
icon()->setVisible(false);
|
||||||
|
message()->setText(app::Strings::instance()->enter_license_activating_message());
|
||||||
|
layout();
|
||||||
|
setEnabled(false);
|
||||||
|
std::string key = licenseKey()->text();
|
||||||
|
m_activationInProgress = true;
|
||||||
|
m_activation = std::thread([this, key]() {
|
||||||
|
drm::LicenseManager::instance()->activate(key, get_app_name(), get_app_version());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
m_activationFailedConn = drm::LicenseManager::instance()->ActivationFailed.connect(
|
||||||
|
[this](drm::LicenseManager::Exception& e) { onActivationFailed(e); });
|
||||||
|
Close.connect([this]() {
|
||||||
|
m_activationFailedConn.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
m_timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnterLicense::onBeforeClose(ui::CloseEvent& ev) {
|
||||||
|
if (m_activationInProgress) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnterLicense::onActivationFailed(drm::LicenseManager::Exception& e) {
|
||||||
|
ui::execute_from_ui_thread([this, e]() {
|
||||||
|
if (m_activation.joinable())
|
||||||
|
m_activation.join();
|
||||||
|
setEnabled(true);
|
||||||
|
icon()->setVisible(true);
|
||||||
|
message()->setText(e.what());
|
||||||
|
layout();
|
||||||
|
m_activationInProgress = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
33
src/app/ui/enter_license.h
Normal file
33
src/app/ui/enter_license.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Aseprite
|
||||||
|
// Copyright (C) 2021 Igara Studio S.A.
|
||||||
|
//
|
||||||
|
// This program is distributed under the terms of
|
||||||
|
// the End-User License Agreement for Aseprite.
|
||||||
|
|
||||||
|
#ifndef APP_UI_ENTER_LICENSE_H_INCLUDED
|
||||||
|
#define APP_UI_ENTER_LICENSE_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "drm/license_manager.h"
|
||||||
|
#include "enter_license.xml.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
class EnterLicense : public app::gen::EnterLicense {
|
||||||
|
public:
|
||||||
|
EnterLicense();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onBeforeClose(ui::CloseEvent& ev) override;
|
||||||
|
void onActivationFailed(drm::LicenseManager::Exception& e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::thread m_activation;
|
||||||
|
ui::Timer m_timer;
|
||||||
|
bool m_activationInProgress;
|
||||||
|
obs::connection m_activationFailedConn;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user