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

Last change on this file since 133 was 132, checked in by Silvan Scherrer, 13 years ago

SMPlayer trunk: built 0.8.0

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