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

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

SMPlayer: update trunk to latest 0.8.7

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