source: smplayer/vendor/0.8.2/src/basegui.cpp

Last change on this file was 137, checked in by Silvan Scherrer, 13 years ago

SMPlayer: updated vendor to 0.8.2

File size: 143.7 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2012 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 "basegui.h"
20
21#include "filedialog.h"
22#include <QMessageBox>
23#include <QLabel>
24#include <QMenu>
25#include <QFileInfo>
26#include <QApplication>
27#include <QMenuBar>
28#include <QHBoxLayout>
29#include <QCursor>
30#include <QTimer>
31#include <QStyle>
32#include <QRegExp>
33#include <QStatusBar>
34#include <QActionGroup>
35#include <QUrl>
36#include <QDragEnterEvent>
37#include <QDropEvent>
38#include <QDesktopServices>
39#include <QInputDialog>
40
41#include <cmath>
42
43#include "mplayerwindow.h"
44#include "desktopinfo.h"
45#include "helper.h"
46#include "paths.h"
47#include "colorutils.h"
48#include "global.h"
49#include "translator.h"
50#include "images.h"
51#include "preferences.h"
52#include "discname.h"
53#include "timeslider.h"
54#include "logwindow.h"
55#include "playlist.h"
56#include "filepropertiesdialog.h"
57#include "eqslider.h"
58#include "videoequalizer.h"
59#include "audioequalizer.h"
60#include "inputdvddirectory.h"
61#include "inputmplayerversion.h"
62#include "inputurl.h"
63#include "recents.h"
64#include "urlhistory.h"
65#include "about.h"
66#include "errordialog.h"
67#include "timedialog.h"
68#include "clhelp.h"
69#include "mplayerversion.h"
70
71#ifdef FIND_SUBTITLES
72#include "findsubtitleswindow.h"
73#endif
74
75#ifdef VIDEOPREVIEW
76#include "videopreview.h"
77#endif
78
79#include "config.h"
80#include "actionseditor.h"
81
82#include "tvlist.h"
83
84#include "preferencesdialog.h"
85#ifndef NO_USE_INI_FILES
86#include "prefgeneral.h"
87#endif
88#include "prefinterface.h"
89#include "prefinput.h"
90#include "prefadvanced.h"
91#include "prefplaylist.h"
92
93#include "myaction.h"
94#include "myactiongroup.h"
95#include "playlist.h"
96
97#include "constants.h"
98
99#include "extensions.h"
100
101#ifdef Q_OS_WIN
102#include "deviceinfo.h"
103#include <QSysInfo>
104#endif
105
106using namespace Global;
107
108BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
109 : QMainWindow( parent, flags ),
110 near_top(false),
111 near_bottom(false)
112{
113#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
114 /* Disable screensaver by event */
115 just_stopped = false;
116#endif
117 ignore_show_hide_events = false;
118
119 arg_close_on_finish = -1;
120 arg_start_in_fullscreen = -1;
121
122 setWindowTitle( "SMPlayer" );
123
124 // Not created objects
125 popup = 0;
126 pref_dialog = 0;
127 file_dialog = 0;
128 clhelp_window = 0;
129#ifdef FIND_SUBTITLES
130 find_subs_dialog = 0;
131#endif
132#ifdef VIDEOPREVIEW
133 video_preview = 0;
134#endif
135
136 // Create objects:
137 createPanel();
138 setCentralWidget(panel);
139
140 createMplayerWindow();
141 createCore();
142 createPlaylist();
143 createVideoEqualizer();
144 createAudioEqualizer();
145
146 // Mouse Wheel
147 connect( this, SIGNAL(wheelUp()),
148 core, SLOT(wheelUp()) );
149 connect( this, SIGNAL(wheelDown()),
150 core, SLOT(wheelDown()) );
151 connect( mplayerwindow, SIGNAL(wheelUp()),
152 core, SLOT(wheelUp()) );
153 connect( mplayerwindow, SIGNAL(wheelDown()),
154 core, SLOT(wheelDown()) );
155
156 // Set style before changing color of widgets:
157 // Set style
158#if STYLE_SWITCHING
159 qDebug( "Style name: '%s'", qApp->style()->objectName().toUtf8().data() );
160 qDebug( "Style class name: '%s'", qApp->style()->metaObject()->className() );
161
162 default_style = qApp->style()->objectName();
163 if (!pref->style.isEmpty()) {
164 qApp->setStyle( pref->style );
165 }
166#endif
167
168#ifdef LOG_MPLAYER
169 mplayer_log_window = new LogWindow(0);
170#endif
171#ifdef LOG_SMPLAYER
172 smplayer_log_window = new LogWindow(0);
173#endif
174
175 createActions();
176 createMenus();
177#if AUTODISABLE_ACTIONS
178 setActionsEnabled(false);
179#endif
180
181#if !DOCK_PLAYLIST
182 connect(playlist, SIGNAL(visibilityChanged(bool)),
183 showPlaylistAct, SLOT(setChecked(bool)) );
184#endif
185
186 retranslateStrings();
187
188 setAcceptDrops(true);
189
190 resize(pref->default_size);
191
192 panel->setFocus();
193
194 initializeGui();
195}
196
197void BaseGui::initializeGui() {
198 if (pref->compact_mode) toggleCompactMode(TRUE);
199 changeStayOnTop(pref->stay_on_top);
200
201#if ALLOW_CHANGE_STYLESHEET
202 changeStyleSheet(pref->iconset);
203#endif
204
205 updateRecents();
206
207 // Call loadActions() outside initialization of the class.
208 // Otherwise DefaultGui (and other subclasses) doesn't exist, and
209 // its actions are not loaded
210 QTimer::singleShot(20, this, SLOT(loadActions()));
211
212 // Single instance
213 /* Deleted */
214}
215
216#ifdef SINGLE_INSTANCE
217void BaseGui::handleMessageFromOtherInstances(const QString& message) {
218 qDebug("BaseGui::handleMessageFromOtherInstances: '%s'", message.toUtf8().constData());
219
220 int pos = message.indexOf(' ');
221 if (pos > -1) {
222 QString command = message.left(pos);
223 QString arg = message.mid(pos+1);
224 qDebug("command: '%s'", command.toUtf8().constData());
225 qDebug("arg: '%s'", arg.toUtf8().constData());
226
227 if (command == "open_file") {
228 open(arg);
229 }
230 else
231 if (command == "open_files") {
232 QStringList file_list = arg.split(" <<sep>> ");
233 openFiles(file_list);
234 }
235 else
236 if (command == "add_to_playlist") {
237 QStringList file_list = arg.split(" <<sep>> ");
238 playlist->addFiles(file_list);
239 }
240 else
241 if (command == "action") {
242 processFunction(arg);
243 }
244 else
245 if (command == "load_sub") {
246 setInitialSubtitle(arg);
247 if (core->state() != Core::Stopped) {
248 core->loadSub(arg);
249 }
250 }
251 }
252}
253#endif
254
255BaseGui::~BaseGui() {
256 delete core; // delete before mplayerwindow, otherwise, segfault...
257#ifdef LOG_MPLAYER
258 delete mplayer_log_window;
259#endif
260#ifdef LOG_SMPLAYER
261 delete smplayer_log_window;
262#endif
263
264 delete favorites;
265 delete tvlist;
266 delete radiolist;
267
268//#if !DOCK_PLAYLIST
269 if (playlist) {
270 delete playlist;
271 playlist = 0;
272 }
273//#endif
274
275#ifdef FIND_SUBTITLES
276 if (find_subs_dialog) {
277 delete find_subs_dialog;
278 find_subs_dialog = 0; // Necessary?
279 }
280#endif
281
282#ifdef VIDEOPREVIEW
283 if (video_preview) {
284 delete video_preview;
285 }
286#endif
287}
288
289void BaseGui::createActions() {
290 // Menu File
291 openFileAct = new MyAction( QKeySequence("Ctrl+F"), this, "open_file" );
292 connect( openFileAct, SIGNAL(triggered()),
293 this, SLOT(openFile()) );
294
295 openDirectoryAct = new MyAction( this, "open_directory" );
296 connect( openDirectoryAct, SIGNAL(triggered()),
297 this, SLOT(openDirectory()) );
298
299 openPlaylistAct = new MyAction( this, "open_playlist" );
300 connect( openPlaylistAct, SIGNAL(triggered()),
301 playlist, SLOT(load()) );
302
303 openVCDAct = new MyAction( this, "open_vcd" );
304 connect( openVCDAct, SIGNAL(triggered()),
305 this, SLOT(openVCD()) );
306
307 openAudioCDAct = new MyAction( this, "open_audio_cd" );
308 connect( openAudioCDAct, SIGNAL(triggered()),
309 this, SLOT(openAudioCD()) );
310
311 openDVDAct = new MyAction( this, "open_dvd" );
312 connect( openDVDAct, SIGNAL(triggered()),
313 this, SLOT(openDVD()) );
314
315 openDVDFolderAct = new MyAction( this, "open_dvd_folder" );
316 connect( openDVDFolderAct, SIGNAL(triggered()),
317 this, SLOT(openDVDFromFolder()) );
318
319 openURLAct = new MyAction( QKeySequence("Ctrl+U"), this, "open_url" );
320 connect( openURLAct, SIGNAL(triggered()),
321 this, SLOT(openURL()) );
322
323 exitAct = new MyAction( QKeySequence("Ctrl+X"), this, "close" );
324 connect( exitAct, SIGNAL(triggered()), this, SLOT(closeWindow()) );
325
326 clearRecentsAct = new MyAction( this, "clear_recents" );
327 connect( clearRecentsAct, SIGNAL(triggered()), this, SLOT(clearRecentsList()) );
328
329 // Favorites
330 favorites = new Favorites(Paths::configPath() + "/favorites.m3u8", this);
331 favorites->menuAction()->setObjectName( "favorites_menu" );
332 addAction(favorites->editAct());
333 addAction(favorites->jumpAct());
334 addAction(favorites->nextAct());
335 addAction(favorites->previousAct());
336 connect(favorites, SIGNAL(activated(QString)), this, SLOT(openFavorite(QString)));
337 connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
338 favorites, SLOT(getCurrentMedia(const QString &, const QString &)));
339
340 // TV and Radio
341 tvlist = new TVList(pref->check_channels_conf_on_startup,
342 TVList::TV, Paths::configPath() + "/tv.m3u8", this);
343 tvlist->menuAction()->setObjectName( "tv_menu" );
344 addAction(tvlist->editAct());
345 addAction(tvlist->jumpAct());
346 addAction(tvlist->nextAct());
347 addAction(tvlist->previousAct());
348 tvlist->nextAct()->setShortcut( Qt::Key_H );
349 tvlist->previousAct()->setShortcut( Qt::Key_L );
350 tvlist->nextAct()->setObjectName("next_tv");
351 tvlist->previousAct()->setObjectName("previous_tv");
352 tvlist->editAct()->setObjectName("edit_tv_list");
353 tvlist->jumpAct()->setObjectName("jump_tv_list");
354 connect(tvlist, SIGNAL(activated(QString)), this, SLOT(open(QString)));
355 connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
356 tvlist, SLOT(getCurrentMedia(const QString &, const QString &)));
357
358 radiolist = new TVList(pref->check_channels_conf_on_startup,
359 TVList::Radio, Paths::configPath() + "/radio.m3u8", this);
360 radiolist->menuAction()->setObjectName( "radio_menu" );
361 addAction(radiolist->editAct());
362 addAction(radiolist->jumpAct());
363 addAction(radiolist->nextAct());
364 addAction(radiolist->previousAct());
365 radiolist->nextAct()->setShortcut( Qt::SHIFT | Qt::Key_H );
366 radiolist->previousAct()->setShortcut( Qt::SHIFT | Qt::Key_L );
367 radiolist->nextAct()->setObjectName("next_radio");
368 radiolist->previousAct()->setObjectName("previous_radio");
369 radiolist->editAct()->setObjectName("edit_radio_list");
370 radiolist->jumpAct()->setObjectName("jump_radio_list");
371 connect(radiolist, SIGNAL(activated(QString)), this, SLOT(open(QString)));
372 connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
373 radiolist, SLOT(getCurrentMedia(const QString &, const QString &)));
374
375
376 // Menu Play
377 playAct = new MyAction( this, "play" );
378 connect( playAct, SIGNAL(triggered()),
379 core, SLOT(play()) );
380
381 playOrPauseAct = new MyAction( Qt::Key_MediaPlay, this, "play_or_pause" );
382 connect( playOrPauseAct, SIGNAL(triggered()),
383 core, SLOT(play_or_pause()) );
384
385 pauseAct = new MyAction( Qt::Key_Space, this, "pause" );
386 connect( pauseAct, SIGNAL(triggered()),
387 core, SLOT(pause()) );
388
389 pauseAndStepAct = new MyAction( this, "pause_and_frame_step" );
390 connect( pauseAndStepAct, SIGNAL(triggered()),
391 core, SLOT(pause_and_frame_step()) );
392
393 stopAct = new MyAction( Qt::Key_MediaStop, this, "stop" );
394 connect( stopAct, SIGNAL(triggered()),
395 core, SLOT(stop()) );
396
397 frameStepAct = new MyAction( Qt::Key_Period, this, "frame_step" );
398 connect( frameStepAct, SIGNAL(triggered()),
399 core, SLOT(frameStep()) );
400
401 rewind1Act = new MyAction( Qt::Key_Left, this, "rewind1" );
402 connect( rewind1Act, SIGNAL(triggered()),
403 core, SLOT(srewind()) );
404
405 rewind2Act = new MyAction( Qt::Key_Down, this, "rewind2" );
406 connect( rewind2Act, SIGNAL(triggered()),
407 core, SLOT(rewind()) );
408
409 rewind3Act = new MyAction( Qt::Key_PageDown, this, "rewind3" );
410 connect( rewind3Act, SIGNAL(triggered()),
411 core, SLOT(fastrewind()) );
412
413 forward1Act = new MyAction( Qt::Key_Right, this, "forward1" );
414 connect( forward1Act, SIGNAL(triggered()),
415 core, SLOT(sforward()) );
416
417 forward2Act = new MyAction( Qt::Key_Up, this, "forward2" );
418 connect( forward2Act, SIGNAL(triggered()),
419 core, SLOT(forward()) );
420
421 forward3Act = new MyAction( Qt::Key_PageUp, this, "forward3" );
422 connect( forward3Act, SIGNAL(triggered()),
423 core, SLOT(fastforward()) );
424
425 setAMarkerAct = new MyAction( this, "set_a_marker" );
426 connect( setAMarkerAct, SIGNAL(triggered()),
427 core, SLOT(setAMarker()) );
428
429 setBMarkerAct = new MyAction( this, "set_b_marker" );
430 connect( setBMarkerAct, SIGNAL(triggered()),
431 core, SLOT(setBMarker()) );
432
433 clearABMarkersAct = new MyAction( this, "clear_ab_markers" );
434 connect( clearABMarkersAct, SIGNAL(triggered()),
435 core, SLOT(clearABMarkers()) );
436
437 repeatAct = new MyAction( this, "repeat" );
438 repeatAct->setCheckable( true );
439 connect( repeatAct, SIGNAL(toggled(bool)),
440 core, SLOT(toggleRepeat(bool)) );
441
442 gotoAct = new MyAction( QKeySequence("Ctrl+J"), this, "jump_to" );
443 connect( gotoAct, SIGNAL(triggered()),
444 this, SLOT(showGotoDialog()) );
445
446 // Submenu Speed
447 normalSpeedAct = new MyAction( Qt::Key_Backspace, this, "normal_speed" );
448 connect( normalSpeedAct, SIGNAL(triggered()),
449 core, SLOT(normalSpeed()) );
450
451 halveSpeedAct = new MyAction( Qt::Key_BraceLeft, this, "halve_speed" );
452 connect( halveSpeedAct, SIGNAL(triggered()),
453 core, SLOT(halveSpeed()) );
454
455 doubleSpeedAct = new MyAction( Qt::Key_BraceRight, this, "double_speed" );
456 connect( doubleSpeedAct, SIGNAL(triggered()),
457 core, SLOT(doubleSpeed()) );
458
459 decSpeed10Act = new MyAction( Qt::Key_BracketLeft, this, "dec_speed" );
460 connect( decSpeed10Act, SIGNAL(triggered()),
461 core, SLOT(decSpeed10()) );
462
463 incSpeed10Act = new MyAction( Qt::Key_BracketRight, this, "inc_speed" );
464 connect( incSpeed10Act, SIGNAL(triggered()),
465 core, SLOT(incSpeed10()) );
466
467 decSpeed4Act = new MyAction( this, "dec_speed_4" );
468 connect( decSpeed4Act, SIGNAL(triggered()),
469 core, SLOT(decSpeed4()) );
470
471 incSpeed4Act = new MyAction( this, "inc_speed_4" );
472 connect( incSpeed4Act, SIGNAL(triggered()),
473 core, SLOT(incSpeed4()) );
474
475 decSpeed1Act = new MyAction( this, "dec_speed_1" );
476 connect( decSpeed1Act, SIGNAL(triggered()),
477 core, SLOT(decSpeed1()) );
478
479 incSpeed1Act = new MyAction( this, "inc_speed_1" );
480 connect( incSpeed1Act, SIGNAL(triggered()),
481 core, SLOT(incSpeed1()) );
482
483
484 // Menu Video
485 fullscreenAct = new MyAction( Qt::Key_F, this, "fullscreen" );
486 fullscreenAct->setCheckable( true );
487 connect( fullscreenAct, SIGNAL(toggled(bool)),
488 this, SLOT(toggleFullscreen(bool)) );
489
490 compactAct = new MyAction( QKeySequence("Ctrl+C"), this, "compact" );
491 compactAct->setCheckable( true );
492 connect( compactAct, SIGNAL(toggled(bool)),
493 this, SLOT(toggleCompactMode(bool)) );
494
495 videoEqualizerAct = new MyAction( QKeySequence("Ctrl+E"), this, "video_equalizer" );
496 videoEqualizerAct->setCheckable( true );
497 connect( videoEqualizerAct, SIGNAL(toggled(bool)),
498 this, SLOT(showVideoEqualizer(bool)) );
499
500 // Single screenshot
501 screenshotAct = new MyAction( Qt::Key_S, this, "screenshot" );
502 connect( screenshotAct, SIGNAL(triggered()),
503 core, SLOT(screenshot()) );
504
505 // Multiple screenshots
506 screenshotsAct = new MyAction( QKeySequence("Shift+D"), this, "multiple_screenshots" );
507 connect( screenshotsAct, SIGNAL(triggered()),
508 core, SLOT(screenshots()) );
509
510#ifdef VIDEOPREVIEW
511 videoPreviewAct = new MyAction( this, "video_preview" );
512 connect( videoPreviewAct, SIGNAL(triggered()),
513 this, SLOT(showVideoPreviewDialog()) );
514#endif
515
516 flipAct = new MyAction( this, "flip" );
517 flipAct->setCheckable( true );
518 connect( flipAct, SIGNAL(toggled(bool)),
519 core, SLOT(toggleFlip(bool)) );
520
521 mirrorAct = new MyAction( this, "mirror" );
522 mirrorAct->setCheckable( true );
523 connect( mirrorAct, SIGNAL(toggled(bool)),
524 core, SLOT(toggleMirror(bool)) );
525
526
527 // Submenu filter
528 postProcessingAct = new MyAction( this, "postprocessing" );
529 postProcessingAct->setCheckable( true );
530 connect( postProcessingAct, SIGNAL(toggled(bool)),
531 core, SLOT(togglePostprocessing(bool)) );
532
533 phaseAct = new MyAction( this, "autodetect_phase" );
534 phaseAct->setCheckable( true );
535 connect( phaseAct, SIGNAL(toggled(bool)),
536 core, SLOT(toggleAutophase(bool)) );
537
538 deblockAct = new MyAction( this, "deblock" );
539 deblockAct->setCheckable( true );
540 connect( deblockAct, SIGNAL(toggled(bool)),
541 core, SLOT(toggleDeblock(bool)) );
542
543 deringAct = new MyAction( this, "dering" );
544 deringAct->setCheckable( true );
545 connect( deringAct, SIGNAL(toggled(bool)),
546 core, SLOT(toggleDering(bool)) );
547
548 gradfunAct = new MyAction( this, "gradfun" );
549 gradfunAct->setCheckable( true );
550 connect( gradfunAct, SIGNAL(toggled(bool)),
551 core, SLOT(toggleGradfun(bool)) );
552
553
554 addNoiseAct = new MyAction( this, "add_noise" );
555 addNoiseAct->setCheckable( true );
556 connect( addNoiseAct, SIGNAL(toggled(bool)),
557 core, SLOT(toggleNoise(bool)) );
558
559 addLetterboxAct = new MyAction( this, "add_letterbox" );
560 addLetterboxAct->setCheckable( true );
561 connect( addLetterboxAct, SIGNAL(toggled(bool)),
562 core, SLOT(changeLetterbox(bool)) );
563
564 upscaleAct = new MyAction( this, "upscaling" );
565 upscaleAct->setCheckable( true );
566 connect( upscaleAct, SIGNAL(toggled(bool)),
567 core, SLOT(changeUpscale(bool)) );
568
569
570 // Menu Audio
571 audioEqualizerAct = new MyAction( this, "audio_equalizer" );
572 audioEqualizerAct->setCheckable( true );
573 connect( audioEqualizerAct, SIGNAL(toggled(bool)),
574 this, SLOT(showAudioEqualizer(bool)) );
575
576 muteAct = new MyAction( Qt::Key_M, this, "mute" );
577 muteAct->setCheckable( true );
578 connect( muteAct, SIGNAL(toggled(bool)),
579 core, SLOT(mute(bool)) );
580
581#if USE_MULTIPLE_SHORTCUTS
582 decVolumeAct = new MyAction( this, "decrease_volume" );
583 decVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("9,/") );
584#else
585 decVolumeAct = new MyAction( Qt::Key_9, this, "dec_volume" );
586#endif
587 connect( decVolumeAct, SIGNAL(triggered()),
588 core, SLOT(decVolume()) );
589
590#if USE_MULTIPLE_SHORTCUTS
591 incVolumeAct = new MyAction( this, "increase_volume" );
592 incVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("0,*") );
593#else
594 incVolumeAct = new MyAction( Qt::Key_0, this, "inc_volume" );
595#endif
596 connect( incVolumeAct, SIGNAL(triggered()),
597 core, SLOT(incVolume()) );
598
599 decAudioDelayAct = new MyAction( Qt::Key_Minus, this, "dec_audio_delay" );
600 connect( decAudioDelayAct, SIGNAL(triggered()),
601 core, SLOT(decAudioDelay()) );
602
603 incAudioDelayAct = new MyAction( Qt::Key_Plus, this, "inc_audio_delay" );
604 connect( incAudioDelayAct, SIGNAL(triggered()),
605 core, SLOT(incAudioDelay()) );
606
607 audioDelayAct = new MyAction( this, "audio_delay" );
608 connect( audioDelayAct, SIGNAL(triggered()),
609 this, SLOT(showAudioDelayDialog()) );
610
611 loadAudioAct = new MyAction( this, "load_audio_file" );
612 connect( loadAudioAct, SIGNAL(triggered()),
613 this, SLOT(loadAudioFile()) );
614
615 unloadAudioAct = new MyAction( this, "unload_audio_file" );
616 connect( unloadAudioAct, SIGNAL(triggered()),
617 core, SLOT(unloadAudioFile()) );
618
619
620 // Submenu Filters
621 extrastereoAct = new MyAction( this, "extrastereo_filter" );
622 extrastereoAct->setCheckable( true );
623 connect( extrastereoAct, SIGNAL(toggled(bool)),
624 core, SLOT(toggleExtrastereo(bool)) );
625
626 karaokeAct = new MyAction( this, "karaoke_filter" );
627 karaokeAct->setCheckable( true );
628 connect( karaokeAct, SIGNAL(toggled(bool)),
629 core, SLOT(toggleKaraoke(bool)) );
630
631 volnormAct = new MyAction( this, "volnorm_filter" );
632 volnormAct->setCheckable( true );
633 connect( volnormAct, SIGNAL(toggled(bool)),
634 core, SLOT(toggleVolnorm(bool)) );
635
636
637 // Menu Subtitles
638 loadSubsAct = new MyAction( this, "load_subs" );
639 connect( loadSubsAct, SIGNAL(triggered()),
640 this, SLOT(loadSub()) );
641
642 unloadSubsAct = new MyAction( this, "unload_subs" );
643 connect( unloadSubsAct, SIGNAL(triggered()),
644 core, SLOT(unloadSub()) );
645
646 decSubDelayAct = new MyAction( Qt::Key_Z, this, "dec_sub_delay" );
647 connect( decSubDelayAct, SIGNAL(triggered()),
648 core, SLOT(decSubDelay()) );
649
650 incSubDelayAct = new MyAction( Qt::Key_X, this, "inc_sub_delay" );
651 connect( incSubDelayAct, SIGNAL(triggered()),
652 core, SLOT(incSubDelay()) );
653
654 subDelayAct = new MyAction( this, "sub_delay" );
655 connect( subDelayAct, SIGNAL(triggered()),
656 this, SLOT(showSubDelayDialog()) );
657
658 decSubPosAct = new MyAction( Qt::Key_R, this, "dec_sub_pos" );
659 connect( decSubPosAct, SIGNAL(triggered()),
660 core, SLOT(decSubPos()) );
661 incSubPosAct = new MyAction( Qt::Key_T, this, "inc_sub_pos" );
662 connect( incSubPosAct, SIGNAL(triggered()),
663 core, SLOT(incSubPos()) );
664
665 decSubScaleAct = new MyAction( Qt::SHIFT | Qt::Key_R, this, "dec_sub_scale" );
666 connect( decSubScaleAct, SIGNAL(triggered()),
667 core, SLOT(decSubScale()) );
668
669 incSubScaleAct = new MyAction( Qt::SHIFT | Qt::Key_T, this, "inc_sub_scale" );
670 connect( incSubScaleAct, SIGNAL(triggered()),
671 core, SLOT(incSubScale()) );
672
673 decSubStepAct = new MyAction( Qt::Key_G, this, "dec_sub_step" );
674 connect( decSubStepAct, SIGNAL(triggered()),
675 core, SLOT(decSubStep()) );
676
677 incSubStepAct = new MyAction( Qt::Key_Y, this, "inc_sub_step" );
678 connect( incSubStepAct, SIGNAL(triggered()),
679 core, SLOT(incSubStep()) );
680
681 useAssAct = new MyAction(this, "use_ass_lib");
682 useAssAct->setCheckable(true);
683 connect( useAssAct, SIGNAL(toggled(bool)), core, SLOT(changeUseAss(bool)) );
684
685 useForcedSubsOnlyAct = new MyAction(this, "use_forced_subs_only");
686 useForcedSubsOnlyAct->setCheckable(true);
687 connect( useForcedSubsOnlyAct, SIGNAL(toggled(bool)), core, SLOT(toggleForcedSubsOnly(bool)) );
688
689 subVisibilityAct = new MyAction(Qt::Key_V, this, "subtitle_visibility");
690 subVisibilityAct->setCheckable(true);
691 connect( subVisibilityAct, SIGNAL(toggled(bool)), core, SLOT(changeSubVisibility(bool)) );
692
693#ifdef FIND_SUBTITLES
694 showFindSubtitlesDialogAct = new MyAction( this, "show_find_sub_dialog" );
695 connect( showFindSubtitlesDialogAct, SIGNAL(triggered()),
696 this, SLOT(showFindSubtitlesDialog()) );
697
698 openUploadSubtitlesPageAct = new MyAction( this, "upload_subtitles" ); //turbos
699 connect( openUploadSubtitlesPageAct, SIGNAL(triggered()), //turbos
700 this, SLOT(openUploadSubtitlesPage()) ); //turbos
701#endif
702
703 // Menu Options
704 showPlaylistAct = new MyAction( QKeySequence("Ctrl+L"), this, "show_playlist" );
705 showPlaylistAct->setCheckable( true );
706 connect( showPlaylistAct, SIGNAL(toggled(bool)),
707 this, SLOT(showPlaylist(bool)) );
708
709 showPropertiesAct = new MyAction( QKeySequence("Ctrl+I"), this, "show_file_properties" );
710 connect( showPropertiesAct, SIGNAL(triggered()),
711 this, SLOT(showFilePropertiesDialog()) );
712
713 showPreferencesAct = new MyAction( QKeySequence("Ctrl+P"), this, "show_preferences" );
714 connect( showPreferencesAct, SIGNAL(triggered()),
715 this, SLOT(showPreferencesDialog()) );
716
717 showTubeBrowserAct = new MyAction( Qt::Key_F11, this, "show_tube_browser" );
718 connect( showTubeBrowserAct, SIGNAL(triggered()),
719 this, SLOT(showTubeBrowser()) );
720
721 // Submenu Logs
722#ifdef LOG_MPLAYER
723 showLogMplayerAct = new MyAction( QKeySequence("Ctrl+M"), this, "show_mplayer_log" );
724 connect( showLogMplayerAct, SIGNAL(triggered()),
725 this, SLOT(showMplayerLog()) );
726#endif
727
728#ifdef LOG_SMPLAYER
729 showLogSmplayerAct = new MyAction( QKeySequence("Ctrl+S"), this, "show_smplayer_log" );
730 connect( showLogSmplayerAct, SIGNAL(triggered()),
731 this, SLOT(showLog()) );
732#endif
733
734 // Menu Help
735 showFAQAct = new MyAction( this, "faq" );
736 connect( showFAQAct, SIGNAL(triggered()),
737 this, SLOT(helpFAQ()) );
738
739 showCLOptionsAct = new MyAction( this, "cl_options" );
740 connect( showCLOptionsAct, SIGNAL(triggered()),
741 this, SLOT(helpCLOptions()) );
742
743 showCheckUpdatesAct = new MyAction( this, "check_updates" );
744 connect( showCheckUpdatesAct, SIGNAL(triggered()),
745 this, SLOT(helpCheckUpdates()) );
746
747 showConfigAct = new MyAction( this, "show_config" );
748 connect( showConfigAct, SIGNAL(triggered()),
749 this, SLOT(helpShowConfig()) );
750
751 aboutQtAct = new MyAction( this, "about_qt" );
752 connect( aboutQtAct, SIGNAL(triggered()),
753 this, SLOT(helpAboutQt()) );
754
755 aboutThisAct = new MyAction( this, "about_smplayer" );
756 connect( aboutThisAct, SIGNAL(triggered()),
757 this, SLOT(helpAbout()) );
758
759 // Playlist
760 playNextAct = new MyAction(Qt::Key_Greater, this, "play_next");
761 connect( playNextAct, SIGNAL(triggered()), playlist, SLOT(playNext()) );
762
763 playPrevAct = new MyAction(Qt::Key_Less, this, "play_prev");
764 connect( playPrevAct, SIGNAL(triggered()), playlist, SLOT(playPrev()) );
765
766
767 // Move video window and zoom
768 moveUpAct = new MyAction(Qt::ALT | Qt::Key_Up, this, "move_up");
769 connect( moveUpAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveUp()) );
770
771 moveDownAct = new MyAction(Qt::ALT | Qt::Key_Down, this, "move_down");
772 connect( moveDownAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveDown()) );
773
774 moveLeftAct = new MyAction(Qt::ALT | Qt::Key_Left, this, "move_left");
775 connect( moveLeftAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveLeft()) );
776
777 moveRightAct = new MyAction(Qt::ALT | Qt::Key_Right, this, "move_right");
778 connect( moveRightAct, SIGNAL(triggered()), mplayerwindow, SLOT(moveRight()) );
779
780 incZoomAct = new MyAction(Qt::Key_E, this, "inc_zoom");
781 connect( incZoomAct, SIGNAL(triggered()), core, SLOT(incZoom()) );
782
783 decZoomAct = new MyAction(Qt::Key_W, this, "dec_zoom");
784 connect( decZoomAct, SIGNAL(triggered()), core, SLOT(decZoom()) );
785
786 resetZoomAct = new MyAction(Qt::SHIFT | Qt::Key_E, this, "reset_zoom");
787 connect( resetZoomAct, SIGNAL(triggered()), core, SLOT(resetZoom()) );
788
789 autoZoomAct = new MyAction(Qt::SHIFT | Qt::Key_W, this, "auto_zoom");
790 connect( autoZoomAct, SIGNAL(triggered()), core, SLOT(autoZoom()) );
791
792 autoZoom169Act = new MyAction(Qt::SHIFT | Qt::Key_A, this, "zoom_169");
793 connect( autoZoom169Act, SIGNAL(triggered()), core, SLOT(autoZoomFor169()) );
794
795 autoZoom235Act = new MyAction(Qt::SHIFT | Qt::Key_S, this, "zoom_235");
796 connect( autoZoom235Act, SIGNAL(triggered()), core, SLOT(autoZoomFor235()) );
797
798#if USE_MPLAYER_PANSCAN
799 incPanscanAct = new MyAction(Qt::SHIFT | Qt::Key_M, this, "inc_panscan");
800 connect( incPanscanAct, SIGNAL(triggered()), core, SLOT(incPanscan()) );
801
802 decPanscanAct = new MyAction(Qt::SHIFT | Qt::Key_N, this, "dec_panscan");
803 connect( decPanscanAct, SIGNAL(triggered()), core, SLOT(decPanscan()) );
804#endif
805
806
807 // Actions not in menus or buttons
808 // Volume 2
809#if !USE_MULTIPLE_SHORTCUTS
810 decVolume2Act = new MyAction( Qt::Key_Slash, this, "dec_volume2" );
811 connect( decVolume2Act, SIGNAL(triggered()), core, SLOT(decVolume()) );
812
813 incVolume2Act = new MyAction( Qt::Key_Asterisk, this, "inc_volume2" );
814 connect( incVolume2Act, SIGNAL(triggered()), core, SLOT(incVolume()) );
815#endif
816 // Exit fullscreen
817 exitFullscreenAct = new MyAction( Qt::Key_Escape, this, "exit_fullscreen" );
818 connect( exitFullscreenAct, SIGNAL(triggered()), this, SLOT(exitFullscreen()) );
819
820 nextOSDAct = new MyAction( Qt::Key_O, this, "next_osd");
821 connect( nextOSDAct, SIGNAL(triggered()), core, SLOT(nextOSD()) );
822
823 decContrastAct = new MyAction( Qt::Key_1, this, "dec_contrast");
824 connect( decContrastAct, SIGNAL(triggered()), core, SLOT(decContrast()) );
825
826 incContrastAct = new MyAction( Qt::Key_2, this, "inc_contrast");
827 connect( incContrastAct, SIGNAL(triggered()), core, SLOT(incContrast()) );
828
829 decBrightnessAct = new MyAction( Qt::Key_3, this, "dec_brightness");
830 connect( decBrightnessAct, SIGNAL(triggered()), core, SLOT(decBrightness()) );
831
832 incBrightnessAct = new MyAction( Qt::Key_4, this, "inc_brightness");
833 connect( incBrightnessAct, SIGNAL(triggered()), core, SLOT(incBrightness()) );
834
835 decHueAct = new MyAction(Qt::Key_5, this, "dec_hue");
836 connect( decHueAct, SIGNAL(triggered()), core, SLOT(decHue()) );
837
838 incHueAct = new MyAction( Qt::Key_6, this, "inc_hue");
839 connect( incHueAct, SIGNAL(triggered()), core, SLOT(incHue()) );
840
841 decSaturationAct = new MyAction( Qt::Key_7, this, "dec_saturation");
842 connect( decSaturationAct, SIGNAL(triggered()), core, SLOT(decSaturation()) );
843
844 incSaturationAct = new MyAction( Qt::Key_8, this, "inc_saturation");
845 connect( incSaturationAct, SIGNAL(triggered()), core, SLOT(incSaturation()) );
846
847 decGammaAct = new MyAction( this, "dec_gamma");
848 connect( decGammaAct, SIGNAL(triggered()), core, SLOT(decGamma()) );
849
850 incGammaAct = new MyAction( this, "inc_gamma");
851 connect( incGammaAct, SIGNAL(triggered()), core, SLOT(incGamma()) );
852
853 nextVideoAct = new MyAction( this, "next_video");
854 connect( nextVideoAct, SIGNAL(triggered()), core, SLOT(nextVideo()) );
855
856 nextAudioAct = new MyAction( Qt::Key_K, this, "next_audio");
857 connect( nextAudioAct, SIGNAL(triggered()), core, SLOT(nextAudio()) );
858
859 nextSubtitleAct = new MyAction( Qt::Key_J, this, "next_subtitle");
860 connect( nextSubtitleAct, SIGNAL(triggered()), core, SLOT(nextSubtitle()) );
861
862 nextChapterAct = new MyAction( Qt::Key_At, this, "next_chapter");
863 connect( nextChapterAct, SIGNAL(triggered()), core, SLOT(nextChapter()) );
864
865 prevChapterAct = new MyAction( Qt::Key_Exclam, this, "prev_chapter");
866 connect( prevChapterAct, SIGNAL(triggered()), core, SLOT(prevChapter()) );
867
868 doubleSizeAct = new MyAction( Qt::CTRL | Qt::Key_D, this, "toggle_double_size");
869 connect( doubleSizeAct, SIGNAL(triggered()), core, SLOT(toggleDoubleSize()) );
870
871 resetVideoEqualizerAct = new MyAction( this, "reset_video_equalizer");
872 connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer, SLOT(reset()) );
873
874 resetAudioEqualizerAct = new MyAction( this, "reset_audio_equalizer");
875 connect( resetAudioEqualizerAct, SIGNAL(triggered()), audio_equalizer, SLOT(reset()) );
876
877 showContextMenuAct = new MyAction( this, "show_context_menu");
878 connect( showContextMenuAct, SIGNAL(triggered()),
879 this, SLOT(showPopupMenu()) );
880
881 nextAspectAct = new MyAction( Qt::Key_A, this, "next_aspect");
882 connect( nextAspectAct, SIGNAL(triggered()),
883 core, SLOT(nextAspectRatio()) );
884
885 nextWheelFunctionAct = new MyAction(this, "next_wheel_function");
886 connect( nextWheelFunctionAct, SIGNAL(triggered()),
887 core, SLOT(nextWheelFunction()) );
888
889 showFilenameAct = new MyAction(Qt::SHIFT | Qt::Key_I, this, "show_filename");
890 connect( showFilenameAct, SIGNAL(triggered()), core, SLOT(showFilenameOnOSD()) );
891
892 toggleDeinterlaceAct = new MyAction(Qt::Key_D, this, "toggle_deinterlacing");
893 connect( toggleDeinterlaceAct, SIGNAL(triggered()), core, SLOT(toggleDeinterlace()) );
894
895
896 // Group actions
897
898 // OSD
899 osdGroup = new MyActionGroup(this);
900 osdNoneAct = new MyActionGroupItem(this, osdGroup, "osd_none", Preferences::None);
901 osdSeekAct = new MyActionGroupItem(this, osdGroup, "osd_seek", Preferences::Seek);
902 osdTimerAct = new MyActionGroupItem(this, osdGroup, "osd_timer", Preferences::SeekTimer);
903 osdTotalAct = new MyActionGroupItem(this, osdGroup, "osd_total", Preferences::SeekTimerTotal);
904 connect( osdGroup, SIGNAL(activated(int)), core, SLOT(changeOSD(int)) );
905
906 // Denoise
907 denoiseGroup = new MyActionGroup(this);
908 denoiseNoneAct = new MyActionGroupItem(this, denoiseGroup, "denoise_none", MediaSettings::NoDenoise);
909 denoiseNormalAct = new MyActionGroupItem(this, denoiseGroup, "denoise_normal", MediaSettings::DenoiseNormal);
910 denoiseSoftAct = new MyActionGroupItem(this, denoiseGroup, "denoise_soft", MediaSettings::DenoiseSoft);
911 connect( denoiseGroup, SIGNAL(activated(int)), core, SLOT(changeDenoise(int)) );
912
913 // Unsharp group
914 unsharpGroup = new MyActionGroup(this);
915 unsharpNoneAct = new MyActionGroupItem(this, unsharpGroup, "unsharp_off", 0);
916 blurAct = new MyActionGroupItem(this, unsharpGroup, "blur", 1);
917 sharpenAct = new MyActionGroupItem(this, unsharpGroup, "sharpen", 2);
918 connect( unsharpGroup, SIGNAL(activated(int)), core, SLOT(changeUnsharp(int)) );
919
920 // Video size
921 sizeGroup = new MyActionGroup(this);
922 size50 = new MyActionGroupItem(this, sizeGroup, "5&0%", "size_50", 50);
923 size75 = new MyActionGroupItem(this, sizeGroup, "7&5%", "size_75", 75);
924 size100 = new MyActionGroupItem(this, sizeGroup, "&100%", "size_100", 100);
925 size125 = new MyActionGroupItem(this, sizeGroup, "1&25%", "size_125", 125);
926 size150 = new MyActionGroupItem(this, sizeGroup, "15&0%", "size_150", 150);
927 size175 = new MyActionGroupItem(this, sizeGroup, "1&75%", "size_175", 175);
928 size200 = new MyActionGroupItem(this, sizeGroup, "&200%", "size_200", 200);
929 size300 = new MyActionGroupItem(this, sizeGroup, "&300%", "size_300", 300);
930 size400 = new MyActionGroupItem(this, sizeGroup, "&400%", "size_400", 400);
931 size100->setShortcut( Qt::CTRL | Qt::Key_1 );
932 size200->setShortcut( Qt::CTRL | Qt::Key_2 );
933 connect( sizeGroup, SIGNAL(activated(int)), core, SLOT(changeSize(int)) );
934 // Make all not checkable
935 QList <QAction *> size_list = sizeGroup->actions();
936 for (int n=0; n < size_list.count(); n++) {
937 size_list[n]->setCheckable(false);
938 }
939
940 // Deinterlace
941 deinterlaceGroup = new MyActionGroup(this);
942 deinterlaceNoneAct = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_none", MediaSettings::NoDeinterlace);
943 deinterlaceL5Act = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_l5", MediaSettings::L5);
944 deinterlaceYadif0Act = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_yadif0", MediaSettings::Yadif);
945 deinterlaceYadif1Act = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_yadif1", MediaSettings::Yadif_1);
946 deinterlaceLBAct = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_lb", MediaSettings::LB);
947 deinterlaceKernAct = new MyActionGroupItem(this, deinterlaceGroup, "deinterlace_kern", MediaSettings::Kerndeint);
948 connect( deinterlaceGroup, SIGNAL(activated(int)),
949 core, SLOT(changeDeinterlace(int)) );
950
951 // Audio channels
952 channelsGroup = new MyActionGroup(this);
953 /* channelsDefaultAct = new MyActionGroupItem(this, channelsGroup, "channels_default", MediaSettings::ChDefault); */
954 channelsStereoAct = new MyActionGroupItem(this, channelsGroup, "channels_stereo", MediaSettings::ChStereo);
955 channelsSurroundAct = new MyActionGroupItem(this, channelsGroup, "channels_surround", MediaSettings::ChSurround);
956 channelsFull51Act = new MyActionGroupItem(this, channelsGroup, "channels_ful51", MediaSettings::ChFull51);
957 channelsFull61Act = new MyActionGroupItem(this, channelsGroup, "channels_ful61", MediaSettings::ChFull61);
958 channelsFull71Act = new MyActionGroupItem(this, channelsGroup, "channels_ful71", MediaSettings::ChFull71);
959 connect( channelsGroup, SIGNAL(activated(int)),
960 core, SLOT(setAudioChannels(int)) );
961
962 // Stereo mode
963 stereoGroup = new MyActionGroup(this);
964 stereoAct = new MyActionGroupItem(this, stereoGroup, "stereo", MediaSettings::Stereo);
965 leftChannelAct = new MyActionGroupItem(this, stereoGroup, "left_channel", MediaSettings::Left);
966 rightChannelAct = new MyActionGroupItem(this, stereoGroup, "right_channel", MediaSettings::Right);
967 connect( stereoGroup, SIGNAL(activated(int)),
968 core, SLOT(setStereoMode(int)) );
969
970 // Video aspect
971 aspectGroup = new MyActionGroup(this);
972 aspectDetectAct = new MyActionGroupItem(this, aspectGroup, "aspect_detect", MediaSettings::AspectAuto);
973 aspect11Act = new MyActionGroupItem(this, aspectGroup, "aspect_1:1", MediaSettings::Aspect11 );
974 aspect32Act = new MyActionGroupItem(this, aspectGroup, "aspect_3:2", MediaSettings::Aspect32);
975 aspect43Act = new MyActionGroupItem(this, aspectGroup, "aspect_4:3", MediaSettings::Aspect43);
976 aspect54Act = new MyActionGroupItem(this, aspectGroup, "aspect_5:4", MediaSettings::Aspect54 );
977 aspect149Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:9", MediaSettings::Aspect149 );
978 aspect1410Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:10", MediaSettings::Aspect1410 );
979 aspect169Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:9", MediaSettings::Aspect169 );
980 aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 );
981 aspect235Act = new MyActionGroupItem(this, aspectGroup, "aspect_2.35:1", MediaSettings::Aspect235 );
982 {
983 QAction * sep = new QAction(aspectGroup);
984 sep->setSeparator(true);
985 }
986 aspectNoneAct = new MyActionGroupItem(this, aspectGroup, "aspect_none", MediaSettings::AspectNone);
987
988 connect( aspectGroup, SIGNAL(activated(int)),
989 core, SLOT(changeAspectRatio(int)) );
990
991 // Rotate
992 rotateGroup = new MyActionGroup(this);
993 rotateNoneAct = new MyActionGroupItem(this, rotateGroup, "rotate_none", MediaSettings::NoRotate);
994 rotateClockwiseFlipAct = new MyActionGroupItem(this, rotateGroup, "rotate_clockwise_flip", MediaSettings::Clockwise_flip);
995 rotateClockwiseAct = new MyActionGroupItem(this, rotateGroup, "rotate_clockwise", MediaSettings::Clockwise);
996 rotateCounterclockwiseAct = new MyActionGroupItem(this, rotateGroup, "rotate_counterclockwise", MediaSettings::Counterclockwise);
997 rotateCounterclockwiseFlipAct = new MyActionGroupItem(this, rotateGroup, "rotate_counterclockwise_flip", MediaSettings::Counterclockwise_flip);
998 connect( rotateGroup, SIGNAL(activated(int)),
999 core, SLOT(changeRotate(int)) );
1000
1001 // On Top
1002 onTopActionGroup = new MyActionGroup(this);
1003 onTopAlwaysAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_always",Preferences::AlwaysOnTop);
1004 onTopNeverAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_never",Preferences::NeverOnTop);
1005 onTopWhilePlayingAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_playing",Preferences::WhilePlayingOnTop);
1006 connect( onTopActionGroup , SIGNAL(activated(int)),
1007 this, SLOT(changeStayOnTop(int)) );
1008
1009 toggleStayOnTopAct = new MyAction( this, "toggle_stay_on_top");
1010 connect( toggleStayOnTopAct, SIGNAL(triggered()), this, SLOT(toggleStayOnTop()) );
1011
1012
1013#if USE_ADAPTER
1014 screenGroup = new MyActionGroup(this);
1015 screenDefaultAct = new MyActionGroupItem(this, screenGroup, "screen_default", -1);
1016#ifdef Q_OS_WIN
1017 DeviceList display_devices = DeviceInfo::displayDevices();
1018 if (!display_devices.isEmpty()) {
1019 for (int n = 0; n < display_devices.count(); n++) {
1020 int id = display_devices[n].ID().toInt();
1021 QString desc = display_devices[n].desc();
1022 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toAscii().constData(), id);
1023 screen_item->change( "&"+QString::number(n) + " - " + desc);
1024 }
1025 }
1026 else
1027#endif // Q_OS_WIN
1028 for (int n = 1; n <= 4; n++) {
1029 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toAscii().constData(), n);
1030 screen_item->change( "&"+QString::number(n) );
1031 }
1032
1033 connect( screenGroup, SIGNAL(activated(int)),
1034 core, SLOT(changeAdapter(int)) );
1035#endif
1036
1037#if PROGRAM_SWITCH
1038 // Program track
1039 programTrackGroup = new MyActionGroup(this);
1040 connect( programTrackGroup, SIGNAL(activated(int)),
1041 core, SLOT(changeProgram(int)) );
1042#endif
1043
1044 // Video track
1045 videoTrackGroup = new MyActionGroup(this);
1046 connect( videoTrackGroup, SIGNAL(activated(int)),
1047 core, SLOT(changeVideo(int)) );
1048
1049 // Audio track
1050 audioTrackGroup = new MyActionGroup(this);
1051 connect( audioTrackGroup, SIGNAL(activated(int)),
1052 core, SLOT(changeAudio(int)) );
1053
1054 // Subtitle track
1055 subtitleTrackGroup = new MyActionGroup(this);
1056 connect( subtitleTrackGroup, SIGNAL(activated(int)),
1057 core, SLOT(changeSubtitle(int)) );
1058
1059 ccGroup = new MyActionGroup(this);
1060 ccNoneAct = new MyActionGroupItem(this, ccGroup, "cc_none", 0);
1061 ccChannel1Act = new MyActionGroupItem(this, ccGroup, "cc_ch_1", 1);
1062 ccChannel2Act = new MyActionGroupItem(this, ccGroup, "cc_ch_2", 2);
1063 ccChannel3Act = new MyActionGroupItem(this, ccGroup, "cc_ch_3", 3);
1064 ccChannel4Act = new MyActionGroupItem(this, ccGroup, "cc_ch_4", 4);
1065 connect( ccGroup, SIGNAL(activated(int)),
1066 core, SLOT(changeClosedCaptionChannel(int)) );
1067
1068 // Titles
1069 titleGroup = new MyActionGroup(this);
1070 connect( titleGroup, SIGNAL(activated(int)),
1071 core, SLOT(changeTitle(int)) );
1072
1073 // Angles
1074 angleGroup = new MyActionGroup(this);
1075 connect( angleGroup, SIGNAL(activated(int)),
1076 core, SLOT(changeAngle(int)) );
1077
1078 // Chapters
1079 chapterGroup = new MyActionGroup(this);
1080 connect( chapterGroup, SIGNAL(activated(int)),
1081 core, SLOT(changeChapter(int)) );
1082
1083#if DVDNAV_SUPPORT
1084 dvdnavUpAct = new MyAction(Qt::SHIFT | Qt::Key_Up, this, "dvdnav_up");
1085 connect( dvdnavUpAct, SIGNAL(triggered()), core, SLOT(dvdnavUp()) );
1086
1087 dvdnavDownAct = new MyAction(Qt::SHIFT | Qt::Key_Down, this, "dvdnav_down");
1088 connect( dvdnavDownAct, SIGNAL(triggered()), core, SLOT(dvdnavDown()) );
1089
1090 dvdnavLeftAct = new MyAction(Qt::SHIFT | Qt::Key_Left, this, "dvdnav_left");
1091 connect( dvdnavLeftAct, SIGNAL(triggered()), core, SLOT(dvdnavLeft()) );
1092
1093 dvdnavRightAct = new MyAction(Qt::SHIFT | Qt::Key_Right, this, "dvdnav_right");
1094 connect( dvdnavRightAct, SIGNAL(triggered()), core, SLOT(dvdnavRight()) );
1095
1096 dvdnavMenuAct = new MyAction(Qt::SHIFT | Qt::Key_Return, this, "dvdnav_menu");
1097 connect( dvdnavMenuAct, SIGNAL(triggered()), core, SLOT(dvdnavMenu()) );
1098
1099 dvdnavSelectAct = new MyAction(Qt::Key_Return, this, "dvdnav_select");
1100 connect( dvdnavSelectAct, SIGNAL(triggered()), core, SLOT(dvdnavSelect()) );
1101
1102 dvdnavPrevAct = new MyAction(Qt::SHIFT | Qt::Key_Escape, this, "dvdnav_prev");
1103 connect( dvdnavPrevAct, SIGNAL(triggered()), core, SLOT(dvdnavPrev()) );
1104
1105 dvdnavMouseAct = new MyAction( this, "dvdnav_mouse");
1106 connect( dvdnavMouseAct, SIGNAL(triggered()), core, SLOT(dvdnavMouse()) );
1107#endif
1108
1109}
1110
1111#if AUTODISABLE_ACTIONS
1112void BaseGui::setActionsEnabled(bool b) {
1113 // Menu Play
1114 playAct->setEnabled(b);
1115 playOrPauseAct->setEnabled(b);
1116 pauseAct->setEnabled(b);
1117 pauseAndStepAct->setEnabled(b);
1118 stopAct->setEnabled(b);
1119 frameStepAct->setEnabled(b);
1120 rewind1Act->setEnabled(b);
1121 rewind2Act->setEnabled(b);
1122 rewind3Act->setEnabled(b);
1123 forward1Act->setEnabled(b);
1124 forward2Act->setEnabled(b);
1125 forward3Act->setEnabled(b);
1126 //repeatAct->setEnabled(b);
1127 gotoAct->setEnabled(b);
1128
1129 // Menu Speed
1130 normalSpeedAct->setEnabled(b);
1131 halveSpeedAct->setEnabled(b);
1132 doubleSpeedAct->setEnabled(b);
1133 decSpeed10Act->setEnabled(b);
1134 incSpeed10Act->setEnabled(b);
1135 decSpeed4Act->setEnabled(b);
1136 incSpeed4Act->setEnabled(b);
1137 decSpeed1Act->setEnabled(b);
1138 incSpeed1Act->setEnabled(b);
1139
1140 // Menu Video
1141 videoEqualizerAct->setEnabled(b);
1142 screenshotAct->setEnabled(b);
1143 screenshotsAct->setEnabled(b);
1144 flipAct->setEnabled(b);
1145 mirrorAct->setEnabled(b);
1146 postProcessingAct->setEnabled(b);
1147 phaseAct->setEnabled(b);
1148 deblockAct->setEnabled(b);
1149 deringAct->setEnabled(b);
1150 gradfunAct->setEnabled(b);
1151 addNoiseAct->setEnabled(b);
1152 addLetterboxAct->setEnabled(b);
1153 upscaleAct->setEnabled(b);
1154
1155 // Menu Audio
1156 audioEqualizerAct->setEnabled(b);
1157 muteAct->setEnabled(b);
1158 decVolumeAct->setEnabled(b);
1159 incVolumeAct->setEnabled(b);
1160 decAudioDelayAct->setEnabled(b);
1161 incAudioDelayAct->setEnabled(b);
1162 audioDelayAct->setEnabled(b);
1163 extrastereoAct->setEnabled(b);
1164 karaokeAct->setEnabled(b);
1165 volnormAct->setEnabled(b);
1166 loadAudioAct->setEnabled(b);
1167 //unloadAudioAct->setEnabled(b);
1168
1169 // Menu Subtitles
1170 loadSubsAct->setEnabled(b);
1171 //unloadSubsAct->setEnabled(b);
1172 decSubDelayAct->setEnabled(b);
1173 incSubDelayAct->setEnabled(b);
1174 subDelayAct->setEnabled(b);
1175 decSubPosAct->setEnabled(b);
1176 incSubPosAct->setEnabled(b);
1177 incSubStepAct->setEnabled(b);
1178 decSubStepAct->setEnabled(b);
1179 incSubScaleAct->setEnabled(b);
1180 decSubScaleAct->setEnabled(b);
1181
1182 // Actions not in menus
1183#if !USE_MULTIPLE_SHORTCUTS
1184 decVolume2Act->setEnabled(b);
1185 incVolume2Act->setEnabled(b);
1186#endif
1187 decContrastAct->setEnabled(b);
1188 incContrastAct->setEnabled(b);
1189 decBrightnessAct->setEnabled(b);
1190 incBrightnessAct->setEnabled(b);
1191 decHueAct->setEnabled(b);
1192 incHueAct->setEnabled(b);
1193 decSaturationAct->setEnabled(b);
1194 incSaturationAct->setEnabled(b);
1195 decGammaAct->setEnabled(b);
1196 incGammaAct->setEnabled(b);
1197 nextVideoAct->setEnabled(b);
1198 nextAudioAct->setEnabled(b);
1199 nextSubtitleAct->setEnabled(b);
1200 nextChapterAct->setEnabled(b);
1201 prevChapterAct->setEnabled(b);
1202 doubleSizeAct->setEnabled(b);
1203
1204 // Moving and zoom
1205 moveUpAct->setEnabled(b);
1206 moveDownAct->setEnabled(b);
1207 moveLeftAct->setEnabled(b);
1208 moveRightAct->setEnabled(b);
1209 incZoomAct->setEnabled(b);
1210 decZoomAct->setEnabled(b);
1211 resetZoomAct->setEnabled(b);
1212 autoZoomAct->setEnabled(b);
1213 autoZoom169Act->setEnabled(b);
1214 autoZoom235Act->setEnabled(b);
1215
1216#if DVDNAV_SUPPORT
1217 dvdnavUpAct->setEnabled(b);
1218 dvdnavDownAct->setEnabled(b);
1219 dvdnavLeftAct->setEnabled(b);
1220 dvdnavRightAct->setEnabled(b);
1221 dvdnavMenuAct->setEnabled(b);
1222 dvdnavSelectAct->setEnabled(b);
1223 dvdnavPrevAct->setEnabled(b);
1224 dvdnavMouseAct->setEnabled(b);
1225#endif
1226
1227 // Groups
1228 denoiseGroup->setActionsEnabled(b);
1229 unsharpGroup->setActionsEnabled(b);
1230 sizeGroup->setActionsEnabled(b);
1231 deinterlaceGroup->setActionsEnabled(b);
1232 aspectGroup->setActionsEnabled(b);
1233 rotateGroup->setActionsEnabled(b);
1234#if USE_ADAPTER
1235 screenGroup->setActionsEnabled(b);
1236#endif
1237 channelsGroup->setActionsEnabled(b);
1238 stereoGroup->setActionsEnabled(b);
1239}
1240
1241void BaseGui::enableActionsOnPlaying() {
1242 qDebug("BaseGui::enableActionsOnPlaying");
1243
1244 setActionsEnabled(true);
1245
1246 playAct->setEnabled(false);
1247
1248 // Screenshot option
1249 bool screenshots_enabled = ( (pref->use_screenshot) &&
1250 (!pref->screenshot_directory.isEmpty()) &&
1251 (QFileInfo(pref->screenshot_directory).isDir()) );
1252
1253 screenshotAct->setEnabled( screenshots_enabled );
1254 screenshotsAct->setEnabled( screenshots_enabled );
1255
1256 // Disable the compact action if not using video window
1257 compactAct->setEnabled( panel->isVisible() );
1258
1259 // Enable or disable the audio equalizer
1260 audioEqualizerAct->setEnabled(pref->use_audio_equalizer);
1261
1262 // Disable audio actions if there's not audio track
1263 if ((core->mdat.audios.numItems()==0) && (core->mset.external_audio.isEmpty())) {
1264 audioEqualizerAct->setEnabled(false);
1265 muteAct->setEnabled(false);
1266 decVolumeAct->setEnabled(false);
1267 incVolumeAct->setEnabled(false);
1268 decAudioDelayAct->setEnabled(false);
1269 incAudioDelayAct->setEnabled(false);
1270 audioDelayAct->setEnabled(false);
1271 extrastereoAct->setEnabled(false);
1272 karaokeAct->setEnabled(false);
1273 volnormAct->setEnabled(false);
1274 channelsGroup->setActionsEnabled(false);
1275 stereoGroup->setActionsEnabled(false);
1276 }
1277
1278 // Disable video actions if it's an audio file
1279 if (core->mdat.novideo) {
1280 videoEqualizerAct->setEnabled(false);
1281 screenshotAct->setEnabled(false);
1282 screenshotsAct->setEnabled(false);
1283 flipAct->setEnabled(false);
1284 mirrorAct->setEnabled(false);
1285 postProcessingAct->setEnabled(false);
1286 phaseAct->setEnabled(false);
1287 deblockAct->setEnabled(false);
1288 deringAct->setEnabled(false);
1289 gradfunAct->setEnabled(false);
1290 addNoiseAct->setEnabled(false);
1291 addLetterboxAct->setEnabled(false);
1292 upscaleAct->setEnabled(false);
1293 doubleSizeAct->setEnabled(false);
1294
1295 // Moving and zoom
1296 moveUpAct->setEnabled(false);
1297 moveDownAct->setEnabled(false);
1298 moveLeftAct->setEnabled(false);
1299 moveRightAct->setEnabled(false);
1300 incZoomAct->setEnabled(false);
1301 decZoomAct->setEnabled(false);
1302 resetZoomAct->setEnabled(false);
1303 autoZoomAct->setEnabled(false);
1304 autoZoom169Act->setEnabled(false);
1305 autoZoom235Act->setEnabled(false);
1306
1307 denoiseGroup->setActionsEnabled(false);
1308 unsharpGroup->setActionsEnabled(false);
1309 sizeGroup->setActionsEnabled(false);
1310 deinterlaceGroup->setActionsEnabled(false);
1311 aspectGroup->setActionsEnabled(false);
1312 rotateGroup->setActionsEnabled(false);
1313#if USE_ADAPTER
1314 screenGroup->setActionsEnabled(false);
1315#endif
1316 }
1317
1318#if USE_ADAPTER
1319 screenGroup->setActionsEnabled(pref->vo.startsWith(OVERLAY_VO));
1320#endif
1321
1322#ifndef Q_OS_WIN
1323 // Disable video filters if using vdpau
1324 if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) {
1325 screenshotAct->setEnabled(false);
1326 screenshotsAct->setEnabled(false);
1327 flipAct->setEnabled(false);
1328 mirrorAct->setEnabled(false);
1329 postProcessingAct->setEnabled(false);
1330 phaseAct->setEnabled(false);
1331 deblockAct->setEnabled(false);
1332 deringAct->setEnabled(false);
1333 gradfunAct->setEnabled(false);
1334 addNoiseAct->setEnabled(false);
1335 addLetterboxAct->setEnabled(false);
1336 upscaleAct->setEnabled(false);
1337
1338 deinterlaceGroup->setActionsEnabled(false);
1339 rotateGroup->setActionsEnabled(false);
1340 denoiseGroup->setActionsEnabled(false);
1341 unsharpGroup->setActionsEnabled(false);
1342
1343 displayMessage( tr("Video filters are disabled when using vdpau") );
1344 }
1345#endif
1346
1347#if DVDNAV_SUPPORT
1348 if (!core->mdat.filename.startsWith("dvdnav:")) {
1349 dvdnavUpAct->setEnabled(false);
1350 dvdnavDownAct->setEnabled(false);
1351 dvdnavLeftAct->setEnabled(false);
1352 dvdnavRightAct->setEnabled(false);
1353 dvdnavMenuAct->setEnabled(false);
1354 dvdnavSelectAct->setEnabled(false);
1355 dvdnavPrevAct->setEnabled(false);
1356 dvdnavMouseAct->setEnabled(false);
1357 }
1358#endif
1359}
1360
1361void BaseGui::disableActionsOnStop() {
1362 qDebug("BaseGui::disableActionsOnStop");
1363
1364 setActionsEnabled(false);
1365
1366 playAct->setEnabled(true);
1367 playOrPauseAct->setEnabled(true);
1368 stopAct->setEnabled(true);
1369}
1370
1371void BaseGui::togglePlayAction(Core::State state) {
1372 qDebug("BaseGui::togglePlayAction");
1373 if (state == Core::Playing)
1374 playAct->setEnabled(false);
1375 else
1376 playAct->setEnabled(true);
1377}
1378#endif // AUTODISABLE_ACTIONS
1379
1380void BaseGui::retranslateStrings() {
1381 setWindowIcon( Images::icon("logo", 64) );
1382
1383 // ACTIONS
1384
1385 // Menu File
1386 openFileAct->change( Images::icon("open"), tr("&File...") );
1387 openDirectoryAct->change( Images::icon("openfolder"), tr("D&irectory...") );
1388 openPlaylistAct->change( Images::icon("open_playlist"), tr("&Playlist...") );
1389 openVCDAct->change( Images::icon("vcd"), tr("V&CD") );
1390 openAudioCDAct->change( Images::icon("cdda"), tr("&Audio CD") );
1391 openDVDAct->change( Images::icon("dvd"), tr("&DVD from drive") );
1392 openDVDFolderAct->change( Images::icon("dvd_hd"), tr("D&VD from folder...") );
1393 openURLAct->change( Images::icon("url"), tr("&URL...") );
1394 exitAct->change( Images::icon("close"), tr("C&lose") );
1395
1396 // Favorites
1397 /*
1398 favorites->editAct()->setText( tr("&Edit...") );
1399 favorites->addCurrentAct()->setText( tr("&Add current media") );
1400 */
1401
1402 // TV & Radio submenus
1403 /*
1404 tvlist->editAct()->setText( tr("&Edit...") );
1405 radiolist->editAct()->setText( tr("&Edit...") );
1406 tvlist->addCurrentAct()->setText( tr("&Add current media") );
1407 radiolist->addCurrentAct()->setText( tr("&Add current media") );
1408 tvlist->jumpAct()->setText( tr("&Jump...") );
1409 radiolist->jumpAct()->setText( tr("&Jump...") );
1410 tvlist->nextAct()->setText( tr("Next TV channel") );
1411 tvlist->previousAct()->setText( tr("Previous TV channel") );
1412 radiolist->nextAct()->setText( tr("Next radio channel") );
1413 radiolist->previousAct()->setText( tr("Previous radio channel") );
1414 */
1415
1416 // Menu Play
1417 playAct->change( tr("P&lay") );
1418 if (qApp->isLeftToRight())
1419 playAct->setIcon( Images::icon("play") );
1420 else
1421 playAct->setIcon( Images::flippedIcon("play") );
1422
1423 pauseAct->change( Images::icon("pause"), tr("&Pause"));
1424 stopAct->change( Images::icon("stop"), tr("&Stop") );
1425 frameStepAct->change( Images::icon("frame_step"), tr("&Frame step") );
1426
1427 playOrPauseAct->change( tr("Play / Pause") );
1428 if (qApp->isLeftToRight())
1429 playOrPauseAct->setIcon( Images::icon("play_pause") );
1430 else
1431 playOrPauseAct->setIcon( Images::flippedIcon("play_pause") );
1432
1433 pauseAndStepAct->change( Images::icon("pause"), tr("Pause / Frame step") );
1434
1435 setJumpTexts(); // Texts for rewind*Act and forward*Act
1436
1437 // Submenu A-B
1438 setAMarkerAct->change( Images::icon("a_marker"), tr("Set &A marker") );
1439 setBMarkerAct->change( Images::icon("b_marker"), tr("Set &B marker") );
1440 clearABMarkersAct->change( Images::icon("clear_markers"), tr("&Clear A-B markers") );
1441 repeatAct->change( Images::icon("repeat"), tr("&Repeat") );
1442
1443 gotoAct->change( Images::icon("jumpto"), tr("&Jump to...") );
1444
1445 // Submenu speed
1446 normalSpeedAct->change( tr("&Normal speed") );
1447 halveSpeedAct->change( tr("&Halve speed") );
1448 doubleSpeedAct->change( tr("&Double speed") );
1449 decSpeed10Act->change( tr("Speed &-10%") );
1450 incSpeed10Act->change( tr("Speed &+10%") );
1451 decSpeed4Act->change( tr("Speed -&4%") );
1452 incSpeed4Act->change( tr("&Speed +4%") );
1453 decSpeed1Act->change( tr("Speed -&1%") );
1454 incSpeed1Act->change( tr("S&peed +1%") );
1455
1456 // Menu Video
1457 fullscreenAct->change( Images::icon("fullscreen"), tr("&Fullscreen") );
1458 compactAct->change( Images::icon("compact"), tr("&Compact mode") );
1459 videoEqualizerAct->change( Images::icon("equalizer"), tr("&Equalizer") );
1460 screenshotAct->change( Images::icon("screenshot"), tr("&Screenshot") );
1461 screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") );
1462#ifdef VIDEOPREVIEW
1463 videoPreviewAct->change( Images::icon("video_preview"), tr("Pre&view...") );
1464#endif
1465 flipAct->change( Images::icon("flip"), tr("Fli&p image") );
1466 mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") );
1467
1468 decZoomAct->change( tr("Zoom &-") );
1469 incZoomAct->change( tr("Zoom &+") );
1470 resetZoomAct->change( tr("&Reset") );
1471 autoZoomAct->change( tr("&Auto zoom") );
1472 autoZoom169Act->change( tr("Zoom for &16:9") );
1473 autoZoom235Act->change( tr("Zoom for &2.35:1") );
1474 moveLeftAct->change( tr("Move &left") );
1475 moveRightAct->change( tr("Move &right") );
1476 moveUpAct->change( tr("Move &up") );
1477 moveDownAct->change( tr("Move &down") );
1478
1479#if USE_MPLAYER_PANSCAN
1480 decPanscanAct->change( "Panscan -" );
1481 incPanscanAct->change( "Panscan +" );
1482#endif
1483
1484 // Submenu Filters
1485 postProcessingAct->change( tr("&Postprocessing") );
1486 phaseAct->change( tr("&Autodetect phase") );
1487 deblockAct->change( tr("&Deblock") );
1488 deringAct->change( tr("De&ring") );
1489 gradfunAct->change( tr("Debanding (&gradfun)") );
1490 addNoiseAct->change( tr("Add n&oise") );
1491 addLetterboxAct->change( Images::icon("letterbox"), tr("Add &black borders") );
1492 upscaleAct->change( Images::icon("upscaling"), tr("Soft&ware scaling") );
1493
1494 // Menu Audio
1495 audioEqualizerAct->change( Images::icon("audio_equalizer"), tr("E&qualizer") );
1496 QIcon icset( Images::icon("volume") );
1497 icset.addPixmap( Images::icon("mute"), QIcon::Normal, QIcon::On );
1498 muteAct->change( icset, tr("&Mute") );
1499 decVolumeAct->change( Images::icon("audio_down"), tr("Volume &-") );
1500 incVolumeAct->change( Images::icon("audio_up"), tr("Volume &+") );
1501 decAudioDelayAct->change( Images::icon("delay_down"), tr("&Delay -") );
1502 incAudioDelayAct->change( Images::icon("delay_up"), tr("D&elay +") );
1503 audioDelayAct->change( Images::icon("audio_delay"), tr("Set dela&y...") );
1504 loadAudioAct->change( Images::icon("open"), tr("&Load external file...") );
1505 unloadAudioAct->change( Images::icon("unload"), tr("U&nload") );
1506
1507 // Submenu Filters
1508 extrastereoAct->change( tr("&Extrastereo") );
1509 karaokeAct->change( tr("&Karaoke") );
1510 volnormAct->change( tr("Volume &normalization") );
1511
1512 // Menu Subtitles
1513 loadSubsAct->change( Images::icon("open"), tr("&Load...") );
1514 unloadSubsAct->change( Images::icon("unload"), tr("U&nload") );
1515 decSubDelayAct->change( Images::icon("delay_down"), tr("Delay &-") );
1516 incSubDelayAct->change( Images::icon("delay_up"), tr("Delay &+") );
1517 subDelayAct->change( Images::icon("sub_delay"), tr("Se&t delay...") );
1518 decSubPosAct->change( Images::icon("sub_up"), tr("&Up") );
1519 incSubPosAct->change( Images::icon("sub_down"), tr("&Down") );
1520 decSubScaleAct->change( Images::icon("dec_sub_scale"), tr("S&ize -") );
1521 incSubScaleAct->change( Images::icon("inc_sub_scale"), tr("Si&ze +") );
1522 decSubStepAct->change( Images::icon("dec_sub_step"),
1523 tr("&Previous line in subtitles") );
1524 incSubStepAct->change( Images::icon("inc_sub_step"),
1525 tr("N&ext line in subtitles") );
1526 useAssAct->change( Images::icon("use_ass_lib"), tr("Use SSA/&ASS library") );
1527 useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") );
1528
1529 subVisibilityAct->change( Images::icon("sub_visibility"), tr("Subtitle &visibility") );
1530
1531#ifdef FIND_SUBTITLES
1532 showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles on &OpenSubtitles.org...") );
1533 openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") );
1534#endif
1535
1536 ccNoneAct->change( tr("&Off", "closed captions menu") );
1537 ccChannel1Act->change( "&1" );
1538 ccChannel2Act->change( "&2" );
1539 ccChannel3Act->change( "&3" );
1540 ccChannel4Act->change( "&4" );
1541
1542 // Menu Options
1543 showPlaylistAct->change( Images::icon("playlist"), tr("&Playlist") );
1544 showPropertiesAct->change( Images::icon("info"), tr("View &info and properties...") );
1545 showPreferencesAct->change( Images::icon("prefs"), tr("P&references") );
1546 showTubeBrowserAct->change( Images::icon("tubebrowser"), tr("&YouTube browser") );
1547
1548 // Submenu Logs
1549#ifdef LOG_MPLAYER
1550 showLogMplayerAct->change( "MPlayer" );
1551#endif
1552#ifdef LOG_SMPLAYER
1553 showLogSmplayerAct->change( "SMPlayer" );
1554#endif
1555
1556 // Menu Help
1557 showFAQAct->change( Images::icon("faq"), tr("&FAQ") );
1558 showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") );
1559 showCheckUpdatesAct->change( Images::icon("check_updates"), tr("Check for &updates") );
1560 showConfigAct->change( Images::icon("show_config"), tr("&Open configuration folder") );
1561 aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );
1562 aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") );
1563
1564 // Playlist
1565 playNextAct->change( tr("&Next") );
1566 playPrevAct->change( tr("Pre&vious") );
1567
1568 if (qApp->isLeftToRight()) {
1569 playNextAct->setIcon( Images::icon("next") );
1570 playPrevAct->setIcon( Images::icon("previous") );
1571 } else {
1572 playNextAct->setIcon( Images::flippedIcon("next") );
1573 playPrevAct->setIcon( Images::flippedIcon("previous") );
1574 }
1575
1576
1577 // Actions not in menus or buttons
1578 // Volume 2
1579#if !USE_MULTIPLE_SHORTCUTS
1580 decVolume2Act->change( tr("Dec volume (2)") );
1581 incVolume2Act->change( tr("Inc volume (2)") );
1582#endif
1583 // Exit fullscreen
1584 exitFullscreenAct->change( tr("Exit fullscreen") );
1585
1586 nextOSDAct->change( tr("OSD - Next level") );
1587 decContrastAct->change( tr("Dec contrast") );
1588 incContrastAct->change( tr("Inc contrast") );
1589 decBrightnessAct->change( tr("Dec brightness") );
1590 incBrightnessAct->change( tr("Inc brightness") );
1591 decHueAct->change( tr("Dec hue") );
1592 incHueAct->change( tr("Inc hue") );
1593 decSaturationAct->change( tr("Dec saturation") );
1594 incSaturationAct->change( tr("Inc saturation") );
1595 decGammaAct->change( tr("Dec gamma") );
1596 incGammaAct->change( tr("Inc gamma") );
1597 nextVideoAct->change( tr("Next video") );
1598 nextAudioAct->change( tr("Next audio") );
1599 nextSubtitleAct->change( tr("Next subtitle") );
1600 nextChapterAct->change( tr("Next chapter") );
1601 prevChapterAct->change( tr("Previous chapter") );
1602 doubleSizeAct->change( tr("&Toggle double size") );
1603 resetVideoEqualizerAct->change( tr("Reset video equalizer") );
1604 resetAudioEqualizerAct->change( tr("Reset audio equalizer") );
1605 showContextMenuAct->change( tr("Show context menu") );
1606 nextAspectAct->change( Images::icon("next_aspect"), tr("Next aspect ratio") );
1607 nextWheelFunctionAct->change( Images::icon("next_wheel_function"), tr("Next wheel function") );
1608
1609 showFilenameAct->change( tr("Show filename on OSD") );
1610 toggleDeinterlaceAct->change( tr("Toggle deinterlacing") );
1611
1612
1613 // Action groups
1614 osdNoneAct->change( tr("Subtitles onl&y") );
1615 osdSeekAct->change( tr("Volume + &Seek") );
1616 osdTimerAct->change( tr("Volume + Seek + &Timer") );
1617 osdTotalAct->change( tr("Volume + Seek + Timer + T&otal time") );
1618
1619
1620 // MENUS
1621 openMenu->menuAction()->setText( tr("&Open") );
1622 playMenu->menuAction()->setText( tr("&Play") );
1623 videoMenu->menuAction()->setText( tr("&Video") );
1624 audioMenu->menuAction()->setText( tr("&Audio") );
1625 subtitlesMenu->menuAction()->setText( tr("&Subtitles") );
1626 browseMenu->menuAction()->setText( tr("&Browse") );
1627 optionsMenu->menuAction()->setText( tr("Op&tions") );
1628 helpMenu->menuAction()->setText( tr("&Help") );
1629
1630 /*
1631 openMenuAct->setIcon( Images::icon("open_menu") );
1632 playMenuAct->setIcon( Images::icon("play_menu") );
1633 videoMenuAct->setIcon( Images::icon("video_menu") );
1634 audioMenuAct->setIcon( Images::icon("audio_menu") );
1635 subtitlesMenuAct->setIcon( Images::icon("subtitles_menu") );
1636 browseMenuAct->setIcon( Images::icon("browse_menu") );
1637 optionsMenuAct->setIcon( Images::icon("options_menu") );
1638 helpMenuAct->setIcon( Images::icon("help_menu") );
1639 */
1640
1641 // Menu Open
1642 recentfiles_menu->menuAction()->setText( tr("&Recent files") );
1643 recentfiles_menu->menuAction()->setIcon( Images::icon("recents") );
1644 clearRecentsAct->change( Images::icon("delete"), tr("&Clear") );
1645
1646 disc_menu->menuAction()->setText( tr("&Disc") );
1647 disc_menu->menuAction()->setIcon( Images::icon("open_disc") );
1648
1649 /* favorites->menuAction()->setText( tr("&Favorites") ); */
1650 favorites->menuAction()->setText( tr("F&avorites") );
1651 favorites->menuAction()->setIcon( Images::icon("open_favorites") );
1652
1653 tvlist->menuAction()->setText( tr("&TV") );
1654 tvlist->menuAction()->setIcon( Images::icon("open_tv") );
1655
1656 radiolist->menuAction()->setText( tr("Radi&o") );
1657 radiolist->menuAction()->setIcon( Images::icon("open_radio") );
1658
1659 // Menu Play
1660 speed_menu->menuAction()->setText( tr("Sp&eed") );
1661 speed_menu->menuAction()->setIcon( Images::icon("speed") );
1662
1663 ab_menu->menuAction()->setText( tr("&A-B section") );
1664 ab_menu->menuAction()->setIcon( Images::icon("ab_menu") );
1665
1666 // Menu Video
1667 videotrack_menu->menuAction()->setText( tr("&Track", "video") );
1668 videotrack_menu->menuAction()->setIcon( Images::icon("video_track") );
1669
1670 videosize_menu->menuAction()->setText( tr("Si&ze") );
1671 videosize_menu->menuAction()->setIcon( Images::icon("video_size") );
1672
1673 /*
1674 panscan_menu->menuAction()->setText( tr("&Pan && scan") );
1675 panscan_menu->menuAction()->setIcon( Images::icon("panscan") );
1676 */
1677 zoom_menu->menuAction()->setText( tr("Zoo&m") );
1678 zoom_menu->menuAction()->setIcon( Images::icon("zoom") );
1679
1680 aspect_menu->menuAction()->setText( tr("&Aspect ratio") );
1681 aspect_menu->menuAction()->setIcon( Images::icon("aspect") );
1682
1683 deinterlace_menu->menuAction()->setText( tr("&Deinterlace") );
1684 deinterlace_menu->menuAction()->setIcon( Images::icon("deinterlace") );
1685
1686 videofilter_menu->menuAction()->setText( tr("F&ilters") );
1687 videofilter_menu->menuAction()->setIcon( Images::icon("video_filters") );
1688
1689 rotate_menu->menuAction()->setText( tr("&Rotate") );
1690 rotate_menu->menuAction()->setIcon( Images::icon("rotate") );
1691
1692 ontop_menu->menuAction()->setText( tr("S&tay on top") );
1693 ontop_menu->menuAction()->setIcon( Images::icon("ontop") );
1694
1695#if USE_ADAPTER
1696 screen_menu->menuAction()->setText( tr("Scree&n") );
1697 screen_menu->menuAction()->setIcon( Images::icon("screen") );
1698#endif
1699
1700 denoise_menu->menuAction()->setText( tr("De&noise") );
1701 denoise_menu->menuAction()->setIcon( Images::icon("denoise") );
1702
1703 unsharp_menu->menuAction()->setText( tr("Blur/S&harp") );
1704 unsharp_menu->menuAction()->setIcon( Images::icon("unsharp") );
1705
1706 aspectDetectAct->change( tr("&Auto") );
1707 aspect11Act->change( "1&:1" );
1708 aspect32Act->change( "&3:2" );
1709 aspect43Act->change( "&4:3" );
1710 aspect54Act->change( "&5:4" );
1711 aspect149Act->change( "&14:9" );
1712 aspect1410Act->change( "1&4:10" );
1713 aspect169Act->change( "16:&9" );
1714 aspect1610Act->change( "1&6:10" );
1715 aspect235Act->change( "&2.35:1" );
1716 aspectNoneAct->change( tr("&Disabled") );
1717
1718 deinterlaceNoneAct->change( tr("&None") );
1719 deinterlaceL5Act->change( tr("&Lowpass5") );
1720 deinterlaceYadif0Act->change( tr("&Yadif (normal)") );
1721 deinterlaceYadif1Act->change( tr("Y&adif (double framerate)") );
1722 deinterlaceLBAct->change( tr("Linear &Blend") );
1723 deinterlaceKernAct->change( tr("&Kerndeint") );
1724
1725 denoiseNoneAct->change( tr("&Off", "denoise menu") );
1726 denoiseNormalAct->change( tr("&Normal","denoise menu") );
1727 denoiseSoftAct->change( tr("&Soft", "denoise menu") );
1728
1729 unsharpNoneAct->change( tr("&None", "unsharp menu") );
1730 blurAct->change( tr("&Blur", "unsharp menu") );
1731 sharpenAct->change( tr("&Sharpen", "unsharp menu") );
1732
1733 rotateNoneAct->change( tr("&Off") );
1734 rotateClockwiseFlipAct->change( tr("&Rotate by 90 degrees clockwise and flip") );
1735 rotateClockwiseAct->change( tr("Rotate by 90 degrees &clockwise") );
1736 rotateCounterclockwiseAct->change( tr("Rotate by 90 degrees counterclock&wise") );
1737 rotateCounterclockwiseFlipAct->change( tr("Rotate by 90 degrees counterclockwise and &flip") );
1738
1739 onTopAlwaysAct->change( tr("&Always") );
1740 onTopNeverAct->change( tr("&Never") );
1741 onTopWhilePlayingAct->change( tr("While &playing") );
1742 toggleStayOnTopAct->change( tr("Toggle stay on top") );
1743
1744#if USE_ADAPTER
1745 screenDefaultAct->change( tr("&Default") );
1746#endif
1747
1748 // Menu Audio
1749 audiotrack_menu->menuAction()->setText( tr("&Track", "audio") );
1750 audiotrack_menu->menuAction()->setIcon( Images::icon("audio_track") );
1751
1752 audiofilter_menu->menuAction()->setText( tr("&Filters") );
1753 audiofilter_menu->menuAction()->setIcon( Images::icon("audio_filters") );
1754
1755 audiochannels_menu->menuAction()->setText( tr("&Channels") );
1756 audiochannels_menu->menuAction()->setIcon( Images::icon("audio_channels") );
1757
1758 stereomode_menu->menuAction()->setText( tr("&Stereo mode") );
1759 stereomode_menu->menuAction()->setIcon( Images::icon("stereo_mode") );
1760
1761 /* channelsDefaultAct->change( tr("&Default") ); */
1762 channelsStereoAct->change( tr("&Stereo") );
1763 channelsSurroundAct->change( tr("&4.0 Surround") );
1764 channelsFull51Act->change( tr("&5.1 Surround") );
1765 channelsFull61Act->change( tr("&6.1 Surround") );
1766 channelsFull71Act->change( tr("&7.1 Surround") );
1767
1768 stereoAct->change( tr("&Stereo") );
1769 leftChannelAct->change( tr("&Left channel") );
1770 rightChannelAct->change( tr("&Right channel") );
1771
1772 // Menu Subtitle
1773 subtitlestrack_menu->menuAction()->setText( tr("&Select") );
1774 subtitlestrack_menu->menuAction()->setIcon( Images::icon("sub") );
1775
1776 closed_captions_menu->menuAction()->setText( tr("&Closed captions") );
1777 closed_captions_menu->menuAction()->setIcon( Images::icon("closed_caption") );
1778
1779 // Menu Browse
1780 titles_menu->menuAction()->setText( tr("&Title") );
1781 titles_menu->menuAction()->setIcon( Images::icon("title") );
1782
1783 chapters_menu->menuAction()->setText( tr("&Chapter") );
1784 chapters_menu->menuAction()->setIcon( Images::icon("chapter") );
1785
1786 angles_menu->menuAction()->setText( tr("&Angle") );
1787 angles_menu->menuAction()->setIcon( Images::icon("angle") );
1788
1789#if PROGRAM_SWITCH
1790 programtrack_menu->menuAction()->setText( tr("P&rogram", "program") );
1791 programtrack_menu->menuAction()->setIcon( Images::icon("program_track") );
1792#endif
1793
1794
1795#if DVDNAV_SUPPORT
1796 dvdnavUpAct->change(Images::icon("dvdnav_up"), tr("DVD menu, move up"));
1797 dvdnavDownAct->change(Images::icon("dvdnav_down"), tr("DVD menu, move down"));
1798 dvdnavLeftAct->change(Images::icon("dvdnav_left"), tr("DVD menu, move left"));
1799 dvdnavRightAct->change(Images::icon("dvdnav_right"), tr("DVD menu, move right"));
1800 dvdnavMenuAct->change(Images::icon("dvdnav_menu"), tr("DVD &menu"));
1801 dvdnavSelectAct->change(Images::icon("dvdnav_select"), tr("DVD menu, select option"));
1802 dvdnavPrevAct->change(Images::icon("dvdnav_prev"), tr("DVD &previous menu"));
1803 dvdnavMouseAct->change(Images::icon("dvdnav_mouse"), tr("DVD menu, mouse click"));
1804#endif
1805
1806 // Menu Options
1807 osd_menu->menuAction()->setText( tr("&OSD") );
1808 osd_menu->menuAction()->setIcon( Images::icon("osd") );
1809
1810#if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
1811 logs_menu->menuAction()->setText( tr("&View logs") );
1812 logs_menu->menuAction()->setIcon( Images::icon("logs") );
1813#endif
1814
1815 // To be sure that the "<empty>" string is translated
1816 initializeMenus();
1817
1818 // Other things
1819#ifdef LOG_MPLAYER
1820 mplayer_log_window->setWindowTitle( tr("SMPlayer - MPlayer log") );
1821#endif
1822#ifdef LOG_SMPLAYER
1823 smplayer_log_window->setWindowTitle( tr("SMPlayer - SMPlayer log") );
1824#endif
1825
1826 updateRecents();
1827 updateWidgets();
1828
1829 // Update actions view in preferences
1830 // It has to be done, here. The actions are translated after the
1831 // preferences dialog.
1832 if (pref_dialog) pref_dialog->mod_input()->actions_editor->updateView();
1833}
1834
1835void BaseGui::setJumpTexts() {
1836 rewind1Act->change( tr("-%1").arg(Helper::timeForJumps(pref->seeking1)) );
1837 rewind2Act->change( tr("-%1").arg(Helper::timeForJumps(pref->seeking2)) );
1838 rewind3Act->change( tr("-%1").arg(Helper::timeForJumps(pref->seeking3)) );
1839
1840 forward1Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking1)) );
1841 forward2Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking2)) );
1842 forward3Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking3)) );
1843
1844 if (qApp->isLeftToRight()) {
1845 rewind1Act->setIcon( Images::icon("rewind10s") );
1846 rewind2Act->setIcon( Images::icon("rewind1m") );
1847 rewind3Act->setIcon( Images::icon("rewind10m") );
1848
1849 forward1Act->setIcon( Images::icon("forward10s") );
1850 forward2Act->setIcon( Images::icon("forward1m") );
1851 forward3Act->setIcon( Images::icon("forward10m") );
1852 } else {
1853 rewind1Act->setIcon( Images::flippedIcon("rewind10s") );
1854 rewind2Act->setIcon( Images::flippedIcon("rewind1m") );
1855 rewind3Act->setIcon( Images::flippedIcon("rewind10m") );
1856
1857 forward1Act->setIcon( Images::flippedIcon("forward10s") );
1858 forward2Act->setIcon( Images::flippedIcon("forward1m") );
1859 forward3Act->setIcon( Images::flippedIcon("forward10m") );
1860 }
1861}
1862
1863void BaseGui::setWindowCaption(const QString & title) {
1864 setWindowTitle(title);
1865}
1866
1867void BaseGui::createCore() {
1868 core = new Core( mplayerwindow, this );
1869
1870 connect( core, SIGNAL(menusNeedInitialize()),
1871 this, SLOT(initializeMenus()) );
1872 connect( core, SIGNAL(widgetsNeedUpdate()),
1873 this, SLOT(updateWidgets()) );
1874 connect( core, SIGNAL(videoEqualizerNeedsUpdate()),
1875 this, SLOT(updateVideoEqualizer()) );
1876
1877 connect( core, SIGNAL(audioEqualizerNeedsUpdate()),
1878 this, SLOT(updateAudioEqualizer()) );
1879
1880 connect( core, SIGNAL(showFrame(int)),
1881 this, SIGNAL(frameChanged(int)) );
1882
1883 connect( core, SIGNAL(ABMarkersChanged(int,int)),
1884 this, SIGNAL(ABMarkersChanged(int,int)) );
1885
1886 connect( core, SIGNAL(showTime(double)),
1887 this, SLOT(gotCurrentTime(double)) );
1888
1889 connect( core, SIGNAL(needResize(int, int)),
1890 this, SLOT(resizeWindow(int,int)) );
1891 connect( core, SIGNAL(showMessage(QString)),
1892 this, SLOT(displayMessage(QString)) );
1893 connect( core, SIGNAL(stateChanged(Core::State)),
1894 this, SLOT(displayState(Core::State)) );
1895 connect( core, SIGNAL(stateChanged(Core::State)),
1896 this, SLOT(checkStayOnTop(Core::State)), Qt::QueuedConnection );
1897
1898 connect( core, SIGNAL(mediaStartPlay()),
1899 this, SLOT(enterFullscreenOnPlay()) );
1900 connect( core, SIGNAL(mediaStoppedByUser()),
1901 this, SLOT(exitFullscreenOnStop()) );
1902
1903 connect( core, SIGNAL(mediaStoppedByUser()),
1904 mplayerwindow, SLOT(showLogo()) );
1905
1906 connect( core, SIGNAL(mediaLoaded()),
1907 this, SLOT(enableActionsOnPlaying()) );
1908#if NOTIFY_AUDIO_CHANGES
1909 connect( core, SIGNAL(audioTracksChanged()),
1910 this, SLOT(enableActionsOnPlaying()) );
1911#endif
1912 connect( core, SIGNAL(mediaFinished()),
1913 this, SLOT(disableActionsOnStop()) );
1914 connect( core, SIGNAL(mediaStoppedByUser()),
1915 this, SLOT(disableActionsOnStop()) );
1916
1917 connect( core, SIGNAL(stateChanged(Core::State)),
1918 this, SLOT(togglePlayAction(Core::State)) );
1919
1920 connect( core, SIGNAL(mediaStartPlay()),
1921 this, SLOT(newMediaLoaded()), Qt::QueuedConnection );
1922 connect( core, SIGNAL(mediaInfoChanged()),
1923 this, SLOT(updateMediaInfo()) );
1924
1925 connect( core, SIGNAL(mediaStartPlay()),
1926 this, SLOT(checkPendingActionsToRun()), Qt::QueuedConnection );
1927#if REPORT_OLD_MPLAYER
1928 connect( core, SIGNAL(mediaStartPlay()),
1929 this, SLOT(checkMplayerVersion()), Qt::QueuedConnection );
1930#endif
1931 connect( core, SIGNAL(failedToParseMplayerVersion(QString)),
1932 this, SLOT(askForMplayerVersion(QString)) );
1933
1934 connect( core, SIGNAL(mplayerFailed(QProcess::ProcessError)),
1935 this, SLOT(showErrorFromMplayer(QProcess::ProcessError)) );
1936
1937 connect( core, SIGNAL(mplayerFinishedWithError(int)),
1938 this, SLOT(showExitCodeFromMplayer(int)) );
1939
1940 // Hide mplayer window
1941#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
1942 if (pref->hide_video_window_on_audio_files) {
1943 connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
1944 } else {
1945 connect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(showLogo()) );
1946 }
1947#else
1948 connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
1949#endif
1950
1951 // Log mplayer output
1952#ifdef LOG_MPLAYER
1953 connect( core, SIGNAL(aboutToStartPlaying()),
1954 this, SLOT(clearMplayerLog()) );
1955 connect( core, SIGNAL(logLineAvailable(QString)),
1956 this, SLOT(recordMplayerLog(QString)) );
1957
1958 connect( core, SIGNAL(mediaLoaded()),
1959 this, SLOT(autosaveMplayerLog()) );
1960#endif
1961}
1962
1963void BaseGui::createMplayerWindow() {
1964 mplayerwindow = new MplayerWindow( panel );
1965 mplayerwindow->setObjectName("mplayerwindow");
1966#if USE_COLORKEY
1967 mplayerwindow->setColorKey( pref->color_key );
1968#endif
1969 mplayerwindow->allowVideoMovement( pref->allow_video_movement );
1970
1971#if LOGO_ANIMATION
1972 mplayerwindow->setAnimatedLogo( pref->animated_logo);
1973#endif
1974
1975 QVBoxLayout * layout = new QVBoxLayout;
1976 layout->setSpacing(0);
1977 layout->setMargin(0);
1978 layout->addWidget(mplayerwindow);
1979 panel->setLayout(layout);
1980
1981 // mplayerwindow
1982 /*
1983 connect( mplayerwindow, SIGNAL(rightButtonReleased(QPoint)),
1984 this, SLOT(showPopupMenu(QPoint)) );
1985 */
1986
1987 // mplayerwindow mouse events
1988 connect( mplayerwindow, SIGNAL(doubleClicked()),
1989 this, SLOT(doubleClickFunction()) );
1990 connect( mplayerwindow, SIGNAL(leftClicked()),
1991 this, SLOT(leftClickFunction()) );
1992 connect( mplayerwindow, SIGNAL(rightClicked()),
1993 this, SLOT(rightClickFunction()) );
1994 connect( mplayerwindow, SIGNAL(middleClicked()),
1995 this, SLOT(middleClickFunction()) );
1996 connect( mplayerwindow, SIGNAL(xbutton1Clicked()),
1997 this, SLOT(xbutton1ClickFunction()) );
1998 connect( mplayerwindow, SIGNAL(xbutton2Clicked()),
1999 this, SLOT(xbutton2ClickFunction()) );
2000 connect( mplayerwindow, SIGNAL(mouseMoved(QPoint)),
2001 this, SLOT(checkMousePos(QPoint)) );
2002 connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)),
2003 this, SLOT(moveWindow(QPoint)));
2004}
2005
2006void BaseGui::createVideoEqualizer() {
2007 // Equalizer
2008 video_equalizer = new VideoEqualizer(this);
2009
2010 connect( video_equalizer->contrast, SIGNAL(valueChanged(int)),
2011 core, SLOT(setContrast(int)) );
2012 connect( video_equalizer->brightness, SIGNAL(valueChanged(int)),
2013 core, SLOT(setBrightness(int)) );
2014 connect( video_equalizer->hue, SIGNAL(valueChanged(int)),
2015 core, SLOT(setHue(int)) );
2016 connect( video_equalizer->saturation, SIGNAL(valueChanged(int)),
2017 core, SLOT(setSaturation(int)) );
2018 connect( video_equalizer->gamma, SIGNAL(valueChanged(int)),
2019 core, SLOT(setGamma(int)) );
2020 connect( video_equalizer, SIGNAL(visibilityChanged()),
2021 this, SLOT(updateWidgets()) );
2022}
2023
2024void BaseGui::createAudioEqualizer() {
2025 // Audio Equalizer
2026 audio_equalizer = new AudioEqualizer(this);
2027
2028 connect( audio_equalizer->eq[0], SIGNAL(valueChanged(int)),
2029 core, SLOT(setAudioEq0(int)) );
2030 connect( audio_equalizer->eq[1], SIGNAL(valueChanged(int)),
2031 core, SLOT(setAudioEq1(int)) );
2032 connect( audio_equalizer->eq[2], SIGNAL(valueChanged(int)),
2033 core, SLOT(setAudioEq2(int)) );
2034 connect( audio_equalizer->eq[3], SIGNAL(valueChanged(int)),
2035 core, SLOT(setAudioEq3(int)) );
2036 connect( audio_equalizer->eq[4], SIGNAL(valueChanged(int)),
2037 core, SLOT(setAudioEq4(int)) );
2038 connect( audio_equalizer->eq[5], SIGNAL(valueChanged(int)),
2039 core, SLOT(setAudioEq5(int)) );
2040 connect( audio_equalizer->eq[6], SIGNAL(valueChanged(int)),
2041 core, SLOT(setAudioEq6(int)) );
2042 connect( audio_equalizer->eq[7], SIGNAL(valueChanged(int)),
2043 core, SLOT(setAudioEq7(int)) );
2044 connect( audio_equalizer->eq[8], SIGNAL(valueChanged(int)),
2045 core, SLOT(setAudioEq8(int)) );
2046 connect( audio_equalizer->eq[9], SIGNAL(valueChanged(int)),
2047 core, SLOT(setAudioEq9(int)) );
2048
2049 connect( audio_equalizer, SIGNAL(applyClicked(AudioEqualizerList)),
2050 core, SLOT(setAudioAudioEqualizerRestart(AudioEqualizerList)) );
2051
2052 connect( audio_equalizer, SIGNAL(visibilityChanged()),
2053 this, SLOT(updateWidgets()) );
2054}
2055
2056void BaseGui::createPlaylist() {
2057#if DOCK_PLAYLIST
2058 playlist = new Playlist(core, this, 0);
2059#else
2060 //playlist = new Playlist(core, this, "playlist");
2061 playlist = new Playlist(core, 0);
2062#endif
2063
2064 /*
2065 connect( playlist, SIGNAL(playlistEnded()),
2066 this, SLOT(exitFullscreenOnStop()) );
2067 */
2068 connect( playlist, SIGNAL(playlistEnded()),
2069 this, SLOT(playlistHasFinished()) );
2070
2071 connect( playlist, SIGNAL(playlistEnded()),
2072 mplayerwindow, SLOT(showLogo()) );
2073
2074 /*
2075 connect( playlist, SIGNAL(visibilityChanged()),
2076 this, SLOT(playlistVisibilityChanged()) );
2077 */
2078
2079}
2080
2081void BaseGui::createPanel() {
2082 panel = new QWidget( this );
2083 panel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
2084 panel->setMinimumSize( QSize(1,1) );
2085 panel->setFocusPolicy( Qt::StrongFocus );
2086
2087 // panel
2088 panel->setAutoFillBackground(TRUE);
2089 ColorUtils::setBackgroundColor( panel, QColor(0,0,0) );
2090}
2091
2092void BaseGui::createPreferencesDialog() {
2093 pref_dialog = new PreferencesDialog(this);
2094 pref_dialog->setModal(false);
2095 /* pref_dialog->mod_input()->setActionsList( actions_list ); */
2096 connect( pref_dialog, SIGNAL(applied()),
2097 this, SLOT(applyNewPreferences()) );
2098}
2099
2100void BaseGui::createFilePropertiesDialog() {
2101 file_dialog = new FilePropertiesDialog(this);
2102 file_dialog->setModal(false);
2103 connect( file_dialog, SIGNAL(applied()),
2104 this, SLOT(applyFileProperties()) );
2105}
2106
2107
2108void BaseGui::createMenus() {
2109 // MENUS
2110 openMenu = menuBar()->addMenu("Open");
2111 playMenu = menuBar()->addMenu("Play");
2112 videoMenu = menuBar()->addMenu("Video");
2113 audioMenu = menuBar()->addMenu("Audio");
2114 subtitlesMenu = menuBar()->addMenu("Subtitles");
2115 /* menuBar()->addMenu(favorites); */
2116 browseMenu = menuBar()->addMenu("Browse");
2117 optionsMenu = menuBar()->addMenu("Options");
2118 helpMenu = menuBar()->addMenu("Help");
2119
2120 // OPEN MENU
2121 openMenu->addAction(openFileAct);
2122
2123 recentfiles_menu = new QMenu(this);
2124 recentfiles_menu->addAction( clearRecentsAct );
2125 recentfiles_menu->addSeparator();
2126
2127 openMenu->addMenu( recentfiles_menu );
2128 openMenu->addMenu(favorites);
2129 openMenu->addAction(openDirectoryAct);
2130 openMenu->addAction(openPlaylistAct);
2131
2132 // Disc submenu
2133 disc_menu = new QMenu(this);
2134 disc_menu->menuAction()->setObjectName("disc_menu");
2135 disc_menu->addAction(openDVDAct);
2136 disc_menu->addAction(openDVDFolderAct);
2137 disc_menu->addAction(openVCDAct);
2138 disc_menu->addAction(openAudioCDAct);
2139
2140 openMenu->addMenu(disc_menu);
2141
2142 openMenu->addAction(openURLAct);
2143/* #ifndef Q_OS_WIN */
2144 openMenu->addMenu(tvlist);
2145 openMenu->addMenu(radiolist);
2146/* #endif */
2147 openMenu->addSeparator();
2148 openMenu->addAction(exitAct);
2149
2150 // PLAY MENU
2151 playMenu->addAction(playAct);
2152 playMenu->addAction(pauseAct);
2153 /* playMenu->addAction(playOrPauseAct); */
2154 playMenu->addAction(stopAct);
2155 playMenu->addAction(frameStepAct);
2156 playMenu->addSeparator();
2157 playMenu->addAction(rewind1Act);
2158 playMenu->addAction(forward1Act);
2159 playMenu->addAction(rewind2Act);
2160 playMenu->addAction(forward2Act);
2161 playMenu->addAction(rewind3Act);
2162 playMenu->addAction(forward3Act);
2163 playMenu->addSeparator();
2164
2165 // Speed submenu
2166 speed_menu = new QMenu(this);
2167 speed_menu->menuAction()->setObjectName("speed_menu");
2168 speed_menu->addAction(normalSpeedAct);
2169 speed_menu->addSeparator();
2170 speed_menu->addAction(halveSpeedAct);
2171 speed_menu->addAction(doubleSpeedAct);
2172 speed_menu->addSeparator();
2173 speed_menu->addAction(decSpeed10Act);
2174 speed_menu->addAction(incSpeed10Act);
2175 speed_menu->addSeparator();
2176 speed_menu->addAction(decSpeed4Act);
2177 speed_menu->addAction(incSpeed4Act);
2178 speed_menu->addSeparator();
2179 speed_menu->addAction(decSpeed1Act);
2180 speed_menu->addAction(incSpeed1Act);
2181
2182 playMenu->addMenu(speed_menu);
2183
2184 // A-B submenu
2185 ab_menu = new QMenu(this);
2186 ab_menu->menuAction()->setObjectName("ab_menu");
2187 ab_menu->addAction(setAMarkerAct);
2188 ab_menu->addAction(setBMarkerAct);
2189 ab_menu->addAction(clearABMarkersAct);
2190 ab_menu->addSeparator();
2191 ab_menu->addAction(repeatAct);
2192
2193 playMenu->addSeparator();
2194 playMenu->addMenu(ab_menu);
2195
2196 playMenu->addSeparator();
2197 playMenu->addAction(gotoAct);
2198 playMenu->addSeparator();
2199 playMenu->addAction(playPrevAct);
2200 playMenu->addAction(playNextAct);
2201
2202 // VIDEO MENU
2203 videotrack_menu = new QMenu(this);
2204 videotrack_menu->menuAction()->setObjectName("videotrack_menu");
2205
2206 videoMenu->addMenu(videotrack_menu);
2207
2208 videoMenu->addAction(fullscreenAct);
2209 videoMenu->addAction(compactAct);
2210
2211#if USE_ADAPTER
2212 // Screen submenu
2213 screen_menu = new QMenu(this);
2214 screen_menu->menuAction()->setObjectName("screen_menu");
2215 screen_menu->addActions( screenGroup->actions() );
2216 videoMenu->addMenu(screen_menu);
2217#endif
2218
2219 // Size submenu
2220 videosize_menu = new QMenu(this);
2221 videosize_menu->menuAction()->setObjectName("videosize_menu");
2222 videosize_menu->addActions( sizeGroup->actions() );
2223 videosize_menu->addSeparator();
2224 videosize_menu->addAction(doubleSizeAct);
2225 videoMenu->addMenu(videosize_menu);
2226
2227 // Zoom submenu
2228 zoom_menu = new QMenu(this);
2229 zoom_menu->menuAction()->setObjectName("zoom_menu");
2230 zoom_menu->addAction(resetZoomAct);
2231 zoom_menu->addSeparator();
2232 zoom_menu->addAction(autoZoomAct);
2233 zoom_menu->addAction(autoZoom169Act);
2234 zoom_menu->addAction(autoZoom235Act);
2235 zoom_menu->addSeparator();
2236 zoom_menu->addAction(decZoomAct);
2237 zoom_menu->addAction(incZoomAct);
2238 zoom_menu->addSeparator();
2239 zoom_menu->addAction(moveLeftAct);
2240 zoom_menu->addAction(moveRightAct);
2241 zoom_menu->addAction(moveUpAct);
2242 zoom_menu->addAction(moveDownAct);
2243
2244 videoMenu->addMenu(zoom_menu);
2245
2246 // Aspect submenu
2247 aspect_menu = new QMenu(this);
2248 aspect_menu->menuAction()->setObjectName("aspect_menu");
2249 aspect_menu->addActions( aspectGroup->actions() );
2250
2251 videoMenu->addMenu(aspect_menu);
2252
2253 // Deinterlace submenu
2254 deinterlace_menu = new QMenu(this);
2255 deinterlace_menu->menuAction()->setObjectName("deinterlace_menu");
2256 deinterlace_menu->addActions( deinterlaceGroup->actions() );
2257
2258 videoMenu->addMenu(deinterlace_menu);
2259
2260 // Video filter submenu
2261 videofilter_menu = new QMenu(this);
2262 videofilter_menu->menuAction()->setObjectName("videofilter_menu");
2263 videofilter_menu->addAction(postProcessingAct);
2264 videofilter_menu->addAction(deblockAct);
2265 videofilter_menu->addAction(deringAct);
2266 videofilter_menu->addAction(gradfunAct);
2267 videofilter_menu->addAction(addNoiseAct);
2268 videofilter_menu->addAction(addLetterboxAct);
2269 videofilter_menu->addAction(upscaleAct);
2270 videofilter_menu->addAction(phaseAct);
2271
2272 // Denoise submenu
2273 denoise_menu = new QMenu(this);
2274 denoise_menu->menuAction()->setObjectName("denoise_menu");
2275 denoise_menu->addActions(denoiseGroup->actions());
2276 videofilter_menu->addMenu(denoise_menu);
2277
2278 // Unsharp submenu
2279 unsharp_menu = new QMenu(this);
2280 unsharp_menu->menuAction()->setObjectName("unsharp_menu");
2281 unsharp_menu->addActions(unsharpGroup->actions());
2282 videofilter_menu->addMenu(unsharp_menu);
2283 /*
2284 videofilter_menu->addSeparator();
2285 videofilter_menu->addActions(denoiseGroup->actions());
2286 videofilter_menu->addSeparator();
2287 videofilter_menu->addActions(unsharpGroup->actions());
2288 */
2289 videoMenu->addMenu(videofilter_menu);
2290
2291 // Rotate submenu
2292 rotate_menu = new QMenu(this);
2293 rotate_menu->menuAction()->setObjectName("rotate_menu");
2294 rotate_menu->addActions(rotateGroup->actions());
2295
2296 videoMenu->addMenu(rotate_menu);
2297
2298 videoMenu->addAction(flipAct);
2299 videoMenu->addAction(mirrorAct);
2300 videoMenu->addSeparator();
2301 videoMenu->addAction(videoEqualizerAct);
2302 videoMenu->addAction(screenshotAct);
2303 videoMenu->addAction(screenshotsAct);
2304
2305 // Ontop submenu
2306 ontop_menu = new QMenu(this);
2307 ontop_menu->menuAction()->setObjectName("ontop_menu");
2308 ontop_menu->addActions(onTopActionGroup->actions());
2309
2310 videoMenu->addMenu(ontop_menu);
2311
2312#ifdef VIDEOPREVIEW
2313 videoMenu->addSeparator();
2314 videoMenu->addAction(videoPreviewAct);
2315#endif
2316
2317
2318 // AUDIO MENU
2319
2320 // Audio track submenu
2321 audiotrack_menu = new QMenu(this);
2322 audiotrack_menu->menuAction()->setObjectName("audiotrack_menu");
2323
2324 audioMenu->addMenu(audiotrack_menu);
2325
2326 audioMenu->addAction(loadAudioAct);
2327 audioMenu->addAction(unloadAudioAct);
2328
2329 // Filter submenu
2330 audiofilter_menu = new QMenu(this);
2331 audiofilter_menu->menuAction()->setObjectName("audiofilter_menu");
2332 audiofilter_menu->addAction(extrastereoAct);
2333 audiofilter_menu->addAction(karaokeAct);
2334 audiofilter_menu->addAction(volnormAct);
2335
2336 audioMenu->addMenu(audiofilter_menu);
2337
2338 // Audio channels submenu
2339 audiochannels_menu = new QMenu(this);
2340 audiochannels_menu->menuAction()->setObjectName("audiochannels_menu");
2341 audiochannels_menu->addActions( channelsGroup->actions() );
2342
2343 audioMenu->addMenu(audiochannels_menu);
2344
2345 // Stereo mode submenu
2346 stereomode_menu = new QMenu(this);
2347 stereomode_menu->menuAction()->setObjectName("stereomode_menu");
2348 stereomode_menu->addActions( stereoGroup->actions() );
2349
2350 audioMenu->addMenu(stereomode_menu);
2351 audioMenu->addAction(audioEqualizerAct);
2352 audioMenu->addSeparator();
2353 audioMenu->addAction(muteAct);
2354 audioMenu->addSeparator();
2355 audioMenu->addAction(decVolumeAct);
2356 audioMenu->addAction(incVolumeAct);
2357 audioMenu->addSeparator();
2358 audioMenu->addAction(decAudioDelayAct);
2359 audioMenu->addAction(incAudioDelayAct);
2360 audioMenu->addSeparator();
2361 audioMenu->addAction(audioDelayAct);
2362
2363
2364 // SUBTITLES MENU
2365 // Track submenu
2366 subtitlestrack_menu = new QMenu(this);
2367 subtitlestrack_menu->menuAction()->setObjectName("subtitlestrack_menu");
2368
2369 subtitlesMenu->addMenu(subtitlestrack_menu);
2370
2371 subtitlesMenu->addAction(loadSubsAct);
2372 subtitlesMenu->addAction(unloadSubsAct);
2373 subtitlesMenu->addSeparator();
2374
2375 closed_captions_menu = new QMenu(this);
2376 closed_captions_menu->menuAction()->setObjectName("closed_captions_menu");
2377 closed_captions_menu->addAction( ccNoneAct);
2378 closed_captions_menu->addAction( ccChannel1Act);
2379 closed_captions_menu->addAction( ccChannel2Act);
2380 closed_captions_menu->addAction( ccChannel3Act);
2381 closed_captions_menu->addAction( ccChannel4Act);
2382 subtitlesMenu->addMenu(closed_captions_menu);
2383 subtitlesMenu->addSeparator();
2384
2385 subtitlesMenu->addAction(decSubDelayAct);
2386 subtitlesMenu->addAction(incSubDelayAct);
2387 subtitlesMenu->addSeparator();
2388 subtitlesMenu->addAction(subDelayAct);
2389 subtitlesMenu->addSeparator();
2390 subtitlesMenu->addAction(decSubPosAct);
2391 subtitlesMenu->addAction(incSubPosAct);
2392 subtitlesMenu->addSeparator();
2393 subtitlesMenu->addAction(decSubScaleAct);
2394 subtitlesMenu->addAction(incSubScaleAct);
2395 subtitlesMenu->addSeparator();
2396 subtitlesMenu->addAction(decSubStepAct);
2397 subtitlesMenu->addAction(incSubStepAct);
2398 subtitlesMenu->addSeparator();
2399 subtitlesMenu->addAction(useForcedSubsOnlyAct);
2400 subtitlesMenu->addSeparator();
2401 subtitlesMenu->addAction(subVisibilityAct);
2402 subtitlesMenu->addSeparator();
2403 subtitlesMenu->addAction(useAssAct);
2404#ifdef FIND_SUBTITLES
2405 subtitlesMenu->addSeparator(); //turbos
2406 subtitlesMenu->addAction(showFindSubtitlesDialogAct);
2407 subtitlesMenu->addAction(openUploadSubtitlesPageAct); //turbos
2408#endif
2409
2410 // BROWSE MENU
2411 // Titles submenu
2412 titles_menu = new QMenu(this);
2413 titles_menu->menuAction()->setObjectName("titles_menu");
2414
2415 browseMenu->addMenu(titles_menu);
2416
2417 // Chapters submenu
2418 chapters_menu = new QMenu(this);
2419 chapters_menu->menuAction()->setObjectName("chapters_menu");
2420
2421 browseMenu->addMenu(chapters_menu);
2422
2423 // Angles submenu
2424 angles_menu = new QMenu(this);
2425 angles_menu->menuAction()->setObjectName("angles_menu");
2426
2427 browseMenu->addMenu(angles_menu);
2428
2429#if DVDNAV_SUPPORT
2430 browseMenu->addSeparator();
2431 browseMenu->addAction(dvdnavMenuAct);
2432 browseMenu->addAction(dvdnavPrevAct);
2433#endif
2434
2435#if PROGRAM_SWITCH
2436 programtrack_menu = new QMenu(this);
2437 programtrack_menu->menuAction()->setObjectName("programtrack_menu");
2438
2439 browseMenu->addSeparator();
2440 browseMenu->addMenu(programtrack_menu);
2441#endif
2442
2443
2444 // OPTIONS MENU
2445 optionsMenu->addAction(showPropertiesAct);
2446 optionsMenu->addAction(showPlaylistAct);
2447 // Check if the smplayer youtube browser is installed
2448 {
2449 QString tube_exec = Paths::appPath() + "/smtube";
2450 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
2451 tube_exec += ".exe";
2452 #endif
2453 if (QFile::exists(tube_exec)) {
2454 optionsMenu->addAction(showTubeBrowserAct);
2455 qDebug("BaseGui::createMenus: %s does exist", tube_exec.toUtf8().constData());
2456 } else {
2457 qDebug("BaseGui::createMenus: %s does not exist", tube_exec.toUtf8().constData());
2458 }
2459 }
2460
2461 // OSD submenu
2462 osd_menu = new QMenu(this);
2463 osd_menu->menuAction()->setObjectName("osd_menu");
2464 osd_menu->addActions(osdGroup->actions());
2465
2466 optionsMenu->addMenu(osd_menu);
2467
2468 // Logs submenu
2469#if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
2470 logs_menu = new QMenu(this);
2471 #ifdef LOG_MPLAYER
2472 logs_menu->addAction(showLogMplayerAct);
2473 #endif
2474 #ifdef LOG_SMPLAYER
2475 logs_menu->addAction(showLogSmplayerAct);
2476 #endif
2477 optionsMenu->addMenu(logs_menu);
2478#endif
2479
2480 optionsMenu->addAction(showPreferencesAct);
2481
2482 /*
2483 Favorites * fav = new Favorites(Paths::configPath() + "/test.fav", this);
2484 connect(fav, SIGNAL(activated(QString)), this, SLOT(open(QString)));
2485 optionsMenu->addMenu( fav->menu() )->setText("Favorites");
2486 */
2487
2488 // HELP MENU
2489 helpMenu->addAction(showFAQAct);
2490 helpMenu->addAction(showCLOptionsAct);
2491 helpMenu->addAction(showCheckUpdatesAct);
2492 helpMenu->addAction(showConfigAct);
2493 helpMenu->addSeparator();
2494 helpMenu->addAction(aboutQtAct);
2495 helpMenu->addAction(aboutThisAct);
2496
2497 // POPUP MENU
2498 if (!popup)
2499 popup = new QMenu(this);
2500 else
2501 popup->clear();
2502
2503 popup->addMenu( openMenu );
2504 popup->addMenu( playMenu );
2505 popup->addMenu( videoMenu );
2506 popup->addMenu( audioMenu );
2507 popup->addMenu( subtitlesMenu );
2508 popup->addMenu( favorites );
2509 popup->addMenu( browseMenu );
2510 popup->addMenu( optionsMenu );
2511
2512 // let's show something, even a <empty> entry
2513 initializeMenus();
2514}
2515
2516/*
2517void BaseGui::closeEvent( QCloseEvent * e ) {
2518 qDebug("BaseGui::closeEvent");
2519
2520 qDebug("mplayer_log_window: %d x %d", mplayer_log_window->width(), mplayer_log_window->height() );
2521 qDebug("smplayer_log_window: %d x %d", smplayer_log_window->width(), smplayer_log_window->height() );
2522
2523 mplayer_log_window->close();
2524 smplayer_log_window->close();
2525 playlist->close();
2526 equalizer->close();
2527
2528 core->stop();
2529 e->accept();
2530}
2531*/
2532
2533
2534void BaseGui::closeWindow() {
2535 qDebug("BaseGui::closeWindow");
2536
2537 if (core->state() != Core::Stopped) {
2538 core->stop();
2539 }
2540
2541 //qApp->quit();
2542 emit quitSolicited();
2543}
2544
2545void BaseGui::showPlaylist() {
2546 showPlaylist( !playlist->isVisible() );
2547}
2548
2549void BaseGui::showPlaylist(bool b) {
2550 if ( !b ) {
2551 playlist->hide();
2552 } else {
2553 exitFullscreenIfNeeded();
2554 playlist->show();
2555 }
2556 //updateWidgets();
2557}
2558
2559void BaseGui::showVideoEqualizer() {
2560 showVideoEqualizer( !video_equalizer->isVisible() );
2561}
2562
2563void BaseGui::showVideoEqualizer(bool b) {
2564 if (!b) {
2565 video_equalizer->hide();
2566 } else {
2567 // Exit fullscreen, otherwise dialog is not visible
2568 exitFullscreenIfNeeded();
2569 video_equalizer->show();
2570 }
2571 updateWidgets();
2572}
2573
2574void BaseGui::showAudioEqualizer() {
2575 showAudioEqualizer( !audio_equalizer->isVisible() );
2576}
2577
2578void BaseGui::showAudioEqualizer(bool b) {
2579 if (!b) {
2580 audio_equalizer->hide();
2581 } else {
2582 // Exit fullscreen, otherwise dialog is not visible
2583 exitFullscreenIfNeeded();
2584 audio_equalizer->show();
2585 }
2586 updateWidgets();
2587}
2588
2589void BaseGui::showPreferencesDialog() {
2590 qDebug("BaseGui::showPreferencesDialog");
2591
2592 exitFullscreenIfNeeded();
2593
2594 if (!pref_dialog) {
2595 createPreferencesDialog();
2596 }
2597
2598 pref_dialog->setData(pref);
2599
2600 pref_dialog->mod_input()->actions_editor->clear();
2601 pref_dialog->mod_input()->actions_editor->addActions(this);
2602#if !DOCK_PLAYLIST
2603 pref_dialog->mod_input()->actions_editor->addActions(playlist);
2604#endif
2605
2606 // Set playlist preferences
2607 PrefPlaylist * pl = pref_dialog->mod_playlist();
2608 pl->setDirectoryRecursion(playlist->directoryRecursion());
2609 pl->setAutoGetInfo(playlist->autoGetInfo());
2610 pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit());
2611 pl->setPlayFilesFromStart(playlist->playFilesFromStart());
2612
2613 pref_dialog->show();
2614}
2615
2616// The user has pressed OK in preferences dialog
2617void BaseGui::applyNewPreferences() {
2618 qDebug("BaseGui::applyNewPreferences");
2619
2620 bool need_update_language = false;
2621
2622 pref_dialog->getData(pref);
2623
2624 if (!pref->default_font.isEmpty()) {
2625 QFont f;
2626 f.fromString( pref->default_font );
2627 qApp->setFont(f);
2628 }
2629
2630#ifndef NO_USE_INI_FILES
2631 PrefGeneral *_general = pref_dialog->mod_general();
2632 if (_general->fileSettingsMethodChanged()) {
2633 core->changeFileSettingsMethod(pref->file_settings_method);
2634 }
2635#endif
2636
2637 PrefInterface *_interface = pref_dialog->mod_interface();
2638 if (_interface->recentsChanged()) {
2639 updateRecents();
2640 }
2641 if (_interface->languageChanged()) need_update_language = true;
2642
2643 if (_interface->iconsetChanged()) {
2644 need_update_language = true;
2645 // Stylesheet
2646#if ALLOW_CHANGE_STYLESHEET
2647 changeStyleSheet(pref->iconset);
2648#endif
2649 }
2650
2651#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
2652 if (pref->hide_video_window_on_audio_files) {
2653 connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
2654 disconnect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(hideLogo()) );
2655 } else {
2656 disconnect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
2657 connect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(showLogo()) );
2658 if (!panel->isVisible()) {
2659 resize( width(), height() + 200);
2660 panel->show();
2661 }
2662 }
2663#endif
2664
2665 PrefAdvanced *advanced = pref_dialog->mod_advanced();
2666#if REPAINT_BACKGROUND_OPTION
2667 if (advanced->repaintVideoBackgroundChanged()) {
2668 mplayerwindow->videoLayer()->setRepaintBackground(pref->repaint_video_background);
2669 }
2670#endif
2671#if USE_COLORKEY
2672 if (advanced->colorkeyChanged()) {
2673 mplayerwindow->setColorKey( pref->color_key );
2674 }
2675#endif
2676 if (advanced->monitorAspectChanged()) {
2677 mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() );
2678 }
2679
2680 // Update playlist preferences
2681 PrefPlaylist * pl = pref_dialog->mod_playlist();
2682 playlist->setDirectoryRecursion(pl->directoryRecursion());
2683 playlist->setAutoGetInfo(pl->autoGetInfo());
2684 playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit());
2685 playlist->setPlayFilesFromStart(pl->playFilesFromStart());
2686
2687
2688 if (need_update_language) {
2689 translator->load(pref->language);
2690 }
2691
2692 setJumpTexts(); // Update texts in menus
2693 updateWidgets(); // Update the screenshot action
2694
2695#if STYLE_SWITCHING
2696 if (_interface->styleChanged()) {
2697 qDebug( "selected style: '%s'", pref->style.toUtf8().data() );
2698 if ( !pref->style.isEmpty()) {
2699 qApp->setStyle( pref->style );
2700 } else {
2701 qDebug("setting default style: '%s'", default_style.toUtf8().data() );
2702 qApp->setStyle( default_style );
2703 }
2704 }
2705#endif
2706
2707 // Restart the video if needed
2708 if (pref_dialog->requiresRestart())
2709 core->restart();
2710
2711 // Update actions
2712 pref_dialog->mod_input()->actions_editor->applyChanges();
2713 saveActions();
2714
2715#ifndef NO_USE_INI_FILES
2716 pref->save();
2717#endif
2718
2719
2720 if (_interface->guiChanged()) {
2721#ifdef GUI_CHANGE_ON_RUNTIME
2722 core->stop();
2723 emit guiChanged(pref->gui);
2724#else
2725 QMessageBox::information(this, tr("Information"),
2726 tr("You need to restart SMPlayer to use the new GUI.") );
2727#endif
2728 }
2729}
2730
2731
2732void BaseGui::showFilePropertiesDialog() {
2733 qDebug("BaseGui::showFilePropertiesDialog");
2734
2735 exitFullscreenIfNeeded();
2736
2737 if (!file_dialog) {
2738 createFilePropertiesDialog();
2739 }
2740
2741 setDataToFileProperties();
2742
2743 file_dialog->show();
2744}
2745
2746void BaseGui::setDataToFileProperties() {
2747 // Save a copy of the original values
2748 if (core->mset.original_demuxer.isEmpty())
2749 core->mset.original_demuxer = core->mdat.demuxer;
2750
2751 if (core->mset.original_video_codec.isEmpty())
2752 core->mset.original_video_codec = core->mdat.video_codec;
2753
2754 if (core->mset.original_audio_codec.isEmpty())
2755 core->mset.original_audio_codec = core->mdat.audio_codec;
2756
2757 QString demuxer = core->mset.forced_demuxer;
2758 if (demuxer.isEmpty()) demuxer = core->mdat.demuxer;
2759
2760 QString ac = core->mset.forced_audio_codec;
2761 if (ac.isEmpty()) ac = core->mdat.audio_codec;
2762
2763 QString vc = core->mset.forced_video_codec;
2764 if (vc.isEmpty()) vc = core->mdat.video_codec;
2765
2766 file_dialog->setDemuxer(demuxer, core->mset.original_demuxer);
2767 file_dialog->setAudioCodec(ac, core->mset.original_audio_codec);
2768 file_dialog->setVideoCodec(vc, core->mset.original_video_codec);
2769
2770 file_dialog->setMplayerAdditionalArguments( core->mset.mplayer_additional_options );
2771 file_dialog->setMplayerAdditionalVideoFilters( core->mset.mplayer_additional_video_filters );
2772 file_dialog->setMplayerAdditionalAudioFilters( core->mset.mplayer_additional_audio_filters );
2773
2774 file_dialog->setMediaData( core->mdat );
2775}
2776
2777void BaseGui::applyFileProperties() {
2778 qDebug("BaseGui::applyFileProperties");
2779
2780 bool need_restart = false;
2781 bool demuxer_changed = false;
2782
2783#undef TEST_AND_SET
2784#define TEST_AND_SET( Pref, Dialog ) \
2785 if ( Pref != Dialog ) { Pref = Dialog; need_restart = TRUE; }
2786
2787 QString prev_demuxer = core->mset.forced_demuxer;
2788
2789 QString demuxer = file_dialog->demuxer();
2790 if (demuxer == core->mset.original_demuxer) demuxer="";
2791 TEST_AND_SET(core->mset.forced_demuxer, demuxer);
2792
2793 if (prev_demuxer != core->mset.forced_demuxer) {
2794 // Demuxer changed
2795 demuxer_changed = true;
2796 core->mset.current_audio_id = MediaSettings::NoneSelected;
2797 core->mset.current_sub_id = MediaSettings::NoneSelected;
2798 }
2799
2800 QString ac = file_dialog->audioCodec();
2801 if (ac == core->mset.original_audio_codec) ac="";
2802 TEST_AND_SET(core->mset.forced_audio_codec, ac);
2803
2804 QString vc = file_dialog->videoCodec();
2805 if (vc == core->mset.original_video_codec) vc="";
2806 TEST_AND_SET(core->mset.forced_video_codec, vc);
2807
2808 TEST_AND_SET(core->mset.mplayer_additional_options, file_dialog->mplayerAdditionalArguments());
2809 TEST_AND_SET(core->mset.mplayer_additional_video_filters, file_dialog->mplayerAdditionalVideoFilters());
2810 TEST_AND_SET(core->mset.mplayer_additional_audio_filters, file_dialog->mplayerAdditionalAudioFilters());
2811
2812 // Restart the video to apply
2813 if (need_restart) {
2814 if (demuxer_changed) {
2815 core->reload();
2816 } else {
2817 core->restart();
2818 }
2819 }
2820}
2821
2822
2823void BaseGui::updateMediaInfo() {
2824 qDebug("BaseGui::updateMediaInfo");
2825
2826 if (file_dialog) {
2827 if (file_dialog->isVisible()) setDataToFileProperties();
2828 }
2829
2830 setWindowCaption( core->mdat.displayName(pref->show_tag_in_window_title) + " - SMPlayer" );
2831
2832 emit videoInfoChanged(core->mdat.video_width, core->mdat.video_height, core->mdat.video_fps.toDouble());
2833}
2834
2835void BaseGui::newMediaLoaded() {
2836 qDebug("BaseGui::newMediaLoaded");
2837
2838 pref->history_recents->addItem( core->mdat.filename );
2839 updateRecents();
2840
2841 // If a VCD, Audio CD or DVD, add items to playlist
2842 bool is_disc = ( (core->mdat.type == TYPE_VCD) || (core->mdat.type == TYPE_DVD) || (core->mdat.type == TYPE_AUDIO_CD) );
2843#if DVDNAV_SUPPORT
2844 // Don't add the list of titles if using dvdnav
2845 if ((core->mdat.type == TYPE_DVD) && (core->mdat.filename.startsWith("dvdnav:"))) is_disc = false;
2846#endif
2847 if (pref->auto_add_to_playlist && is_disc)
2848 {
2849 int first_title = 1;
2850 if (core->mdat.type == TYPE_VCD) first_title = pref->vcd_initial_title;
2851
2852 QString type = "dvd"; // FIXME: support dvdnav
2853 if (core->mdat.type == TYPE_VCD) type="vcd";
2854 else
2855 if (core->mdat.type == TYPE_AUDIO_CD) type="cdda";
2856
2857 if (core->mset.current_title_id == first_title) {
2858 playlist->clear();
2859 QStringList l;
2860 QString s;
2861 QString folder;
2862 if (core->mdat.type == TYPE_DVD) {
2863 DiscData disc_data = DiscName::split(core->mdat.filename);
2864 folder = disc_data.device;
2865 }
2866 for (int n=0; n < core->mdat.titles.numItems(); n++) {
2867 s = type + "://" + QString::number(core->mdat.titles.itemAt(n).ID());
2868 if ( !folder.isEmpty() ) {
2869 s += "/" + folder; // FIXME: dvd names are not created as they should
2870 }
2871 l.append(s);
2872 }
2873 playlist->addFiles(l);
2874 //playlist->setModified(false); // Not a real playlist
2875 }
2876 } /*else {
2877 playlist->clear();
2878 playlist->addCurrentFile();
2879 }*/
2880
2881 if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist) && (pref->add_to_playlist_consecutive_files)) {
2882 // Look for consecutive files
2883 QStringList files_to_add = Helper::searchForConsecutiveFiles(core->mdat.filename);
2884 if (!files_to_add.empty()) playlist->addFiles(files_to_add);
2885 }
2886}
2887
2888#ifdef LOG_MPLAYER
2889void BaseGui::clearMplayerLog() {
2890 mplayer_log.clear();
2891 if (mplayer_log_window->isVisible()) mplayer_log_window->clear();
2892}
2893
2894void BaseGui::recordMplayerLog(QString line) {
2895 if (pref->log_mplayer) {
2896 if ( (line.indexOf("A:")==-1) && (line.indexOf("V:")==-1) ) {
2897 line.append("\n");
2898 mplayer_log.append(line);
2899 if (mplayer_log_window->isVisible()) mplayer_log_window->appendText(line);
2900 }
2901 }
2902}
2903
2904/*!
2905 Save the mplayer log to a file, so it can be used by external
2906 applications.
2907*/
2908void BaseGui::autosaveMplayerLog() {
2909 qDebug("BaseGui::autosaveMplayerLog");
2910
2911 if (pref->autosave_mplayer_log) {
2912 if (!pref->mplayer_log_saveto.isEmpty()) {
2913 QFile file( pref->mplayer_log_saveto );
2914 if ( file.open( QIODevice::WriteOnly ) ) {
2915 QTextStream strm( &file );
2916 strm << mplayer_log;
2917 file.close();
2918 }
2919 }
2920 }
2921}
2922
2923void BaseGui::showMplayerLog() {
2924 qDebug("BaseGui::showMplayerLog");
2925
2926 exitFullscreenIfNeeded();
2927
2928 mplayer_log_window->setText( mplayer_log );
2929 mplayer_log_window->show();
2930}
2931#endif
2932
2933#ifdef LOG_SMPLAYER
2934void BaseGui::recordSmplayerLog(QString line) {
2935 if (pref->log_smplayer) {
2936 line.append("\n");
2937 smplayer_log.append(line);
2938 if (smplayer_log_window->isVisible()) smplayer_log_window->appendText(line);
2939 }
2940}
2941
2942void BaseGui::showLog() {
2943 qDebug("BaseGui::showLog");
2944
2945 exitFullscreenIfNeeded();
2946
2947 smplayer_log_window->setText( smplayer_log );
2948 smplayer_log_window->show();
2949}
2950#endif
2951
2952
2953void BaseGui::initializeMenus() {
2954 qDebug("BaseGui::initializeMenus");
2955
2956#define EMPTY 1
2957
2958 int n;
2959
2960 // Subtitles
2961 subtitleTrackGroup->clear(true);
2962 QAction * subNoneAct = subtitleTrackGroup->addAction( tr("&None") );
2963 subNoneAct->setData(MediaSettings::SubNone);
2964 subNoneAct->setCheckable(true);
2965 for (n=0; n < core->mdat.subs.numItems(); n++) {
2966 QAction *a = new QAction(subtitleTrackGroup);
2967 a->setCheckable(true);
2968 a->setText(core->mdat.subs.itemAt(n).displayName());
2969 a->setData(n);
2970 }
2971 subtitlestrack_menu->addActions( subtitleTrackGroup->actions() );
2972
2973 // Audio
2974 audioTrackGroup->clear(true);
2975 if (core->mdat.audios.numItems()==0) {
2976 QAction * a = audioTrackGroup->addAction( tr("<empty>") );
2977 a->setEnabled(false);
2978 } else {
2979 for (n=0; n < core->mdat.audios.numItems(); n++) {
2980 QAction *a = new QAction(audioTrackGroup);
2981 a->setCheckable(true);
2982 a->setText(core->mdat.audios.itemAt(n).displayName());
2983 a->setData(core->mdat.audios.itemAt(n).ID());
2984 }
2985 }
2986 audiotrack_menu->addActions( audioTrackGroup->actions() );
2987
2988#if PROGRAM_SWITCH
2989 // Program
2990 programTrackGroup->clear(true);
2991 if (core->mdat.programs.numItems()==0) {
2992 QAction * a = programTrackGroup->addAction( tr("<empty>") );
2993 a->setEnabled(false);
2994 } else {
2995 for (n=0; n < core->mdat.programs.numItems(); n++) {
2996 QAction *a = new QAction(programTrackGroup);
2997 a->setCheckable(true);
2998 a->setText(core->mdat.programs.itemAt(n).displayName());
2999 a->setData(core->mdat.programs.itemAt(n).ID());
3000 }
3001 }
3002 programtrack_menu->addActions( programTrackGroup->actions() );
3003#endif
3004
3005 // Video
3006 videoTrackGroup->clear(true);
3007 if (core->mdat.videos.numItems()==0) {
3008 QAction * a = videoTrackGroup->addAction( tr("<empty>") );
3009 a->setEnabled(false);
3010 } else {
3011 for (n=0; n < core->mdat.videos.numItems(); n++) {
3012 QAction *a = new QAction(videoTrackGroup);
3013 a->setCheckable(true);
3014 a->setText(core->mdat.videos.itemAt(n).displayName());
3015 a->setData(core->mdat.videos.itemAt(n).ID());
3016 }
3017 }
3018 videotrack_menu->addActions( videoTrackGroup->actions() );
3019
3020 // Titles
3021 titleGroup->clear(true);
3022 if (core->mdat.titles.numItems()==0) {
3023 QAction * a = titleGroup->addAction( tr("<empty>") );
3024 a->setEnabled(false);
3025 } else {
3026 for (n=0; n < core->mdat.titles.numItems(); n++) {
3027 QAction *a = new QAction(titleGroup);
3028 a->setCheckable(true);
3029 a->setText(core->mdat.titles.itemAt(n).displayName());
3030 a->setData(core->mdat.titles.itemAt(n).ID());
3031 }
3032 }
3033 titles_menu->addActions( titleGroup->actions() );
3034
3035 // Chapters
3036 chapterGroup->clear(true);
3037 if (core->mdat.chapters.numItems() > 0) {
3038 for (n=0; n < core->mdat.chapters.numItems(); n++) {
3039 QAction *a = new QAction(chapterGroup);
3040 //a->setCheckable(true);
3041 a->setText(core->mdat.chapters.itemAt(n).name());
3042 a->setData(core->mdat.chapters.itemAt(n).ID());
3043 }
3044 }
3045 else
3046 if (core->mdat.n_chapters > 0) {
3047 for (n=0; n < core->mdat.n_chapters; n++) {
3048 QAction *a = new QAction(chapterGroup);
3049 //a->setCheckable(true);
3050 a->setText( QString::number(n+1) );
3051 a->setData( n + Core::firstChapter() );
3052 }
3053 }
3054 else {
3055 QAction * a = chapterGroup->addAction( tr("<empty>") );
3056 a->setEnabled(false);
3057 }
3058 chapters_menu->addActions( chapterGroup->actions() );
3059
3060 // Angles
3061 angleGroup->clear(true);
3062 int n_angles = 0;
3063 if (core->mset.current_angle_id > 0) {
3064 int i = core->mdat.titles.find(core->mset.current_angle_id);
3065 if (i > -1) n_angles = core->mdat.titles.itemAt(i).angles();
3066 }
3067 if (n_angles > 0) {
3068 for (n=1; n <= n_angles; n++) {
3069 QAction *a = new QAction(angleGroup);
3070 a->setCheckable(true);
3071 a->setText( QString::number(n) );
3072 a->setData( n );
3073 }
3074 } else {
3075 QAction * a = angleGroup->addAction( tr("<empty>") );
3076 a->setEnabled(false);
3077 }
3078 angles_menu->addActions( angleGroup->actions() );
3079}
3080
3081void BaseGui::updateRecents() {
3082 qDebug("BaseGui::updateRecents");
3083
3084 // Not clear the first 2 items
3085 while (recentfiles_menu->actions().count() > 2) {
3086 QAction * a = recentfiles_menu->actions()[2];
3087 recentfiles_menu->removeAction( a );
3088 a->deleteLater();
3089 }
3090
3091 int current_items = 0;
3092
3093 if (pref->history_recents->count() > 0) {
3094 for (int n=0; n < pref->history_recents->count(); n++) {
3095 QString i = QString::number( n+1 );
3096 QString fullname = pref->history_recents->item(n);
3097 QString filename = fullname;
3098 QFileInfo fi(fullname);
3099 //if (fi.exists()) filename = fi.fileName(); // Can be slow
3100
3101 // Let's see if it looks like a file (no dvd://1 or something)
3102 if (fullname.indexOf(QRegExp("^.*://.*")) == -1) filename = fi.fileName();
3103
3104 if (filename.size() > 85) {
3105 filename = filename.left(80) + "...";
3106 }
3107
3108 QAction * a = recentfiles_menu->addAction( QString("%1. " + filename ).arg( i.insert( i.size()-1, '&' ), 3, ' ' ));
3109 a->setStatusTip(fullname);
3110 a->setData(n);
3111 connect(a, SIGNAL(triggered()), this, SLOT(openRecent()));
3112 current_items++;
3113 }
3114 } else {
3115 QAction * a = recentfiles_menu->addAction( tr("<empty>") );
3116 a->setEnabled(false);
3117 }
3118
3119 recentfiles_menu->menuAction()->setVisible( current_items > 0 );
3120}
3121
3122void BaseGui::clearRecentsList() {
3123 // Delete items in menu
3124 pref->history_recents->clear();
3125 updateRecents();
3126}
3127
3128void BaseGui::updateWidgets() {
3129 qDebug("BaseGui::updateWidgets");
3130
3131 // Subtitles menu
3132 subtitleTrackGroup->setChecked( core->mset.current_sub_id );
3133
3134 // Disable the unload subs action if there's no external subtitles
3135 unloadSubsAct->setEnabled( !core->mset.external_subtitles.isEmpty() );
3136
3137 // Closed caption menu
3138 ccGroup->setChecked( core->mset.closed_caption_channel );
3139
3140 // Audio menu
3141 audioTrackGroup->setChecked( core->mset.current_audio_id );
3142 channelsGroup->setChecked( core->mset.audio_use_channels );
3143 stereoGroup->setChecked( core->mset.stereo_mode );
3144 // Disable the unload audio file action if there's no external audio file
3145 unloadAudioAct->setEnabled( !core->mset.external_audio.isEmpty() );
3146
3147#if PROGRAM_SWITCH
3148 // Program menu
3149 programTrackGroup->setChecked( core->mset.current_program_id );
3150#endif
3151
3152 // Video menu
3153 videoTrackGroup->setChecked( core->mset.current_video_id );
3154
3155 // Aspect ratio
3156 aspectGroup->setChecked( core->mset.aspect_ratio_id );
3157
3158 // Rotate
3159 rotateGroup->setChecked( core->mset.rotate );
3160
3161#if USE_ADAPTER
3162 screenGroup->setChecked( pref->adapter );
3163#endif
3164
3165 // OSD
3166 osdGroup->setChecked( pref->osd );
3167
3168 // Titles
3169 titleGroup->setChecked( core->mset.current_title_id );
3170
3171 // Chapters
3172 chapterGroup->setChecked( core->mset.current_chapter_id );
3173
3174 // Angles
3175 angleGroup->setChecked( core->mset.current_angle_id );
3176
3177 // Deinterlace menu
3178 deinterlaceGroup->setChecked( core->mset.current_deinterlacer );
3179
3180 // Video size menu
3181 sizeGroup->setChecked( pref->size_factor );
3182
3183 // Auto phase
3184 phaseAct->setChecked( core->mset.phase_filter );
3185
3186 // Deblock
3187 deblockAct->setChecked( core->mset.deblock_filter );
3188
3189 // Dering
3190 deringAct->setChecked( core->mset.dering_filter );
3191
3192 // Gradfun
3193 gradfunAct->setChecked( core->mset.gradfun_filter );
3194
3195 // Add noise
3196 addNoiseAct->setChecked( core->mset.noise_filter );
3197
3198 // Letterbox
3199 addLetterboxAct->setChecked( core->mset.add_letterbox );
3200
3201 // Upscaling
3202 upscaleAct->setChecked( core->mset.upscaling_filter );
3203
3204
3205 // Postprocessing
3206 postProcessingAct->setChecked( core->mset.postprocessing_filter );
3207
3208 // Denoise submenu
3209 denoiseGroup->setChecked( core->mset.current_denoiser );
3210
3211 // Unsharp submenu
3212 unsharpGroup->setChecked( core->mset.current_unsharp );
3213
3214 /*
3215 // Fullscreen button
3216 fullscreenbutton->setOn(pref->fullscreen);
3217
3218 // Mute button
3219 mutebutton->setOn(core->mset.mute);
3220 if (core->mset.mute)
3221 mutebutton->setPixmap( Images::icon("mute_small") );
3222 else
3223 mutebutton->setPixmap( Images::icon("volume_small") );
3224
3225 // Volume slider
3226 volumeslider->setValue( core->mset.volume );
3227 */
3228
3229 // Mute menu option
3230 muteAct->setChecked( (pref->global_volume ? pref->mute : core->mset.mute) );
3231
3232 // Karaoke menu option
3233 karaokeAct->setChecked( core->mset.karaoke_filter );
3234
3235 // Extrastereo menu option
3236 extrastereoAct->setChecked( core->mset.extrastereo_filter );
3237
3238 // Volnorm menu option
3239 volnormAct->setChecked( core->mset.volnorm_filter );
3240
3241 // Repeat menu option
3242 repeatAct->setChecked( core->mset.loop );
3243
3244 // Fullscreen action
3245 fullscreenAct->setChecked( pref->fullscreen );
3246
3247 // Time slider
3248 if (core->state()==Core::Stopped) {
3249 //FIXME
3250 //timeslider->setValue( (int) core->mset.current_sec );
3251 }
3252
3253 // Video equalizer
3254 videoEqualizerAct->setChecked( video_equalizer->isVisible() );
3255
3256 // Audio equalizer
3257 audioEqualizerAct->setChecked( audio_equalizer->isVisible() );
3258
3259 // Playlist
3260#if !DOCK_PLAYLIST
3261 //showPlaylistAct->setChecked( playlist->isVisible() );
3262#endif
3263
3264#if DOCK_PLAYLIST
3265 showPlaylistAct->setChecked( playlist->isVisible() );
3266#endif
3267
3268 // Compact mode
3269 compactAct->setChecked( pref->compact_mode );
3270
3271 // Stay on top
3272 onTopActionGroup->setChecked( (int) pref->stay_on_top );
3273
3274 // Flip
3275 flipAct->setChecked( core->mset.flip );
3276
3277 // Mirror
3278 mirrorAct->setChecked( core->mset.mirror );
3279
3280 // Use ass lib
3281 useAssAct->setChecked( pref->use_ass_subtitles );
3282
3283 // Forced subs
3284 useForcedSubsOnlyAct->setChecked( pref->use_forced_subs_only );
3285
3286 // Subtitle visibility
3287 subVisibilityAct->setChecked(pref->sub_visibility);
3288
3289 // Enable or disable subtitle options
3290 bool e = ((core->mset.current_sub_id != MediaSettings::SubNone) &&
3291 (core->mset.current_sub_id != MediaSettings::NoneSelected));
3292
3293 if (core->mset.closed_caption_channel !=0 ) e = true; // Enable if using closed captions
3294
3295 decSubDelayAct->setEnabled(e);
3296 incSubDelayAct->setEnabled(e);
3297 subDelayAct->setEnabled(e);
3298 decSubPosAct->setEnabled(e);
3299 incSubPosAct->setEnabled(e);
3300 decSubScaleAct->setEnabled(e);
3301 incSubScaleAct->setEnabled(e);
3302 decSubStepAct->setEnabled(e);
3303 incSubStepAct->setEnabled(e);
3304}
3305
3306void BaseGui::updateVideoEqualizer() {
3307 // Equalizer
3308 video_equalizer->contrast->setValue( core->mset.contrast );
3309 video_equalizer->brightness->setValue( core->mset.brightness );
3310 video_equalizer->hue->setValue( core->mset.hue );
3311 video_equalizer->saturation->setValue( core->mset.saturation );
3312 video_equalizer->gamma->setValue( core->mset.gamma );
3313}
3314
3315void BaseGui::updateAudioEqualizer() {
3316 // Audio Equalizer
3317 for (int n = 0; n < 10; n++) {
3318 audio_equalizer->eq[n]->setValue( core->mset.audio_equalizer[n].toInt() );
3319 }
3320}
3321
3322/*
3323void BaseGui::playlistVisibilityChanged() {
3324#if !DOCK_PLAYLIST
3325 bool visible = playlist->isVisible();
3326
3327 showPlaylistAct->setChecked( visible );
3328#endif
3329}
3330*/
3331
3332/*
3333void BaseGui::openRecent(int item) {
3334 qDebug("BaseGui::openRecent: %d", item);
3335 if ((item > -1) && (item < RECENTS_CLEAR)) { // 1000 = Clear item
3336 open( recents->item(item) );
3337 }
3338}
3339*/
3340
3341void BaseGui::openRecent() {
3342 QAction *a = qobject_cast<QAction *> (sender());
3343 if (a) {
3344 int item = a->data().toInt();
3345 qDebug("BaseGui::openRecent: %d", item);
3346 QString file = pref->history_recents->item(item);
3347
3348 if (pref->auto_add_to_playlist) {
3349 if (playlist->maybeSave()) {
3350 playlist->clear();
3351 playlist->addFile(file, Playlist::NoGetInfo);
3352
3353 open( file );
3354 }
3355 } else {
3356 open( file );
3357 }
3358
3359 }
3360}
3361
3362void BaseGui::open(QString file) {
3363 qDebug("BaseGui::open: '%s'", file.toUtf8().data());
3364
3365 // If file is a playlist, open that playlist
3366 QString extension = QFileInfo(file).suffix().toLower();
3367 if ( ((extension=="m3u") || (extension=="m3u8")) && (QFile::exists(file)) ) {
3368 playlist->load_m3u(file);
3369 }
3370 else
3371 if (extension=="pls") {
3372 playlist->load_pls(file);
3373 }
3374 else
3375 if (QFileInfo(file).isDir()) {
3376 openDirectory(file);
3377 }
3378 else {
3379 // Let the core to open it, autodetecting the file type
3380 //if (playlist->maybeSave()) {
3381 // playlist->clear();
3382 // playlist->addFile(file);
3383
3384 core->open(file);
3385 //}
3386 }
3387
3388 if (QFile::exists(file)) pref->latest_dir = QFileInfo(file).absolutePath();
3389}
3390
3391void BaseGui::openFiles(QStringList files) {
3392 qDebug("BaseGui::openFiles");
3393 if (files.empty()) return;
3394
3395 if (files.count()==1) {
3396 if (pref->auto_add_to_playlist) {
3397 if (playlist->maybeSave()) {
3398 playlist->clear();
3399 playlist->addFile(files[0], Playlist::NoGetInfo);
3400
3401 open(files[0]);
3402 }
3403 } else {
3404 open(files[0]);
3405 }
3406 } else {
3407 if (playlist->maybeSave()) {
3408 playlist->clear();
3409 playlist->addFiles(files);
3410 open(files[0]);
3411 }
3412 }
3413}
3414
3415void BaseGui::openFavorite(QString file) {
3416 qDebug("BaseGui::openFavorite");
3417
3418 openFiles(QStringList() << file);
3419}
3420
3421void BaseGui::openURL() {
3422 qDebug("BaseGui::openURL");
3423
3424 exitFullscreenIfNeeded();
3425
3426 /*
3427 bool ok;
3428 QString s = QInputDialog::getText(this,
3429 tr("SMPlayer - Enter URL"), tr("URL:"), QLineEdit::Normal,
3430 pref->last_url, &ok );
3431
3432 if ( ok && !s.isEmpty() ) {
3433
3434 //playlist->clear();
3435 //playlistdock->hide();
3436
3437 openURL(s);
3438 } else {
3439 // user entered nothing or pressed Cancel
3440 }
3441 */
3442
3443 InputURL d(this);
3444
3445 for (int n=0; n < pref->history_urls->count(); n++) {
3446 d.setURL( pref->history_urls->url(n) );
3447 }
3448
3449 if (d.exec() == QDialog::Accepted ) {
3450 QString url = d.url();
3451 if (!url.isEmpty()) {
3452 pref->history_urls->addUrl(url);
3453 openURL(url);
3454 }
3455 }
3456}
3457
3458void BaseGui::openURL(QString url) {
3459 if (!url.isEmpty()) {
3460 //pref->history_urls->addUrl(url);
3461
3462 if (pref->auto_add_to_playlist) {
3463 if (playlist->maybeSave()) {
3464 core->openStream(url);
3465
3466 playlist->clear();
3467 playlist->addFile(url, Playlist::NoGetInfo);
3468 }
3469 } else {
3470 core->openStream(url);
3471 }
3472 }
3473}
3474
3475
3476void BaseGui::openFile() {
3477 qDebug("BaseGui::fileOpen");
3478
3479 exitFullscreenIfNeeded();
3480
3481 Extensions e;
3482 QString s = MyFileDialog::getOpenFileName(
3483 this, tr("Choose a file"), pref->latest_dir,
3484 tr("Multimedia") + e.allPlayable().forFilter()+";;" +
3485 tr("Video") + e.video().forFilter()+";;" +
3486 tr("Audio") + e.audio().forFilter()+";;" +
3487 tr("Playlists") + e.playlist().forFilter()+";;" +
3488 tr("All files") +" (*.*)" );
3489
3490 if ( !s.isEmpty() ) {
3491 openFile(s);
3492 }
3493}
3494
3495void BaseGui::openFile(QString file) {
3496 qDebug("BaseGui::openFile: '%s'", file.toUtf8().data());
3497
3498 if ( !file.isEmpty() ) {
3499
3500 //playlist->clear();
3501 //playlistdock->hide();
3502
3503 // If file is a playlist, open that playlist
3504 QString extension = QFileInfo(file).suffix().toLower();
3505 if ( (extension=="m3u") || (extension=="m3u8") ) {
3506 playlist->load_m3u(file);
3507 }
3508 else
3509 if (extension=="pls") {
3510 playlist->load_pls(file);
3511 }
3512 else
3513 if (extension=="iso") {
3514 if (playlist->maybeSave()) {
3515 core->open(file);
3516 }
3517 }
3518 else {
3519 if (pref->auto_add_to_playlist) {
3520 if (playlist->maybeSave()) {
3521 core->openFile(file);
3522
3523 playlist->clear();
3524 playlist->addFile(file, Playlist::NoGetInfo);
3525 }
3526 } else {
3527 core->openFile(file);
3528 }
3529 }
3530 if (QFile::exists(file)) pref->latest_dir = QFileInfo(file).absolutePath();
3531 }
3532}
3533
3534void BaseGui::configureDiscDevices() {
3535 QMessageBox::information( this, tr("SMPlayer - Information"),
3536 tr("The CDROM / DVD drives are not configured yet.\n"
3537 "The configuration dialog will be shown now, "
3538 "so you can do it."), QMessageBox::Ok);
3539
3540 showPreferencesDialog();
3541 pref_dialog->showSection( PreferencesDialog::Drives );
3542}
3543
3544void BaseGui::openVCD() {
3545 qDebug("BaseGui::openVCD");
3546
3547 if ( (pref->dvd_device.isEmpty()) ||
3548 (pref->cdrom_device.isEmpty()) )
3549 {
3550 configureDiscDevices();
3551 } else {
3552 if (playlist->maybeSave()) {
3553 core->openVCD( pref->vcd_initial_title );
3554 }
3555 }
3556}
3557
3558void BaseGui::openAudioCD() {
3559 qDebug("BaseGui::openAudioCD");
3560
3561 if ( (pref->dvd_device.isEmpty()) ||
3562 (pref->cdrom_device.isEmpty()) )
3563 {
3564 configureDiscDevices();
3565 } else {
3566 if (playlist->maybeSave()) {
3567 core->openAudioCD();
3568 }
3569 }
3570}
3571
3572void BaseGui::openDVD() {
3573 qDebug("BaseGui::openDVD");
3574
3575 if ( (pref->dvd_device.isEmpty()) ||
3576 (pref->cdrom_device.isEmpty()) )
3577 {
3578 configureDiscDevices();
3579 } else {
3580 if (playlist->maybeSave()) {
3581#if DVDNAV_SUPPORT
3582 core->openDVD( DiscName::joinDVD(pref->use_dvdnav ? 0: 1, pref->dvd_device, pref->use_dvdnav) );
3583#else
3584 core->openDVD( DiscName::joinDVD(1, pref->dvd_device, false) );
3585#endif
3586 }
3587 }
3588}
3589
3590void BaseGui::openDVDFromFolder() {
3591 qDebug("BaseGui::openDVDFromFolder");
3592
3593 if (playlist->maybeSave()) {
3594 InputDVDDirectory *d = new InputDVDDirectory(this);
3595 d->setFolder( pref->last_dvd_directory );
3596
3597 if (d->exec() == QDialog::Accepted) {
3598 qDebug("BaseGui::openDVDFromFolder: accepted");
3599 openDVDFromFolder( d->folder() );
3600 }
3601
3602 delete d;
3603 }
3604}
3605
3606void BaseGui::openDVDFromFolder(QString directory) {
3607 pref->last_dvd_directory = directory;
3608#if DVDNAV_SUPPORT
3609 core->openDVD( DiscName::joinDVD(pref->use_dvdnav ? 0: 1, directory, pref->use_dvdnav) );
3610#else
3611 core->openDVD( DiscName::joinDVD(1, directory, false) );
3612#endif
3613}
3614
3615void BaseGui::openDirectory() {
3616 qDebug("BaseGui::openDirectory");
3617
3618 QString s = MyFileDialog::getExistingDirectory(
3619 this, tr("Choose a directory"),
3620 pref->latest_dir );
3621
3622 if (!s.isEmpty()) {
3623 openDirectory(s);
3624 }
3625}
3626
3627void BaseGui::openDirectory(QString directory) {
3628 qDebug("BaseGui::openDirectory: '%s'", directory.toUtf8().data());
3629
3630 if (Helper::directoryContainsDVD(directory)) {
3631 core->open(directory);
3632 }
3633 else {
3634 QFileInfo fi(directory);
3635 if ( (fi.exists()) && (fi.isDir()) ) {
3636 playlist->clear();
3637 //playlist->addDirectory(directory);
3638 playlist->addDirectory( fi.absoluteFilePath() );
3639 playlist->startPlay();
3640 } else {
3641 qDebug("BaseGui::openDirectory: directory is not valid");
3642 }
3643 }
3644}
3645
3646void BaseGui::loadSub() {
3647 qDebug("BaseGui::loadSub");
3648
3649 exitFullscreenIfNeeded();
3650
3651 Extensions e;
3652 QString s = MyFileDialog::getOpenFileName(
3653 this, tr("Choose a file"),
3654 pref->latest_dir,
3655 tr("Subtitles") + e.subtitles().forFilter()+ ";;" +
3656 tr("All files") +" (*.*)" );
3657
3658 if (!s.isEmpty()) core->loadSub(s);
3659}
3660
3661void BaseGui::setInitialSubtitle(const QString & subtitle_file) {
3662 qDebug("BaseGui::setInitialSubtitle: '%s'", subtitle_file.toUtf8().constData());
3663
3664 core->setInitialSubtitle(subtitle_file);
3665}
3666
3667void BaseGui::loadAudioFile() {
3668 qDebug("BaseGui::loadAudioFile");
3669
3670 exitFullscreenIfNeeded();
3671
3672 Extensions e;
3673 QString s = MyFileDialog::getOpenFileName(
3674 this, tr("Choose a file"),
3675 pref->latest_dir,
3676 tr("Audio") + e.audio().forFilter()+";;" +
3677 tr("All files") +" (*.*)" );
3678
3679 if (!s.isEmpty()) core->loadAudioFile(s);
3680}
3681
3682void BaseGui::helpFAQ() {
3683 QUrl url = QUrl::fromLocalFile(Paths::doc("faq.html", pref->language));
3684 qDebug("BaseGui::helpFAQ: file to open %s", url.toString().toUtf8().data());
3685 QDesktopServices::openUrl( url );
3686}
3687
3688void BaseGui::helpCLOptions() {
3689 if (clhelp_window == 0) {
3690 clhelp_window = new LogWindow(this);
3691 }
3692 clhelp_window->setWindowTitle( tr("SMPlayer command line options") );
3693 clhelp_window->setHtml(CLHelp::help(true));
3694 clhelp_window->show();
3695}
3696
3697void BaseGui::helpCheckUpdates() {
3698 QString url = "http://smplayer.sourceforge.net/latest.php";
3699 if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language);
3700 QDesktopServices::openUrl( QUrl(url) );
3701}
3702
3703void BaseGui::helpShowConfig() {
3704 QDesktopServices::openUrl(QUrl::fromLocalFile(Paths::configPath()));
3705}
3706
3707void BaseGui::helpAbout() {
3708 About d(this);
3709 d.exec();
3710}
3711
3712void BaseGui::helpAboutQt() {
3713 QMessageBox::aboutQt(this, tr("About Qt") );
3714}
3715
3716void BaseGui::showGotoDialog() {
3717 TimeDialog d(this);
3718 d.setLabel(tr("&Jump to:"));
3719 d.setWindowTitle(tr("SMPlayer - Seek"));
3720 d.setMaximumTime( (int) core->mdat.duration);
3721 d.setTime( (int) core->mset.current_sec);
3722 if (d.exec() == QDialog::Accepted) {
3723 core->goToSec( d.time() );
3724 }
3725}
3726
3727void BaseGui::showAudioDelayDialog() {
3728 bool ok;
3729 int delay = QInputDialog::getInteger(this, tr("SMPlayer - Audio delay"),
3730 tr("Audio delay (in milliseconds):"), core->mset.audio_delay,
3731 -3600000, 3600000, 1, &ok);
3732 if (ok) {
3733 core->setAudioDelay(delay);
3734 }
3735}
3736
3737void BaseGui::showSubDelayDialog() {
3738 bool ok;
3739 int delay = QInputDialog::getInteger(this, tr("SMPlayer - Subtitle delay"),
3740 tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay,
3741 -3600000, 3600000, 1, &ok);
3742 if (ok) {
3743 core->setSubDelay(delay);
3744 }
3745}
3746
3747void BaseGui::exitFullscreen() {
3748 if (pref->fullscreen) {
3749 toggleFullscreen(false);
3750 }
3751}
3752
3753void BaseGui::toggleFullscreen() {
3754 qDebug("BaseGui::toggleFullscreen");
3755
3756 toggleFullscreen(!pref->fullscreen);
3757}
3758
3759void BaseGui::toggleFullscreen(bool b) {
3760 qDebug("BaseGui::toggleFullscreen: %d", b);
3761
3762 if (b==pref->fullscreen) {
3763 // Nothing to do
3764 qDebug("BaseGui::toggleFullscreen: nothing to do, returning");
3765 return;
3766 }
3767
3768 pref->fullscreen = b;
3769
3770 // If using mplayer window
3771 if (pref->use_mplayer_window) {
3772 core->tellmp("vo_fullscreen " + QString::number(b) );
3773 updateWidgets();
3774 return;
3775 }
3776
3777 if (!panel->isVisible()) return; // mplayer window is not used.
3778
3779 if (pref->fullscreen) {
3780 compactAct->setEnabled(false);
3781
3782 if (pref->restore_pos_after_fullscreen) {
3783 win_pos = pos();
3784 win_size = size();
3785 }
3786
3787 was_maximized = isMaximized();
3788 qDebug("BaseGui::toggleFullscreen: was_maximized: %d", was_maximized);
3789
3790 aboutToEnterFullscreen();
3791
3792 #ifdef Q_OS_WIN
3793 // Hack to avoid the windows taskbar to be visible on Windows XP
3794 if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
3795 if (!pref->pause_when_hidden) hide();
3796 }
3797 #endif
3798
3799 showFullScreen();
3800
3801 } else {
3802 showNormal();
3803
3804 if (was_maximized) showMaximized(); // It has to be called after showNormal()
3805
3806 aboutToExitFullscreen();
3807
3808 if (pref->restore_pos_after_fullscreen) {
3809 move( win_pos );
3810 resize( win_size );
3811 }
3812
3813 compactAct->setEnabled(true);
3814 }
3815
3816 updateWidgets();
3817
3818 if ((pref->add_blackborders_on_fullscreen) &&
3819 (!core->mset.add_letterbox))
3820 {
3821 core->restart();
3822 }
3823
3824 setFocus(); // Fixes bug #2493415
3825}
3826
3827
3828void BaseGui::aboutToEnterFullscreen() {
3829 if (!pref->compact_mode) {
3830 menuBar()->hide();
3831 statusBar()->hide();
3832 }
3833}
3834
3835void BaseGui::aboutToExitFullscreen() {
3836 if (!pref->compact_mode) {
3837 menuBar()->show();
3838 statusBar()->show();
3839 }
3840}
3841
3842
3843void BaseGui::leftClickFunction() {
3844 qDebug("BaseGui::leftClickFunction");
3845
3846 if (!pref->mouse_left_click_function.isEmpty()) {
3847 processFunction(pref->mouse_left_click_function);
3848 }
3849}
3850
3851void BaseGui::rightClickFunction() {
3852 qDebug("BaseGui::rightClickFunction");
3853
3854 if (!pref->mouse_right_click_function.isEmpty()) {
3855 processFunction(pref->mouse_right_click_function);
3856 }
3857}
3858
3859void BaseGui::doubleClickFunction() {
3860 qDebug("BaseGui::doubleClickFunction");
3861
3862 if (!pref->mouse_double_click_function.isEmpty()) {
3863 processFunction(pref->mouse_double_click_function);
3864 }
3865}
3866
3867void BaseGui::middleClickFunction() {
3868 qDebug("BaseGui::middleClickFunction");
3869
3870 if (!pref->mouse_middle_click_function.isEmpty()) {
3871 processFunction(pref->mouse_middle_click_function);
3872 }
3873}
3874
3875void BaseGui::xbutton1ClickFunction() {
3876 qDebug("BaseGui::xbutton1ClickFunction");
3877
3878 if (!pref->mouse_xbutton1_click_function.isEmpty()) {
3879 processFunction(pref->mouse_xbutton1_click_function);
3880 }
3881}
3882
3883void BaseGui::xbutton2ClickFunction() {
3884 qDebug("BaseGui::xbutton2ClickFunction");
3885
3886 if (!pref->mouse_xbutton2_click_function.isEmpty()) {
3887 processFunction(pref->mouse_xbutton2_click_function);
3888 }
3889}
3890
3891void BaseGui::processFunction(QString function) {
3892 qDebug("BaseGui::processFunction: '%s'", function.toUtf8().data());
3893
3894 //parse args for checkable actions
3895 QRegExp func_rx("(.*) (true|false)");
3896 bool value = false;
3897 bool checkableFunction = false;
3898
3899 if(func_rx.indexIn(function) > -1){
3900 function = func_rx.cap(1);
3901 value = (func_rx.cap(2) == "true");
3902 checkableFunction = true;
3903 } //end if
3904
3905 QAction * action = ActionsEditor::findAction(this, function);
3906 if (!action) action = ActionsEditor::findAction(playlist, function);
3907
3908 if (action) {
3909 qDebug("BaseGui::processFunction: action found");
3910
3911 if (!action->isEnabled()) {
3912 qDebug("BaseGui::processFunction: action is disabled, doing nothing");
3913 return;
3914 }
3915
3916 if (action->isCheckable()){
3917 if(checkableFunction)
3918 action->setChecked(value);
3919 else
3920 //action->toggle();
3921 action->trigger();
3922 }else{
3923 action->trigger();
3924 }
3925 }
3926}
3927
3928void BaseGui::runActions(QString actions) {
3929 qDebug("BaseGui::runActions");
3930
3931 actions = actions.simplified(); // Remove white space
3932
3933 QAction * action;
3934 QStringList actionsList = actions.split(" ");
3935
3936 for (int n = 0; n < actionsList.count(); n++) {
3937 QString actionStr = actionsList[n];
3938 QString par = ""; //the parameter which the action takes
3939
3940 //set par if the next word is a boolean value
3941 if ( (n+1) < actionsList.count() ) {
3942 if ( (actionsList[n+1].toLower() == "true") || (actionsList[n+1].toLower() == "false") ) {
3943 par = actionsList[n+1].toLower();
3944 n++;
3945 } //end if
3946 } //end if
3947
3948 action = ActionsEditor::findAction(this, actionStr);
3949 if (!action) action = ActionsEditor::findAction(playlist, actionStr);
3950
3951 if (action) {
3952 qDebug("BaseGui::runActions: running action: '%s' (par: '%s')",
3953 actionStr.toUtf8().data(), par.toUtf8().data() );
3954
3955 if (action->isCheckable()) {
3956 if (par.isEmpty()) {
3957 //action->toggle();
3958 action->trigger();
3959 } else {
3960 action->setChecked( (par == "true") );
3961 } //end if
3962 } else {
3963 action->trigger();
3964 } //end if
3965 } else {
3966 qWarning("BaseGui::runActions: action: '%s' not found",actionStr.toUtf8().data());
3967 } //end if
3968 } //end for
3969}
3970
3971void BaseGui::checkPendingActionsToRun() {
3972 qDebug("BaseGui::checkPendingActionsToRun");
3973
3974 QString actions;
3975 if (!pending_actions_to_run.isEmpty()) {
3976 actions = pending_actions_to_run;
3977 pending_actions_to_run.clear();
3978 if (!pref->actions_to_run.isEmpty()) {
3979 actions = pref->actions_to_run +" "+ actions;
3980 }
3981 } else {
3982 actions = pref->actions_to_run;
3983 }
3984
3985 if (!actions.isEmpty()) {
3986 qDebug("BaseGui::checkPendingActionsToRun: actions: '%s'", actions.toUtf8().constData());
3987 runActions(actions);
3988 }
3989}
3990
3991#if REPORT_OLD_MPLAYER
3992void BaseGui::checkMplayerVersion() {
3993 qDebug("BaseGui::checkMplayerVersion");
3994
3995 // Qt 4.3.5 is crazy, I can't popup a messagebox here, it calls
3996 // this function once and again when the messagebox is shown
3997
3998 if ( (pref->mplayer_detected_version > 0) && (!MplayerVersion::isMplayerAtLeast(25158)) ) {
3999 QTimer::singleShot(1000, this, SLOT(displayWarningAboutOldMplayer()));
4000 }
4001}
4002
4003void BaseGui::displayWarningAboutOldMplayer() {
4004 qDebug("BaseGui::displayWarningAboutOldMplayer");
4005
4006 if (!pref->reported_mplayer_is_old) {
4007 QMessageBox::warning(this, tr("Warning - Using old MPlayer"),
4008 tr("The version of MPlayer (%1) installed on your system "
4009 "is obsolete. SMPlayer can't work well with it: some "
4010 "options won't work, subtitle selection may fail...")
4011 .arg(MplayerVersion::toString(pref->mplayer_detected_version)) +
4012 "<br><br>" +
4013 tr("Please, update your MPlayer.") +
4014 "<br><br>" +
4015 tr("(This warning won't be displayed anymore)") );
4016
4017 pref->reported_mplayer_is_old = true;
4018 }
4019 //else
4020 //statusBar()->showMessage( tr("Using an old MPlayer, please update it"), 10000 );
4021}
4022#endif
4023
4024void BaseGui::dragEnterEvent( QDragEnterEvent *e ) {
4025 qDebug("BaseGui::dragEnterEvent");
4026
4027 if (e->mimeData()->hasUrls()) {
4028 e->acceptProposedAction();
4029 }
4030}
4031
4032
4033
4034void BaseGui::dropEvent( QDropEvent *e ) {
4035 qDebug("BaseGui::dropEvent");
4036
4037 QStringList files;
4038
4039 if (e->mimeData()->hasUrls()) {
4040 QList <QUrl> l = e->mimeData()->urls();
4041 QString s;
4042 for (int n=0; n < l.count(); n++) {
4043 if (l[n].isValid()) {
4044 qDebug("BaseGui::dropEvent: scheme: '%s'", l[n].scheme().toUtf8().data());
4045 if (l[n].scheme() == "file")
4046 s = l[n].toLocalFile();
4047 else
4048 s = l[n].toString();
4049 /*
4050 qDebug(" * '%s'", l[n].toString().toUtf8().data());
4051 qDebug(" * '%s'", l[n].toLocalFile().toUtf8().data());
4052 */
4053 qDebug("BaseGui::dropEvent: file: '%s'", s.toUtf8().data());
4054 files.append(s);
4055 }
4056 }
4057 }
4058
4059
4060 qDebug( "BaseGui::dropEvent: count: %d", files.count());
4061 if (files.count() > 0) {
4062 if (files.count() == 1) {
4063 QFileInfo fi( files[0] );
4064
4065 Extensions e;
4066 QRegExp ext_sub(e.subtitles().forRegExp());
4067 ext_sub.setCaseSensitivity(Qt::CaseInsensitive);
4068 if (ext_sub.indexIn(fi.suffix()) > -1) {
4069 qDebug( "BaseGui::dropEvent: loading sub: '%s'", files[0].toUtf8().data());
4070 core->loadSub( files[0] );
4071 }
4072 else
4073 if (fi.isDir()) {
4074 openDirectory( files[0] );
4075 } else {
4076 //openFile( files[0] );
4077 if (pref->auto_add_to_playlist) {
4078 if (playlist->maybeSave()) {
4079 playlist->clear();
4080 playlist->addFile(files[0], Playlist::NoGetInfo);
4081
4082 open( files[0] );
4083 }
4084 } else {
4085 open( files[0] );
4086 }
4087 }
4088 } else {
4089 // More than one file
4090 qDebug("BaseGui::dropEvent: adding files to playlist");
4091 playlist->clear();
4092 playlist->addFiles(files);
4093 //openFile( files[0] );
4094 playlist->startPlay();
4095 }
4096 }
4097}
4098
4099void BaseGui::showPopupMenu() {
4100 showPopupMenu(QCursor::pos());
4101}
4102
4103void BaseGui::showPopupMenu( QPoint p ) {
4104 //qDebug("BaseGui::showPopupMenu: %d, %d", p.x(), p.y());
4105 popup->move( p );
4106 popup->show();
4107}
4108
4109/*
4110void BaseGui::mouseReleaseEvent( QMouseEvent * e ) {
4111 qDebug("BaseGui::mouseReleaseEvent");
4112
4113 if (e->button() == Qt::LeftButton) {
4114 e->accept();
4115 emit leftClicked();
4116 }
4117 else
4118 if (e->button() == Qt::MidButton) {
4119 e->accept();
4120 emit middleClicked();
4121 }
4122 //
4123 //else
4124 //if (e->button() == Qt::RightButton) {
4125 // showPopupMenu( e->globalPos() );
4126 //}
4127 //
4128 else
4129 e->ignore();
4130}
4131
4132void BaseGui::mouseDoubleClickEvent( QMouseEvent * e ) {
4133 e->accept();
4134 emit doubleClicked();
4135}
4136*/
4137
4138void BaseGui::wheelEvent( QWheelEvent * e ) {
4139 qDebug("BaseGui::wheelEvent: delta: %d", e->delta());
4140 e->accept();
4141
4142 if (e->orientation() == Qt::Vertical) {
4143 if (e->delta() >= 0)
4144 emit wheelUp();
4145 else
4146 emit wheelDown();
4147 } else {
4148 qDebug("BaseGui::wheelEvent: horizontal event received, doing nothing");
4149 }
4150}
4151
4152
4153// Called when a video has started to play
4154void BaseGui::enterFullscreenOnPlay() {
4155 qDebug("BaseGui::enterFullscreenOnPlay: arg_start_in_fullscreen: %d, pref->start_in_fullscreen: %d", arg_start_in_fullscreen, pref->start_in_fullscreen);
4156
4157 if (arg_start_in_fullscreen != 0) {
4158 if ( (arg_start_in_fullscreen == 1) || (pref->start_in_fullscreen) ) {
4159 if (!pref->fullscreen) toggleFullscreen(TRUE);
4160 }
4161 }
4162}
4163
4164// Called when the playlist has stopped
4165void BaseGui::exitFullscreenOnStop() {
4166 if (pref->fullscreen) {
4167 toggleFullscreen(FALSE);
4168 }
4169}
4170
4171void BaseGui::playlistHasFinished() {
4172 qDebug("BaseGui::playlistHasFinished");
4173 core->stop();
4174
4175 exitFullscreenOnStop();
4176
4177 qDebug("BaseGui::playlistHasFinished: arg_close_on_finish: %d, pref->close_on_finish: %d", arg_close_on_finish, pref->close_on_finish);
4178
4179 if (arg_close_on_finish != 0) {
4180 if ((arg_close_on_finish == 1) || (pref->close_on_finish)) exitAct->trigger();
4181 }
4182}
4183
4184void BaseGui::displayState(Core::State state) {
4185 qDebug("BaseGui::displayState: %s", core->stateToString().toUtf8().data());
4186 switch (state) {
4187 case Core::Playing: statusBar()->showMessage( tr("Playing %1").arg(core->mdat.filename), 2000); break;
4188 case Core::Paused: statusBar()->showMessage( tr("Pause") ); break;
4189 case Core::Stopped: statusBar()->showMessage( tr("Stop") , 2000); break;
4190 }
4191 if (state == Core::Stopped) setWindowCaption( "SMPlayer" );
4192
4193#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
4194 /* Disable screensaver by event */
4195 just_stopped = false;
4196
4197 if (state == Core::Stopped) {
4198 just_stopped = true;
4199 int time = 1000 * 60; // 1 minute
4200 QTimer::singleShot( time, this, SLOT(clear_just_stopped()) );
4201 }
4202#endif
4203}
4204
4205void BaseGui::displayMessage(QString message) {
4206 statusBar()->showMessage(message, 2000);
4207}
4208
4209void BaseGui::gotCurrentTime(double sec) {
4210 //qDebug( "DefaultGui::displayTime: %f", sec);
4211
4212 static int last_second = 0;
4213
4214 if (floor(sec)==last_second) return; // Update only once per second
4215 last_second = (int) floor(sec);
4216
4217 QString time = Helper::formatTime( (int) sec ) + " / " +
4218 Helper::formatTime( (int) core->mdat.duration );
4219
4220 //qDebug( " duration: %f, current_sec: %f", core->mdat.duration, core->mset.current_sec);
4221
4222 emit timeChanged( time );
4223}
4224
4225void BaseGui::resizeWindow(int w, int h) {
4226 qDebug("BaseGui::resizeWindow: %d, %d", w, h);
4227
4228 // If fullscreen, don't resize!
4229 if (pref->fullscreen) return;
4230
4231 if ( (pref->resize_method==Preferences::Never) && (panel->isVisible()) ) {
4232 return;
4233 }
4234
4235 if (!panel->isVisible()) {
4236 panel->show();
4237
4238 // Enable compact mode
4239 //compactAct->setEnabled(true);
4240 }
4241
4242 if (pref->size_factor != 100) {
4243 w = w * pref->size_factor / 100;
4244 h = h * pref->size_factor / 100;
4245 }
4246
4247 qDebug("BaseGui::resizeWindow: size to scale: %d, %d", w, h);
4248
4249 QSize video_size(w,h);
4250
4251 if (video_size == panel->size()) {
4252 qDebug("BaseGui::resizeWindow: the panel size is already the required size. Doing nothing.");
4253 return;
4254 }
4255
4256 int diff_width = this->width() - panel->width();
4257 int diff_height = this->height() - panel->height();
4258
4259 int new_width = w + diff_width;
4260 int new_height = h + diff_height;
4261
4262#if USE_MINIMUMSIZE
4263 int minimum_width = minimumSizeHint().width();
4264 if (pref->gui_minimum_width != 0) minimum_width = pref->gui_minimum_width;
4265 if (new_width < minimum_width) {
4266 qDebug("BaseGui::resizeWindow: width is too small, setting width to %d", minimum_width);
4267 new_width = minimum_width;
4268 }
4269#endif
4270
4271 resize(new_width, new_height);
4272
4273 qDebug("BaseGui::resizeWindow: done: window size: %d, %d", this->width(), this->height());
4274 qDebug("BaseGui::resizeWindow: done: panel->size: %d, %d",
4275 panel->size().width(),
4276 panel->size().height() );
4277 qDebug("BaseGui::resizeWindow: done: mplayerwindow->size: %d, %d",
4278 mplayerwindow->size().width(),
4279 mplayerwindow->size().height() );
4280}
4281
4282void BaseGui::hidePanel() {
4283 qDebug("BaseGui::hidePanel");
4284
4285 if (panel->isVisible()) {
4286 // Exit from fullscreen mode
4287 if (pref->fullscreen) { toggleFullscreen(false); update(); }
4288
4289 // Exit from compact mode first
4290 if (pref->compact_mode) toggleCompactMode(false);
4291
4292 //resizeWindow( size().width(), 0 );
4293 int width = size().width();
4294 if (width > pref->default_size.width()) width = pref->default_size.width();
4295 resize( width, size().height() - panel->size().height() );
4296 panel->hide();
4297
4298 // Disable compact mode
4299 //compactAct->setEnabled(false);
4300 }
4301}
4302
4303void BaseGui::displayGotoTime(int t) {
4304#ifdef SEEKBAR_RESOLUTION
4305 int jump_time = (int)core->mdat.duration * t / SEEKBAR_RESOLUTION;
4306#else
4307 int jump_time = (int)core->mdat.duration * t / 100;
4308#endif
4309 QString s = tr("Jump to %1").arg( Helper::formatTime(jump_time) );
4310 statusBar()->showMessage( s, 1000 );
4311
4312 if (pref->fullscreen) {
4313 core->displayTextOnOSD( s );
4314 }
4315}
4316
4317void BaseGui::goToPosOnDragging(int t) {
4318 if (pref->update_while_seeking) {
4319#if ENABLE_DELAYED_DRAGGING
4320 #ifdef SEEKBAR_RESOLUTION
4321 core->goToPosition(t);
4322 #else
4323 core->goToPos(t);
4324 #endif
4325#else
4326 if ( ( t % 4 ) == 0 ) {
4327 qDebug("BaseGui::goToPosOnDragging: %d", t);
4328 #ifdef SEEKBAR_RESOLUTION
4329 core->goToPosition(t);
4330 #else
4331 core->goToPos(t);
4332 #endif
4333 }
4334#endif
4335 }
4336}
4337
4338void BaseGui::toggleCompactMode() {
4339 toggleCompactMode( !pref->compact_mode );
4340}
4341
4342void BaseGui::toggleCompactMode(bool b) {
4343 qDebug("BaseGui::toggleCompactMode: %d", b);
4344
4345 if (b)
4346 aboutToEnterCompactMode();
4347 else
4348 aboutToExitCompactMode();
4349
4350 pref->compact_mode = b;
4351 updateWidgets();
4352}
4353
4354void BaseGui::aboutToEnterCompactMode() {
4355 menuBar()->hide();
4356 statusBar()->hide();
4357}
4358
4359void BaseGui::aboutToExitCompactMode() {
4360 menuBar()->show();
4361 statusBar()->show();
4362}
4363
4364void BaseGui::setStayOnTop(bool b) {
4365 qDebug("BaseGui::setStayOnTop: %d", b);
4366
4367 if ( (b && (windowFlags() & Qt::WindowStaysOnTopHint)) ||
4368 (!b && (!(windowFlags() & Qt::WindowStaysOnTopHint))) )
4369 {
4370 // identical do nothing
4371 qDebug("BaseGui::setStayOnTop: nothing to do");
4372 return;
4373 }
4374
4375 ignore_show_hide_events = true;
4376
4377 bool visible = isVisible();
4378
4379 QPoint old_pos = pos();
4380
4381 if (b) {
4382 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
4383 }
4384 else {
4385 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
4386 }
4387
4388 move(old_pos);
4389
4390 if (visible) {
4391 show();
4392 }
4393
4394 ignore_show_hide_events = false;
4395}
4396
4397void BaseGui::changeStayOnTop(int stay_on_top) {
4398 switch (stay_on_top) {
4399 case Preferences::AlwaysOnTop : setStayOnTop(true); break;
4400 case Preferences::NeverOnTop : setStayOnTop(false); break;
4401 case Preferences::WhilePlayingOnTop : setStayOnTop((core->state() == Core::Playing)); break;
4402 }
4403
4404 pref->stay_on_top = (Preferences::OnTop) stay_on_top;
4405 updateWidgets();
4406}
4407
4408void BaseGui::checkStayOnTop(Core::State state) {
4409 qDebug("BaseGui::checkStayOnTop");
4410 if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) {
4411 setStayOnTop((state == Core::Playing));
4412 }
4413}
4414
4415void BaseGui::toggleStayOnTop() {
4416 if (pref->stay_on_top == Preferences::AlwaysOnTop)
4417 changeStayOnTop(Preferences::NeverOnTop);
4418 else
4419 if (pref->stay_on_top == Preferences::NeverOnTop)
4420 changeStayOnTop(Preferences::AlwaysOnTop);
4421}
4422
4423// Called when a new window (equalizer, preferences..) is opened.
4424void BaseGui::exitFullscreenIfNeeded() {
4425 /*
4426 if (pref->fullscreen) {
4427 toggleFullscreen(FALSE);
4428 }
4429 */
4430}
4431
4432void BaseGui::checkMousePos(QPoint p) {
4433 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
4434
4435 bool compact = (pref->floating_display_in_compact_mode && pref->compact_mode);
4436
4437 if (!pref->fullscreen && !compact) return;
4438
4439 #define MARGIN 70
4440
4441 int margin = MARGIN + pref->floating_control_margin;
4442
4443 if (p.y() > mplayerwindow->height() - margin) {
4444 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
4445 if (!near_bottom) {
4446 emit cursorNearBottom(p);
4447 near_bottom = true;
4448 }
4449 } else {
4450 if (near_bottom) {
4451 emit cursorFarEdges();
4452 near_bottom = false;
4453 }
4454 }
4455
4456 if (p.y() < margin) {
4457 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
4458 if (!near_top) {
4459 emit cursorNearTop(p);
4460 near_top = true;
4461 }
4462 } else {
4463 if (near_top) {
4464 emit cursorFarEdges();
4465 near_top = false;
4466 }
4467 }
4468}
4469
4470#if ALLOW_CHANGE_STYLESHEET
4471void BaseGui::loadQss(QString filename) {
4472 QFile file( filename );
4473 file.open(QFile::ReadOnly);
4474 QString styleSheet = QLatin1String(file.readAll());
4475
4476 QDir current = QDir::current();
4477 QString td = Images::themesDirectory();
4478 QString relativePath = current.relativeFilePath(td);
4479 styleSheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
4480 QString("url(%1\\1)").arg(relativePath + "/"));
4481 qDebug("styeSheet: %s", styleSheet.toUtf8().constData());
4482
4483 qApp->setStyleSheet(styleSheet);
4484}
4485
4486void BaseGui::changeStyleSheet(QString style) {
4487 if (style.isEmpty()) {
4488 qApp->setStyleSheet("");
4489 }
4490 else {
4491 QString qss_file = Paths::configPath() + "/themes/" + pref->iconset +"/style.qss";
4492 //qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
4493 if (!QFile::exists(qss_file)) {
4494 qss_file = Paths::themesPath() +"/"+ pref->iconset +"/style.qss";
4495 }
4496 if (QFile::exists(qss_file)) {
4497 qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
4498 loadQss(qss_file);
4499 } else {
4500 qApp->setStyleSheet("");
4501 }
4502 }
4503}
4504#endif
4505
4506void BaseGui::loadActions() {
4507 qDebug("BaseGui::loadActions");
4508 ActionsEditor::loadFromConfig(this, settings);
4509#if !DOCK_PLAYLIST
4510 ActionsEditor::loadFromConfig(playlist, settings);
4511#endif
4512
4513 actions_list = ActionsEditor::actionsNames(this);
4514#if !DOCK_PLAYLIST
4515 actions_list += ActionsEditor::actionsNames(playlist);
4516#endif
4517}
4518
4519void BaseGui::saveActions() {
4520 qDebug("BaseGui::saveActions");
4521
4522 ActionsEditor::saveToConfig(this, settings);
4523#if !DOCK_PLAYLIST
4524 ActionsEditor::saveToConfig(playlist, settings);
4525#endif
4526}
4527
4528void BaseGui::moveWindow(QPoint diff) {
4529 if (pref->fullscreen || isMaximized()) {
4530 return;
4531 }
4532 move(pos() + diff);
4533}
4534
4535void BaseGui::showEvent( QShowEvent * ) {
4536 qDebug("BaseGui::showEvent");
4537
4538 if (ignore_show_hide_events) return;
4539
4540 //qDebug("BaseGui::showEvent: pref->pause_when_hidden: %d", pref->pause_when_hidden);
4541 if ((pref->pause_when_hidden) && (core->state() == Core::Paused)) {
4542 qDebug("BaseGui::showEvent: unpausing");
4543 core->pause(); // Unpauses
4544 }
4545}
4546
4547void BaseGui::hideEvent( QHideEvent * ) {
4548 qDebug("BaseGui::hideEvent");
4549
4550 if (ignore_show_hide_events) return;
4551
4552 //qDebug("BaseGui::hideEvent: pref->pause_when_hidden: %d", pref->pause_when_hidden);
4553 if ((pref->pause_when_hidden) && (core->state() == Core::Playing)) {
4554 qDebug("BaseGui::hideEvent: pausing");
4555 core->pause();
4556 }
4557}
4558
4559void BaseGui::askForMplayerVersion(QString line) {
4560 qDebug("BaseGui::askForMplayerVersion: %s", line.toUtf8().data());
4561
4562 if (pref->mplayer_user_supplied_version <= 0) {
4563 InputMplayerVersion d(this);
4564 d.setVersion( pref->mplayer_user_supplied_version );
4565 d.setVersionFromOutput(line);
4566 if (d.exec() == QDialog::Accepted) {
4567 pref->mplayer_user_supplied_version = d.version();
4568 qDebug("BaseGui::askForMplayerVersion: user supplied version: %d", pref->mplayer_user_supplied_version);
4569 }
4570 } else {
4571 qDebug("BaseGui::askForMplayerVersion: already have a version supplied by user, so no asking");
4572 }
4573}
4574
4575void BaseGui::showExitCodeFromMplayer(int exit_code) {
4576 qDebug("BaseGui::showExitCodeFromMplayer: %d", exit_code);
4577
4578 if (!pref->report_mplayer_crashes) {
4579 qDebug("BaseGui::showExitCodeFromMplayer: not displaying error dialog");
4580 return;
4581 }
4582
4583 if (exit_code != 255 ) {
4584 ErrorDialog d(this);
4585 d.setText(tr("MPlayer has finished unexpectedly.") + " " +
4586 tr("Exit code: %1").arg(exit_code));
4587#ifdef LOG_MPLAYER
4588 d.setLog( mplayer_log );
4589#endif
4590 d.exec();
4591 }
4592}
4593
4594void BaseGui::showErrorFromMplayer(QProcess::ProcessError e) {
4595 qDebug("BaseGui::showErrorFromMplayer");
4596
4597 if (!pref->report_mplayer_crashes) {
4598 qDebug("showErrorFromMplayer: not displaying error dialog");
4599 return;
4600 }
4601
4602 if ((e == QProcess::FailedToStart) || (e == QProcess::Crashed)) {
4603 ErrorDialog d(this);
4604 if (e == QProcess::FailedToStart) {
4605 d.setText(tr("MPlayer failed to start.") + " " +
4606 tr("Please check the MPlayer path in preferences."));
4607 } else {
4608 d.setText(tr("MPlayer has crashed.") + " " +
4609 tr("See the log for more info."));
4610 }
4611#ifdef LOG_MPLAYER
4612 d.setLog( mplayer_log );
4613#endif
4614 d.exec();
4615 }
4616}
4617
4618
4619#ifdef FIND_SUBTITLES
4620void BaseGui::showFindSubtitlesDialog() {
4621 qDebug("BaseGui::showFindSubtitlesDialog");
4622
4623 if (!find_subs_dialog) {
4624 find_subs_dialog = new FindSubtitlesWindow(this, Qt::Window | Qt::WindowMinMaxButtonsHint);
4625 find_subs_dialog->setSettings(Global::settings);
4626 find_subs_dialog->setWindowIcon(windowIcon());
4627#if DOWNLOAD_SUBS
4628 connect(find_subs_dialog, SIGNAL(subtitleDownloaded(const QString &)),
4629 core, SLOT(loadSub(const QString &)));
4630#endif
4631 }
4632
4633 find_subs_dialog->show();
4634 find_subs_dialog->setMovie(core->mdat.filename);
4635}
4636
4637void BaseGui::openUploadSubtitlesPage() {
4638 //QDesktopServices::openUrl( QUrl("http://ds6.ovh.org/hashsubtitles/upload.php") );
4639 //QDesktopServices::openUrl( QUrl("http://www.opensubtitles.com/upload") );
4640 QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/uploadjava") );
4641}
4642#endif
4643
4644#ifdef VIDEOPREVIEW
4645void BaseGui::showVideoPreviewDialog() {
4646 qDebug("BaseGui::showVideoPreviewDialog");
4647
4648 if (video_preview == 0) {
4649 video_preview = new VideoPreview( pref->mplayer_bin, this );
4650 video_preview->setSettings(Global::settings);
4651 }
4652
4653 if (!core->mdat.filename.isEmpty()) {
4654 video_preview->setVideoFile(core->mdat.filename);
4655
4656 // DVD
4657 if (core->mdat.type==TYPE_DVD) {
4658 QString file = core->mdat.filename;
4659 DiscData disc_data = DiscName::split(file);
4660 QString dvd_folder = disc_data.device;
4661 if (dvd_folder.isEmpty()) dvd_folder = pref->dvd_device;
4662 int dvd_title = disc_data.title;
4663 file = disc_data.protocol + "://" + QString::number(dvd_title);
4664
4665 video_preview->setVideoFile(file);
4666 video_preview->setDVDDevice(dvd_folder);
4667 } else {
4668 video_preview->setDVDDevice("");
4669 }
4670 }
4671
4672 video_preview->setMplayerPath(pref->mplayer_bin);
4673
4674 if ( (video_preview->showConfigDialog(this)) && (video_preview->createThumbnails()) ) {
4675 video_preview->show();
4676 video_preview->adjustWindowSize();
4677 }
4678}
4679#endif
4680
4681void BaseGui::showTubeBrowser() {
4682 qDebug("BaseGui::showTubeBrowser");
4683 QString exec = Paths::appPath() + "/smtube";
4684 qDebug("BaseGui::showTubeBrowser: '%s'", exec.toUtf8().constData());
4685 if (!QProcess::startDetached(exec, QStringList())) {
4686 QMessageBox::warning(this, tr("An error happened - SMPlayer"), tr("The YouTube Browser couldn't be launched"));
4687 }
4688}
4689
4690// Language change stuff
4691void BaseGui::changeEvent(QEvent *e) {
4692 if (e->type() == QEvent::LanguageChange) {
4693 retranslateStrings();
4694 } else {
4695 QMainWindow::changeEvent(e);
4696 }
4697}
4698
4699#ifdef Q_OS_WIN
4700/* Disable screensaver by event */
4701bool BaseGui::winEvent ( MSG * m, long * result ) {
4702 //qDebug("BaseGui::winEvent");
4703 if (m->message==WM_SYSCOMMAND) {
4704 if ((m->wParam & 0xFFF0)==SC_SCREENSAVE || (m->wParam & 0xFFF0)==SC_MONITORPOWER) {
4705 qDebug("BaseGui::winEvent: received SC_SCREENSAVE or SC_MONITORPOWER");
4706 qDebug("BaseGui::winEvent: avoid_screensaver: %d", pref->avoid_screensaver);
4707 qDebug("BaseGui::winEvent: playing: %d", core->state()==Core::Playing);
4708 qDebug("BaseGui::winEvent: video: %d", !core->mdat.novideo);
4709
4710 if ((pref->avoid_screensaver) && (core->state()==Core::Playing) && (!core->mdat.novideo)) {
4711 qDebug("BaseGui::winEvent: not allowing screensaver");
4712 (*result) = 0;
4713 return true;
4714 } else {
4715 if ((pref->avoid_screensaver) && (just_stopped)) {
4716 qDebug("BaseGui::winEvent: file just stopped, so not allowing screensaver for a while");
4717 (*result) = 0;
4718 return true;
4719 } else {
4720 qDebug("BaseGui::winEvent: allowing screensaver");
4721 return false;
4722 }
4723 }
4724 }
4725 }
4726 return false;
4727}
4728#endif
4729
4730#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
4731void BaseGui::clear_just_stopped() {
4732 qDebug("BaseGui::clear_just_stopped");
4733 just_stopped = false;
4734}
4735#endif
4736
4737#include "moc_basegui.cpp"
Note: See TracBrowser for help on using the repository browser.