~ubuntu-branches/ubuntu/wily/smplayer/wily

« back to all changes in this revision

Viewing changes to src/basegui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-0h2hfwpwlu9opbv2
* New upstream release. (Closes: #523791)
  - Reworked subtitle font preferences. (Closes: #503295)
  - No longer installs qt_fr.qm. (Closes: #486314)
* debian/control:
  - Bumped Standards-Version to 3.8.1.
  - Changed maintainer name (still the same person and GPG key).
  - Changed section to video.
  - Build-depend on zlib1g-dev for findsubtitles.
  - Require Qt >= 4.3 per readme.
  - Added ${misc:Depends}.
  - Make smplayer-translations depend on smplayer and smplayer recommend
    smplayer-translations, not the other way round. (Closes: #489375)
* debian/copyright:
  - Significantly expanded per-file with new upstream authors.
* debian/rules:
  - Make make use correct uic in install.
  - Clean svn_revision.
  - Removed get-orig-source - not needed with uscan --repack.
* debian/patches/01_gl_translation.patch:
  - Added patch to fix lrelease error on smplayer_gl.ts.
* Added debian/README.source for simple-patchsys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  smplayer, GUI front-end for mplayer.
2
 
    Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
 
2
    Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
3
3
 
4
4
    This program is free software; you can redistribute it and/or modify
5
5
    it under the terms of the GNU General Public License as published by
36
36
#include <QDragEnterEvent>
37
37
#include <QDropEvent>
38
38
#include <QDesktopServices>
 
39
#include <QInputDialog>
39
40
 
40
41
#include <cmath>
41
42
 
42
43
#include "mplayerwindow.h"
43
44
#include "desktopinfo.h"
44
45
#include "helper.h"
 
46
#include "paths.h"
 
47
#include "colorutils.h"
45
48
#include "global.h"
46
49
#include "translator.h"
47
50
#include "images.h"
48
51
#include "preferences.h"
 
52
#include "discname.h"
49
53
#include "timeslider.h"
50
54
#include "logwindow.h"
51
55
#include "playlist.h"
52
56
#include "filepropertiesdialog.h"
53
57
#include "eqslider.h"
54
58
#include "videoequalizer.h"
 
59
#include "audioequalizer.h"
55
60
#include "inputdvddirectory.h"
56
61
#include "inputmplayerversion.h"
57
62
#include "inputurl.h"
58
63
#include "recents.h"
 
64
#include "urlhistory.h"
59
65
#include "about.h"
60
66
#include "errordialog.h"
61
67
#include "timedialog.h"
62
68
#include "clhelp.h"
 
69
#include "findsubtitleswindow.h"
 
70
#include "videopreview.h"
 
71
#include "mplayerversion.h"
63
72
 
64
73
#include "config.h"
65
74
#include "actionseditor.h"
67
76
#include "myserver.h"
68
77
 
69
78
#include "preferencesdialog.h"
 
79
#ifndef NO_USE_INI_FILES
 
80
#include "prefgeneral.h"
 
81
#endif
70
82
#include "prefinterface.h"
71
83
#include "prefinput.h"
72
84
#include "prefadvanced.h"
78
90
 
79
91
#include "extensions.h"
80
92
 
 
93
#ifdef Q_OS_WIN
 
94
#include "deviceinfo.h"
 
95
#endif
 
96
 
81
97
using namespace Global;
82
98
 
83
99
BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) 
89
105
        /* Disable screensaver by event */
90
106
        just_stopped = false;
91
107
#endif
 
108
        ignore_show_hide_events = false;
92
109
 
93
110
        setWindowTitle( "SMPlayer" );
94
111
 
98
115
        pref_dialog = 0;
99
116
        file_dialog = 0;
100
117
        clhelp_window = 0;
 
118
        find_subs_dialog = 0;
 
119
        video_preview = 0;
101
120
 
102
121
        // Create objects:
103
 
        recents = new Recents(this);
104
 
 
105
122
        createPanel();
106
123
        setCentralWidget(panel);
107
124
 
109
126
        createCore();
110
127
        createPlaylist();
111
128
        createVideoEqualizer();
 
129
        createAudioEqualizer();
112
130
 
113
131
        // Mouse Wheel
114
132
        connect( this, SIGNAL(wheelUp()),
132
150
        }
133
151
#endif
134
152
 
135
 
    mplayer_log_window = new LogWindow(this);
136
 
        smplayer_log_window = new LogWindow(this);
 
153
    mplayer_log_window = new LogWindow(0);
 
154
        smplayer_log_window = new LogWindow(0);
137
155
 
138
156
        createActions();
139
157
        createMenus();
146
164
            showPlaylistAct, SLOT(setChecked(bool)) );
147
165
#endif
148
166
 
149
 
#if NEW_RESIZE_CODE
150
 
        diff_size = QSize(0,0);
151
 
        connect(core, SIGNAL(aboutToStartPlaying()),
152
 
            this, SLOT(calculateDiff()));
153
 
#endif
154
 
 
155
167
        retranslateStrings();
156
168
 
157
169
        setAcceptDrops(true);
158
170
 
159
 
        resize(580, 440);
 
171
        resize(pref->default_size);
160
172
 
161
173
        panel->setFocus();
162
174
 
165
177
 
166
178
void BaseGui::initializeGui() {
167
179
        if (pref->compact_mode) toggleCompactMode(TRUE);
168
 
        if (pref->stay_on_top) toggleStayOnTop(TRUE);
 
180
        changeStayOnTop(pref->stay_on_top);
169
181
        toggleFrameCounter( pref->show_frame_counter );
170
182
 
171
183
#if ALLOW_CHANGE_STYLESHEET
172
184
        changeStyleSheet(pref->iconset);
173
185
#endif
174
186
 
175
 
        recents->setMaxItems( pref->recents_max_items);
176
187
        updateRecents();
177
188
 
178
189
        // Call loadActions() outside initialization of the class.
192
203
            this, SLOT(processFunction(QString)));              
193
204
 
194
205
        if (pref->use_single_instance) {
195
 
                if (server->listen(pref->connection_port)) {
196
 
                        qDebug("BaseGui::initializeGui: server running on port %d", pref->connection_port);
 
206
                int port = 0;
 
207
                if (!pref->use_autoport) port = pref->connection_port;
 
208
                if (server->listen(port)) {
 
209
                        pref->autoport = server->serverPort();
 
210
                        pref->save();
 
211
                        qDebug("BaseGui::initializeGui: server running on port %d", pref->autoport);
197
212
                } else {
198
213
                        qWarning("BaseGui::initializeGui: server couldn't be started");
199
214
                }
240
255
                playlist = 0;
241
256
        }
242
257
//#endif
 
258
 
 
259
        if (find_subs_dialog) {
 
260
                delete find_subs_dialog;
 
261
                find_subs_dialog = 0; // Necessary?
 
262
        }
 
263
 
 
264
        if (video_preview) {
 
265
                delete video_preview;
 
266
        }
243
267
}
244
268
 
245
269
void BaseGui::createActions() {
360
384
        connect( doubleSpeedAct, SIGNAL(triggered()),
361
385
             core, SLOT(doubleSpeed()) );
362
386
 
363
 
        decSpeedAct = new MyAction( Qt::Key_BracketLeft, this, "dec_speed" );
364
 
        connect( decSpeedAct, SIGNAL(triggered()),
365
 
             core, SLOT(decSpeed()) );
366
 
 
367
 
        incSpeedAct = new MyAction( Qt::Key_BracketRight, this, "inc_speed" );
368
 
        connect( incSpeedAct, SIGNAL(triggered()),
369
 
             core, SLOT(incSpeed()) );
 
387
        decSpeed10Act = new MyAction( Qt::Key_BracketLeft, this, "dec_speed" );
 
388
        connect( decSpeed10Act, SIGNAL(triggered()),
 
389
             core, SLOT(decSpeed10()) );
 
390
 
 
391
        incSpeed10Act = new MyAction( Qt::Key_BracketRight, this, "inc_speed" );
 
392
        connect( incSpeed10Act, SIGNAL(triggered()),
 
393
             core, SLOT(incSpeed10()) );
 
394
 
 
395
        decSpeed4Act = new MyAction( this, "dec_speed_4" );
 
396
        connect( decSpeed4Act, SIGNAL(triggered()),
 
397
             core, SLOT(decSpeed4()) );
 
398
 
 
399
        incSpeed4Act = new MyAction( this, "inc_speed_4" );
 
400
        connect( incSpeed4Act, SIGNAL(triggered()),
 
401
             core, SLOT(incSpeed4()) );
 
402
 
 
403
        decSpeed1Act = new MyAction( this, "dec_speed_1" );
 
404
        connect( decSpeed1Act, SIGNAL(triggered()),
 
405
             core, SLOT(decSpeed1()) );
 
406
 
 
407
        incSpeed1Act = new MyAction( this, "inc_speed_1" );
 
408
        connect( incSpeed1Act, SIGNAL(triggered()),
 
409
             core, SLOT(incSpeed1()) );
370
410
 
371
411
 
372
412
        // Menu Video
380
420
        connect( compactAct, SIGNAL(toggled(bool)),
381
421
             this, SLOT(toggleCompactMode(bool)) );
382
422
 
383
 
        equalizerAct = new MyAction( QKeySequence("Ctrl+E"), this, "equalizer" );
384
 
        equalizerAct->setCheckable( true );
385
 
        connect( equalizerAct, SIGNAL(toggled(bool)),
386
 
             this, SLOT(showEqualizer(bool)) );
 
423
        videoEqualizerAct = new MyAction( QKeySequence("Ctrl+E"), this, "video_equalizer" );
 
424
        videoEqualizerAct->setCheckable( true );
 
425
        connect( videoEqualizerAct, SIGNAL(toggled(bool)),
 
426
             this, SLOT(showVideoEqualizer(bool)) );
387
427
 
388
428
        screenshotAct = new MyAction( Qt::Key_S, this, "screenshot" );
389
429
        connect( screenshotAct, SIGNAL(triggered()),
390
430
             core, SLOT(screenshot()) );
391
431
 
392
 
        onTopAct = new MyAction( this, "on_top" );
393
 
        onTopAct->setCheckable( true );
394
 
        connect( onTopAct, SIGNAL(toggled(bool)),
395
 
             this, SLOT(toggleStayOnTop(bool)) );
 
432
        videoPreviewAct = new MyAction( this, "video_preview" );
 
433
        connect( videoPreviewAct, SIGNAL(triggered()),
 
434
             this, SLOT(showVideoPreviewDialog()) );
396
435
 
397
436
        flipAct = new MyAction( this, "flip" );
398
437
        flipAct->setCheckable( true );
399
438
        connect( flipAct, SIGNAL(toggled(bool)),
400
439
             core, SLOT(toggleFlip(bool)) );
401
440
 
 
441
        mirrorAct = new MyAction( this, "mirror" );
 
442
        mirrorAct->setCheckable( true );
 
443
        connect( mirrorAct, SIGNAL(toggled(bool)),
 
444
             core, SLOT(toggleMirror(bool)) );
402
445
 
403
446
        // Submenu filter
404
447
        postProcessingAct = new MyAction( this, "postprocessing" );
440
483
 
441
484
 
442
485
        // Menu Audio
 
486
        audioEqualizerAct = new MyAction( this, "audio_equalizer" );
 
487
        audioEqualizerAct->setCheckable( true );
 
488
        connect( audioEqualizerAct, SIGNAL(toggled(bool)),
 
489
             this, SLOT(showAudioEqualizer(bool)) );
 
490
 
443
491
        muteAct = new MyAction( Qt::Key_M, this, "mute" );
444
492
        muteAct->setCheckable( true );
445
493
        connect( muteAct, SIGNAL(toggled(bool)),
471
519
        connect( incAudioDelayAct, SIGNAL(triggered()),
472
520
             core, SLOT(incAudioDelay()) );
473
521
 
 
522
        audioDelayAct = new MyAction( this, "audio_delay" );
 
523
        connect( audioDelayAct, SIGNAL(triggered()),
 
524
             this, SLOT(showAudioDelayDialog()) );
 
525
 
474
526
        loadAudioAct = new MyAction( this, "load_audio_file" );
475
527
        connect( loadAudioAct, SIGNAL(triggered()),
476
528
             this, SLOT(loadAudioFile()) );
514
566
        connect( incSubDelayAct, SIGNAL(triggered()),
515
567
             core, SLOT(incSubDelay()) );
516
568
 
 
569
        subDelayAct = new MyAction( this, "sub_delay" );
 
570
        connect( subDelayAct, SIGNAL(triggered()),
 
571
             this, SLOT(showSubDelayDialog()) );
 
572
 
517
573
        decSubPosAct = new MyAction( Qt::Key_R, this, "dec_sub_pos" );
518
574
        connect( decSubPosAct, SIGNAL(triggered()),
519
575
             core, SLOT(decSubPos()) );
549
605
        useForcedSubsOnlyAct->setCheckable(true);
550
606
        connect( useForcedSubsOnlyAct, SIGNAL(toggled(bool)), core, SLOT(toggleForcedSubsOnly(bool)) );
551
607
 
 
608
        showFindSubtitlesDialogAct = new MyAction( this, "show_find_sub_dialog" );
 
609
        connect( showFindSubtitlesDialogAct, SIGNAL(triggered()), 
 
610
             this, SLOT(showFindSubtitlesDialog()) );
 
611
 
 
612
        openUploadSubtitlesPageAct = new MyAction( this, "upload_subtitles" );          //turbos
 
613
        connect( openUploadSubtitlesPageAct, SIGNAL(triggered()),                                       //turbos
 
614
             this, SLOT(openUploadSubtitlesPage()) );                                                   //turbos
 
615
 
 
616
 
552
617
        // Menu Options
553
618
        showPlaylistAct = new MyAction( QKeySequence("Ctrl+L"), this, "show_playlist" );
554
619
        showPlaylistAct->setCheckable( true );
587
652
        connect( showFAQAct, SIGNAL(triggered()),
588
653
             this, SLOT(helpFAQ()) );
589
654
 
590
 
        showCLOptions = new MyAction( this, "cl_options" );
591
 
        connect( showCLOptions, SIGNAL(triggered()),
 
655
        showCLOptionsAct = new MyAction( this, "cl_options" );
 
656
        connect( showCLOptionsAct, SIGNAL(triggered()),
592
657
             this, SLOT(helpCLOptions()) );
593
658
 
 
659
        showTipsAct = new MyAction( this, "tips" );
 
660
        connect( showTipsAct, SIGNAL(triggered()),
 
661
             this, SLOT(helpTips()) );
 
662
 
594
663
        aboutQtAct = new MyAction( this, "about_qt" );
595
664
        connect( aboutQtAct, SIGNAL(triggered()),
596
665
             this, SLOT(helpAboutQt()) );
629
698
        resetZoomAct = new MyAction(Qt::SHIFT | Qt::Key_E, this, "reset_zoom");
630
699
        connect( resetZoomAct, SIGNAL(triggered()), core, SLOT(resetPanscan()) );
631
700
 
 
701
        autoZoomAct = new MyAction(Qt::SHIFT | Qt::Key_W, this, "auto_zoom");
 
702
        connect( autoZoomAct, SIGNAL(triggered()), core, SLOT(autoPanscan()) );
 
703
 
 
704
        autoZoom169Act = new MyAction(Qt::SHIFT | Qt::Key_A, this, "zoom_169");
 
705
        connect( autoZoom169Act, SIGNAL(triggered()), core, SLOT(autoPanscanFor169()) );
 
706
 
 
707
        autoZoom235Act = new MyAction(Qt::SHIFT | Qt::Key_S, this, "zoom_235");
 
708
        connect( autoZoom235Act, SIGNAL(triggered()), core, SLOT(autoPanscanFor235()) );
 
709
 
632
710
 
633
711
        // Actions not in menus or buttons
634
712
        // Volume 2
670
748
        incSaturationAct = new MyAction( Qt::Key_8, this, "inc_saturation");
671
749
        connect( incSaturationAct, SIGNAL(triggered()), core, SLOT(incSaturation()) );
672
750
 
673
 
        decGammaAct = new MyAction( Qt::ALT | Qt::Key_1, this, "dec_gamma");
 
751
        decGammaAct = new MyAction( this, "dec_gamma");
674
752
        connect( decGammaAct, SIGNAL(triggered()), core, SLOT(decGamma()) );
675
753
 
676
 
        incGammaAct = new MyAction( Qt::ALT | Qt::Key_2, this, "inc_gamma");
 
754
        incGammaAct = new MyAction( this, "inc_gamma");
677
755
        connect( incGammaAct, SIGNAL(triggered()), core, SLOT(incGamma()) );
678
756
 
 
757
        nextVideoAct = new MyAction( this, "next_video");
 
758
        connect( nextVideoAct, SIGNAL(triggered()), core, SLOT(nextVideo()) );
 
759
 
679
760
        nextAudioAct = new MyAction( Qt::Key_H, this, "next_audio");
680
761
        connect( nextAudioAct, SIGNAL(triggered()), core, SLOT(nextAudio()) );
681
762
 
692
773
        connect( doubleSizeAct, SIGNAL(triggered()), core, SLOT(toggleDoubleSize()) );
693
774
 
694
775
        resetVideoEqualizerAct = new MyAction( this, "reset_video_equalizer");
695
 
        connect( resetVideoEqualizerAct, SIGNAL(triggered()), equalizer, SLOT(reset()) );
 
776
        connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer, SLOT(reset()) );
 
777
 
 
778
        resetAudioEqualizerAct = new MyAction( this, "reset_audio_equalizer");
 
779
        connect( resetAudioEqualizerAct, SIGNAL(triggered()), audio_equalizer, SLOT(reset()) );
696
780
 
697
781
        showContextMenuAct = new MyAction( this, "show_context_menu");
698
782
        connect( showContextMenuAct, SIGNAL(triggered()), 
699
783
             this, SLOT(showPopupMenu()) );
700
784
 
 
785
#if NEW_ASPECT_CODE
 
786
        nextAspectAct = new MyAction( Qt::Key_A, this, "next_aspect");
 
787
        connect( nextAspectAct, SIGNAL(triggered()), 
 
788
             core, SLOT(nextAspectRatio()) );
 
789
#endif
 
790
 
701
791
        // Group actions
702
792
 
703
793
        // OSD
772
862
        aspect169Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:9", MediaSettings::Aspect169 );
773
863
        aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 );
774
864
        aspect235Act = new MyActionGroupItem(this, aspectGroup, "aspect_2.35:1", MediaSettings::Aspect235 );
 
865
#if NEW_ASPECT_CODE
 
866
        aspect11Act = new MyActionGroupItem(this, aspectGroup, "aspect_1:1", MediaSettings::Aspect11 );
 
867
        {
 
868
                QAction * sep = new QAction(aspectGroup);
 
869
                sep->setSeparator(true);
 
870
        }
 
871
        aspectNoneAct = new MyActionGroupItem(this, aspectGroup, "aspect_none", MediaSettings::AspectNone);
 
872
#endif
 
873
 
775
874
#if !NEW_ASPECT_CODE
776
875
        QAction * aspect_separator = new QAction(aspectGroup);
777
876
        aspect_separator->setSeparator(true);
793
892
        connect( rotateGroup, SIGNAL(activated(int)),
794
893
             core, SLOT(changeRotate(int)) );
795
894
 
 
895
        // On Top
 
896
        onTopActionGroup = new MyActionGroup(this);
 
897
        onTopAlwaysAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_always",Preferences::AlwaysOnTop);
 
898
        onTopNeverAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_never",Preferences::NeverOnTop);
 
899
        onTopWhilePlayingAct = new MyActionGroupItem( this,onTopActionGroup,"on_top_playing",Preferences::WhilePlayingOnTop);
 
900
        connect( onTopActionGroup , SIGNAL(activated(int)),
 
901
             this, SLOT(changeStayOnTop(int)) );
 
902
 
 
903
        toggleStayOnTopAct = new MyAction( this, "toggle_stay_on_top");
 
904
        connect( toggleStayOnTopAct, SIGNAL(triggered()), this, SLOT(toggleStayOnTop()) );
 
905
 
 
906
 
 
907
#if USE_ADAPTER
 
908
        screenGroup = new MyActionGroup(this);
 
909
        screenDefaultAct = new MyActionGroupItem(this, screenGroup, "screen_default", -1);
 
910
#ifdef Q_OS_WIN
 
911
        DeviceList display_devices = DeviceInfo::displayDevices();
 
912
        if (!display_devices.isEmpty()) {
 
913
                for (int n = 0; n < display_devices.count(); n++) {
 
914
                        int id = display_devices[n].ID().toInt();
 
915
                        QString desc = display_devices[n].desc();
 
916
                        MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toAscii().constData(), id);
 
917
                        screen_item->change( "&"+QString::number(n) + " - " + desc);
 
918
                }
 
919
        }
 
920
        else
 
921
#endif // Q_OS_WIN
 
922
        for (int n = 1; n <= 4; n++) {
 
923
                MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toAscii().constData(), n);
 
924
                screen_item->change( "&"+QString::number(n) );
 
925
        }
 
926
 
 
927
        connect( screenGroup, SIGNAL(activated(int)),
 
928
             core, SLOT(changeAdapter(int)) );
 
929
#endif
 
930
 
 
931
        // Video track
 
932
        videoTrackGroup = new MyActionGroup(this);
 
933
        connect( videoTrackGroup, SIGNAL(activated(int)), 
 
934
                 core, SLOT(changeVideo(int)) );
 
935
 
796
936
        // Audio track
797
937
        audioTrackGroup = new MyActionGroup(this);
798
938
        connect( audioTrackGroup, SIGNAL(activated(int)), 
817
957
        chapterGroup = new MyActionGroup(this);
818
958
        connect( chapterGroup, SIGNAL(activated(int)),
819
959
                         core, SLOT(changeChapter(int)) );
 
960
 
 
961
#if DVDNAV_SUPPORT
 
962
        dvdnavUpAct = new MyAction(Qt::SHIFT | Qt::Key_Up, this, "dvdnav_up");
 
963
        connect( dvdnavUpAct, SIGNAL(triggered()), core, SLOT(dvdnavUp()) );
 
964
 
 
965
        dvdnavDownAct = new MyAction(Qt::SHIFT | Qt::Key_Down, this, "dvdnav_down");
 
966
        connect( dvdnavDownAct, SIGNAL(triggered()), core, SLOT(dvdnavDown()) );
 
967
 
 
968
        dvdnavLeftAct = new MyAction(Qt::SHIFT | Qt::Key_Left, this, "dvdnav_left");
 
969
        connect( dvdnavLeftAct, SIGNAL(triggered()), core, SLOT(dvdnavLeft()) );
 
970
 
 
971
        dvdnavRightAct = new MyAction(Qt::SHIFT | Qt::Key_Right, this, "dvdnav_right");
 
972
        connect( dvdnavRightAct, SIGNAL(triggered()), core, SLOT(dvdnavRight()) );
 
973
 
 
974
        dvdnavMenuAct = new MyAction(Qt::SHIFT | Qt::Key_Return, this, "dvdnav_menu");
 
975
        connect( dvdnavMenuAct, SIGNAL(triggered()), core, SLOT(dvdnavMenu()) );
 
976
 
 
977
        dvdnavSelectAct = new MyAction(Qt::Key_Return, this, "dvdnav_select");
 
978
        connect( dvdnavSelectAct, SIGNAL(triggered()), core, SLOT(dvdnavSelect()) );
 
979
 
 
980
        dvdnavPrevAct = new MyAction(Qt::SHIFT | Qt::Key_Escape, this, "dvdnav_prev");
 
981
        connect( dvdnavPrevAct, SIGNAL(triggered()), core, SLOT(dvdnavPrev()) );
 
982
 
 
983
        dvdnavMouseAct = new MyAction( this, "dvdnav_mouse");
 
984
        connect( dvdnavMouseAct, SIGNAL(triggered()), core, SLOT(dvdnavMouse()) );
 
985
#endif
 
986
 
820
987
}
821
988
 
822
989
#if AUTODISABLE_ACTIONS
841
1008
        normalSpeedAct->setEnabled(b);
842
1009
        halveSpeedAct->setEnabled(b);
843
1010
        doubleSpeedAct->setEnabled(b);
844
 
        decSpeedAct->setEnabled(b);
845
 
        incSpeedAct->setEnabled(b);
 
1011
        decSpeed10Act->setEnabled(b);
 
1012
        incSpeed10Act->setEnabled(b);
 
1013
        decSpeed4Act->setEnabled(b);
 
1014
        incSpeed4Act->setEnabled(b);
 
1015
        decSpeed1Act->setEnabled(b);
 
1016
        incSpeed1Act->setEnabled(b);
846
1017
 
847
1018
        // Menu Video
848
 
        equalizerAct->setEnabled(b);
 
1019
        videoEqualizerAct->setEnabled(b);
849
1020
        screenshotAct->setEnabled(b);
850
1021
        flipAct->setEnabled(b);
 
1022
        mirrorAct->setEnabled(b);
851
1023
        postProcessingAct->setEnabled(b);
852
1024
        phaseAct->setEnabled(b);
853
1025
        deblockAct->setEnabled(b);
859
1031
        upscaleAct->setEnabled(b);
860
1032
 
861
1033
        // Menu Audio
 
1034
        audioEqualizerAct->setEnabled(b);
862
1035
        muteAct->setEnabled(b);
863
1036
        decVolumeAct->setEnabled(b);
864
1037
        incVolumeAct->setEnabled(b);
865
1038
        decAudioDelayAct->setEnabled(b);
866
1039
        incAudioDelayAct->setEnabled(b);
 
1040
        audioDelayAct->setEnabled(b);
867
1041
        extrastereoAct->setEnabled(b);
868
1042
        karaokeAct->setEnabled(b);
869
1043
        volnormAct->setEnabled(b);
875
1049
        //unloadSubsAct->setEnabled(b);
876
1050
        decSubDelayAct->setEnabled(b);
877
1051
        incSubDelayAct->setEnabled(b);
 
1052
        subDelayAct->setEnabled(b);
878
1053
        decSubPosAct->setEnabled(b);
879
1054
        incSubPosAct->setEnabled(b);
880
1055
        incSubStepAct->setEnabled(b);
897
1072
        incSaturationAct->setEnabled(b);
898
1073
        decGammaAct->setEnabled(b);
899
1074
        incGammaAct->setEnabled(b);
 
1075
        nextVideoAct->setEnabled(b);
900
1076
        nextAudioAct->setEnabled(b);
901
1077
        nextSubtitleAct->setEnabled(b);
902
1078
        nextChapterAct->setEnabled(b);
911
1087
        incZoomAct->setEnabled(b);
912
1088
        decZoomAct->setEnabled(b);
913
1089
        resetZoomAct->setEnabled(b);
 
1090
        autoZoomAct->setEnabled(b);
 
1091
        autoZoom169Act->setEnabled(b);
 
1092
        autoZoom235Act->setEnabled(b);
 
1093
 
 
1094
#if DVDNAV_SUPPORT
 
1095
        dvdnavUpAct->setEnabled(b);
 
1096
        dvdnavDownAct->setEnabled(b);
 
1097
        dvdnavLeftAct->setEnabled(b);
 
1098
        dvdnavRightAct->setEnabled(b);
 
1099
        dvdnavMenuAct->setEnabled(b);
 
1100
        dvdnavSelectAct->setEnabled(b);
 
1101
        dvdnavPrevAct->setEnabled(b);
 
1102
        dvdnavMouseAct->setEnabled(b);
 
1103
#endif
914
1104
 
915
1105
        // Groups
916
1106
        denoiseGroup->setActionsEnabled(b);
918
1108
        deinterlaceGroup->setActionsEnabled(b);
919
1109
        aspectGroup->setActionsEnabled(b);
920
1110
        rotateGroup->setActionsEnabled(b);
 
1111
#if USE_ADAPTER
 
1112
        screenGroup->setActionsEnabled(b);
 
1113
#endif
921
1114
        channelsGroup->setActionsEnabled(b);
922
1115
        stereoGroup->setActionsEnabled(b);
923
1116
}
935
1128
        // Disable the compact action if not using video window
