Changeset 175 for smplayer/vendor/current/src/prefsubtitles.cpp
- Timestamp:
- May 3, 2016, 2:14:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/prefsubtitles.cpp
r168 r175 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 4Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 25 25 #include "filedialog.h" 26 26 #include "languages.h" 27 #include "playerid.h" 27 28 28 29 #include <QInputDialog> … … 33 34 setupUi(this); 34 35 35 ttf_font_edit->setDialogType(FileChooser::GetFileName); 36 #ifdef Q_OS_WIN 37 ttf_font_edit->setOptions(QFileDialog::DontUseNativeDialog); 38 #endif 36 ass_subs->setEnabled(false); 37 38 connect(ass_custom_check, SIGNAL(toggled(bool)), 39 ass_subs, SLOT(setEnabled(bool))); 40 41 /* 42 connect(use_ass_check, SIGNAL(toggled(bool)), 43 tab2, SLOT(setEnabled(bool))); 44 */ 39 45 40 46 connect( style_border_style_combo, SIGNAL(currentIndexChanged(int)), 41 47 this, SLOT(checkBorderStyleCombo(int)) ); 42 48 43 #ifndef Q_OS_WIN49 #ifndef FONTS_HACK 44 50 windowsfontdir_check->hide(); 45 51 #endif … … 62 68 63 69 void PrefSubtitles::retranslateStrings() { 64 int font_autoscale_item = font_autoscale_combo->currentIndex();65 70 int font_autoload_item = font_autoload_combo->currentIndex(); 66 71 67 72 retranslateUi(this); 68 73 69 font_autoscale_combo->setCurrentIndex(font_autoscale_item);70 74 font_autoload_combo->setCurrentIndex(font_autoload_item); 71 75 … … 83 87 font_encoding_combo->addItem( i.value() + " (" + i.key() + ")", i.key() ); 84 88 } 85 l = Languages::list(); i = l; 89 90 l = Languages::enca(); 91 i = l; 86 92 while (i.hasNext()) { 87 93 i.next(); 88 94 enca_lang_combo->addItem( i.value() + " (" + i.key() + ")", i.key() ); 89 95 } 96 90 97 font_encoding_combo->model()->sort(0); 91 98 enca_lang_combo->model()->sort(0); … … 94 101 setEncaLang(current_enca_lang); 95 102 96 sub_pos_label->setNum( sub_pos_slider->value() );97 98 ttf_font_edit->setCaption(tr("Choose a ttf file"));99 ttf_font_edit->setFilter(tr("Truetype Fonts") + " (*.ttf)");100 101 103 // Ass styles 102 104 int alignment_item = style_alignment_combo->currentIndex(); 103 105 style_alignment_combo->clear(); 104 style_alignment_combo->addItem(tr("Left", "horizontal alignment"), 1);105 style_alignment_combo->addItem(tr("Centered", "horizontal alignment"), 2);106 style_alignment_combo->addItem(tr("Right", "horizontal alignment"), 3);106 style_alignment_combo->addItem(tr("Left", "horizontal alignment"), AssStyles::Left); 107 style_alignment_combo->addItem(tr("Centered", "horizontal alignment"), AssStyles::HCenter); 108 style_alignment_combo->addItem(tr("Right", "horizontal alignment"), AssStyles::Right); 107 109 style_alignment_combo->setCurrentIndex(alignment_item); 108 110 109 111 int valignment_item = style_valignment_combo->currentIndex(); 110 112 style_valignment_combo->clear(); 111 style_valignment_combo->addItem(tr("Bottom", "vertical alignment") );112 style_valignment_combo->addItem(tr("Middle", "vertical alignment") );113 style_valignment_combo->addItem(tr("Top", "vertical alignment") );113 style_valignment_combo->addItem(tr("Bottom", "vertical alignment"), AssStyles::Bottom); 114 style_valignment_combo->addItem(tr("Middle", "vertical alignment"), AssStyles::VCenter); 115 style_valignment_combo->addItem(tr("Top", "vertical alignment"), AssStyles::Top); 114 116 style_valignment_combo->setCurrentIndex(valignment_item); 115 117 116 118 int borderstyle_item = style_border_style_combo->currentIndex(); 117 119 style_border_style_combo->clear(); 118 style_border_style_combo->addItem(tr("Outline", "border style"), 1);119 style_border_style_combo->addItem(tr("Opaque box", "border style"), 3);120 style_border_style_combo->addItem(tr("Outline", "border style"), AssStyles::Outline); 121 style_border_style_combo->addItem(tr("Opaque box", "border style"), AssStyles::Opaque); 120 122 style_border_style_combo->setCurrentIndex(borderstyle_item); 121 123 … … 124 126 125 127 void PrefSubtitles::setData(Preferences * pref) { 126 setFontName( pref->font_name );127 setFontFile( pref->font_file );128 setUseFontconfig( pref->use_fontconfig );129 setFontAutoscale( pref->font_autoscale );130 setFontTextscale( pref->initial_sub_scale );131 128 setAssFontScale( pref->initial_sub_scale_ass ); 132 129 setAutoloadSub( pref->autoload_sub ); … … 135 132 setUseEnca( pref->use_enca ); 136 133 setEncaLang( pref->enca_lang ); 137 setUseFontASS( pref->use_ass_subtitles );138 134 setAssLineSpacing( pref->ass_line_spacing ); 139 setSubPos( pref->initial_sub_pos );140 135 setSubtitlesOnScreenshots( pref->subtitles_on_screenshots ); 141 136 setFreetypeSupport( pref->freetype_support ); 137 use_ass_check->setChecked( pref->use_ass_subtitles ); 142 138 143 139 // Load ass styles … … 161 157 setCustomizedAssStyle(pref->user_forced_ass_style); 162 158 163 #ifdef Q_OS_WIN 159 ass_custom_check->setChecked(pref->enable_ass_styles); 160 161 #ifdef FONTS_HACK 164 162 windowsfontdir_check->setChecked(pref->use_windowsfontdir); 165 163 if (!windowsfontdir_check->isChecked()) on_windowsfontdir_check_toggled(false); … … 170 168 requires_restart = false; 171 169 172 TEST_AND_SET(pref->font_name, fontName());173 TEST_AND_SET(pref->font_file, fontFile());174 TEST_AND_SET(pref->use_fontconfig, useFontconfig());175 TEST_AND_SET(pref->font_autoscale, fontAutoscale());176 pref->initial_sub_scale = fontTextscale();177 170 pref->initial_sub_scale_ass = assFontScale(); 178 171 TEST_AND_SET(pref->autoload_sub, autoloadSub()); … … 181 174 TEST_AND_SET(pref->use_enca, useEnca()); 182 175 TEST_AND_SET(pref->enca_lang, encaLang()); 183 TEST_AND_SET(pref->use_ass_subtitles, useFontASS());184 176 TEST_AND_SET(pref->ass_line_spacing, assLineSpacing()); 185 pref->initial_sub_pos = subPos();186 177 TEST_AND_SET(pref->subtitles_on_screenshots, subtitlesOnScreenshots()); 187 178 TEST_AND_SET(pref->freetype_support, freetypeSupport()); 179 TEST_AND_SET(pref->use_ass_subtitles, use_ass_check->isChecked()); 188 180 189 181 // Save ass styles … … 209 201 TEST_AND_SET(pref->user_forced_ass_style, customizedAssStyle()); 210 202 211 #ifdef Q_OS_WIN 203 TEST_AND_SET(pref->enable_ass_styles, ass_custom_check->isChecked()); 204 205 #ifdef FONTS_HACK 212 206 pref->use_windowsfontdir = windowsfontdir_check->isChecked(); 213 207 #endif … … 223 217 224 218 225 void PrefSubtitles::setFontName(QString font_name) {226 fontCombo->setCurrentText(font_name);227 }228 229 QString PrefSubtitles::fontName() {230 return fontCombo->currentText();231 }232 233 void PrefSubtitles::setFontFile(QString font_file) {234 ttf_font_edit->setText( font_file );235 }236 237 QString PrefSubtitles::fontFile() {238 return ttf_font_edit->text();239 }240 241 242 void PrefSubtitles::setUseFontconfig(bool b) {243 system_font_button->setChecked(b);244 ttf_font_button->setChecked(!b);245 }246 247 bool PrefSubtitles::useFontconfig() {248 return system_font_button->isChecked();249 }250 251 void PrefSubtitles::setFontAutoscale(int n) {252 font_autoscale_combo->setCurrentIndex(n);253 }254 255 int PrefSubtitles::fontAutoscale() {256 return font_autoscale_combo->currentIndex();257 }258 259 void PrefSubtitles::setFontTextscale(double n) {260 font_text_scale_spin->setValue(n);261 }262 263 double PrefSubtitles::fontTextscale() {264 return font_text_scale_spin->value();265 }266 219 267 220 void PrefSubtitles::setAssFontScale(double n) { … … 309 262 } 310 263 311 void PrefSubtitles::setSubPos(int pos) {312 sub_pos_slider->setValue(pos);313 }314 315 int PrefSubtitles::subPos() {316 return sub_pos_slider->value();317 }318 319 void PrefSubtitles::setUseFontASS(bool v) {320 ass_subs_button->setChecked(v);321 normal_subs_button->setChecked(!v);322 }323 324 bool PrefSubtitles::useFontASS() {325 return ass_subs_button->isChecked();326 }327 328 264 void PrefSubtitles::setFontFuzziness(int n) { 329 265 font_autoload_combo->setCurrentIndex(n); … … 358 294 } 359 295 296 /* 360 297 void PrefSubtitles::on_ass_subs_button_toggled(bool b) { 361 if (b) 298 if (b) 362 299 stackedWidget->setCurrentIndex(1); 363 300 else 364 301 stackedWidget->setCurrentIndex(0); 365 302 } 303 */ 366 304 367 305 void PrefSubtitles::on_ass_customize_button_clicked() { … … 413 351 void PrefSubtitles::on_freetype_check_toggled(bool b) { 414 352 qDebug("PrefSubtitles:on_freetype_check_toggled: %d", b); 415 if (!b) { 416 ass_subs_button->setChecked(false); 417 normal_subs_button->setChecked(true); 418 } 419 } 420 353 } 354 355 #ifdef FONTS_HACK 421 356 void PrefSubtitles::on_windowsfontdir_check_toggled(bool b) { 422 357 qDebug("PrefSubtitles::on_windowsfontdir_check_toggled: %d", b); 423 358 424 #ifdef Q_OS_WIN425 359 if (b) { 426 360 style_font_combo->setFontsFromDir(QString::null); 427 fontCombo->setFontsFromDir(QString::null);428 361 } else { 429 362 QString fontdir = Paths::fontPath(); … … 433 366 // Calling setFontsFromDir resets the fonts in other comboboxes! 434 367 // So the font list is copied from the previous combobox 368 /* 435 369 QString current_text = fontCombo->currentText(); 436 370 fontCombo->clear(); … … 439 373 } 440 374 fontCombo->setCurrentText(current_text); 375 */ 441 376 } 377 } 442 378 #endif 443 }444 379 445 380 void PrefSubtitles::createHelp() { … … 465 400 "tried to be autodetected for the given language. " 466 401 "It will fall back to the default encoding if the autodetection " 467 "fails. This option requires a MPlayer compiledwith ENCA "468 "support.") );402 "fails. This option requires a %1 with ENCA " 403 "support.").arg(PLAYER_NAME) ); 469 404 470 405 setWhatsThis(enca_lang_combo, tr("Subtitle language"), … … 477 412 "screenshots. <b>Note:</b> it may cause some troubles sometimes." ) ); 478 413 414 setWhatsThis(use_ass_check, tr("Use the ASS library"), 415 tr("This option enables the ASS library, which allows to display " 416 "subtitles with multiple colors, fonts...") ); 417 479 418 setWhatsThis(freetype_check, tr("Freetype support"), 480 419 tr("You should normally not disable this option. Do it only if your " 481 " MPlayeris compiled without freetype support. "482 "<b>Disabling this option could make that subtitles won'twork "483 "at all!</b>") 484 485 #ifdef Q_OS_WIN486 setWhatsThis(windowsfontdir_check, tr("Enable Windows fonts"), 420 "%1 is compiled without freetype support. " 421 "<b>Disabling this option could make subtitles not to work " 422 "at all!</b>").arg(PLAYER_NAME)); 423 424 #ifdef FONTS_HACK 425 setWhatsThis(windowsfontdir_check, tr("Enable Windows fonts"), 487 426 tr("If this option is enabled the Windows system fonts will be " 488 427 "available for subtitles. There's an inconvenience: a font cache have " … … 494 433 addSectionTitle(tr("Font")); 495 434 496 setWhatsThis(normal_subs_button, tr("Enable normal subtitles"),497 tr("Click this button to select the normal/traditional subtitles. "498 "This kind of subtitles can only display white subtitles."));499 500 setWhatsThis(ass_subs_button, tr("Enable SSA/ASS subtitles"),501 tr("Click this button to enable the new SSA/ASS library. "502 "This allows to display subtitles with multiple colors, fonts..."));503 504 addSectionTitle(tr("Normal subtitles"));505 506 setWhatsThis(ttf_font_edit, tr("TTF font"),507 tr("Here you can select a ttf font to be used for the subtitles. "508 "Usually you'll find a lot of ttf fonts in %1")509 #ifdef Q_OS_WIN510 .arg("<i>C:\\Windows\\Fonts\\</i>")511 #else512 #ifdef Q_OS_OS2513 .arg("<i>C:\\PSFONTS</i>")514 #else515 .arg("<i>/usr/X11R6/lib/X11/fonts/truetype/</i>")516 #endif517 #endif518 );519 520 setWhatsThis(fontCombo, tr("System font"),521 tr("Here you can select a system font to be used for the subtitles "522 "and OSD.") );523 524 setWhatsThis(font_autoscale_combo, tr("Autoscale"),525 tr("Select the subtitle autoscaling method.") );526 527 435 QString scale_note = tr("This option does NOT change the size of the " 528 436 "subtitles in the current video. To do so, use the options " 529 437 "<i>Size+</i> and <i>Size-</i> in the subtitles menu."); 530 531 setWhatsThis(font_text_scale_spin, tr("Default scale"),532 tr("This option specifies the default font scale for normal "533 "subtitles which will be used for new opened files.") +"<br>"+534 scale_note);535 536 setWhatsThis(sub_pos_slider, tr("Subtitle position"),537 tr("This option specifies the position of the subtitles over the "538 "video window. <i>100</i> means the bottom, while <i>0</i> means "539 "the top." ) );540 541 addSectionTitle(tr("SSA/ASS subtitles"));542 438 543 439 setWhatsThis(ass_font_scale_spin, tr("Default scale"), … … 604 500 "the depth of the drop shadow behind the text in pixels.") ); 605 501 606 setWhatsThis(force_ass_styles, tr("Apply style to assfiles too"),502 setWhatsThis(force_ass_styles, tr("Apply style to ASS files too"), 607 503 tr("If this option is checked, the style defined above will be " 608 504 "applied to ass subtitles too.") );
Note:
See TracChangeset
for help on using the changeset viewer.