Ignore:
Timestamp:
May 3, 2016, 2:14:41 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update vendor to version 16.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smplayer/vendor/current/src/prefsubtitles.cpp

    r168 r175  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    2525#include "filedialog.h"
    2626#include "languages.h"
     27#include "playerid.h"
    2728
    2829#include <QInputDialog>
     
    3334        setupUi(this);
    3435
    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        */
    3945
    4046        connect( style_border_style_combo, SIGNAL(currentIndexChanged(int)),
    4147             this, SLOT(checkBorderStyleCombo(int)) );
    4248
    43 #ifndef Q_OS_WIN
     49#ifndef FONTS_HACK
    4450        windowsfontdir_check->hide();
    4551#endif
     
    6268
    6369void PrefSubtitles::retranslateStrings() {
    64         int font_autoscale_item = font_autoscale_combo->currentIndex();
    6570        int font_autoload_item = font_autoload_combo->currentIndex();
    6671
    6772        retranslateUi(this);
    6873
    69         font_autoscale_combo->setCurrentIndex(font_autoscale_item);
    7074        font_autoload_combo->setCurrentIndex(font_autoload_item);
    7175
     
    8387                font_encoding_combo->addItem( i.value() + " (" + i.key() + ")", i.key() );
    8488        }
    85         l = Languages::list(); i = l;
     89
     90        l = Languages::enca();
     91        i = l;
    8692        while (i.hasNext()) {
    8793                i.next();
    8894                enca_lang_combo->addItem( i.value() + " (" + i.key() + ")", i.key() );
    8995        }
     96
    9097        font_encoding_combo->model()->sort(0);
    9198        enca_lang_combo->model()->sort(0);
     
    94101        setEncaLang(current_enca_lang);
    95102
    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 
    101103        // Ass styles
    102104        int alignment_item = style_alignment_combo->currentIndex();
    103105        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);
    107109        style_alignment_combo->setCurrentIndex(alignment_item);
    108110
    109111        int valignment_item = style_valignment_combo->currentIndex();
    110112        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);
    114116        style_valignment_combo->setCurrentIndex(valignment_item);
    115117
    116118        int borderstyle_item = style_border_style_combo->currentIndex();
    117119        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);
    120122        style_border_style_combo->setCurrentIndex(borderstyle_item);
    121123
     
    124126
    125127void 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 );
    131128        setAssFontScale( pref->initial_sub_scale_ass );
    132129        setAutoloadSub( pref->autoload_sub );
     
    135132        setUseEnca( pref->use_enca );
    136133        setEncaLang( pref->enca_lang );
    137         setUseFontASS( pref->use_ass_subtitles );
    138134        setAssLineSpacing( pref->ass_line_spacing );
    139         setSubPos( pref->initial_sub_pos );
    140135        setSubtitlesOnScreenshots( pref->subtitles_on_screenshots );
    141136        setFreetypeSupport( pref->freetype_support );
     137        use_ass_check->setChecked( pref->use_ass_subtitles );
    142138
    143139        // Load ass styles
     
    161157        setCustomizedAssStyle(pref->user_forced_ass_style);
    162158
    163 #ifdef Q_OS_WIN
     159        ass_custom_check->setChecked(pref->enable_ass_styles);
     160
     161#ifdef FONTS_HACK
    164162        windowsfontdir_check->setChecked(pref->use_windowsfontdir);
    165163        if (!windowsfontdir_check->isChecked()) on_windowsfontdir_check_toggled(false);
     
    170168        requires_restart = false;
    171169
    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();
    177170        pref->initial_sub_scale_ass = assFontScale();
    178171        TEST_AND_SET(pref->autoload_sub, autoloadSub());
     
    181174        TEST_AND_SET(pref->use_enca, useEnca());
    182175        TEST_AND_SET(pref->enca_lang, encaLang());
    183         TEST_AND_SET(pref->use_ass_subtitles, useFontASS());
    184176        TEST_AND_SET(pref->ass_line_spacing, assLineSpacing());
    185         pref->initial_sub_pos = subPos();
    186177        TEST_AND_SET(pref->subtitles_on_screenshots, subtitlesOnScreenshots());
    187178        TEST_AND_SET(pref->freetype_support, freetypeSupport());
     179        TEST_AND_SET(pref->use_ass_subtitles, use_ass_check->isChecked());
    188180
    189181        // Save ass styles
     
    209201        TEST_AND_SET(pref->user_forced_ass_style, customizedAssStyle());
    210202
    211 #ifdef Q_OS_WIN
     203        TEST_AND_SET(pref->enable_ass_styles, ass_custom_check->isChecked());
     204
     205#ifdef FONTS_HACK
    212206        pref->use_windowsfontdir = windowsfontdir_check->isChecked();
    213207#endif
     
    223217
    224218
    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 }
    266219
    267220void PrefSubtitles::setAssFontScale(double n) {
     
    309262}
    310263
    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 
    328264void PrefSubtitles::setFontFuzziness(int n) {
    329265        font_autoload_combo->setCurrentIndex(n);
     
    358294}
    359295
     296/*
    360297void PrefSubtitles::on_ass_subs_button_toggled(bool b) {
    361         if (b) 
     298        if (b)
    362299                stackedWidget->setCurrentIndex(1);
    363300         else
    364301                stackedWidget->setCurrentIndex(0);
    365302}
     303*/
    366304
    367305void PrefSubtitles::on_ass_customize_button_clicked() {
     
    413351void PrefSubtitles::on_freetype_check_toggled(bool b) {
    414352        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
    421356void PrefSubtitles::on_windowsfontdir_check_toggled(bool b) {
    422357        qDebug("PrefSubtitles::on_windowsfontdir_check_toggled: %d", b);
    423358
    424 #ifdef Q_OS_WIN
    425359        if (b) {
    426360                style_font_combo->setFontsFromDir(QString::null);
    427                 fontCombo->setFontsFromDir(QString::null);
    428361        } else {
    429362                QString fontdir = Paths::fontPath();
     
    433366                // Calling setFontsFromDir resets the fonts in other comboboxes!
    434367                // So the font list is copied from the previous combobox
     368                /*
    435369                QString current_text = fontCombo->currentText();
    436370                fontCombo->clear();
     
    439373                }
    440374                fontCombo->setCurrentText(current_text);
     375                */
    441376        }
     377}
    442378#endif
    443 }
    444379
    445380void PrefSubtitles::createHelp() {
     
    465400           "tried to be autodetected for the given language. "
    466401           "It will fall back to the default encoding if the autodetection "
    467            "fails. This option requires a MPlayer compiled with ENCA "
    468            "support.") );
     402           "fails. This option requires a %1 with ENCA "
     403           "support.").arg(PLAYER_NAME) );
    469404
    470405        setWhatsThis(enca_lang_combo, tr("Subtitle language"),
     
    477412           "screenshots. <b>Note:</b> it may cause some troubles sometimes." ) );
    478413
     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
    479418        setWhatsThis(freetype_check, tr("Freetype support"),
    480419                tr("You should normally not disable this option. Do it only if your "
    481            "MPlayer is compiled without freetype support. "
    482            "<b>Disabling this option could make that subtitles won't work "
    483            "at all!</b>") );
    484 
    485 #ifdef Q_OS_WIN
    486         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"),
    487426                tr("If this option is enabled the Windows system fonts will be "
    488427           "available for subtitles. There's an inconvenience: a font cache have "
     
    494433        addSectionTitle(tr("Font"));
    495434
    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_WIN
    510         .arg("<i>C:\\Windows\\Fonts\\</i>")
    511 #else
    512 #ifdef Q_OS_OS2
    513         .arg("<i>C:\\PSFONTS</i>")
    514 #else
    515         .arg("<i>/usr/X11R6/lib/X11/fonts/truetype/</i>")
    516 #endif
    517 #endif
    518         );
    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 
    527435        QString scale_note = tr("This option does NOT change the size of the "
    528                    "subtitles in the current video. To do so, use the options "
     436           "subtitles in the current video. To do so, use the options "
    529437           "<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"));
    542438
    543439        setWhatsThis(ass_font_scale_spin, tr("Default scale"),
     
    604500           "the depth of the drop shadow behind the text in pixels.") );
    605501
    606         setWhatsThis(force_ass_styles, tr("Apply style to ass files too"),
     502        setWhatsThis(force_ass_styles, tr("Apply style to ASS files too"),
    607503        tr("If this option is checked, the style defined above will be "
    608504           "applied to ass subtitles too.") );
Note: See TracChangeset for help on using the changeset viewer.