936
1129
        compactAct->setEnabled( panel->isVisible() );
937
1130
 
 
1131
        // Enable or disable the audio equalizer
 
1132
        audioEqualizerAct->setEnabled(pref->use_audio_equalizer);
 
1133
 
938
1134
        // Disable audio actions if there's not audio track
939
1135
        if ((core->mdat.audios.numItems()==0) && (core->mset.external_audio.isEmpty())) {
 
1136
                audioEqualizerAct->setEnabled(false);
940
1137
                muteAct->setEnabled(false);
941
1138
                decVolumeAct->setEnabled(false);
942
1139
                incVolumeAct->setEnabled(false);
943
1140
                decAudioDelayAct->setEnabled(false);
944
1141
                incAudioDelayAct->setEnabled(false);
 
1142
                audioDelayAct->setEnabled(false);
945
1143
                extrastereoAct->setEnabled(false);
946
1144
                karaokeAct->setEnabled(false);
947
1145
                volnormAct->setEnabled(false);
951
1149
 
952
1150
        // Disable video actions if it's an audio file
953
1151
        if (core->mdat.novideo) {
954
 
                equalizerAct->setEnabled(false);
 
1152
                videoEqualizerAct->setEnabled(false);
955
1153
                screenshotAct->setEnabled(false);
956
1154
                flipAct->setEnabled(false);
 
1155
                mirrorAct->setEnabled(false);
957
1156
                postProcessingAct->setEnabled(false);
958
1157
                phaseAct->setEnabled(false);
959
1158
                deblockAct->setEnabled(false);
973
1172
                incZoomAct->setEnabled(false);
974
1173
                decZoomAct->setEnabled(false);
975
1174
                resetZoomAct->setEnabled(false);
 
1175
                autoZoomAct->setEnabled(false);
 
1176
                autoZoom169Act->setEnabled(false);
 
1177
                autoZoom235Act->setEnabled(false);
976
1178
 
977
1179
                denoiseGroup->setActionsEnabled(false);
978
1180
                sizeGroup->setActionsEnabled(false);
979
1181
                deinterlaceGroup->setActionsEnabled(false);
980
1182
                aspectGroup->setActionsEnabled(false);
981
1183
                rotateGroup->setActionsEnabled(false);
982
 
        }
 
1184
#if USE_ADAPTER
 
1185
                screenGroup->setActionsEnabled(false);
 
1186
#endif
 
1187
        }
 
