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

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

SMPlayer: updated trunk to 14.9.0

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