sub setMode {
my $class = shift;
my $client = shift;
my $method = shift;
# Handle requests to exit this mode/plugin by going back to where the user was before they came
# here. If you don't this, pressing LEFT will just put you straight back to where you already
# are! (try commenting out the following if statement)
if ($method eq 'pop') {
# Pop the current mode off the mode stack and restore the previous one
Slim::Buttons::Common::popMode($client);
return;
}
if (isBlindTest($client)) {
Slim::Buttons::Common::pushMode($client, $modeBlindTest);
} else {
pushMainMenuMode($client);
}
}
####
my $valueref = $client->modeParam('valueRef');
if ($$valueref eq 'PLUGIN_BRUTEFIR_DRC_CHANGE_FILTER') {
my $baseDir = getFilterDir();
my $currentDir = getCurrentFilterDir($client);
$currentDir =~ s/$baseDir//;
my @dirs = File::Spec->splitdir($currentDir);
$currentDir = $baseDir;
# push all directories on the path to current selected filters dir as mode to make left pop them each out
foreach my $dir (@dirs) {
if ($dir) {
Slim::Buttons::Common::pushMode($client, $modeFilterSelection, { folder => $currentDir });
$currentDir = File::Spec->catdir($currentDir, $dir);
}
}
Slim::Buttons::Common::pushModeLeft($client, $modeFilterSelection, { folder => getCurrentFilterDir($client) });
}
####
sub filterMenu {
my ($client, $callback, $args) = @_;
my $baseDir = getFilterDir();
my $currentDir = getCurrentFilterDir($client);
$currentDir =~ s/$baseDir//;
my @dirs = File::Spec->splitdir($currentDir);
$currentDir = $baseDir;
my $folder = $currentDir;
my @filters;
my %filters = getFiltersList($folder);
my @choices = sort keys %filters;
my @choicev = map $filters{$_}, @choices;
my $filter = $filters{getCurrentFilter($client)} eq getCurrentFilterPath($client) ? getCurrentFilter($client) : '';
opendir DIR, $currentDir or die "cannot open dir $currentDir: $!";
my @file= readdir DIR;
closedir DIR;
my $items;
$items = [{
{ name => 'Select a Filter',
url => \&filterMenu,
},{
name => $filter,
url => \&filterMenu,
}
}];
for my $file (@file) {
push @$items,
{
name => $file,
url => sub { my ($client, $cb, $params) = @_; },
nextWindow => 'refresh',
};
}
$callback->({
items => $items
});
}