1188
 
 
1189
#if USE_ADAPTER
 
1190
        screenGroup->setActionsEnabled(pref->vo.startsWith(OVERLAY_VO));
 
1191
#endif
 
1192
 
 
1193
#if DVDNAV_SUPPORT
 
1194
        if (!core->mdat.filename.startsWith("dvdnav:")) {
 
1195
                dvdnavUpAct->setEnabled(false);
 
1196
                dvdnavDownAct->setEnabled(false);
 
1197
                dvdnavLeftAct->setEnabled(false);
 
1198
                dvdnavRightAct->setEnabled(false);
 
1199
                dvdnavMenuAct->setEnabled(false);
 
1200
                dvdnavSelectAct->setEnabled(false);
 
1201
                dvdnavPrevAct->setEnabled(false);
 
1202
                dvdnavMouseAct->setEnabled(false);
 
1203
        }
 
1204
#endif
983
1205
}
984
1206
 
985
1207
void BaseGui::disableActionsOnStop() {
1022
1244
 
1023
1245
        playOrPauseAct->change( tr("Play / Pause") );
1024
1246
        if (qApp->isLeftToRight()) 
1025
 
                playOrPauseAct->setIcon( Images::icon("play") );
 
1247
                playOrPauseAct->setIcon( Images::icon("play_pause") );
1026
1248
        else
1027
 
                playOrPauseAct->setIcon( Images::flippedIcon("play") );
 
1249
                playOrPauseAct->setIcon( Images::flippedIcon("play_pause") );
1028
1250
 
1029
1251
        pauseAndStepAct->change( Images::icon("pause"), tr("Pause / Frame step") );
1030
1252
 
1037
1259
        normalSpeedAct->change( tr("&Normal speed") );
1038
1260
        halveSpeedAct->change( tr("&Halve speed") );
1039
1261
        doubleSpeedAct->change( tr("&Double speed") );
1040
 
        decSpeedAct->change( tr("Speed &-10%") );
1041
 
        incSpeedAct->change( tr("Speed &+10%") );
 
1262
        decSpeed10Act->change( tr("Speed &-10%") );
 
1263
        incSpeed10Act->change( tr("Speed &+10%") );
 
1264
        decSpeed4Act->change( tr("Speed -&4%") );
 
1265
        incSpeed4Act->change( tr("&Speed +4%") );
 
1266
        decSpeed1Act->change( tr("Speed -&1%") );
 
1267
        incSpeed1Act->change( tr("S&peed +1%") );
1042
1268
 
1043
1269
        // Menu Video
1044
1270
        fullscreenAct->change( Images::icon("fullscreen"), tr("&Fullscreen") );
1045
1271
        compactAct->change( Images::icon("compact"), tr("&Compact mode") );
1046
 
        equalizerAct->change( Images::icon("equalizer"), tr("&Equalizer") );
 
1272
        videoEqualizerAct->change( Images::icon("equalizer"), tr("&Equalizer") );
1047
1273
        screenshotAct->change( Images::icon("screenshot"), tr("&Screenshot") );
1048
 
        onTopAct->change( Images::icon("ontop"), tr("S&tay on top") );
 
1274
        videoPreviewAct->change( Images::icon("video_preview"), tr("Pre&view...") );
1049
1275
        flipAct->change( Images::icon("flip"), tr("Flip i&mage") );
 
1276
        mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") );
1050
1277
 
1051
1278
        decZoomAct->change( tr("Zoom &-") );
1052
1279
        incZoomAct->change( tr("Zoom &+") );
1053
1280
        resetZoomAct->change( tr("&Reset") );
 
1281
        autoZoomAct->change( tr("&Auto zoom") );
 
1282
        autoZoom169Act->change( tr("Zoom for &16:9") );
 
1283
        autoZoom235Act->change( tr("Zoom for &2.35:1") );
1054
1284
        moveLeftAct->change( tr("Move &left") );
1055
1285
        moveRightAct->change( tr("Move &right") );
1056
1286
        moveUpAct->change( tr("Move &up") );
1068
1298
        upscaleAct->change( Images::icon("upscaling"), tr("Soft&ware scaling") );
1069
1299
 
1070
1300
        // Menu Audio
 
1301
        audioEqualizerAct->change( Images::icon("audio_equalizer"), tr("E&qualizer") );
1071
1302
        QIcon icset( Images::icon("volume") );
1072
1303
        icset.addPixmap( Images::icon("mute"), QIcon::Normal, QIcon::On  );
1073
1304
        muteAct->change( icset, tr("&Mute") );
1075
1306
        incVolumeAct->change( Images::icon("audio_up"), tr("Volume &+") );
1076
1307
        decAudioDelayAct->change( Images::icon("delay_down"), tr("&Delay -") );
1077
1308
        incAudioDelayAct->change( Images::icon("delay_up"), tr("D&elay +") );
 
1309
        audioDelayAct->change( Images::icon("audio_delay"), tr("Set dela&y...") );
1078
1310
        loadAudioAct->change( Images::icon("open"), tr("&Load external file...") );
1079
1311
        unloadAudioAct->change( Images::icon("unload"), tr("U&nload") );
1080
1312
 
1088
1320
        unloadSubsAct->change( Images::icon("unload"), tr("U&nload") );
1089
1321
        decSubDelayAct->change( Images::icon("delay_down"), tr("Delay &-") );
1090
1322
        incSubDelayAct->change( Images::icon("delay_up"), tr("Delay &+") );
 
1323
        subDelayAct->change( Images::icon("sub_delay"), tr("Se&t delay...") );
1091
1324
        decSubPosAct->change( Images::icon("sub_up"), tr("&Up") );
1092
1325
        incSubPosAct->change( Images::icon("sub_down"), tr("&Down") );
1093
1326
        decSubScaleAct->change( Images::icon("dec_sub_scale"), tr("S&ize -") );
1100
1333
        useClosedCaptionAct->change( Images::icon("closed_caption"), tr("Enable &closed caption") );
1101
1334
        useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") );
1102
1335
 
 
1336
        showFindSubtitlesDialogAct->change( tr("Find subtitles on &OpenSubtitles.org...") );
 
1337
        openUploadSubtitlesPageAct->change( tr("Upload su&btitles to OpenSubtitles.org...") );
 
1338
 
1103
1339
        // Menu Options
1104
1340
        showPlaylistAct->change( Images::icon("playlist"), tr("&Playlist") );
1105
1341
        showPropertiesAct->change( Images::icon("info"), tr("View &info and properties...") );
1115
1351
 
1116
1352
        // Menu Help
1117
1353
        showFAQAct->change( Images::icon("faq"), tr("&FAQ") );
1118
 
        showCLOptions->change( Images::icon("cl_help"), tr("&Command line options") );
 
1354
        showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") );
 
1355
        showTipsAct->change( Images::icon("tips"), tr("&Tips") );
1119
1356
        aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );
1120
1357
        aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") );
1121
1358
 
1152
1389
        incSaturationAct->change( tr("Inc saturation") );
1153
1390
        decGammaAct->change( tr("Dec gamma") );
1154
1391
        incGammaAct->change( tr("Inc gamma") );
 
1392
        nextVideoAct->change( tr("Next video") );
1155
1393
        nextAudioAct->change( tr("Next audio") );
1156
1394
        nextSubtitleAct->change( tr("Next subtitle") );
1157
1395
        nextChapterAct->change( tr("Next chapter") );
1158
1396
        prevChapterAct->change( tr("Previous chapter") );
1159
1397
        doubleSizeAct->change( tr("&Toggle double size") );
1160
1398
        resetVideoEqualizerAct->change( tr("Reset video equalizer") );
 
1399
        resetAudioEqualizerAct->change( tr("Reset audio equalizer") );
1161
1400
        showContextMenuAct->change( tr("Show context menu") );
 
1401
#if NEW_ASPECT_CODE
 
1402
        nextAspectAct->change( Images::icon("next_aspect"), tr("Next aspect ratio") );
 
1403
#endif
1162
1404
 
1163
1405
        // Action groups
1164
1406
        osdNoneAct->change( tr("&Disabled") );
1198
1440
        speed_menu->menuAction()->setIcon( Images::icon("speed") );
1199
1441
 
1200
1442
        // Menu Video
 
1443
        videotrack_menu->menuAction()->setText( tr("&Track", "video") );
 
1444
        videotrack_menu->menuAction()->setIcon( Images::icon("video_track") );
 
1445
 
1201
1446
        videosize_menu->menuAction()->setText( tr("Si&ze") );
1202
1447
        videosize_menu->menuAction()->setIcon( Images::icon("video_size") );
1203
1448
 
1216
1461
        rotate_menu->menuAction()->setText( tr("&Rotate") );
1217
1462
        rotate_menu->menuAction()->setIcon( Images::icon("rotate") );
1218
1463
 
 
1464
        ontop_menu->menuAction()->setText( tr("S&tay on top") );
 
1465
        ontop_menu->menuAction()->setIcon( Images::icon("ontop") );
 
1466
 
 
1467
#if USE_ADAPTER
 
1468
        screen_menu->menuAction()->setText( tr("Scree&n") );
 
1469
        screen_menu->menuAction()->setIcon( Images::icon("screen") );
 
1470
#endif
 
1471
 
1219
1472
        /*
1220
1473
        denoise_menu->menuAction()->setText( tr("De&noise") );
1221
1474
        denoise_menu->menuAction()->setIcon( Images::icon("denoise") );
1222
1475
        */
1223
1476
 
1224
 
        aspectDetectAct->change( tr("&Autodetect") );
 
1477
        aspectDetectAct->change( tr("&Auto") );
1225
1478
        aspect43Act->change( "&4:3" );
1226
1479
        aspect54Act->change( "&5:4" );
