65
66
font_autoload_combo->setCurrentIndex(font_autoload_item);
68
int font_encoding_item = font_encoding_combo->currentIndex();
69
//int font_encoding_item = font_encoding_combo->currentIndex();
70
QString current_encoding = fontEncoding();
71
QString current_enca_lang = encaLang();
69
72
font_encoding_combo->clear();
70
encodings->retranslate();
71
font_encoding_combo->insertItems( 0, encodings->list() );
72
font_encoding_combo->setCurrentIndex(font_encoding_item);
73
enca_lang_combo->clear();
75
QMap<QString,QString> l = Languages::encodings();
76
QMapIterator<QString, QString> i(l);
79
font_encoding_combo->addItem( i.value() + " (" + i.key() + ")", i.key() );
81
l = Languages::list(); i = l;
84
enca_lang_combo->addItem( i.value() + " (" + i.key() + ")", i.key() );
86
font_encoding_combo->model()->sort(0);
87
enca_lang_combo->model()->sort(0);
88
//font_encoding_combo->setCurrentIndex(font_encoding_item);
89
setFontEncoding(current_encoding);
90
setEncaLang(current_enca_lang);
74
92
sub_pos_label->setNum( sub_pos_slider->value() );
76
94
ttf_font_edit->setCaption(tr("Choose a ttf file"));
77
95
ttf_font_edit->setFilter(tr("Truetype Fonts") + " (*.ttf)");
98
int alignment_item = style_alignment_combo->currentIndex();
99
style_alignment_combo->clear();
100
style_alignment_combo->addItem(tr("Left", "horizontal alignment"), 1);
101
style_alignment_combo->addItem(tr("Centered", "horizontal alignment"), 2);
102
style_alignment_combo->addItem(tr("Right", "horizontal alignment"), 3);
103
style_alignment_combo->setCurrentIndex(alignment_item);
105
int valignment_item = style_valignment_combo->currentIndex();
106
style_valignment_combo->clear();
107
style_valignment_combo->addItem(tr("Bottom", "vertical alignment"));
108
style_valignment_combo->addItem(tr("Middle", "vertical alignment"));
109
style_valignment_combo->addItem(tr("Top", "vertical alignment"));
110
style_valignment_combo->setCurrentIndex(valignment_item);
112
int borderstyle_item = style_border_style_combo->currentIndex();
113
style_border_style_combo->clear();
114
style_border_style_combo->addItem(tr("Outline", "border style"), 1);
115
style_border_style_combo->addItem(tr("Opaque box", "border style"), 3);
116
style_border_style_combo->setCurrentIndex(borderstyle_item);
89
128
setAutoloadSub( pref->autoload_sub );
90
129
setFontFuzziness( pref->subfuzziness );
91
130
setFontEncoding( pref->subcp );
131
setUseEnca( pref->use_enca );
132
setEncaLang( pref->enca_lang );
92
133
setUseFontASS( pref->use_ass_subtitles );
93
setAssColor( pref->ass_color );
94
setAssBorderColor( pref->ass_border_color );
95
setAssStyles( pref->ass_styles );
134
setAssLineSpacing( pref->ass_line_spacing );
96
135
setSubPos( pref->initial_sub_pos );
97
136
setSubtitlesOnScreenshots( pref->subtitles_on_screenshots );
137
setFreetypeSupport( pref->freetype_support );
140
style_font_combo->setCurrentText(pref->ass_styles.fontname);
141
style_size_spin->setValue(pref->ass_styles.fontsize);
142
style_text_color_button->setColor(pref->ass_styles.primarycolor);
143
style_border_color_button->setColor(pref->ass_styles.outlinecolor);
144
style_shadow_color_button->setColor(pref->ass_styles.backcolor);
145
style_bold_check->setChecked(pref->ass_styles.bold);
146
style_italic_check->setChecked(pref->ass_styles.italic);
147
style_alignment_combo->setCurrentIndex(style_alignment_combo->findData(pref->ass_styles.halignment));
148
style_valignment_combo->setCurrentIndex(pref->ass_styles.valignment);
149
style_border_style_combo->setCurrentIndex(style_border_style_combo->findData(pref->ass_styles.borderstyle));
150
style_outline_spin->setValue(pref->ass_styles.outline);
151
style_shadow_spin->setValue(pref->ass_styles.shadow);
152
style_marginl_spin->setValue(pref->ass_styles.marginl);
153
style_marginr_spin->setValue(pref->ass_styles.marginr);
154
style_marginv_spin->setValue(pref->ass_styles.marginv);
156
setForceAssStyles(pref->force_ass_styles);
157
setCustomizedAssStyle(pref->user_forced_ass_style);
100
160
void PrefSubtitles::getData(Preferences * pref) {
109
169
TEST_AND_SET(pref->autoload_sub, autoloadSub());
110
170
TEST_AND_SET(pref->subfuzziness, fontFuzziness());
111
171
TEST_AND_SET(pref->subcp, fontEncoding());
172
TEST_AND_SET(pref->use_enca, useEnca());
173
TEST_AND_SET(pref->enca_lang, encaLang());
112
174
TEST_AND_SET(pref->use_ass_subtitles, useFontASS());
113
TEST_AND_SET(pref->ass_color, assColor());
114
TEST_AND_SET(pref->ass_border_color, assBorderColor());
115
TEST_AND_SET(pref->ass_styles, assStyles());
175
TEST_AND_SET(pref->ass_line_spacing, assLineSpacing());
116
176
pref->initial_sub_pos = subPos();
117
177
TEST_AND_SET(pref->subtitles_on_screenshots, subtitlesOnScreenshots());
178
TEST_AND_SET(pref->freetype_support, freetypeSupport());
181
TEST_AND_SET(pref->ass_styles.fontname, style_font_combo->currentText());
182
TEST_AND_SET(pref->ass_styles.fontsize, style_size_spin->value());
183
TEST_AND_SET(pref->ass_styles.primarycolor, style_text_color_button->color().rgb());
184
TEST_AND_SET(pref->ass_styles.outlinecolor, style_border_color_button->color().rgb());
185
TEST_AND_SET(pref->ass_styles.backcolor, style_shadow_color_button->color().rgb());
186
TEST_AND_SET(pref->ass_styles.bold, style_bold_check->isChecked());
187
TEST_AND_SET(pref->ass_styles.italic, style_italic_check->isChecked());
188
TEST_AND_SET(pref->ass_styles.halignment, style_alignment_combo->itemData(style_alignment_combo->currentIndex()).toInt());
189
TEST_AND_SET(pref->ass_styles.valignment, style_valignment_combo->currentIndex());
190
TEST_AND_SET(pref->ass_styles.borderstyle, style_border_style_combo->itemData(style_border_style_combo->currentIndex()).toInt());
191
TEST_AND_SET(pref->ass_styles.outline, style_outline_spin->value());
192
TEST_AND_SET(pref->ass_styles.shadow, style_shadow_spin->value());
193
TEST_AND_SET(pref->ass_styles.marginl, style_marginl_spin->value());
194
TEST_AND_SET(pref->ass_styles.marginr, style_marginr_spin->value());
195
TEST_AND_SET(pref->ass_styles.marginv, style_marginv_spin->value());
197
pref->ass_styles.exportStyles( Paths::subtitleStyleFile() );
199
TEST_AND_SET(pref->force_ass_styles, forceAssStyles());
200
TEST_AND_SET(pref->user_forced_ass_style, customizedAssStyle());
203
void PrefSubtitles::checkBorderStyleCombo( int index ) {
204
bool b = (index == 0);
205
style_outline_spin->setEnabled(b);
206
style_shadow_spin->setEnabled(b);
207
style_outline_label->setEnabled(b);
208
style_shadow_label->setEnabled(b);
120
212
void PrefSubtitles::setFontName(QString font_name) {
121
213
fontCombo->setCurrentText(font_name);
178
270
void PrefSubtitles::setFontEncoding(QString s) {
179
int n = encodings->findEncoding( s );
181
font_encoding_combo->setCurrentIndex(n);
183
font_encoding_combo->setCurrentText(s);
271
int i = font_encoding_combo->findData(s);
272
font_encoding_combo->setCurrentIndex(i);
186
275
QString PrefSubtitles::fontEncoding() {
187
qDebug("PrefSubtitles::fontEncoding");
188
QString res = encodings->parseEncoding( font_encoding_combo->currentText() );
189
qDebug(" * res: '%s'", res.toUtf8().data() );
276
int index = font_encoding_combo->currentIndex();
277
return font_encoding_combo->itemData(index).toString();
280
void PrefSubtitles::setEncaLang(QString s) {
281
int i = enca_lang_combo->findData(s);
282
enca_lang_combo->setCurrentIndex(i);
285
QString PrefSubtitles::encaLang() {
286
int index = enca_lang_combo->currentIndex();
287
return enca_lang_combo->itemData(index).toString();
290
void PrefSubtitles::setUseEnca(bool b) {
291
use_enca_check->setChecked(b);
294
bool PrefSubtitles::useEnca() {
295
return use_enca_check->isChecked();
193
298
void PrefSubtitles::setSubPos(int pos) {
201
306
void PrefSubtitles::setUseFontASS(bool v) {
202
font_ass_check->setChecked(v);
203
//assButtonToggled(v);
307
ass_subs_button->setChecked(v);
308
normal_subs_button->setChecked(!v);
206
311
bool PrefSubtitles::useFontASS() {
207
return font_ass_check->isChecked();
210
void PrefSubtitles::setAssColor( unsigned int color ) {
213
colorButton->setStyleSheet( "border-width: 1px; border-style: solid; border-color: #000000; background: #" + Helper::colorToRRGGBB(ass_color) + ";");
215
//colorButton->setAutoFillBackground(true);
216
Helper::setBackgroundColor( colorButton, color );
220
unsigned int PrefSubtitles::assColor() {
224
void PrefSubtitles::setAssBorderColor( unsigned int color ) {
225
ass_border_color = color;
228
borderButton->setStyleSheet( "border-width: 1px; border-style: solid; border-color: #000000; background: #" + Helper::colorToRRGGBB(ass_border_color) + ";");
230
//borderButton->setAutoFillBackground(true);
231
Helper::setBackgroundColor( borderButton, color );
235
unsigned int PrefSubtitles::assBorderColor() {
236
return ass_border_color;
239
void PrefSubtitles::setAssStyles(QString styles) {
240
ass_styles_edit->setText(styles);
243
QString PrefSubtitles::assStyles() {
244
return ass_styles_edit->text();
312
return ass_subs_button->isChecked();
247
315
void PrefSubtitles::setFontFuzziness(int n) {
260
328
return subtitles_on_screeshots_check->isChecked();
264
void PrefSubtitles::on_colorButton_clicked() {
265
QColor c = QColorDialog::getColor ( ass_color, this );
267
setAssColor( c.rgb() );
271
void PrefSubtitles::on_borderButton_clicked() {
272
QColor c = QColorDialog::getColor ( ass_border_color, this );
274
setAssBorderColor( c.rgb() );
331
void PrefSubtitles::setAssLineSpacing(int spacing) {
332
ass_line_spacing_spin->setValue(spacing);
335
int PrefSubtitles::assLineSpacing() {
336
return ass_line_spacing_spin->value();
339
void PrefSubtitles::setForceAssStyles(bool b) {
340
force_ass_styles->setChecked(b);
343
bool PrefSubtitles::forceAssStyles() {
344
return force_ass_styles->isChecked();
347
void PrefSubtitles::on_ass_subs_button_toggled(bool b) {
349
stackedWidget->setCurrentIndex(1);
351
stackedWidget->setCurrentIndex(0);
354
void PrefSubtitles::on_ass_customize_button_clicked() {
357
QString edit = forced_ass_style;
359
// A copy with the current values in the dialog
360
AssStyles ass_styles;
361
ass_styles.fontname = style_font_combo->currentText();
362
ass_styles.fontsize = style_size_spin->value();
363
ass_styles.primarycolor = style_text_color_button->color().rgb();
364
ass_styles.outlinecolor = style_border_color_button->color().rgb();
365
ass_styles.backcolor = style_shadow_color_button->color().rgb();
366
ass_styles.bold = style_bold_check->isChecked();
367
ass_styles.italic = style_italic_check->isChecked();
368
ass_styles.halignment = style_alignment_combo->itemData(style_alignment_combo->currentIndex()).toInt();
369
ass_styles.valignment = style_valignment_combo->currentIndex();
370
ass_styles.borderstyle = style_border_style_combo->itemData(style_border_style_combo->currentIndex()).toInt();
371
ass_styles.outline = style_outline_spin->value();
372
ass_styles.shadow = style_shadow_spin->value();
373
ass_styles.marginl = style_marginl_spin->value();
374
ass_styles.marginr = style_marginr_spin->value();
375
ass_styles.marginv = style_marginv_spin->value();
377
if (edit.isEmpty()) {
378
edit = ass_styles.toString();
381
QString s = QInputDialog::getText(this, tr("Customize SSA/ASS style"),
382
tr("Here you can enter your customized SSA/ASS style.") +"<br>"+
383
tr("Clear the edit line to disable the customized style."),
387
if (s == ass_styles.toString()) s.clear(); // Clear string if it wasn't changed by the user
388
setCustomizedAssStyle(s);
392
void PrefSubtitles::setFreetypeSupport(bool b) {
393
freetype_check->setChecked(b);
396
bool PrefSubtitles::freetypeSupport() {
397
return freetype_check->isChecked();
400
void PrefSubtitles::on_freetype_check_toggled(bool b) {
401
qDebug("PrefSubtitles:on_freetype_check_toggled: %d", b);
403
ass_subs_button->setChecked(false);
404
normal_subs_button->setChecked(true);
290
420
"be used instead.") );
292
422
setWhatsThis(font_encoding_combo, tr("Default subtitle encoding"),
293
tr("Select the encoding which will be used for subtitle files.") );
295
setWhatsThis(sub_pos_slider, tr("Subtitle position"),
296
tr("This option specifies the position of the subtitles over the "
297
"video window. <i>100</i> means the bottom, while <i>0</i> means "
423
tr("Select the encoding which will be used for subtitle files "
426
setWhatsThis(use_enca_check, tr("Try to autodetect for this language"),
427
tr("When this option is on, the encoding of the subtitles will be "
428
"tried to be autodetected for the given language. "
429
"It will fall back to the default encoding if the autodetection "
430
"fails. This option requires a MPlayer compiled with ENCA "
433
setWhatsThis(enca_lang_combo, tr("Subtitle language"),
434
tr("Select the language for which you want the encoding to be guessed "
300
437
setWhatsThis(subtitles_on_screeshots_check,
301
438
tr("Include subtitles on screenshots"),
302
439
tr("If this option is checked, the subtitles will appear in the "
303
"screenshots. Note: it may cause some troubles sometimes." ) );
440
"screenshots. <b>Note:</b> it may cause some troubles sometimes." ) );
442
setWhatsThis(freetype_check, tr("Freetype support"),
443
tr("You should normally not disable this option. Do it only if your "
444
"MPlayer is compiled without freetype support. "
445
"<b>Disabling this option could make that subtitles won't work "
305
448
addSectionTitle(tr("Font"));
450
setWhatsThis(normal_subs_button, tr("Enable normal subtitles"),
451
tr("Click this button to select the normal/traditional subtitles. "
452
"This kind of subtitles can only display white subtitles."));
454
setWhatsThis(ass_subs_button, tr("Enable SSA/ASS subtitles"),
455
tr("Click this button to enable the new SSA/ASS library. "
456
"This allows to display subtitles with multiple colors, fonts..."));
458
addSectionTitle(tr("Normal subtitles"));
307
460
setWhatsThis(ttf_font_edit, tr("TTF font"),
308
461
tr("Here you can select a ttf font to be used for the subtitles. "
309
"Usually you'll find a lot of ttf fonts in <i>%1</i>.")
462
"Usually you'll find a lot of ttf fonts in %1")
311
.arg("C:\\Windows\\Fonts\\")
464
.arg("<i>C:\\Windows\\Fonts\\</i>")
313
.arg("/usr/X11R6/lib/X11/fonts/truetype/")
466
.arg("<i>/usr/X11R6/lib/X11/fonts/truetype/</i>")
321
474
setWhatsThis(font_autoscale_combo, tr("Autoscale"),
322
475
tr("Select the subtitle autoscaling method.") );
324
setWhatsThis(font_text_scale, tr("Default scale for normal subtitles"),
325
tr("This option specifies the default font scale for normal (white) "
326
"subtitles which will be used for new videos."));
328
setWhatsThis(ass_font_scale, tr("Default scale for SSA/ASS subtitles"),
477
QString scale_note = tr("This option does NOT change the size of the "
478
"subtitles in the current video. To do so, use the options "
479
"<i>Size+</i> and <i>Size-</i> in the subtitles menu.");
481
setWhatsThis(font_text_scale_spin, tr("Default scale"),
482
tr("This option specifies the default font scale for normal "
483
"subtitles which will be used for new opened files.") +"<br>"+
486
setWhatsThis(sub_pos_slider, tr("Subtitle position"),
487
tr("This option specifies the position of the subtitles over the "
488
"video window. <i>100</i> means the bottom, while <i>0</i> means "
491
addSectionTitle(tr("SSA/ASS subtitles"));
493
setWhatsThis(ass_font_scale_spin, tr("Default scale"),
329
494
tr("This option specifies the default font scale for SSA/ASS "
330
"subtitles which will be used for new videos."));
332
addSectionTitle(tr("SSA/ASS library"));
334
setWhatsThis(font_ass_check, tr("Use SSA/ASS library for subtitle rendering"),
335
tr("Check this option to activate the SSA/ASS library. It provides "
336
"nicer subtitles, so it's a good idea to do it.") );
338
setWhatsThis(colorButton, tr("Text color"),
495
"subtitles which will be used for new opened files.") +"<br>"+
498
setWhatsThis(ass_line_spacing_spin, tr("Line spacing"),
499
tr("This specifies the spacing that will be used to separate "
500
"multiple lines. It can have negative values.") );
502
setWhatsThis(styles_container, tr("SSA/ASS style"),
503
tr("The following options allows you to define the style to "
504
"be used for non-styled subtitles (srt, sub...).") );
506
setWhatsThis(style_font_combo, tr("Font"),
507
tr("Select the font for the subtitles.") );
509
setWhatsThis(style_size_spin, tr("Size"),
510
tr("The size in pixels.") );
512
setWhatsThis(style_bold_check, tr("Bold"),
513
tr("If checked, the text will be displayed in <b>bold</b>.") );
515
setWhatsThis(style_italic_check, tr("Italic"),
516
tr("If checked, the text will be displayed in <i>italic</i>.") );
518
setWhatsThis(style_text_color_button, tr("Text color"),
339
519
tr("Select the color for the text of the subtitles.") );
341
setWhatsThis(borderButton, tr("Border color"),
521
setWhatsThis(style_border_color_button, tr("Border color"),
342
522
tr("Select the color for the border of the subtitles.") );
344
setWhatsThis(ass_styles_edit, tr("SSA/ASS styles"),
345
tr("Here you can override styles for SSA/ASS subtitles. "
346
"It can be also used for fine-tuning the rendering of SRT and SUB "
347
"subtitles by the SSA/ASS library. "
348
"Example: <b>Bold=1,Outline=2,Shadow=4</b>"));
524
setWhatsThis(style_shadow_color_button, tr("Shadow color"),
525
tr("This color will be used for the shadow of the subtitles.") );
527
setWhatsThis(style_marginl_spin, tr("Left margin"),
528
tr("Specifies the left margin in pixels.") );
530
setWhatsThis(style_marginr_spin, tr("Right margin"),
531
tr("Specifies the right margin in pixels.") );
533
setWhatsThis(style_marginv_spin, tr("Vertical margin"),
534
tr("Specifies the vertical margin in pixels.") );
536
setWhatsThis(style_alignment_combo, tr("Horizontal alignment"),
537
tr("Specifies the horizontal alignment. Possible values are "
538
"left, centered and right.") );
540
setWhatsThis(style_valignment_combo, tr("Vertical alignment"),
541
tr("Specifies the vertical alignment. Possible values: "
542
"bottom, middle and top.") );
544
setWhatsThis(style_border_style_combo, tr("Border style"),
545
tr("Specifies the border style. Possible values: outline "
546
"and opaque box.") );
548
setWhatsThis(style_outline_spin, tr("Outline"),
549
tr("If border style is set to <i>outline</i>, this option specifies "
550
"the width of the outline around the text in pixels.") );
552
setWhatsThis(style_shadow_spin, tr("Shadow"),
553
tr("If border style is set to <i>outline</i>, this option specifies "
554
"the depth of the drop shadow behind the text in pixels.") );
556
setWhatsThis(force_ass_styles, tr("Apply style to ass files too"),
557
tr("If this option is checked, the style defined above will be "
558
"applied to ass subtitles too.") );
351
561
#include "moc_prefsubtitles.cpp"