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

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

SMplayer: update trunk to 0.8.1

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