1227
1480
        aspect149Act->change( "&14:9" );
1228
1481
        aspect169Act->change( "16:&9" );
1229
1482
        aspect1610Act->change( "1&6:10" );
1230
1483
        aspect235Act->change( "&2.35:1" );
 
1484
#if NEW_ASPECT_CODE
 
1485
        aspect11Act->change( "1&:1" );
 
1486
        aspectNoneAct->change( tr("&Disabled") );
 
1487
#endif
 
1488
 
1231
1489
#if !NEW_ASPECT_CODE
1232
1490
        aspect43LetterAct->change( tr("4:3 &Letterbox") );
1233
1491
        aspect169LetterAct->change( tr("16:9 L&etterbox") );
1252
1510
        rotateCounterclockwiseAct->change( tr("Rotate by 90 degrees counterclock&wise") );
1253
1511
        rotateCounterclockwiseFlipAct->change( tr("Rotate by 90 degrees counterclockwise and &flip") );
1254
1512
 
 
1513
        onTopAlwaysAct->change( tr("&Always") );
 
1514
        onTopNeverAct->change( tr("&Never") );
 
1515
        onTopWhilePlayingAct->change( tr("While &playing") );
 
1516
        toggleStayOnTopAct->change( tr("Toggle stay on top") );
 
1517
 
 
1518
#if USE_ADAPTER
 
1519
        screenDefaultAct->change( tr("&Default") );
 
1520
#endif
 
1521
 
1255
1522
        // Menu Audio
1256
 
        audiotrack_menu->menuAction()->setText( tr("&Track") );
 
1523
        audiotrack_menu->menuAction()->setText( tr("&Track", "audio") );
1257
1524
        audiotrack_menu->menuAction()->setIcon( Images::icon("audio_track") );
1258
1525
 
1259
1526
        audiofilter_menu->menuAction()->setText( tr("&Filters") );
1288
1555
        angles_menu->menuAction()->setText( tr("&Angle") );
1289
1556
        angles_menu->menuAction()->setIcon( Images::icon("angle") );
1290
1557
 
 
1558
#if DVDNAV_SUPPORT
 
1559
        dvdnavUpAct->change(Images::icon("dvdnav_up"), tr("DVD menu, move up"));
 
1560
        dvdnavDownAct->change(Images::icon("dvdnav_down"), tr("DVD menu, move down"));
 
1561
        dvdnavLeftAct->change(Images::icon("dvdnav_left"), tr("DVD menu, move left"));
 
1562
        dvdnavRightAct->change(Images::icon("dvdnav_right"), tr("DVD menu, move right"));
 
1563
        dvdnavMenuAct->change(Images::icon("dvdnav_menu"), tr("DVD &menu"));
 
1564
        dvdnavSelectAct->change(Images::icon("dvdnav_select"), tr("DVD menu, select option"));
 
1565
        dvdnavPrevAct->change(Images::icon("dvdnav_prev"), tr("DVD &previous menu"));
 
1566
        dvdnavMouseAct->change(Images::icon("dvdnav_mouse"), tr("DVD menu, mouse click"));
 
1567
#endif
 
1568
 
1291
1569
        // Menu Options
1292
1570
        osd_menu->menuAction()->setText( tr("&OSD") );
1293
1571
        osd_menu->menuAction()->setIcon( Images::icon("osd") );
1351
1629
             this, SLOT(initializeMenus()) );
1352
1630
        connect( core, SIGNAL(widgetsNeedUpdate()),
1353
1631
             this, SLOT(updateWidgets()) );
1354
 
        connect( core, SIGNAL(equalizerNeedsUpdate()),
1355
 
             this, SLOT(updateEqualizer()) );
 
1632
        connect( core, SIGNAL(videoEqualizerNeedsUpdate()),
 
1633
             this, SLOT(updateVideoEqualizer()) );
 
1634
 
 
1635
        connect( core, SIGNAL(audioEqualizerNeedsUpdate()),
 
1636
             this, SLOT(updateAudioEqualizer()) );
1356
1637
 
1357
1638
        connect( core, SIGNAL(showFrame(int)),
1358
1639
             this, SIGNAL(frameChanged(int)) );
1366
1647
             this, SLOT(displayMessage(QString)) );
1367
1648
        connect( core, SIGNAL(stateChanged(Core::State)),
1368
1649
             this, SLOT(displayState(Core::State)) );
 
1650
        connect( core, SIGNAL(stateChanged(Core::State)),
 
1651
             this, SLOT(checkStayOnTop(Core::State)), Qt::QueuedConnection );
1369
1652
 
1370
1653
        connect( core, SIGNAL(mediaStartPlay()),
1371
1654
             this, SLOT(enterFullscreenOnPlay()) );
1374
1657
 
1375
1658
        connect( core, SIGNAL(mediaLoaded()),
1376
1659
             this, SLOT(enableActionsOnPlaying()) );
 
1660
#if NOTIFY_AUDIO_CHANGES
 
1661
        connect( core, SIGNAL(audioTracksChanged()),
 
1662
             this, SLOT(enableActionsOnPlaying()) );
 
1663
#endif
1377
1664
        connect( core, SIGNAL(mediaFinished()),
1378
1665
             this, SLOT(disableActionsOnStop()) );
1379
1666
        connect( core, SIGNAL(mediaStoppedByUser()),
1380
1667
             this, SLOT(disableActionsOnStop()) );
1381
1668
 
1382
 
        connect( core, SIGNAL(mediaLoaded()),
1383
 
             this, SLOT(newMediaLoaded()) );
 
1669
        connect( core, SIGNAL(mediaStartPlay()),
 
1670
             this, SLOT(newMediaLoaded()), Qt::QueuedConnection );
1384
1671
        connect( core, SIGNAL(mediaInfoChanged()),
1385
1672
             this, SLOT(updateMediaInfo()) );
1386
1673
 
 
1674
        connect( core, SIGNAL(mediaStartPlay()),
 
1675
             this, SLOT(checkPendingActionsToRun()), Qt::QueuedConnection );
 
1676
#if REPORT_OLD_MPLAYER
 
1677
        connect( core, SIGNAL(mediaStartPlay()),
 
1678
             this, SLOT(checkMplayerVersion()), Qt::QueuedConnection );
 
1679
#endif
1387
1680
        connect( core, SIGNAL(failedToParseMplayerVersion(QString)),
1388
1681
             this, SLOT(askForMplayerVersion(QString)) );
1389
1682
 
1396
1689
        // Hide mplayer window
1397
1690
        connect( core, SIGNAL(noVideo()),
1398
1691
             this, SLOT(hidePanel()) );
 
1692
 
 
1693
        // Log mplayer output
 
1694
        connect( core, SIGNAL(aboutToStartPlaying()),
 
1695
             this, SLOT(clearMplayerLog()) );
 
1696
        connect( core, SIGNAL(logLineAvailable(QString)),
 
1697
             this, SLOT(recordMplayerLog(QString)) );
 
1698
 
 
1699
        connect( core, SIGNAL(mediaLoaded()), 
 
1700
             this, SLOT(autosaveMplayerLog()) );
1399
1701
}
1400
1702
 
