| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include "filepropertiesdialog.h"
|
|---|
| 20 | #include <QListWidget>
|
|---|
| 21 | #include <QLineEdit>
|
|---|
| 22 | #include <QTextEdit>
|
|---|
| 23 | #include <QPushButton>
|
|---|
| 24 | #include "images.h"
|
|---|
| 25 | #include "infofile.h"
|
|---|
| 26 | #include "playerid.h"
|
|---|
| 27 |
|
|---|
| 28 | FilePropertiesDialog::FilePropertiesDialog( QWidget* parent, Qt::WindowFlags f )
|
|---|
| 29 | : QDialog(parent, f)
|
|---|
| 30 | {
|
|---|
| 31 | setupUi(this);
|
|---|
| 32 |
|
|---|
| 33 | // Setup buttons
|
|---|
| 34 | okButton = buttonBox->button(QDialogButtonBox::Ok);
|
|---|
| 35 | cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
|
|---|
| 36 | applyButton = buttonBox->button(QDialogButtonBox::Apply);
|
|---|
| 37 | connect( applyButton, SIGNAL(clicked()), this, SLOT(apply()) );
|
|---|
| 38 |
|
|---|
| 39 | #if ALLOW_DEMUXER_CODEC_CHANGE
|
|---|
| 40 | codecs_set = false;
|
|---|
| 41 | #else
|
|---|
| 42 | // Hide unused tabs
|
|---|
| 43 | int i = tabWidget->indexOf(demuxer_page);
|
|---|
| 44 | if (i != -1) tabWidget->removeTab(i);
|
|---|
| 45 | i = tabWidget->indexOf(vc_page);
|
|---|
| 46 | if (i != -1) tabWidget->removeTab(i);
|
|---|
| 47 | i = tabWidget->indexOf(ac_page);
|
|---|
| 48 | if (i != -1) tabWidget->removeTab(i);
|
|---|
| 49 | #endif
|
|---|
| 50 |
|
|---|
| 51 | retranslateStrings();
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | FilePropertiesDialog::~FilePropertiesDialog() {
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | void FilePropertiesDialog::setMediaData(MediaData md) {
|
|---|
| 58 | media_data = md;
|
|---|
| 59 | showInfo();
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | void FilePropertiesDialog::showInfo() {
|
|---|
| 63 | InfoFile info;
|
|---|
| 64 | info_edit->setText( info.getInfo(media_data) );
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | void FilePropertiesDialog::retranslateStrings() {
|
|---|
| 68 | retranslateUi(this);
|
|---|
| 69 |
|
|---|
| 70 | setWindowIcon( Images::icon("logo") );
|
|---|
| 71 |
|
|---|
| 72 | showInfo();
|
|---|
| 73 |
|
|---|
| 74 | // Qt 4.2 doesn't update the buttons' text
|
|---|
| 75 | #if QT_VERSION < 0x040300
|
|---|
| 76 | okButton->setText( tr("OK") );
|
|---|
| 77 | cancelButton->setText( tr("Cancel") );
|
|---|
| 78 | applyButton->setText( tr("Apply") );
|
|---|
| 79 | #endif
|
|---|
| 80 |
|
|---|
| 81 | #if ALLOW_DEMUXER_CODEC_CHANGE
|
|---|
| 82 | int tab_idx = 4;
|
|---|
| 83 | #else
|
|---|
| 84 | int tab_idx = 1;
|
|---|
| 85 | #endif
|
|---|
| 86 | tabWidget->setTabText(tab_idx, tr("O&ptions for %1").arg(PLAYER_NAME) );
|
|---|
| 87 | groupBox->setTitle( tr("Additional Options for %1").arg(PLAYER_NAME) );
|
|---|
| 88 | options_info_label->setText( tr("Here you can pass extra options to %1.").arg(PLAYER_NAME) +"<br>"+
|
|---|
| 89 | tr("Write them separated by spaces.") + "<br>" + tr("Example:") + " -volume 50 -fps 25" );
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | void FilePropertiesDialog::accept() {
|
|---|
| 93 | qDebug("FilePropertiesDialog::accept");
|
|---|
| 94 |
|
|---|
| 95 | hide();
|
|---|
| 96 | setResult( QDialog::Accepted );
|
|---|
| 97 | emit applied();
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | void FilePropertiesDialog::apply() {
|
|---|
| 101 | qDebug("FilePropertiesDialog::apply");
|
|---|
| 102 |
|
|---|
| 103 | setResult( QDialog::Accepted );
|
|---|
| 104 | emit applied();
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | #if ALLOW_DEMUXER_CODEC_CHANGE
|
|---|
| 108 | void FilePropertiesDialog::setCodecs(InfoList vc, InfoList ac, InfoList demuxer)
|
|---|
| 109 | {
|
|---|
| 110 | vclist = vc;
|
|---|
| 111 | aclist = ac;
|
|---|
| 112 | demuxerlist = demuxer;
|
|---|
| 113 |
|
|---|
| 114 | qSort(vclist);
|
|---|
| 115 | qSort(aclist);
|
|---|
| 116 | qSort(demuxerlist);
|
|---|
| 117 |
|
|---|
| 118 | vc_listbox->clear();
|
|---|
| 119 | ac_listbox->clear();
|
|---|
| 120 | demuxer_listbox->clear();
|
|---|
| 121 |
|
|---|
| 122 | InfoList::iterator it;
|
|---|
| 123 |
|
|---|
| 124 | for ( it = vclist.begin(); it != vclist.end(); ++it ) {
|
|---|
| 125 | vc_listbox->addItem( (*it).name() +" - "+ (*it).desc() );
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | for ( it = aclist.begin(); it != aclist.end(); ++it ) {
|
|---|
| 129 | ac_listbox->addItem( (*it).name() +" - "+ (*it).desc() );
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | for ( it = demuxerlist.begin(); it != demuxerlist.end(); ++it ) {
|
|---|
| 133 | demuxer_listbox->addItem( (*it).name() +" - "+ (*it).desc() );
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | codecs_set = true;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | void FilePropertiesDialog::setDemuxer(QString demuxer, QString original_demuxer) {
|
|---|
| 140 | qDebug("FilePropertiesDialog::setDemuxer");
|
|---|
| 141 | if (!original_demuxer.isEmpty()) orig_demuxer = original_demuxer;
|
|---|
| 142 | int pos = find(demuxer, demuxerlist );
|
|---|
| 143 | if (pos != -1) demuxer_listbox->setCurrentRow(pos);
|
|---|
| 144 |
|
|---|
| 145 | qDebug(" * demuxer: '%s', pos: %d", demuxer.toUtf8().data(), pos );
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | QString FilePropertiesDialog::demuxer() {
|
|---|
| 149 | int pos = demuxer_listbox->currentRow();
|
|---|
| 150 | if ( pos < 0 )
|
|---|
| 151 | return "";
|
|---|
| 152 | else
|
|---|
| 153 | return demuxerlist[pos].name();
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | void FilePropertiesDialog::setVideoCodec(QString vc, QString original_vc) {
|
|---|
| 157 | qDebug("FilePropertiesDialog::setVideoCodec");
|
|---|
| 158 | if (!original_vc.isEmpty()) orig_vc = original_vc;
|
|---|
| 159 | int pos = find(vc, vclist );
|
|---|
| 160 | if (pos != -1) vc_listbox->setCurrentRow(pos);
|
|---|
| 161 |
|
|---|
| 162 | qDebug(" * vc: '%s', pos: %d", vc.toUtf8().data(), pos );
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | QString FilePropertiesDialog::videoCodec() {
|
|---|
| 166 | int pos = vc_listbox->currentRow();
|
|---|
| 167 | if ( pos < 0 )
|
|---|
| 168 | return "";
|
|---|
| 169 | else
|
|---|
| 170 | return vclist[pos].name();
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | void FilePropertiesDialog::setAudioCodec(QString ac, QString original_ac) {
|
|---|
| 174 | qDebug("FilePropertiesDialog::setAudioCodec");
|
|---|
| 175 | if (!original_ac.isEmpty()) orig_ac = original_ac;
|
|---|
| 176 | int pos = find(ac, aclist );
|
|---|
| 177 | if (pos != -1) ac_listbox->setCurrentRow(pos);
|
|---|
| 178 |
|
|---|
| 179 | qDebug(" * ac: '%s', pos: %d", ac.toUtf8().data(), pos );
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | QString FilePropertiesDialog::audioCodec() {
|
|---|
| 183 | int pos = ac_listbox->currentRow();
|
|---|
| 184 | if ( pos < 0 )
|
|---|
| 185 | return "";
|
|---|
| 186 | else
|
|---|
| 187 | return aclist[pos].name();
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | void FilePropertiesDialog::on_resetDemuxerButton_clicked() {
|
|---|
| 191 | setDemuxer( orig_demuxer );
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | void FilePropertiesDialog::on_resetACButton_clicked() {
|
|---|
| 195 | setAudioCodec( orig_ac );
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | void FilePropertiesDialog::on_resetVCButton_clicked() {
|
|---|
| 199 | setVideoCodec( orig_vc );
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | int FilePropertiesDialog::find(QString s, InfoList &list) {
|
|---|
| 203 | qDebug("FilePropertiesDialog::find");
|
|---|
| 204 |
|
|---|
| 205 | int n=0;
|
|---|
| 206 | InfoList::iterator it;
|
|---|
| 207 |
|
|---|
| 208 | for ( it = list.begin(); it != list.end(); ++it ) {
|
|---|
| 209 | //qDebug(" * item: '%s', s: '%s'", (*it).name().toUtf8().data(), s.toUtf8().data());
|
|---|
| 210 | if ((*it).name() == s) return n;
|
|---|
| 211 | n++;
|
|---|
| 212 | }
|
|---|
| 213 | return -1;
|
|---|
| 214 | }
|
|---|
| 215 | #endif
|
|---|
| 216 |
|
|---|
| 217 | void FilePropertiesDialog::setMplayerAdditionalArguments(QString args) {
|
|---|
| 218 | mplayer_args_edit->setText(args);
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | QString FilePropertiesDialog::mplayerAdditionalArguments() {
|
|---|
| 222 | return mplayer_args_edit->text();
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | void FilePropertiesDialog::setMplayerAdditionalVideoFilters(QString s) {
|
|---|
| 226 | mplayer_vfilters_edit->setText(s);
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | QString FilePropertiesDialog::mplayerAdditionalVideoFilters() {
|
|---|
| 230 | return mplayer_vfilters_edit->text();
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | void FilePropertiesDialog::setMplayerAdditionalAudioFilters(QString s) {
|
|---|
| 234 | mplayer_afilters_edit->setText(s);
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | QString FilePropertiesDialog::mplayerAdditionalAudioFilters() {
|
|---|
| 238 | return mplayer_afilters_edit->text();
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | // Language change stuff
|
|---|
| 242 | void FilePropertiesDialog::changeEvent(QEvent *e) {
|
|---|
| 243 | if (e->type() == QEvent::LanguageChange) {
|
|---|
| 244 | retranslateStrings();
|
|---|
| 245 | } else {
|
|---|
| 246 | QDialog::changeEvent(e);
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | #include "moc_filepropertiesdialog.cpp"
|
|---|