mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
Add Aseprite update dialog and fix enter license dialog
This commit is contained in:
parent
1403424f3a
commit
7ec08ca54c
@ -1077,6 +1077,9 @@ license_key = License Key
|
|||||||
activating_message = Activating...
|
activating_message = Activating...
|
||||||
activated_message = Aseprite has been successfully activated!
|
activated_message = Aseprite has been successfully activated!
|
||||||
|
|
||||||
|
[aseprite_update]
|
||||||
|
title = Aseprite update
|
||||||
|
|
||||||
[tileset_selector]
|
[tileset_selector]
|
||||||
new_tileset = New Tileset
|
new_tileset = New Tileset
|
||||||
grid_width = Grid Width:
|
grid_width = Grid Width:
|
||||||
|
23
data/widgets/aseprite_update.xml
Normal file
23
data/widgets/aseprite_update.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<!-- Aseprite -->
|
||||||
|
<!-- Copyright (c) 2021 Igara Studio S.A. -->
|
||||||
|
<gui>
|
||||||
|
<window id="aseprite_update" text="@.title" minwidth="300" minheight="200">
|
||||||
|
<box vertical="true" expansive="true">
|
||||||
|
<hbox>
|
||||||
|
<slider min="0" max="100" id="progress" cell_align="horizontal" expansive="true" readonly="true" />
|
||||||
|
</hbox>
|
||||||
|
<hbox expansive="true">
|
||||||
|
<view expansive="true" style="workspace_view">
|
||||||
|
<listbox id="logitems" />
|
||||||
|
</view>
|
||||||
|
</hbox>
|
||||||
|
<box horizontal="true">
|
||||||
|
<box horizontal="true" expansive="true" />
|
||||||
|
<box horizontal="true" homogeneous="true">
|
||||||
|
<button text="@general.ok" id="ok_button" magnet="true" width="60" />
|
||||||
|
<button text="@general.cancel" closewindow="true" />
|
||||||
|
</box>
|
||||||
|
</box>
|
||||||
|
</box>
|
||||||
|
</window>
|
||||||
|
</gui>
|
@ -430,6 +430,7 @@ if(ENABLE_UI)
|
|||||||
if(ENABLE_DRM)
|
if(ENABLE_DRM)
|
||||||
set(ui_app_files
|
set(ui_app_files
|
||||||
ui/enter_license.cpp
|
ui/enter_license.cpp
|
||||||
|
ui/aseprite_update.cpp
|
||||||
${ui_app_files})
|
${ui_app_files})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/console.h"
|
#include "app/console.h"
|
||||||
#include "app/crash/data_recovery.h"
|
#include "app/crash/data_recovery.h"
|
||||||
|
#include "app/drm.h"
|
||||||
#include "app/extensions.h"
|
#include "app/extensions.h"
|
||||||
#include "app/file/file.h"
|
#include "app/file/file.h"
|
||||||
#include "app/file/file_formats_manager.h"
|
#include "app/file/file_formats_manager.h"
|
||||||
@ -59,7 +60,6 @@
|
|||||||
#include "base/scoped_lock.h"
|
#include "base/scoped_lock.h"
|
||||||
#include "base/split_string.h"
|
#include "base/split_string.h"
|
||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
#include "drm.h"
|
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "os/error.h"
|
#include "os/error.h"
|
||||||
#include "os/surface.h"
|
#include "os/surface.h"
|
||||||
@ -846,9 +846,13 @@ int app_get_color_to_clear_layer(Layer* layer)
|
|||||||
|
|
||||||
#ifdef ENABLE_DRM
|
#ifdef ENABLE_DRM
|
||||||
void app_configure_drm() {
|
void app_configure_drm() {
|
||||||
ResourceFinder rf;
|
ResourceFinder userDirRf, dataDirRf;
|
||||||
rf.includeUserDir("");
|
userDirRf.includeUserDir("");
|
||||||
DRM_CONFIGURE(rf.getFirstOrCreateDefault(), updater::getUserAgent());
|
dataDirRf.includeDataDir("");
|
||||||
|
std::map<std::string, std::string> config = {
|
||||||
|
{"data", dataDirRf.getFirstOrCreateDefault()}
|
||||||
|
};
|
||||||
|
DRM_CONFIGURE(get_app_name(), get_app_version(), userDirRf.getFirstOrCreateDefault(), updater::getUserAgent(), config);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
101
src/app/ui/aseprite_update.cpp
Normal file
101
src/app/ui/aseprite_update.cpp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// 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 "aseprite_update.h"
|
||||||
|
#include "base/time.h"
|
||||||
|
#include "base/trim_string.h"
|
||||||
|
#include "ui/label.h"
|
||||||
|
#include "ui/system.h"
|
||||||
|
#include "ver/info.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
AsepriteUpdate::AsepriteUpdate(std::string version) : m_timer(500, this), m_download(get_app_name(), version)
|
||||||
|
{
|
||||||
|
okButton()->setEnabled(false);
|
||||||
|
okButton()->Click.connect([this](ui::Event&) {
|
||||||
|
});
|
||||||
|
m_timer.Tick.connect([this] { this->onTimerTick(); });
|
||||||
|
|
||||||
|
log(base::string_printf("Downloading Aseprite %s...", version.c_str()));
|
||||||
|
m_download.DataReceived.connect(
|
||||||
|
[this](long total, long now) {
|
||||||
|
onDataReceived(total, now);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
m_download.DownloadFailed.connect(
|
||||||
|
[this](drm::LicenseManager::DownloadException& e) {
|
||||||
|
onDownloadFailed(e);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
m_download.DownloadFinished.connect(
|
||||||
|
[this](drm::Package& package) {
|
||||||
|
onDownloadFinished(package);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
m_download.start();
|
||||||
|
m_timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsepriteUpdate::onBeforeClose(ui::CloseEvent& ev)
|
||||||
|
{
|
||||||
|
if (m_download.status() != drm::DownloadThread::Status::FINISHED) {
|
||||||
|
log("Stopping, please wait...");
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
if (!m_closing) {
|
||||||
|
m_download.shutdown();
|
||||||
|
}
|
||||||
|
m_closing = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsepriteUpdate::onDataReceived(long total, long now)
|
||||||
|
{
|
||||||
|
ui::execute_from_ui_thread([this, total, now] {
|
||||||
|
progress()->setValue(100 * now / total);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsepriteUpdate::onDownloadFailed(drm::LicenseManager::DownloadException& e)
|
||||||
|
{
|
||||||
|
ui::execute_from_ui_thread([this, e] {
|
||||||
|
log(e.what());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsepriteUpdate::onDownloadFinished(drm::Package& package)
|
||||||
|
{
|
||||||
|
ui::execute_from_ui_thread([this, package] {
|
||||||
|
log("Download finished!");
|
||||||
|
drm::LicenseManager::instance()->installPackage(package);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsepriteUpdate::onTimerTick()
|
||||||
|
{
|
||||||
|
if (m_closing && m_download.status() == drm::DownloadThread::Status::FINISHED) {
|
||||||
|
this->closeWindow(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsepriteUpdate::log(std::string text)
|
||||||
|
{
|
||||||
|
if (m_closing) return;
|
||||||
|
|
||||||
|
base::trim_string(text, text);
|
||||||
|
|
||||||
|
auto now = base::current_time();
|
||||||
|
auto strNow = base::string_printf("%d-%02d-%02d %02d:%02d:%02d", now.year, now.month, now.day, now.hour, now.minute, now.second);
|
||||||
|
logitems()->addChild(new ui::Label(strNow + " " + text));
|
||||||
|
layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
src/app/ui/aseprite_update.h
Normal file
39
src/app/ui/aseprite_update.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// 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_ASEPRITE_UPDATE_H_INCLUDED
|
||||||
|
#define APP_UI_ASEPRITE_UPDATE_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <drm/download_thread.h>
|
||||||
|
#include "aseprite_update.xml.h"
|
||||||
|
#include "ui/timer.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
class AsepriteUpdate : public app::gen::AsepriteUpdate {
|
||||||
|
public:
|
||||||
|
AsepriteUpdate(std::string version);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void onBeforeClose(ui::CloseEvent& ev) override;
|
||||||
|
void onDataReceived(long total, long now);
|
||||||
|
void onDownloadFailed(drm::LicenseManager::DownloadException& e);
|
||||||
|
void onDownloadFinished(drm::Package& package);
|
||||||
|
void onTimerTick();
|
||||||
|
|
||||||
|
private:
|
||||||
|
drm::DownloadThread m_download;
|
||||||
|
ui::Timer m_timer;
|
||||||
|
bool m_closing = false;
|
||||||
|
|
||||||
|
void log(std::string text);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -56,7 +56,7 @@ void EnterLicense::onActivationFailed(drm::LicenseManager::ActivationException&
|
|||||||
|
|
||||||
void EnterLicense::onActivated(std::string token)
|
void EnterLicense::onActivated(std::string token)
|
||||||
{
|
{
|
||||||
drm::LicenseManager::instance()->save(token);
|
drm::LicenseManager::instance()->saveToken(token);
|
||||||
|
|
||||||
ui::execute_from_ui_thread([this]() {
|
ui::execute_from_ui_thread([this]() {
|
||||||
showSuccess();
|
showSuccess();
|
||||||
@ -73,7 +73,7 @@ void EnterLicense::startActivation()
|
|||||||
m_activationInProgress = true;
|
m_activationInProgress = true;
|
||||||
m_activation = std::thread([this, key]() {
|
m_activation = std::thread([this, key]() {
|
||||||
try {
|
try {
|
||||||
auto token = drm::LicenseManager::instance()->activate(key, get_app_name(), get_app_version());
|
auto token = drm::LicenseManager::instance()->activate(key);
|
||||||
onActivated(token);
|
onActivated(token);
|
||||||
}
|
}
|
||||||
catch (drm::LicenseManager::ActivationException& e) {
|
catch (drm::LicenseManager::ActivationException& e) {
|
||||||
|
@ -42,6 +42,11 @@
|
|||||||
#include "app/sentry_wrapper.h"
|
#include "app/sentry_wrapper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_DRM
|
||||||
|
#include "drm/drm.h"
|
||||||
|
#include "aseprite_update.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
@ -234,7 +239,20 @@ void HomeView::onNewUpdate(const std::string& url, const std::string& version)
|
|||||||
checkUpdate()->setText(
|
checkUpdate()->setText(
|
||||||
fmt::format(Strings::home_view_new_version_available(),
|
fmt::format(Strings::home_view_new_version_available(),
|
||||||
get_app_name(), version));
|
get_app_name(), version));
|
||||||
|
#ifdef ENABLE_DRM
|
||||||
|
DRM_INVALID {
|
||||||
|
checkUpdate()->setUrl(url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkUpdate()->setUrl("");
|
||||||
|
checkUpdate()->Click.connect([version] {
|
||||||
|
app::AsepriteUpdate dlg(version);
|
||||||
|
dlg.openWindowInForeground();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#else
|
||||||
checkUpdate()->setUrl(url);
|
checkUpdate()->setUrl(url);
|
||||||
|
#endif
|
||||||
checkUpdate()->setVisible(true);
|
checkUpdate()->setVisible(true);
|
||||||
checkUpdate()->InitTheme.connect(
|
checkUpdate()->InitTheme.connect(
|
||||||
[this]{
|
[this]{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user