1401
1703
void BaseGui::createMplayerWindow() {
1437
1739
 
1438
1740
void BaseGui::createVideoEqualizer() {
1439
1741
        // Equalizer
1440
 
        equalizer = new VideoEqualizer(this);
 
1742
        video_equalizer = new VideoEqualizer(this);
1441
1743
 
1442
 
        connect( equalizer->contrast, SIGNAL(valueChanged(int)), 
 
1744
        connect( video_equalizer->contrast, SIGNAL(valueChanged(int)), 
1443
1745
             core, SLOT(setContrast(int)) );
1444
 
        connect( equalizer->brightness, SIGNAL(valueChanged(int)), 
 
1746
        connect( video_equalizer->brightness, SIGNAL(valueChanged(int)), 
1445
1747
             core, SLOT(setBrightness(int)) );
1446
 
        connect( equalizer->hue, SIGNAL(valueChanged(int)), 
 
1748
        connect( video_equalizer->hue, SIGNAL(valueChanged(int)), 
1447
1749
             core, SLOT(setHue(int)) );
1448
 
        connect( equalizer->saturation, SIGNAL(valueChanged(int)), 
 
1750
        connect( video_equalizer->saturation, SIGNAL(valueChanged(int)), 
1449
1751
             core, SLOT(setSaturation(int)) );
1450
 
        connect( equalizer->gamma, SIGNAL(valueChanged(int)), 
 
1752
        connect( video_equalizer->gamma, SIGNAL(valueChanged(int)), 
1451
1753
             core, SLOT(setGamma(int)) );
1452
 
        connect( equalizer, SIGNAL(visibilityChanged()),
 
1754
        connect( video_equalizer, SIGNAL(visibilityChanged()),
 
1755
             this, SLOT(updateWidgets()) );
 
1756
}
 
1757
 
 
1758
void BaseGui::createAudioEqualizer() {
 
1759
        // Audio Equalizer
 
1760
        audio_equalizer = new AudioEqualizer(this);
 
1761
 
 
1762
        connect( audio_equalizer->eq[0], SIGNAL(valueChanged(int)), 
 
1763
             core, SLOT(setAudioEq0(int)) );
 
1764
        connect( audio_equalizer->eq[1], SIGNAL(valueChanged(int)), 
 
1765
             core, SLOT(setAudioEq1(int)) );
 
1766
        connect( audio_equalizer->eq[2], SIGNAL(valueChanged(int)), 
 
1767
             core, SLOT(setAudioEq2(int)) );
 
1768
        connect( audio_equalizer->eq[3], SIGNAL(valueChanged(int)), 
 
1769
             core, SLOT(setAudioEq3(int)) );
 
1770
        connect( audio_equalizer->eq[4], SIGNAL(valueChanged(int)), 
 
1771
             core, SLOT(setAudioEq4(int)) );
 
1772
        connect( audio_equalizer->eq[5], SIGNAL(valueChanged(int)), 
 
1773
             core, SLOT(setAudioEq5(int)) );
 
1774
        connect( audio_equalizer->eq[6], SIGNAL(valueChanged(int)), 
 
1775
             core, SLOT(setAudioEq6(int)) );
 
1776
        connect( audio_equalizer->eq[7], SIGNAL(valueChanged(int)), 
 
1777
             core, SLOT(setAudioEq7(int)) );
 
1778
        connect( audio_equalizer->eq[8], SIGNAL(valueChanged(int)), 
 
1779
             core, SLOT(setAudioEq8(int)) );
 
1780
        connect( audio_equalizer->eq[9], SIGNAL(valueChanged(int)), 
 
1781
             core, SLOT(setAudioEq9(int)) );
 
1782
 
 
1783
        connect( audio_equalizer, SIGNAL(applyClicked(AudioEqualizerList)), 
 
1784
             core, SLOT(setAudioAudioEqualizerRestart(AudioEqualizerList)) );
 
1785
 
 
1786
        connect( audio_equalizer, SIGNAL(visibilityChanged()),
1453
1787
             this, SLOT(updateWidgets()) );
1454
1788
}
1455
1789
 
1477
1811
void BaseGui::createPanel() {
1478
1812
        panel = new QWidget( this );
1479
1813
        panel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
1480
 
        panel->setMinimumSize( QSize(0,0) );
 
1814
        panel->setMinimumSize( QSize(1,1) );
1481
1815
        panel->setFocusPolicy( Qt::StrongFocus );
1482
1816
 
1483
1817
        // panel
1484
1818
        panel->setAutoFillBackground(TRUE);
1485
 
        Helper::setBackgroundColor( panel, QColor(0,0,0) );
 
1819
        ColorUtils::setBackgroundColor( panel, QColor(0,0,0) );
1486
1820
}
1487
1821
 
1488
1822
void BaseGui::createPreferencesDialog() {
1550
1884
        // Speed submenu
1551
1885
        speed_menu = new QMenu(this);
1552
1886
        speed_menu->addAction(normalSpeedAct);
 
1887
        speed_menu->addSeparator();
1553
1888
        speed_menu->addAction(halveSpeedAct);
1554
1889
        speed_menu->addAction(doubleSpeedAct);
1555
 
        speed_menu->addAction(decSpeedAct);
1556
 
        speed_menu->addAction(incSpeedAct);
 
1890
        speed_menu->addSeparator();
 
1891
        speed_menu->addAction(decSpeed10Act);
 
1892
        speed_menu->addAction(incSpeed10Act);
 
1893
        speed_menu->addSeparator();
 
1894
        speed_menu->addAction(decSpeed4Act);
 
1895
        speed_menu->addAction(incSpeed4Act);
 
1896
        speed_menu->addSeparator();
 
1897
        speed_menu->addAction(decSpeed1Act);
 
1898
        speed_menu->addAction(incSpeed1Act);
1557
1899
 
1558
1900
        playMenu->addMenu(speed_menu);
1559
1901
 
1560
1902
        playMenu->addAction(repeatAct);
1561
1903
        playMenu->addSeparator();
1562
1904
        playMenu->addAction(gotoAct);
 
1905
        playMenu->addSeparator();
 
1906
        playMenu->addAction(playPrevAct);
 
1907
        playMenu->addAction(playNextAct);
1563
1908
        
1564
1909
        // VIDEO MENU
 
1910
        videotrack_menu = new QMenu(this);
 
1911
 
 
1912
        videoMenu->addMenu(videotrack_menu);
 
1913
 
1565
1914
        videoMenu->addAction(fullscreenAct);
1566
1915
        videoMenu->addAction(compactAct);
1567
1916
 
 
1917
#if USE_ADAPTER
 
1918
        // Screen submenu
 
1919
        screen_menu = new QMenu(this);
 
1920
        screen_menu->addActions( screenGroup->actions() );
 
1921
        videoMenu->addMenu(screen_menu);
 
1922
#endif
 
1923
 
1568
1924
        // Size submenu
1569
1925
        videosize_menu = new QMenu(this);
1570
1926
        videosize_menu->addActions( sizeGroup->actions() );
1575
1931
        // Panscan submenu
1576
1932
        panscan_menu = new QMenu(this);
1577
1933
        panscan_menu->addAction(resetZoomAct);
 
1934
        panscan_menu->addSeparator();
 
1935
        panscan_menu->addAction(autoZoomAct);
 
1936
        panscan_menu->addAction(autoZoom169Act);
 
1937
        panscan_menu->addAction(autoZoom235Act);
 
1938
        panscan_menu->addSeparator();
1578
1939
        panscan_menu->addAction(decZoomAct);
1579
1940
        panscan_menu->addAction(incZoomAct);
1580
1941
        panscan_menu->addSeparator();
1627
1988
        videoMenu->addMenu(rotate_menu);
1628
1989
 
1629
1990
        videoMenu->addAction(flipAct);
 
1991
        videoMenu->addAction(mirrorAct);
1630
1992
        videoMenu->addSeparator();
1631
 
        videoMenu->addAction(equalizerAct);
 
1993
        videoMenu->addAction(videoEqualizerAct);
1632
1994
        videoMenu->addAction(screenshotAct);
1633
 
        videoMenu->addAction(onTopAct);
 
1995
 
 
1996
        // Ontop submenu
 
1997
        ontop_menu = new QMenu(this);
 
1998
        ontop_menu->addActions(onTopActionGroup->actions());
 
1999
 
 
2000
        videoMenu->addMenu(ontop_menu);
 
2001
 
 
2002
        videoMenu->addSeparator();
 
2003
        videoMenu->addAction(videoPreviewAct);
1634
2004
 
1635
2005
 
1636
2006
    // AUDIO MENU
1662
2032
        stereomode_menu->addActions( stereoGroup->actions() );
1663
2033
 
1664
2034
        audioMenu->addMenu(stereomode_menu);
1665
 
 
 
2035
        audioMenu->addAction(audioEqualizerAct);
 
2036
        audioMenu->addSeparator();
1666
2037
        audioMenu->addAction(muteAct);
1667
2038
        audioMenu->addSeparator();
1668
2039
        audioMenu->addAction(decVolumeAct);
1670
2041
        audioMenu->addSeparator();
1671
2042
        audioMenu->addAction(decAudioDelayAct);
1672
2043
        audioMenu->addAction(incAudioDelayAct);
 
2044
        audioMenu->addSeparator();
 
2045
        audioMenu->addAction(audioDelayAct);
1673
2046
 
1674
2047
 
1675
2048
        // SUBTITLES MENU
1684
2057
        subtitlesMenu->addAction(decSubDelayAct);
1685
2058
        subtitlesMenu->addAction(incSubDelayAct);
1686
2059
        subtitlesMenu->addSeparator();
 
2060
        subtitlesMenu->addAction(subDelayAct);
 
2061
        subtitlesMenu->addSeparator();
1687
2062
        subtitlesMenu->addAction(decSubPosAct);
1688
2063
        subtitlesMenu->addAction(incSubPosAct);
1689
2064
        subtitlesMenu->addSeparator();
1697
2072
        subtitlesMenu->addAction(useForcedSubsOnlyAct);
1698
2073
        subtitlesMenu->addSeparator();
1699
2074
        subtitlesMenu->addAction(useAssAct);
 
2075
        subtitlesMenu->addSeparator(); //turbos
 
2076
        subtitlesMenu->addAction(showFindSubtitlesDialogAct);
 
2077
        subtitlesMenu->addAction(openUploadSubtitlesPageAct); //turbos
1700
2078
 
1701
2079
        // BROWSE MENU
1702
2080
        // Titles submenu
1714
2092
 
1715
2093
        browseMenu->addMenu(angles_menu);
1716
2094
 
 
2095
#if DVDNAV_SUPPORT
 
2096
        browseMenu->addSeparator();
 
2097
        browseMenu->addAction(dvdnavMenuAct);
 
2098
        browseMenu->addAction(dvdnavPrevAct);
 
2099
#endif
 
2100
 
1717
2101
        // OPTIONS MENU
1718
2102
        optionsMenu->addAction(showPropertiesAct);
1719
2103
        optionsMenu->addAction(showPlaylistAct);
1738
2122
 
1739
2123
        // HELP MENU
1740
2124
        helpMenu->addAction(showFAQAct);
1741
 
        helpMenu->addAction(showCLOptions);
 
2125
        helpMenu->addAction(showCLOptionsAct);
 
2126
        helpMenu->addAction(showTipsAct);
1742
2127
        helpMenu->addSeparator();
1743
2128
        helpMenu->addAction(aboutQtAct);
1744
2129
        helpMenu->addAction(aboutThisAct);
1801
2186
        //updateWidgets();
1802
2187
}
1803
2188
 
1804
 
void BaseGui::showEqualizer() {
1805
 
        showEqualizer( !equalizer->isVisible() );
1806
 
}
1807
 
 
1808
 
void BaseGui::showEqualizer(bool b) {
1809
 
        if (!b) {
1810
 
                equalizer->hide();
1811
 
        } else {
1812
 
                // Exit fullscreen, otherwise dialog is not visible
1813
 
                exitFullscreenIfNeeded();
1814
 
                equalizer->show();
 
2189
void BaseGui::showVideoEqualizer() {
 
2190
        showVideoEqualizer( !video_equalizer->isVisible() );
 
2191
}
 
2192
 
 
2193
void BaseGui::showVideoEqualizer(bool b) {
 
2194
        if (!b) {
 
2195
                video_equalizer->hide();
 
2196
        } else {
 
2197
                // Exit fullscreen, otherwise dialog is not visible
 
2198
                exitFullscreenIfNeeded();
 
2199
                video_equalizer->show();
 
2200
        }
 
2201
        updateWidgets();
 
2202
}
 
2203
 
 
2204
void BaseGui::showAudioEqualizer() {
 
2205
        showAudioEqualizer( !audio_equalizer->isVisible() );
 
2206
}
 
2207
 
 
2208
void BaseGui::showAudioEqualizer(bool b) {
 
2209
        if (!b) {
 
2210
                audio_equalizer->hide();
 
2211
        } else {
 
2212
                // Exit fullscreen, otherwise dialog is not visible
 
2213
                exitFullscreenIfNeeded();
 
2214
                audio_equalizer->show();
1815
2215
        }
1816
2216
        updateWidgets();
1817
2217
}
1849
2249
                qApp->setFont(f);
1850
2250
        }
1851
2251
 
 
2252
#ifndef NO_USE_INI_FILES
 
2253
        PrefGeneral *_general = pref_dialog->mod_general();
 
2254
        if (_general->fileSettingsMethodChanged()) {
 
2255
                core->changeFileSettingsMethod(pref->file_settings_method);
 
2256
        }
 
2257
#endif
 
2258
 
1852
2259
        PrefInterface *_interface = pref_dialog->mod_interface();
1853
2260
        if (_interface->recentsChanged()) {
1854
 
                recents->setMaxItems(pref->recents_max_items);
1855
2261
                updateRecents();
1856
2262
        }
1857
2263
        if (_interface->languageChanged()) need_update_language = true;
1876
2282
 
1877
2283
                if (server_requires_restart) {
1878
2284
                        server->close();
1879
 
                        if (server->listen(pref->connection_port)) {
1880
 
                                qDebug("BaseGui::applyNewPreferences: server running on port %d", pref->connection_port);
 
2285
                        int port = 0;
 
2286
                        if (!pref->use_autoport) port = pref->connection_port;
 
2287
                        if (server->listen(port)) {
 
2288
                                pref->autoport = server->serverPort();
 
2289
                                qDebug("BaseGui::applyNewPreferences: server running on port %d", pref->autoport);
1881
2290
                        } else {
1882
2291
                                qWarning("BaseGui::applyNewPreferences: server couldn't be started");
1883
2292
                        }
1885
2294
        }
1886
2295
 
1887
2296
        PrefAdvanced *advanced = pref_dialog->mod_advanced();
1888
 
        if (advanced->clearingBackgroundChanged()) {
1889
 
                mplayerwindow->videoLayer()->allowClearingBackground(pref->always_clear_video_background);
 
2297
#if REPAINT_BACKGROUND_OPTION
 
2298
        if (advanced->repaintVideoBackgroundChanged()) {
 
2299
                mplayerwindow->videoLayer()->setRepaintBackground(pref->repaint_video_background);
1890
2300
        }
 
2301
#endif
1891
2302
#if USE_COLORKEY
1892
2303
        if (advanced->colorkeyChanged()) {
1893
2304
                mplayerwindow->setColorKey( pref->color_key );
2034
2445
void BaseGui::newMediaLoaded() {
2035
2446
    qDebug("BaseGui::newMediaLoaded");
2036
2447
 
2037
 
        recents->add( core->mdat.filename );
 
2448
        pref->history_recents->addItem( core->mdat.filename );
2038
2449
        updateRecents();
2039
2450
 
2040
2451
        // If a VCD, Audio CD or DVD, add items to playlist
2041
 
        if ( (core->mdat.type == TYPE_VCD) || (core->mdat.type == TYPE_DVD) || 
2042
 
         (core->mdat.type == TYPE_AUDIO_CD) ) 
 
2452
        bool is_disc = ( (core->mdat.type == TYPE_VCD) || (core->mdat.type == TYPE_DVD) || (core->mdat.type == TYPE_AUDIO_CD) );
 
2453
#if DVDNAV_SUPPORT
 
2454
        // Don't add the list of titles if using dvdnav
 
2455
        if ((core->mdat.type == TYPE_DVD) && (core->mdat.filename.startsWith("dvdnav:"))) is_disc = false;
 
2456
#endif
 
2457
        if (pref->auto_add_to_playlist && is_disc)
2043
2458
        {
2044
2459
                int first_title = 1;
2045
2460
                if (core->mdat.type == TYPE_VCD) first_title = pref->vcd_initial_title;
2046
2461
 
2047
 
                QString type = "dvd";
 
2462
                QString type = "dvd"; // FIXME: support dvdnav
2048
2463
                if (core->mdat.type == TYPE_VCD) type="vcd";
2049
2464
                else
2050
2465
                if (core->mdat.type == TYPE_AUDIO_CD) type="cdda";
2055
2470
                        QString s;
2056
2471
                        QString folder;
2057
2472
                        if (core->mdat.type == TYPE_DVD) {
2058
 
                                folder = Helper::dvdSplitFolder( core->mdat.filename );
 
2473
                                DiscData disc_data = DiscName::split(core->mdat.filename);
 
2474
                                folder = disc_data.device;
2059
2475
                        }
2060
2476
                        for (int n=0; n < core->mdat.titles.numItems(); n++) {
2061
2477
                                s = type + "://" + QString::number(core->mdat.titles.itemAt(n).ID());
2062
2478
                                if ( !folder.isEmpty() ) {
2063
 
                                        s += ":" + folder;
 
2479
                                        s += "/" + folder; // FIXME: dvd names are not created as they should
2064
2480
                                }
2065
2481
                                l.append(s);
2066
2482
                        }
2071
2487
                playlist->clear();
2072
2488
                playlist->addCurrentFile();
2073
2489
        }*/
 
2490
 
 
2491
        if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist) && (pref->add_to_playlist_consecutive_files)) {
 
2492
                // Look for consecutive files
 
2493
                QStringList files_to_add = Helper::searchForConsecutiveFiles(core->mdat.filename);
 
2494
                if (!files_to_add.empty()) playlist->addFiles(files_to_add);
 
2495
        }
 
2496
}
 
2497
 
 
2498
void BaseGui::clearMplayerLog() {
 
2499
        mplayer_log.clear();
 
2500
        if (mplayer_log_window->isVisible()) mplayer_log_window->clear();
 
2501
}
 
2502
 
 
2503
void BaseGui::recordMplayerLog(QString line) {
 
2504
        if (pref->log_mplayer) {
 
2505
                if ( (line.indexOf("A:")==-1) && (line.indexOf("V:")==-1) ) {
 
2506
                        line.append("\n");
 
2507
                        mplayer_log.append(line);
 
2508
                        if (mplayer_log_window->isVisible()) mplayer_log_window->appendText(line);
 
2509
                }
 
2510
        }
 
2511
}
 
2512
 
 
2513
void BaseGui::recordSmplayerLog(QString line) {
 
2514
        if (pref->log_smplayer) {
 
2515
                line.append("\n");
 
2516
                smplayer_log.append(line);
 
2517
                if (smplayer_log_window->isVisible()) smplayer_log_window->appendText(line);
 
2518
        }
 
2519
}
 
2520
 
 
2521
/*! 
 
2522
        Save the mplayer log to a file, so it can be used by external
 
2523
        applications.
 
2524
*/
 
2525
void BaseGui::autosaveMplayerLog() {
 
2526
        qDebug("BaseGui::autosaveMplayerLog");
 
2527
 
 
2528
        if (pref->autosave_mplayer_log) {
 
2529
                if (!pref->mplayer_log_saveto.isEmpty()) {
 
2530
                        QFile file( pref->mplayer_log_saveto );
 
2531
                        if ( file.open( QIODevice::WriteOnly ) ) {
 
2532
                                QTextStream strm( &file );
 
2533
                                strm << mplayer_log;
 
2534
                                file.close();
 
2535
                        }
 
2536
                }
 
2537
        }
2074
2538
}
2075
2539
 
2076
2540
void BaseGui::showMplayerLog() {
2078
2542
 
2079
2543
        exitFullscreenIfNeeded();
2080
2544
 
2081
 
    mplayer_log_window->setText( core->mplayer_log );
 
2545
    mplayer_log_window->setText( mplayer_log );
2082
2546
        mplayer_log_window->show();
2083
2547
}
2084
2548
 
2087
2551
 
2088
2552
        exitFullscreenIfNeeded();
2089
2553
 
2090
 
        smplayer_log_window->setText( Helper::log() );
 
2554
        smplayer_log_window->setText( smplayer_log );
2091
2555
    smplayer_log_window->show();
2092
2556
}
2093
2557
 
2127
2591
        }
2128
2592
        audiotrack_menu->addActions( audioTrackGroup->actions() );
2129
2593
 
 
2594
        // Video
 
2595
        videoTrackGroup->clear(true);
 
2596
        if (core->mdat.videos.numItems()==0) {
 
2597
                QAction * a = videoTrackGroup->addAction( tr("<empty>") );
 
2598
                a->setEnabled(false);
 
2599
        } else {
 
2600
                for (n=0; n < core->mdat.videos.numItems(); n++) {
 
2601
                        QAction *a = new QAction(videoTrackGroup);
 
2602
                        a->setCheckable(true);
 
2603
                        a->setText(core->mdat.videos.itemAt(n).displayName());
 
2604
                        a->setData(core->mdat.videos.itemAt(n).ID());
 
2605
                }
 
2606
        }
 
2607
        videotrack_menu->addActions( videoTrackGroup->actions() );
 
2608
 
2130
2609
        // Titles
2131
2610
        titleGroup->clear(true);
2132
2611
        if (core->mdat.titles.numItems()==0) {
2142
2621
        }
2143
2622
        titles_menu->addActions( titleGroup->actions() );
2144
2623
 
 
2624
#if GENERIC_CHAPTER_SUPPORT
 
2625
        chapterGroup->clear(true);
 
2626
        if (core->mdat.chapters > 0) {
 
2627
                for (n=0; n < core->mdat.chapters; n++) {
 
2628
                        QAction *a = new QAction(chapterGroup);
 
2629
                        a->setCheckable(true);
 
2630
                        a->setText( QString::number(n+1) );
 
2631
                        a->setData( n + Core::firstChapter() );
 
2632
                }
 
2633
        } else {
 
2634
                QAction * a = chapterGroup->addAction( tr("<empty>") );
 
2635
                a->setEnabled(false);
 
2636
        }
 
2637
        chapters_menu->addActions( chapterGroup->actions() );
 
2638
#else
2145
2639
        // DVD Chapters
2146
2640
        chapterGroup->clear(true);
2147
2641
        if ( (core->mdat.type == TYPE_DVD) && (core->mset.current_title_id > 0) ) {
2149
2643
                        QAction *a = new QAction(chapterGroup);
2150
2644
                        a->setCheckable(true);
2151
2645
                        a->setText( QString::number(n+1) );
2152
 
                        a->setData( n + Core::dvd_first_chapter() );
 
2646
                        a->setData( n + Core::dvdFirstChapter() );
2153
2647
                }
2154
2648
        } else {
2155
2649
                // *** Matroshka chapters ***
2158
2652
                                QAction *a = new QAction(chapterGroup);
2159
2653
                                a->setCheckable(true);
2160
2654
                                a->setText( QString::number(n+1) );
2161
 
                                a->setData( n + Core::mkv_first_chapter() );
 
2655
                                a->setData( n + Core::firstChapter() );
2162
2656
                        }
2163
2657
                } else {
2164
2658
                        QAction * a = chapterGroup->addAction( tr("<empty>") );
2166
2660
                }
2167
2661
        }
2168
2662
        chapters_menu->addActions( chapterGroup->actions() );
 
2663
#endif
2169
2664
 
2170
2665
        // Angles
2171
2666
        angleGroup->clear(true);
 
2667
        int n_angles = 0;
2172
2668
        if (core->mset.current_angle_id > 0) {
2173
 
                for (n=1; n <= core->mdat.titles.item(core->mset.current_title_id).angles(); n++) {
 
2669
                int i = core->mdat.titles.find(core->mset.current_angle_id);
 
2670
                if (i > -1) n_angles = core->mdat.titles.itemAt(i).angles();
 
2671
        }
 
2672
        if (n_angles > 0) {
 
2673
                for (n=1; n <= n_angles; n++) {
2174
2674
                        QAction *a = new QAction(angleGroup);
2175
2675
                        a->setCheckable(true);
2176
2676
                        a->setText( QString::number(n) );
2195
2695
 
2196
2696
        int current_items = 0;
2197
2697
 
2198
 
        if (recents->count() > 0) {
2199
 
                int max_items = recents->count();
2200
 
                if (max_items > pref->recents_max_items) {
2201
 
                        max_items = pref->recents_max_items;
2202
 
                }
2203
 
                for (int n=0; n < max_items; n++) {
2204
 
                        QString fullname = recents->item(n);
 
2698
        if (pref->history_recents->count() > 0) {
 
2699
                for (int n=0; n < pref->history_recents->count(); n++) {
 
2700
                        QString fullname = pref->history_recents->item(n);
2205
2701
                        QString filename = fullname;
2206
2702
                        QFileInfo fi(fullname);
2207
2703
                        //if (fi.exists()) filename = fi.fileName(); // Can be slow
2218
2714
        } else {
2219
2715
                QAction * a = recentfiles_menu->addAction( tr("<empty>") );
2220
2716
                a->setEnabled(false);
2221
 
 
2222
2717
        }
2223
2718
 
2224
2719
        recentfiles_menu->menuAction()->setVisible( current_items > 0 );
2226
2721
 
2227
2722
void BaseGui::clearRecentsList() {
2228
2723
        // Delete items in menu
2229
 
        recents->clear();
 
2724
        pref->history_recents->clear();
2230
2725
        updateRecents();
2231
2726
}
2232
2727
 
2246
2741
        // Disable the unload audio file action if there's no external audio file
2247
2742
        unloadAudioAct->setEnabled( !core->mset.external_audio.isEmpty() );
2248
2743
 
 
2744
        // Video menu
 
2745
        videoTrackGroup->setChecked( core->mset.current_video_id );
 
2746
 
2249
2747
        // Aspect ratio
2250
2748
        aspectGroup->setChecked( core->mset.aspect_ratio_id );
2251
2749
 
2252
2750
        // Rotate
2253
2751
        rotateGroup->setChecked( core->mset.rotate );
2254
2752
 
 
2753
#if USE_ADAPTER
 
2754
        screenGroup->setChecked( pref->adapter );
 
2755
#endif
 
2756
 
2255
2757
        // OSD
2256
2758
        osdGroup->setChecked( pref->osd );
2257
2759
 
2337
2839
        }
2338
2840
 
2339
2841
        // Video equalizer
2340
 
        equalizerAct->setChecked( equalizer->isVisible() );
 
2842
        videoEqualizerAct->setChecked( video_equalizer->isVisible() );
 
2843
 
 
2844
        // Audio equalizer
 
2845
        audioEqualizerAct->setChecked( audio_equalizer->isVisible() );
2341
2846
 
2342
2847
        // Playlist
2343
2848
#if !DOCK_PLAYLIST
2358
2863
        compactAct->setChecked( pref->compact_mode );
2359
2864
 
2360
2865
        // Stay on top
2361
 
        onTopAct->setChecked( pref->stay_on_top );
 
2866
        onTopActionGroup->setChecked( (int) pref->stay_on_top );
2362
2867
 
2363
2868
        // Flip
2364
2869
        flipAct->setChecked( core->mset.flip );
2365
2870
 
 
2871
        // Mirror
 
2872
        mirrorAct->setChecked( core->mset.mirror );
2366
2873
 
2367
2874
        // Use ass lib
2368
2875
        useAssAct->setChecked( pref->use_ass_subtitles );
2379
2886
 
2380
2887
        decSubDelayAct->setEnabled(e);
2381
2888
        incSubDelayAct->setEnabled(e);
 
2889
        subDelayAct->setEnabled(e);
2382
2890
        decSubPosAct->setEnabled(e);
2383
2891
        incSubPosAct->setEnabled(e);
2384
2892
        decSubScaleAct->setEnabled(e);
2387
2895
        incSubStepAct->setEnabled(e);
2388
2896
}
2389
2897
 
2390
 
void BaseGui::updateEqualizer() {
 
2898
void BaseGui::updateVideoEqualizer() {
2391
2899
        // Equalizer
2392
 
        equalizer->contrast->setValue( core->mset.contrast );
2393
 
        equalizer->brightness->setValue( core->mset.brightness );
2394
 
        equalizer->hue->setValue( core->mset.hue );
2395
 
        equalizer->saturation->setValue( core->mset.saturation );
2396
 
        equalizer->gamma->setValue( core->mset.gamma );
 
2900
        video_equalizer->contrast->setValue( core->mset.contrast );
 
2901
        video_equalizer->brightness->setValue( core->mset.brightness );
 
2902
        video_equalizer->hue->setValue( core->mset.hue );
 
2903
        video_equalizer->saturation->setValue( core->mset.saturation );
 
2904
        video_equalizer->gamma->setValue( core->mset.gamma );
 
2905
}
 
2906
 
 
2907
void BaseGui::updateAudioEqualizer() {
 
2908
        // Audio Equalizer
 
2909
        for (int n = 0; n < 10; n++) {
 
2910
                audio_equalizer->eq[n]->setValue( core->mset.audio_equalizer[n].toInt() );
 
2911
        }
2397
2912
}
2398
2913
 
2399
2914
/*
2420
2935
        if (a) {
2421
2936
                int item = a->data().toInt();
2422
2937
                qDebug("BaseGui::openRecent: %d", item);
2423
 
                QString file = recents->item(item);
 
2938
                QString file = pref->history_recents->item(item);
2424
2939
 
2425
2940
                if (pref->auto_add_to_playlist) {
2426
2941
                        if (playlist->maybeSave()) {
2513
3028
 
2514
3029
        InputURL d(this);
2515
3030
 
2516
 
        QString url = pref->last_url;
2517
 
        if (url.endsWith(IS_PLAYLIST_TAG)) {
2518
 
                url = url.remove( QRegExp(IS_PLAYLIST_TAG_RX) );
2519
 
                d.setPlaylist(true);
 
3031
        for (int n=0; n < pref->history_urls->count(); n++) {
 
3032
                d.setURL( pref->history_urls->url(n), pref->history_urls->isPlaylist(n) );
2520
3033
        }
2521
3034
 
2522
 
        d.setURL(url);
2523
3035
        if (d.exec() == QDialog::Accepted ) {
2524
3036
                QString url = d.url();
 
3037
                bool is_playlist = d.isPlaylist();
2525
3038
                if (!url.isEmpty()) {
2526
 
                        if (d.isPlaylist()) url = url + IS_PLAYLIST_TAG;
 
3039
                        pref->history_urls->addUrl(url, is_playlist);
 
3040
                        if (is_playlist) url = url + IS_PLAYLIST_TAG;
2527
3041
                        openURL(url);
2528
3042
                }
2529
3043
        }
2531
3045
 
2532
3046
void BaseGui::openURL(QString url) {
2533
3047
        if (!url.isEmpty()) {
2534
 
                pref->last_url = url;
 
3048
                //pref->history_urls->addUrl(url);
2535
3049
 
2536
3050
                if (pref->auto_add_to_playlist) {
2537
3051
                        if (playlist->maybeSave()) {
2652
3166
                configureDiscDevices();
2653
3167
        } else {
2654
3168
                if (playlist->maybeSave()) {
2655
 
                        core->openDVD("dvd://1");
 
3169
#if DVDNAV_SUPPORT
 
3170
                        core->openDVD( DiscName::joinDVD(pref->use_dvdnav ? 0: 1, pref->dvd_device, pref->use_dvdnav) );
 
3171
#else
 
3172
                        core->openDVD( DiscName::joinDVD(1, pref->dvd_device, false) );
 
3173
#endif
2656
3174
                }
2657
3175
        }
2658
3176
}
2674
3192
}
2675
3193
 
2676
3194
void BaseGui::openDVDFromFolder(QString directory) {
2677
 
        //core->openDVD(TRUE, directory);
2678
3195
        pref->last_dvd_directory = directory;
2679
 
        core->openDVD( "dvd://1:" + directory);
 
3196
#if DVDNAV_SUPPORT
 
3197
        core->openDVD( DiscName::joinDVD(pref->use_dvdnav ? 0: 1, directory, pref->use_dvdnav) );
 
3198
#else
 
3199
        core->openDVD( DiscName::joinDVD(1, directory, false) );
 
3200
#endif
2680
3201
}
2681
3202
 
2682
3203
void BaseGui::openDirectory() {
2725
3246
        if (!s.isEmpty()) core->loadSub(s);
2726
3247
}
2727
3248
 
 
3249
void BaseGui::setInitialSubtitle(const QString & subtitle_file) {
 
3250
        qDebug("BaseGui::setInitialSubtitle: '%s'", subtitle_file.toUtf8().constData());
 
3251
 
 
3252
        core->setInitialSubtitle(subtitle_file);
 
3253
}
 
3254
 
2728
3255
void BaseGui::loadAudioFile() {
2729
3256
        qDebug("BaseGui::loadAudioFile");
2730
3257
 
2741
3268
}
2742
3269
 
2743
3270
void BaseGui::helpFAQ() {
2744
 
        QUrl url = QUrl::fromLocalFile(Helper::doc("faq.html", pref->language));
 
3271
        QUrl url = QUrl::fromLocalFile(Paths::doc("faq.html", pref->language));
2745
3272
        qDebug("BaseGui::helpFAQ: file to open %s", url.toString().toUtf8().data());
2746
3273
        QDesktopServices::openUrl( url );
2747
3274
}
2755
3282
        clhelp_window->show();
2756
3283
}
2757
3284
 
 
3285
void BaseGui::helpTips() {
 
3286
        QDesktopServices::openUrl( QUrl("http://smplayer.wiki.sourceforge.net/Tips") );
 
3287
}
 
3288
 
2758
3289
void BaseGui::helpAbout() {
2759
3290
        About d(this);
2760
3291
        d.exec();
2766
3297
 
2767
3298
void BaseGui::showGotoDialog() {
2768
3299
        TimeDialog d(this);
 
3300
        d.setLabel(tr("&Jump to:"));
 
3301
        d.setWindowTitle(tr("SMPlayer - Seek"));
2769
3302
        d.setMaximumTime( (int) core->mdat.duration);
2770
3303
        d.setTime( (int) core->mset.current_sec);
2771
3304
        if (d.exec() == QDialog::Accepted) {
2773
3306
        }
2774
3307
}
2775
3308
 
 
3309
void BaseGui::showAudioDelayDialog() {
 
3310
        bool ok;
 
3311
        int delay = QInputDialog::getInteger(this, tr("SMPlayer - Audio delay"),
 
3312
                                         tr("Audio delay (in milliseconds):"), core->mset.audio_delay, 
 
3313
                                         -3600000, 3600000, 1, &ok);
 
3314
        if (ok) {
 
3315
                core->setAudioDelay(delay);
 
3316
        }
 
3317
}
 
3318
 
 
3319
void BaseGui::showSubDelayDialog() {
 
3320
        bool ok;
 
3321
        int delay = QInputDialog::getInteger(this, tr("SMPlayer - Subtitle delay"),
 
3322
                                         tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay, 
 
3323
                                         -3600000, 3600000, 1, &ok);
 
3324
        if (ok) {
 
3325
                core->setSubDelay(delay);
 
3326
        }
 
3327
}
 
3328
 
2776
3329
void BaseGui::exitFullscreen() {
2777
3330
        if (pref->fullscreen) {
2778
3331
                toggleFullscreen(false);
2805
3358
 
2806
3359
        if (!panel->isVisible()) return; // mplayer window is not used.
2807
3360
 
2808
 
 
2809
3361
        if (pref->fullscreen) {
2810
3362
                compactAct->setEnabled(false);
2811
3363
 
2847
3399
        }
2848
3400
 
2849
3401
        updateWidgets();
 
3402
 
 
3403
        if ((pref->add_blackborders_on_fullscreen) && 
 
3404
        (!core->mset.add_letterbox)) 
 
3405
        {
 
3406
                core->restart();
 
3407
        }
 
3408
 
 
3409
        setFocus(); // Fixes bug #2493415
2850
3410
}
2851
3411
 
2852
3412
 
2979
3539
        }
2980
3540
}
2981
3541
 
 
3542
void BaseGui::checkPendingActionsToRun() {
 
3543
        qDebug("BaseGui::checkPendingActionsToRun");
 
3544
 
 
3545
        QString actions;
 
3546
        if (!pending_actions_to_run.isEmpty()) {
 
3547
                actions = pending_actions_to_run;
 
3548
                pending_actions_to_run.clear();
 
3549
                if (!pref->actions_to_run.isEmpty()) {
 
3550
                        actions = pref->actions_to_run +" "+ actions;
 
3551
                }
 
3552
        } else {
 
3553
                actions = pref->actions_to_run;
 
3554
        }
 
3555
 
 
3556
        if (!actions.isEmpty()) {
 
3557
                qDebug("BaseGui::checkPendingActionsToRun: actions: '%s'", actions.toUtf8().constData());
 
3558
                runActions(actions);
 
3559
        }
 
3560
}
 
3561
 
 
3562
#if REPORT_OLD_MPLAYER
 
3563
void BaseGui::checkMplayerVersion() {
 
3564
        qDebug("BaseGui::checkMplayerVersion");
 
3565
 
 
3566
        // Qt 4.3.5 is crazy, I can't popup a messagebox here, it calls 
 
3567
        // this function once and again when the messagebox is shown
 
3568
 
 
3569
        if ( (pref->mplayer_detected_version > 0) && (!MplayerVersion::isMplayerAtLeast(25158)) ) {
 
3570
                QTimer::singleShot(1000, this, SLOT(displayWarningAboutOldMplayer()));
 
3571
        }
 
3572
}
 
3573
 
 
3574
void BaseGui::displayWarningAboutOldMplayer() {
 
3575
        qDebug("BaseGui::displayWarningAboutOldMplayer");
 
3576
 
 
3577
        if (!pref->reported_mplayer_is_old) {
 
3578
                QMessageBox::warning(this, tr("Warning - Using old MPlayer"),
 
3579
                        tr("The version of MPlayer (%1) installed on your system "
 
3580
               "is obsolete. SMPlayer can't work well with it: some "
 
3581
               "options won't work, subtitle selection may fail...")
 
3582
               .arg(MplayerVersion::toString(pref->mplayer_detected_version)) +
 
3583
            "<br><br>" + 
 
3584
            tr("Please, update your MPlayer.") +
 
3585
            "<br><br>" + 
 
3586
            tr("(This warning won't be displayed anymore)") );
 
3587
 
 
3588
                pref->reported_mplayer_is_old = true;
 
3589
        }
 
3590
        //else
 
3591
        //statusBar()->showMessage( tr("Using an old MPlayer, please update it"), 10000 );
 
3592
}
 
3593
#endif
 
3594
 
2982
3595
void BaseGui::dragEnterEvent( QDragEnterEvent *e ) {
2983
3596
        qDebug("BaseGui::dragEnterEvent");
2984
3597
 
3055
3668
}
3056
3669
 
3057
3670
void BaseGui::showPopupMenu() {
3058
 
        showPopupMenu(mplayerwindow->mapToGlobal(mplayerwindow->mousePosition()));
 
3671
        showPopupMenu(QCursor::pos());
3059
3672
}
3060
3673
 
3061
3674
void BaseGui::showPopupMenu( QPoint p ) {
3170
3783
        emit timeChanged( time );
3171
3784
}
3172
3785
 
3173
 
 
3174
 
#if NEW_RESIZE_CODE
3175
 
 
3176
3786
void BaseGui::resizeWindow(int w, int h) {
3177
3787
        qDebug("BaseGui::resizeWindow: %d, %d", w, h);
3178
3788
 
3199
3809
 
3200
3810
        QSize video_size(w,h);
3201
3811
 
3202
 
        //panel->resize(w, h);
3203
 
        resize(w + diff_size.width(), h + diff_size.height());
3204
 
 
3205
 
        if ( panel->size() != video_size ) {
3206
 
                //adjustSize();
3207
 
 
3208
 
                qDebug("BaseGui::resizeWindow: temp window size: %d, %d", this->width(), this->height());
3209
 
                qDebug("BaseGui::resizeWindow: temp panel->size: %d, %d", 
3210
 
                   panel->size().width(),  
3211
 
                   panel->size().height() );
3212
 
 
3213
 
                int diff_width = this->width() - panel->width();
3214
 
                int diff_height = this->height() - panel->height();
3215
 
 
3216
 
                int new_width = w + diff_width;
3217
 
                int new_height = h + diff_height;
3218
 
 
3219
 
                if ((new_width < w) || (new_height < h)) {
3220
 
                        qWarning("BaseGui::resizeWindow: invalid new size: %d, %d. Not resizing", new_width, new_height);
3221
 
                } else {
3222
 
                        qDebug("BaseGui::resizeWindow: diff: %d, %d", diff_width, diff_height);
3223
 
                        resize(new_width, new_height);
3224
 
 
3225
 
                        diff_size = QSize(diff_width, diff_height );
3226
 
                }
3227
 
        }
 
3812
        if (video_size == panel->size()) {
 
3813
                qDebug("BaseGui::resizeWindow: the panel size is already the required size. Doing nothing.");
 
3814
                return;
 
3815
        }
 
3816
 
 
3817
        int diff_width = this->width() - panel->width();
 
3818
        int diff_height = this->height() - panel->height();
 
3819
 
 
3820
        int new_width = w + diff_width;
 
3821
        int new_height = h + diff_height;
 
3822
 
 
3823
#if USE_MINIMUMSIZE
 
3824
        int minimum_width = minimumSizeHint().width();
 
3825
        if (pref->gui_minimum_width != 0) minimum_width = pref->gui_minimum_width;
 
3826
        if (new_width < minimum_width) {
 
3827
                qDebug("BaseGui::resizeWindow: width is too small, setting width to %d", minimum_width);
 
3828
                new_width = minimum_width;
 
3829
        }
 
3830
#endif
 
3831
 
 
3832
        resize(new_width, new_height);
3228
3833
 
3229
3834
        qDebug("BaseGui::resizeWindow: done: window size: %d, %d", this->width(), this->height());
3230
3835
        qDebug("BaseGui::resizeWindow: done: panel->size: %d, %d", 
3235
3840
           mplayerwindow->size().height() );
3236
3841
}
3237
3842
 
3238
 
void BaseGui::calculateDiff() {
3239
 
        qDebug("BaseGui::calculateDiff: diff_size: %d, %d", diff_size.width(), diff_size.height());
3240
 
 
3241
 
//      if (diff_size == QSize(0,0)) {
3242
 
                int diff_width = width() - panel->width();
3243
 
                int diff_height = height() - panel->height();
3244
 
 
3245
 
                if ((diff_width < 0) || (diff_height < 0)) {
3246
 
                        qWarning("BaseGui::calculateDiff: invalid diff: %d, %d", diff_width, diff_height);
3247
 
                } else {
3248
 
                        diff_size = QSize(diff_width, diff_height);
3249
 
                        qDebug("BaseGui::calculateDiff: diff_size set to: %d, %d", diff_size.width(), diff_size.height());
3250
 
                }
3251
 
//      }
3252
 
}
3253
 
 
3254
 
#else
3255
 
 
3256
 
void BaseGui::resizeWindow(int w, int h) {
3257
 
        qDebug("BaseGui::resizeWindow: %d, %d", w, h);
3258
 
 
3259
 
        // If fullscreen, don't resize!
3260
 
        if (pref->fullscreen) return;
3261
 
 
3262
 
        if ( (pref->resize_method==Preferences::Never) && (panel->isVisible()) ) {
3263
 
                return;
3264
 
        }
3265
 
 
3266
 
        if (!panel->isVisible()) {
3267
 
                //hide();
3268
 
/* #if QT_VERSION >= 0x040301 */
3269
 
                // Work-around for Qt 4.3.1
3270
 
#if DOCK_PLAYLIST
3271
 
                panel->show();
3272
 
                resize(600,600);
3273
 
#else
3274
 
                resize(300,300);
3275
 
                panel->show();
3276
 
#endif
3277
 
/*
3278
 
#else
3279
 
                panel->show();
3280
 
                QPoint p = pos();
3281
 
                adjustSize();
3282
 
                move(p);
3283
 
#endif
3284
 
*/
3285
 
                //show();
3286
 
 
3287
 
                // Enable compact mode
3288
 
                //compactAct->setEnabled(true);
3289
 
        }
3290
 
 
3291
 
        if (pref->size_factor != 100) {
3292
 
                double zoom = (double) pref->size_factor/100;
3293
 
                w = w * zoom;
3294
 
                h = h * zoom;
3295
 
        }
3296
 
 
3297
 
        int width = size().width() - panel->size().width();
3298
 
        int height = size().height() - panel->size().height();
3299
 
 
3300
 
        width += w;
3301
 
        height += h;
3302
 
 
3303
 
        resize(width,height);
3304
 
 
3305
 
        qDebug("width: %d, height: %d", width, height);
3306
 
        qDebug("mplayerwindow->size: %d, %d", 
3307
 
           mplayerwindow->size().width(),  
3308
 
           mplayerwindow->size().height() );
3309
 
 
3310
 
        mplayerwindow->setFocus(); // Needed?
3311
 
}
3312
 
#endif
3313
 
 
3314
3843
void BaseGui::hidePanel() {
3315
3844
        qDebug("BaseGui::hidePanel");
3316
3845
 
 
3846
#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
 
3847
        if (!pref->hide_video_window_on_audio_files) {
 
3848
                mplayerwindow->showLogo(true);
 
3849
        }
 
3850
        else
 
3851
#endif
 
3852
 
3317
3853
        if (panel->isVisible()) {
3318
3854
                // Exit from fullscreen mode 
3319
3855
            if (pref->fullscreen) { toggleFullscreen(false); update(); }
3323
3859
 
3324
3860
                //resizeWindow( size().width(), 0 );
3325
3861
                int width = size().width();
3326
 
                if (width > 580) width = 580;
 
3862
                if (width > pref->default_size.width()) width = pref->default_size.width();
3327
3863
                resize( width, size().height() - panel->size().height() );
3328
3864
                panel->hide();
3329
3865
 
3333
3869
}
3334
3870
 
3335
3871
void BaseGui::displayGotoTime(int t) {
 
3872
#ifdef SEEKBAR_RESOLUTION
 
3873
        int jump_time = (int)core->mdat.duration * t / SEEKBAR_RESOLUTION;
 
3874
#else
3336
3875
        int jump_time = (int)core->mdat.duration * t / 100;
 
3876
#endif
3337
3877
        //QString s = tr("Jump to %1").arg( Helper::formatTime(jump_time) );
3338
3878
        QString s = QString("Jump to %1").arg( Helper::formatTime(jump_time) );
3339
3879
        statusBar()->showMessage( s, 1000 );
3346
3886
void BaseGui::goToPosOnDragging(int t) {
3347
3887
        if (pref->update_while_seeking) {
3348
3888
#if ENABLE_DELAYED_DRAGGING
 
3889
                #ifdef SEEKBAR_RESOLUTION
 
3890
                core->goToPosition(t);
 
3891
                #else
3349
3892
                core->goToPos(t);
 
3893
                #endif
3350
3894
#else
3351
3895
                if ( ( t % 4 ) == 0 ) {
3352
3896
                        qDebug("BaseGui::goToPosOnDragging: %d", t);
 
3897
                        #ifdef SEEKBAR_RESOLUTION
 
3898
                        core->goToPosition(t);
 
3899
                        #else
3353
3900
                        core->goToPos(t);
 
3901
                        #endif
3354
3902
                }
3355
3903
#endif
3356
3904
        }
3382
3930
        statusBar()->show();
3383
3931
}
3384
3932
 
3385
 
 
3386
 
void BaseGui::toggleStayOnTop() {
3387
 
        toggleStayOnTop( !pref->stay_on_top );
3388
 
}
3389
 
 
3390
 
void BaseGui::toggleStayOnTop(bool b) {
 
3933
void BaseGui::setStayOnTop(bool b) {
 
3934
        qDebug("BaseGui::setStayOnTop: %d", b);
 
3935
 
 
3936
        if ( (b && (windowFlags() & Qt::WindowStaysOnTopHint)) ||
 
3937
         (!b && (!(windowFlags() & Qt::WindowStaysOnTopHint))) )
 
3938
        {
 
3939
                // identical do nothing
 
3940
                qDebug("BaseGui::setStayOnTop: nothing to do");
 
3941
                return;
 
3942
        }
 
3943
 
 
3944
        ignore_show_hide_events = true;
 
3945
 
3391
3946
        bool visible = isVisible();
3392
3947
 
3393
3948
        QPoint old_pos = pos();
3405
3960
                show();
3406
3961
        }
3407
3962
 
3408
 
        pref->stay_on_top = b;
3409
 
 
 
3963
        ignore_show_hide_events = false;
 
3964
}
 
3965
 
 
3966
void BaseGui::changeStayOnTop(int stay_on_top) {
 
3967
        switch (stay_on_top) {
 
3968
                case Preferences::AlwaysOnTop : setStayOnTop(true); break;
 
3969
                case Preferences::NeverOnTop  : setStayOnTop(false); break;
 
3970
                case Preferences::WhilePlayingOnTop : setStayOnTop((core->state() == Core::Playing)); break;
 
3971
        }
 
3972
 
 
3973
        pref->stay_on_top = (Preferences::OnTop) stay_on_top;
3410
3974
        updateWidgets();
3411
3975
}
3412
3976
 
 
3977
void BaseGui::checkStayOnTop(Core::State state) {
 
3978
        qDebug("BaseGui::checkStayOnTop");
 
3979
    if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) {
 
3980
                setStayOnTop((state == Core::Playing));
 
3981
        }
 
3982
}
 
3983
 
 
3984
void BaseGui::toggleStayOnTop() {
 
3985
        if (pref->stay_on_top == Preferences::AlwaysOnTop) 
 
3986
                changeStayOnTop(Preferences::NeverOnTop);
 
3987
        else
 
3988
        if (pref->stay_on_top == Preferences::NeverOnTop) 
 
3989
                changeStayOnTop(Preferences::AlwaysOnTop);
 
3990
}
3413
3991
 
3414
3992
// Called when a new window (equalizer, preferences..) is opened.
3415
3993
void BaseGui::exitFullscreenIfNeeded() {
3423
4001
void BaseGui::checkMousePos(QPoint p) {
3424
4002
        //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
3425
4003
 
3426
 
        if (!pref->fullscreen) return;
 
4004
        bool compact = (pref->floating_display_in_compact_mode && pref->compact_mode);
 
4005
 
 
4006
        if (!pref->fullscreen && !compact) return;
3427
4007
 
3428
4008
        #define MARGIN 70
3429
 
        if (p.y() > mplayerwindow->height() - MARGIN) {
 
4009
 
 
4010
        int margin = MARGIN + pref->floating_control_margin;
 
4011
 
 
4012
        if (p.y() > mplayerwindow->height() - margin) {
3430
4013
                //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
3431
4014
                if (!near_bottom) {
3432
4015
                        emit cursorNearBottom(p);
3439
4022
                }
3440
4023
        }
3441
4024
 
3442
 
        if (p.y() < MARGIN) {
 
4025
        if (p.y() < margin) {
3443
4026
                //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
3444
4027
                if (!near_top) {
3445
4028
                        emit cursorNearTop(p);
3467
4050
                qApp->setStyleSheet("");
3468
4051
        } 
3469
4052
        else {
3470
 
                QString qss_file = Helper::appHomePath() + "/themes/" + pref->iconset +"/style.qss";
 
4053
                QString qss_file = Paths::configPath() + "/themes/" + pref->iconset +"/style.qss";
3471
4054
                //qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
3472
4055
                if (!QFile::exists(qss_file)) {
3473
 
                        qss_file = Helper::themesPath() +"/"+ pref->iconset +"/style.qss";
 
4056
                        qss_file = Paths::themesPath() +"/"+ pref->iconset +"/style.qss";
3474
4057
                }
3475
4058
                if (QFile::exists(qss_file)) {
3476
4059
                        qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
3511
4094
void BaseGui::showEvent( QShowEvent * ) {
3512
4095
        qDebug("BaseGui::showEvent");
3513
4096
 
 
4097
        if (ignore_show_hide_events) return;
 
4098
 
3514
4099
        //qDebug("BaseGui::showEvent: pref->pause_when_hidden: %d", pref->pause_when_hidden);
3515
4100
        if ((pref->pause_when_hidden) && (core->state() == Core::Paused)) {
3516
4101
                qDebug("BaseGui::showEvent: unpausing");
3521
4106
void BaseGui::hideEvent( QHideEvent * ) {
3522
4107
        qDebug("BaseGui::hideEvent");
3523
4108
 
 
4109
        if (ignore_show_hide_events) return;
 
4110
 
3524
4111
        //qDebug("BaseGui::hideEvent: pref->pause_when_hidden: %d", pref->pause_when_hidden);
3525
4112
        if ((pref->pause_when_hidden) && (core->state() == Core::Playing)) {
3526
4113
                qDebug("BaseGui::hideEvent: pausing");
3547
4134
void BaseGui::showExitCodeFromMplayer(int exit_code) {
3548
4135
        qDebug("BaseGui::showExitCodeFromMplayer: %d", exit_code);
3549
4136
 
 
4137
        if (!pref->report_mplayer_crashes) {
 
4138
                qDebug("BaseGui::showExitCodeFromMplayer: not displaying error dialog");
 
4139
                return;
 
4140
        }
 
4141
 
3550
4142
        if (exit_code != 255 ) {
3551
4143
                ErrorDialog d(this);
3552
4144
                d.setText(tr("MPlayer has finished unexpectedly.") + " " + 
3553
4145
                      tr("Exit code: %1").arg(exit_code));
3554
 
                d.setLog( core->mplayer_log );
 
4146
                d.setLog( mplayer_log );
3555
4147
                d.exec();
3556
4148
        } 
3557
4149
}
3558
4150
 
3559
4151
void BaseGui::showErrorFromMplayer(QProcess::ProcessError e) {
 
4152
        qDebug("BaseGui::showErrorFromMplayer");
 
4153
 
 
4154
        if (!pref->report_mplayer_crashes) {
 
4155
                qDebug("showErrorFromMplayer: not displaying error dialog");
 
4156
                return;
 
4157
        }
 
4158
 
3560
4159
        if ((e == QProcess::FailedToStart) || (e == QProcess::Crashed)) {
3561
4160
                ErrorDialog d(this);
3562
4161
                if (e == QProcess::FailedToStart) {
3566
4165
                        d.setText(tr("MPlayer has crashed.") + " " + 
3567
4166
                      tr("See the log for more info."));
3568
4167
                }
3569
 
                d.setLog( core->mplayer_log );
 
4168
                d.setLog( mplayer_log );
3570
4169
                d.exec();
3571
4170
        }
3572
4171
}
3573
4172
 
 
4173
 
 
4174
void BaseGui::showFindSubtitlesDialog() {
 
4175
        qDebug("BaseGui::showFindSubtitlesDialog");
 
4176
 
 
4177
        if (!find_subs_dialog) {
 
4178
                find_subs_dialog = new FindSubtitlesWindow(this, Qt::Window | Qt::WindowMinMaxButtonsHint);
 
4179
                find_subs_dialog->setSettings(Global::settings);
 
4180
                find_subs_dialog->setWindowIcon(windowIcon());
 
4181
#if DOWNLOAD_SUBS
 
4182
                connect(find_subs_dialog, SIGNAL(subtitleDownloaded(const QString &)),
 
4183
                core, SLOT(loadSub(const QString &)));
 
4184
#endif
 
4185
        }
 
4186
 
 
4187
        find_subs_dialog->show();
 
4188
        find_subs_dialog->setMovie(core->mdat.filename);
 
4189
}
 
4190
 
 
4191
void BaseGui::openUploadSubtitlesPage() {       
 
4192
        //QDesktopServices::openUrl( QUrl("http://ds6.ovh.org/hashsubtitles/upload.php") );
 
4193
        //QDesktopServices::openUrl( QUrl("http://www.opensubtitles.com/upload") );
 
4194
        QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/uploadjava") );
 
4195
}
 
4196
 
 
4197
void BaseGui::showVideoPreviewDialog() {
 
4198
        qDebug("BaseGui::showVideoPreviewDialog");
 
4199
 
 
4200
        if (video_preview == 0) {
 
4201
                video_preview = new VideoPreview( pref->mplayer_bin, this );
 
4202
                video_preview->setSettings(Global::settings);
 
4203
        }
 
4204
 
 
4205
        if (!core->mdat.filename.isEmpty()) {
 
4206
                video_preview->setVideoFile(core->mdat.filename);
 
4207
 
 
4208
                // DVD
 
4209
                if (core->mdat.type==TYPE_DVD) {
 
4210
                        QString file = core->mdat.filename;
 
4211
                        DiscData disc_data = DiscName::split(file);
 
4212
                        QString dvd_folder = disc_data.device;
 
4213
                        if (dvd_folder.isEmpty()) dvd_folder = pref->dvd_device;
 
4214
                        int dvd_title = disc_data.title;
 
4215
                        file = disc_data.protocol + "://" + QString::number(dvd_title);
 
4216
 
 
4217
                        video_preview->setVideoFile(file);
 
4218
                        video_preview->setDVDDevice(dvd_folder);
 
4219
                } else {
 
4220
                        video_preview->setDVDDevice("");
 
4221
                }
 
4222
        }
 
4223
 
 
4224
        video_preview->setMplayerPath(pref->mplayer_bin);
 
4225
 
 
4226
        if ( (video_preview->showConfigDialog(this)) && (video_preview->createThumbnails()) ) {
 
4227
                video_preview->show();
 
4228
                video_preview->adjustWindowSize();
 
4229
        }
 
4230
}
 
4231
 
3574
4232
// Language change stuff
3575
4233
void BaseGui::changeEvent(QEvent *e) {
3576
4234
        if (e->type() == QEvent::LanguageChange) {
3577
4235
                retranslateStrings();
3578
4236
        } else {
3579
 
                QWidget::changeEvent(e);
 
4237
                QMainWindow::changeEvent(e);
3580
4238
        }
3581
4239
}
3582
4240
 
3587
4245
        if (m->message==WM_SYSCOMMAND) {
3588
4246
                if ((m->wParam & 0xFFF0)==SC_SCREENSAVE || (m->wParam & 0xFFF0)==SC_MONITORPOWER) {
3589
4247
                        qDebug("BaseGui::winEvent: received SC_SCREENSAVE or SC_MONITORPOWER");
3590
 
                        if ((pref->disable_screensaver) && (core->state()==Core::Playing)) {
 
4248
                        qDebug("BaseGui::winEvent: disable_screensaver: %d", pref->disable_screensaver);
 
4249
                        qDebug("BaseGui::winEvent: playing: %d", core->state()==Core::Playing);
 
4250
                        qDebug("BaseGui::winEvent: video: %d", !core->mdat.novideo);
 
4251
                        
 
4252
                        if ((pref->disable_screensaver) && (core->state()==Core::Playing) && (!core->mdat.novideo)) {
3591
4253
                                qDebug("BaseGui::winEvent: not allowing screensaver");
3592
4254
                                (*result) = 0;
3593
4255
                                return true;