source: smplayer/trunk/src/prefadvanced.cpp@ 102

Last change on this file since 102 was 93, checked in by Silvan Scherrer, 15 years ago

smplayer: 0.6.9

File size: 15.1 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
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
20#include "prefadvanced.h"
21#include "images.h"
22#include "preferences.h"
23#include "paths.h"
24#include <QColorDialog>
25
26PrefAdvanced::PrefAdvanced(QWidget * parent, Qt::WindowFlags f)
27 : PrefWidget(parent, f )
28{
29 setupUi(this);
30
31#ifndef Q_OS_WIN
32 shortnames_check->hide();
33#endif
34
35#if !USE_COLORKEY
36 colorkey_label->hide();
37 colorkey_view->hide();
38 changeButton->hide();
39#endif
40
41#if !REPAINT_BACKGROUND_OPTION
42 repaint_video_background_check->hide();
43#endif
44
45 // Monitor aspect
46 monitoraspect_combo->addItem("Auto");
47 monitoraspect_combo->addItem("4:3");
48 monitoraspect_combo->addItem("16:9");
49 monitoraspect_combo->addItem("5:4");
50 monitoraspect_combo->addItem("16:10");
51
52 retranslateStrings();
53}
54
55PrefAdvanced::~PrefAdvanced()
56{
57}
58
59QString PrefAdvanced::sectionName() {
60 return tr("Advanced");
61}
62
63QPixmap PrefAdvanced::sectionIcon() {
64 return Images::icon("pref_advanced");
65}
66
67
68void PrefAdvanced::retranslateStrings() {
69 retranslateUi(this);
70
71 monitor_aspect_icon->setPixmap( Images::icon("monitor") );
72
73 monitoraspect_combo->setItemText(0, tr("Auto") );
74
75 createHelp();
76}
77
78void PrefAdvanced::setData(Preferences * pref) {
79 setMonitorAspect( pref->monitor_aspect );
80
81#if REPAINT_BACKGROUND_OPTION
82 setRepaintVideoBackground( pref->repaint_video_background );
83#endif
84 setUseMplayerWindow( pref->use_mplayer_window );
85 setMplayerAdditionalArguments( pref->mplayer_additional_options );
86 setMplayerAdditionalVideoFilters( pref->mplayer_additional_video_filters );
87 setMplayerAdditionalAudioFilters( pref->mplayer_additional_audio_filters );
88#if USE_COLORKEY
89 setColorKey( pref->color_key );
90#endif
91 setPreferIpv4( pref->prefer_ipv4 );
92 setUseIdx( pref->use_idx );
93 setUseCorrectPts( pref->use_correct_pts );
94 setActionsToRun( pref->actions_to_run );
95
96 setLogMplayer( pref->log_mplayer );
97 setMplayerLogVerbose( pref->verbose_log );
98 setLogSmplayer( pref->log_smplayer );
99 setLogFilter( pref->log_filter );
100
101 setSaveMplayerLog( pref->autosave_mplayer_log );
102 setMplayerLogName( pref->mplayer_log_saveto );
103
104 setSaveSmplayerLog( pref->save_smplayer_log );
105
106 setUseShortNames( pref->use_short_pathnames );
107}
108
109void PrefAdvanced::getData(Preferences * pref) {
110 requires_restart = false;
111
112#if REPAINT_BACKGROUND_OPTION
113 repaint_video_background_changed = false;
114#endif
115
116 monitor_aspect_changed = false;
117#if USE_COLORKEY
118 colorkey_changed = false;
119#endif
120 pref->prefer_ipv4 = preferIpv4();
121 TEST_AND_SET(pref->use_idx, useIdx());
122 TEST_AND_SET(pref->use_correct_pts, useCorrectPts());
123 pref->actions_to_run = actionsToRun();
124
125 if (pref->monitor_aspect != monitorAspect()) {
126 pref->monitor_aspect = monitorAspect();
127 monitor_aspect_changed = true;
128 requires_restart = true;
129 }
130
131#if REPAINT_BACKGROUND_OPTION
132 if (pref->repaint_video_background != repaintVideoBackground()) {
133 pref->repaint_video_background = repaintVideoBackground();
134 repaint_video_background_changed = true;
135 }
136#endif
137
138 TEST_AND_SET(pref->use_mplayer_window, useMplayerWindow());
139 TEST_AND_SET(pref->mplayer_additional_options, mplayerAdditionalArguments());
140 TEST_AND_SET(pref->mplayer_additional_video_filters, mplayerAdditionalVideoFilters());
141 TEST_AND_SET(pref->mplayer_additional_audio_filters, mplayerAdditionalAudioFilters());
142#if USE_COLORKEY
143 if (pref->color_key != colorKey()) {
144 pref->color_key = colorKey();
145 colorkey_changed = true;
146 requires_restart = true;
147 }
148#endif
149 pref->log_mplayer = logMplayer();
150 TEST_AND_SET( pref->verbose_log, mplayerLogVerbose() );
151 pref->log_smplayer = logSmplayer();
152 pref->log_filter = logFilter();
153 pref->autosave_mplayer_log = saveMplayerLog();
154 pref->mplayer_log_saveto = mplayerLogName();
155
156 pref->save_smplayer_log = saveSmplayerLog();
157
158 pref->use_short_pathnames = useShortNames();
159}
160
161void PrefAdvanced::setMonitorAspect(QString asp) {
162 if (asp.isEmpty())
163 monitoraspect_combo->setCurrentIndex( 0 );
164 else
165 monitoraspect_combo->setCurrentText(asp);
166 //monitoraspect_combo->setEditText(asp);
167}
168
169QString PrefAdvanced::monitorAspect() {
170 if (monitoraspect_combo->currentIndex() == 0 )
171 return "";
172 else
173 return monitoraspect_combo->currentText();
174}
175
176#if REPAINT_BACKGROUND_OPTION
177void PrefAdvanced::setRepaintVideoBackground(bool b) {
178 repaint_video_background_check->setChecked(b);
179}
180
181bool PrefAdvanced::repaintVideoBackground() {
182 return repaint_video_background_check->isChecked();
183}
184#endif
185
186void PrefAdvanced::setUseMplayerWindow(bool v) {
187 mplayer_use_window_check->setChecked(v);
188}
189
190bool PrefAdvanced::useMplayerWindow() {
191 return mplayer_use_window_check->isChecked();
192}
193
194void PrefAdvanced::setUseShortNames(bool b) {
195 shortnames_check->setChecked(b);
196}
197
198bool PrefAdvanced::useShortNames() {
199 return shortnames_check->isChecked();
200}
201
202void PrefAdvanced::setMplayerAdditionalArguments(QString args) {
203 mplayer_args_edit->setText(args);
204}
205
206QString PrefAdvanced::mplayerAdditionalArguments() {
207 return mplayer_args_edit->text();
208}
209
210void PrefAdvanced::setMplayerAdditionalVideoFilters(QString s) {
211 mplayer_vfilters_edit->setText(s);
212}
213
214QString PrefAdvanced::mplayerAdditionalVideoFilters() {
215 return mplayer_vfilters_edit->text();
216}
217
218void PrefAdvanced::setMplayerAdditionalAudioFilters(QString s) {
219 mplayer_afilters_edit->setText(s);
220}
221
222QString PrefAdvanced::mplayerAdditionalAudioFilters() {
223 return mplayer_afilters_edit->text();
224}
225
226#if USE_COLORKEY
227void PrefAdvanced::setColorKey(unsigned int c) {
228 QString color = QString::number(c, 16);
229 while (color.length() < 6) color = "0"+color;
230 colorkey_view->setText( "#" + color );
231}
232
233unsigned int PrefAdvanced::colorKey() {
234 QString c = colorkey_view->text();
235 if (c.startsWith("#")) c = c.mid(1);
236
237 bool ok;
238 unsigned int color = c.toUInt(&ok, 16);
239
240 if (!ok)
241 qWarning("PrefAdvanced::colorKey: cannot convert color to uint");
242
243 qDebug("PrefAdvanced::colorKey: color: %s", QString::number(color,16).toUtf8().data() );
244
245 return color;
246}
247#endif
248
249void PrefAdvanced::setPreferIpv4(bool b) {
250 if (b)
251 ipv4_button->setChecked(true);
252 else
253 ipv6_button->setChecked(true);
254}
255
256bool PrefAdvanced::preferIpv4() {
257 return ipv4_button->isChecked();
258}
259
260void PrefAdvanced::setUseIdx(bool b) {
261 idx_check->setChecked(b);
262}
263
264bool PrefAdvanced::useIdx() {
265 return idx_check->isChecked();
266}
267
268void PrefAdvanced::setUseCorrectPts(Preferences::OptionState value) {
269 correct_pts_combo->setState(value);
270}
271
272Preferences::OptionState PrefAdvanced::useCorrectPts() {
273 return correct_pts_combo->state();
274}
275
276void PrefAdvanced::setActionsToRun(QString actions) {
277 actions_to_run_edit->setText(actions);
278}
279
280QString PrefAdvanced::actionsToRun() {
281 return actions_to_run_edit->text();
282}
283
284void PrefAdvanced::on_changeButton_clicked() {
285 //bool ok;
286 //int color = colorkey_view->text().toUInt(&ok, 16);
287 QColor color( colorkey_view->text() );
288 QColor c = QColorDialog::getColor ( color, this );
289 if (c.isValid()) {
290 //colorkey_view->setText( QString::number( c.rgb(), 16 ) );
291 colorkey_view->setText( c.name() );
292 }
293}
294
295// Log options
296void PrefAdvanced::setLogMplayer(bool b) {
297 log_mplayer_check->setChecked(b);
298}
299
300bool PrefAdvanced::logMplayer() {
301 return log_mplayer_check->isChecked();
302}
303
304void PrefAdvanced::setMplayerLogVerbose(bool b) {
305 verbose_check->setChecked(b);
306}
307
308bool PrefAdvanced::mplayerLogVerbose() {
309 return verbose_check->isChecked();
310}
311
312void PrefAdvanced::setLogSmplayer(bool b) {
313 log_smplayer_check->setChecked(b);
314}
315
316bool PrefAdvanced::logSmplayer() {
317 return log_smplayer_check->isChecked();
318}
319
320void PrefAdvanced::setLogFilter(QString filter) {
321 log_filter_edit->setText(filter);
322}
323
324QString PrefAdvanced::logFilter() {
325 return log_filter_edit->text();
326}
327
328
329void PrefAdvanced::setSaveMplayerLog(bool b) {
330 log_mplayer_save_check->setChecked(b);
331}
332
333bool PrefAdvanced::saveMplayerLog() {
334 return log_mplayer_save_check->isChecked();
335}
336
337void PrefAdvanced::setMplayerLogName(QString filter) {
338 log_mplayer_save_name->setText(filter);
339}
340
341QString PrefAdvanced::mplayerLogName() {
342 return log_mplayer_save_name->text();
343}
344
345void PrefAdvanced::setSaveSmplayerLog(bool b) {
346 log_smplayer_save_check->setChecked(b);
347}
348
349bool PrefAdvanced::saveSmplayerLog(){
350 return log_smplayer_save_check->isChecked();
351}
352
353
354void PrefAdvanced::createHelp() {
355 clearHelp();
356
357 addSectionTitle(tr("Advanced"));
358
359 setWhatsThis(monitoraspect_combo, tr("Monitor aspect"),
360 tr("Select the aspect ratio of your monitor.") );
361
362 setWhatsThis(mplayer_use_window_check, tr("Run MPlayer in its own window"),
363 tr("If you check this option, the MPlayer video window won't be "
364 "embedded in SMPlayer's main window but instead it will use its "
365 "own window. Note that mouse and keyboard events will be handled "
366 "directly by MPlayer, that means key shortcuts and mouse clicks "
367 "probably won't work as expected when the MPlayer window has the "
368 "focus.") );
369
370 setWhatsThis(idx_check, tr("Rebuild index if needed"),
371 tr("Rebuilds index of files if no index was found, allowing seeking. "
372 "Useful with broken/incomplete downloads, or badly created files. "
373 "This option only works if the underlying media supports "
374 "seeking (i.e. not with stdin, pipe, etc).<br> "
375 "<b>Note:</b> the creation of the index may take some time.") );
376
377 setWhatsThis(correct_pts_combo, tr("Correct pts"),
378 tr("Switches MPlayer to an experimental mode where timestamps for "
379 "video frames are calculated differently and video filters which "
380 "add new frames or modify timestamps of existing ones are "
381 "supported. The more accurate timestamps can be visible for "
382 "example when playing subtitles timed to scene changes with the "
383 "SSA/ASS library enabled. Without correct pts the subtitle timing "
384 "will typically be off by some frames. This option does not work "
385 "correctly with some demuxers and codecs.") );
386
387#ifdef Q_OS_WIN
388 setWhatsThis(shortnames_check, tr("Pass short filenames (8+3) to MPlayer"),
389 tr("Currently MPlayer can't open filenames which contains characters "
390 "outside the local codepage. Checking this option will make "
391 "SMPlayer to pass to MPlayer the short version of the filenames, "
392 "and thus it will able to open them.") );
393#endif
394
395#if REPAINT_BACKGROUND_OPTION
396 setWhatsThis(repaint_video_background_check,
397 tr("Repaint the background of the video window"),
398 tr("Checking this option may reduce flickering, but it also might "
399 "produce that the video won't be displayed properly.") );
400#endif
401
402#if USE_COLORKEY
403 setWhatsThis(colorkey_view, tr("Colorkey"),
404 tr("If you see parts of the video over any other window, you can "
405 "change the colorkey to fix it. Try to select a color close to "
406 "black.") );
407#endif
408
409 setWhatsThis(actions_to_run_edit, tr("Actions list"),
410 tr("Here you can specify a list of <i>actions</i> which will be "
411 "run every time a file is opened. You'll find all available "
412 "actions in the key shortcut editor in the <b>Keyboard and mouse</b> "
413 "section. The actions must be separated by spaces. Checkable "
414 "actions can be followed by <i>true</i> or <i>false</i> to "
415 "enable or disable the action.") +"<br>"+
416 tr("Example:") +" <i>auto_zoom compact true</i><br>" +
417 tr("Limitation: the actions are run only when a file is opened and "
418 "not when the mplayer process is restarted (e.g. you select an "
419 "audio or video filter).") );
420
421 addSectionTitle(tr("Options for MPlayer"));
422
423 setWhatsThis(mplayer_args_edit, tr("Options"),
424 tr("Here you can type options for MPlayer. Write them separated "
425 "by spaces.") );
426
427 setWhatsThis(mplayer_vfilters_edit, tr("Video filters"),
428 tr("Here you can add video filters for MPlayer. Write them separated "
429 "by commas. Don't use spaces!") );
430
431 setWhatsThis(mplayer_afilters_edit, tr("Audio filters"),
432 tr("Here you can add audio filters for MPlayer. Write them separated "
433 "by commas. Don't use spaces!") );
434
435 addSectionTitle(tr("Network"));
436
437 setWhatsThis(ipv4_button, tr("IPv4"),
438 tr("Use IPv4 on network connections. Falls back on IPv6 automatically."));
439
440 setWhatsThis(ipv6_button, tr("IPv6"),
441 tr("Use IPv6 on network connections. Falls back on IPv4 automatically."));
442
443 addSectionTitle(tr("Logs"));
444
445 setWhatsThis(log_smplayer_check, tr("Log SMPlayer output"),
446 tr("If this option is checked, SMPlayer will store the debugging "
447 "messages that SMPlayer outputs "
448 "(you can see the log in <b>Options -> View logs -> SMPlayer</b>). "
449 "This information can be very useful for the developer in case "
450 "you find a bug." ) );
451
452 setWhatsThis(log_smplayer_save_check, tr("Save SMPlayer log to file"),
453 tr("If this option is checked, the SMPlayer log wil be recorded to %1")
454 .arg( "<i>"+ Paths::configPath() + "/smplayer_log.txt</i>" ) );
455
456 setWhatsThis(log_mplayer_check, tr("Log MPlayer output"),
457 tr("If checked, SMPlayer will store the output of MPlayer "
458 "(you can see it in <b>Options -> View logs -> MPlayer</b>). "
459 "In case of problems this log can contain important information, "
460 "so it's recommended to keep this option checked.") );
461
462 setWhatsThis(log_mplayer_save_check, tr("Autosave MPlayer log"),
463 tr("If this option is checked, the MPlayer log will be saved to the "
464 "specified file every time a new file starts to play. "
465 "It's intended for external applications, so they can get "
466 "info about the file you're playing.") );
467
468 setWhatsThis(log_mplayer_save_name, tr("Autosave MPlayer log filename"),
469 tr("Enter here the path and filename that will be used to save the "
470 "MPlayer log.") );
471
472 setWhatsThis(log_filter_edit, tr("Filter for SMPlayer logs"),
473 tr("This option allows to filter the SMPlayer messages that will "
474 "be stored in the log. Here you can write any regular expression.<br>"
475 "For instance: <i>^Core::.*</i> will display only the lines "
476 "starting with <i>Core::</i>") );
477
478}
479
480#include "moc_prefadvanced.cpp"
Note: See TracBrowser for help on using the repository browser.