source: smplayer/trunk/src/basegui.cpp@ 162

Last change on this file since 162 was 156, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to 0.8.6

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