Adding support for production.

This commit is contained in:
Sergiotarxz 2024-11-02 21:54:45 +01:00
parent f930f6151f
commit 026538cd94
3 changed files with 110 additions and 93 deletions

View File

@ -25,6 +25,7 @@ has device => ( is => 'rw' );
has _pay_url => ( is => 'lazy' );
has _activated => ( is => 'rw' );
has _last_valid_preview_file => ( is => 'rw' );
has _is_showing_paywall => (is => 'rw');
has file_format => (
is => 'rw',
default => sub {
@ -128,7 +129,8 @@ sub start( $self, $exd_file ) {
$execute_log->set_editable(0);
$execute_log->set_cursor_visible(0);
$win->set_title('Hiperthermia (Thermal Printer) ' . ($self->_exd->debug ? 'DEBUG' : '') );
$win->set_title( 'Hiperthermia (Thermal Printer) '
. ( $self->_exd->debug ? 'DEBUG' : '' ) );
$win->set_default_size( 1200, 900 );
$execute_log->set_hexpand(1);
@ -169,7 +171,7 @@ sub start( $self, $exd_file ) {
if ( !$self->_activated ) {
my $uuid = $self->_exd->uuid;
my $instance_id = $self->instance_id;
$self->_add_timeout_paywall($overlay);
$self->_show_paywall($overlay);
$self->app->send_packet_check_if_activated( $self, $uuid );
}
$win->set_child($overlay);
@ -184,7 +186,9 @@ sub _show_about_dialog($self) {
my $picture = Gtk4::Picture->new;
$picture->set_property( 'width-request', 256 );
$picture->set_property( 'height-request', 256 );
$picture->set_filename(path(__FILE__)->parent->parent->parent->parent->child('exd-logo.png').'');
$picture->set_filename(
path(__FILE__)->parent->parent->parent->parent->child('exd-logo.png')
. '' );
my $label = Gtk4::Label->new(undef);
$label->set_markup(<<"EOF");
Welcome to Hiperthermia.
@ -225,14 +229,9 @@ EOF
$window->present;
}
sub _add_timeout_paywall( $self, $overlay ) {
if ( $self->_activated ) {
return 0;
}
if ( defined $self->_pay_url ) {
Glib::Timeout->add(
$self->_exd->debug ? 1_000 : 20_000,
sub {
sub _show_paywall( $self, $overlay ) {
return if $self->_is_showing_paywall;
$self->_is_showing_paywall(1);
my $box = Gtk4::Box->new( 'vertical', 10 );
$self->_transparent_avoid_input($box);
$box->set_opacity(0.7);
@ -249,8 +248,7 @@ sub _add_timeout_paywall( $self, $overlay ) {
my $title = Gtk4::Label->new('This program is not activated');
my $activate = Gtk4::Button->new_with_label('Pay and activate');
my $about = Gtk4::Button->new_with_label('More about the program');
my $remind_me_later =
Gtk4::Button->new_with_label('Remind me later');
my $remind_me_later = Gtk4::Button->new_with_label('Remind me later');
$about->signal_connect(
clicked => sub {
$self->_show_about_dialog;
@ -258,13 +256,13 @@ sub _add_timeout_paywall( $self, $overlay ) {
);
$activate->signal_connect(
clicked => sub {
my $launcher =
Gtk4::UriLauncher->new( $self->_pay_url );
my $launcher = Gtk4::UriLauncher->new( $self->_pay_url );
$launcher->launch( $self->window, undef, undef );
}
);
$remind_me_later->signal_connect(
'clicked' => sub {
$self->_is_showing_paywall(0);
$overlay->remove_overlay($paywall);
$overlay->remove_overlay($box);
$self->_paywall(undef);
@ -272,12 +270,16 @@ sub _add_timeout_paywall( $self, $overlay ) {
$self->_add_timeout_paywall($overlay);
}
);
my $picture = Gtk4::Image->new_from_file(path(__FILE__)->parent->parent->parent->parent->child('exd-logo.png').'');
my $picture = Gtk4::Image->new_from_file(
path(__FILE__)->parent->parent->parent->parent->child('exd-logo.png')
. '' );
$picture->set_pixel_size(256);
$inner_paywall_box->append($picture);
$inner_paywall_box->append($title);
if ( $self->_exd->debug ) {
my $debug_message = Gtk4::Label->new('This is debug compilation, do not use your real payment data but a Stripe test card');
my $debug_message = Gtk4::Label->new(
'This is debug compilation, do not use your real payment data but a Stripe test card'
);
$inner_paywall_box->append($debug_message);
}
$inner_paywall_box->append($activate);
@ -311,6 +313,17 @@ sub _add_timeout_paywall( $self, $overlay ) {
);
return 0;
}
sub _add_timeout_paywall( $self, $overlay ) {
if ( $self->_activated ) {
return 0;
}
if ( defined $self->_pay_url ) {
Glib::Timeout->add(
$self->_exd->debug ? 1_000 : 20_000,
sub {
$self->_show_paywall($overlay);
}
);
}
}
@ -532,10 +545,12 @@ sub _add_to_log( $self, $text ) {
sub _on_preview($self) {
my $scroll = $self->_preview_widget;
if ( -f $self->_preview_file
if (
-f $self->_preview_file
&& ( !defined $self->_last_valid_preview_file
|| $self->_last_valid_preview_file ne $self->_preview_file )
) {
)
{
$self->_last_valid_preview_file( $self->_preview_file );
my $preview_picture = Gtk4::Picture->new;
$preview_picture->set_filename( '' . $self->_preview_file );
@ -763,8 +778,9 @@ sub _open_action($self) {
sub _open_file( $self, $file ) {
$self->_save_path($file);
my $window = $self->window;
$window->set_title(
"Hiperthermia (Thermal Printer) " . ($self->_exd->debug ? 'DEBUG' : '') . path( $self->_save_path )->basename );
$window->set_title( "Hiperthermia (Thermal Printer) "
. ( $self->_exd->debug ? 'DEBUG' : '' )
. path( $self->_save_path )->basename );
$self->file_format( Exd::FileFormat->from_zip_file($file) );
$self->_update_editor_buffer;
}

View File

@ -121,7 +121,7 @@ sub print($self) {
if system(
qw/magick/,
$image_file_in,
qw/-resize 384x -brightness-contrast +0.8 -dither FloydSteinberg -remap pattern:gray50/,
qw/-resize 384x -brightness-contrast +0.1 -dither FloydSteinberg -remap pattern:gray50/,
$image_file_out
);
$image_final = Exd::Utils::get_gd_image( $image_file_out . '' );

View File

@ -102,6 +102,7 @@ modules:
- 'cd HiperthermiaSource; perl lib/Exd/FileFormat/Fontconfig.pm'
- 'cd HiperthermiaSource; perl -Ilib lib/Exd/Gui.pm'
- 'cd HiperthermiaSource; chmod 755 -R _Inline/'
- 'cp HiperthermiaSource/app_config.prod.json HiperthermiaSource/app_config.json'
- 'cp -vr HiperthermiaSource ${FLATPAK_DEST}/Hiperthermia'
- 'glib-compile-resources --sourcedir=${FLATPAK_DEST}/Hiperthermia ${FLATPAK_DEST}/Hiperthermia/resources.xml'
- 'install -Dm644 HiperthermiaSource/me.sergiotarxz.Exd.desktop /app/share/applications/me.sergiotarxz.Exd.desktop'