App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/Wx/SettingsDialog.pm  view on Meta::CPAN

#! perl

use v5.26;
use Object::Pad;
use utf8;

class ChordPro::Wx::SettingsDialog
  :repr(HASH)
  :isa(ChordPro::Wx::SettingsDialog_wxg);

use Wx qw[:everything];
use Wx::Locale gettext => '_T';
use ChordPro::Files;
use ChordPro::Paths;
use ChordPro::Wx::Config;
use ChordPro::Wx::Utils;
use File::Basename;
use Ref::Util qw( is_arrayref );
use List::Util qw( first );

BUILD ( $parent, $id, $title ) {
    $self->refresh;
    $self->{sz_prefs_outer}->Fit($self);
    $self->Layout;
    Wx::Event::EVT_SYS_COLOUR_CHANGED( $self,
				       $self->can("OnSysColourChanged") );

    Wx::Event::EVT_ENTER_WINDOW( $self->{ch_stylemods},
				 $self->{ch_stylemods}->can("OnEnter") );
    Wx::Event::EVT_LEAVE_WINDOW( $self->{ch_stylemods},
				 $self->{ch_stylemods}->can("OnLeave") );
    Wx::Event::EVT_MOTION( $self->{ch_stylemods},
				 $self->{ch_stylemods}->can("OnMotion") );

    # Do not DeletePage until we're sure none of the widgets are referenced.
    $self->{nb_preferences}->RemovePage(5) # HTML viewer
      unless $preferences{expert};
    $self->{nb_preferences}->RemovePage(4) # PDF viewer
      unless $preferences{pdfviewer} || $preferences{enable_pdfviewer};

    unless ( has_appearance() ) {
	$self->{ch_theme}->Delete(2); # Follow System
    }

    $self;
}

my $checkpfx = "✔ ";

method refresh() {
    $self->fetch_prefs;
    $self->{t_editor}->refresh;
    $self->{t_editor}->SetText(<<EOD);
{title: St. James Infirmary Blues}
{subtitle: Traditional}

# Song starts here.
I went [Em]down to the [Am]St James In[Em]firmary
I found my [Am]baby [B7]there
EOD
}

method enablecustom() {
    my $n = $self->{cb_configfile}->IsChecked;
    $self->{fp_customconfig}->Enable($n);
    $self->{b_createconfig}->Enable($n);

    $n = $self->{cb_customlib}->IsChecked;
    $self->{dp_customlibrary}->Enable($n);

    $n = $self->{cb_tmplfile}->IsChecked;
    $self->{fp_tmplfile}->Enable($n);

    # Add instruments.
    for my $ctl ( $self->{ch_instrument} ) {
	$ctl->Clear;
	for ( sort keys %{$state{presets}{instruments}} ) {
	    $ctl->Append( $state{presets}{instruments}->{$_}->{title},



( run in 0.636 second using v1.01-cache-2.11-cpan-ceb78f64989 )