1
# This file is part of qVamps.
3
# qVamps is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# qVamps is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with qVamps; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
use Qt::isa qw (Qt::Object);
25
use Qt::attributes qw (mtable_items title_combo audio_combo
26
subtitle_combo title_list_items ct);
27
use QVamps qw (search);
36
my $title_combo = shift;
37
my $audio_combo = shift;
38
my $subtitle_combo = shift;
39
my $title_list_items = shift;
40
my $mtable_items = shift;
42
$this -> SUPER::NEW ($parent, $name);
44
title_combo = $title_combo;
45
audio_combo = $audio_combo;
46
subtitle_combo = $subtitle_combo;
47
title_list_items = $title_list_items;
48
mtable_items = $mtable_items;
54
parent () -> removeChild (this);
58
title_list_items = undef;
59
subtitle_combo = undef;
70
my $title_combo = title_combo;
71
my $ttn = $title_combo -> currentText ();
72
my $selected_titles = title_list_items -> selected_titles ();
74
# wipe out all combo box items
75
$title_combo -> clear ();
78
if (@{$selected_titles})
80
# list of selected titles not empty
81
# --> create combo box items and set new title number to first in list
82
$title_combo -> insertStringList ($selected_titles);
83
$nttn = $title_combo -> currentText ();
88
# we had a title selected --> search in titles selected now
89
my $i = search ($selected_titles, $ttn);
93
# title still selected --> restore combo box selection
94
$title_combo -> setCurrentItem ($i);
97
# As user may have changed the title's audio and subtitle selection,
98
# we need to update the audio and subtitle combo boxes. Even though
99
# the title is still selected. Since the currently selected audio
100
# and subtitle stream should be preserved in this case, returning
101
# the title as negative number here indicates this situation.
107
# adjust width of combo box
108
adjust_combo_width ($title_combo);
119
my $audio_combo = audio_combo;
124
$item = $audio_combo -> currentText ();
127
$audio_combo -> clear ();
132
my $item_hash = mtable_items -> make_audio_item_hash ($ttn);
133
my @streams = sort { $a <=> $b } keys %{$item_hash};
134
my @item_list = map $item_hash -> {$_}, @streams;
140
for (my $j = 0; $j < @item_list; $j++)
142
if ($item eq $item_list [$j])
151
$i = search (\@streams, mtable_items -> default_audio_stream ());
154
$audio_combo -> insertStringList (\@item_list);
155
$audio_combo -> setCurrentItem ($i) unless ($i < 0);
158
adjust_combo_width ($audio_combo);
167
my $subtitle_combo = subtitle_combo;
172
$item = $subtitle_combo -> currentText ();
175
$subtitle_combo -> clear ();
179
my $item_hash = mtable_items -> make_subtitle_item_hash ($ttn);
180
my @streams = sort { $a <=> $b } keys %{$item_hash};
181
my @item_list = map $item_hash -> {$_}, @streams;
183
$subtitle_combo -> insertStringList (\@item_list);
187
for (my $i = 0; $i < @item_list; $i++)
189
if ($item eq $item_list [$i])
191
$subtitle_combo -> setCurrentItem ($i);
198
adjust_combo_width ($subtitle_combo);
202
sub adjust_combo_width
206
$combo -> setFont ($combo -> font ());
207
$combo -> updateGeometry ();
213
my $ttn = update_title ();
216
update_subtitle ($ttn);
228
update_subtitle ($ttn);
235
my $title_combo = title_combo;
237
return 0 unless ($title_combo -> count ());
239
return $title_combo -> currentItem () + 1;
245
return audio_combo -> currentItem ();
251
return audio_combo -> currentItem () - 1;