Ignore:
Timestamp:
May 15, 2014, 7:53:54 PM (11 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer: update vendor to 0.8.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smplayer/vendor/current/src/basegui.cpp

    r154 r163  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    3939#include <QInputDialog>
    4040#include <QClipboard>
     41#include <QMimeData>
    4142
    4243#include <cmath>
     
    5758#include "filepropertiesdialog.h"
    5859#include "eqslider.h"
    59 #include "videoequalizer2.h"
     60#include "videoequalizer.h"
    6061#include "audioequalizer.h"
    6162#include "inputdvddirectory.h"
     
    112113#endif
    113114
     115#ifdef REMINDER_ACTIONS
     116#include "sharedialog.h"
     117#endif
     118
    114119using namespace Global;
    115120
    116121BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
    117         : QMainWindow( parent, flags ),
    118                 near_top(false),
    119                 near_bottom(false)
     122        : QMainWindow( parent, flags )
    120123{
    121124#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     
    153156
    154157        // Mouse Wheel
     158        /*
    155159        connect( this, SIGNAL(wheelUp()),
    156160             core, SLOT(wheelUp()) );
    157161        connect( this, SIGNAL(wheelDown()),
    158162             core, SLOT(wheelDown()) );
     163        */
    159164        connect( mplayerwindow, SIGNAL(wheelUp()),
    160165             core, SLOT(wheelUp()) );
     
    185190#if AUTODISABLE_ACTIONS
    186191        setActionsEnabled(false);
     192        if (playlist->count() > 0) {
     193                playAct->setEnabled(true);
     194                playOrPauseAct->setEnabled(true);
     195        }
    187196#endif
    188197
     
    218227
    219228void BaseGui::initializeGui() {
    220         if (pref->compact_mode) toggleCompactMode(TRUE);
     229        if (pref->compact_mode) toggleCompactMode(true);
    221230        changeStayOnTop(pref->stay_on_top);
    222231
     
    342351             this, SLOT(openDVDFromFolder()) );
    343352
     353        // Bluray section.
     354#ifdef BLURAY_SUPPORT
     355        openBluRayAct = new MyAction( this, "open_bluray" );
     356        connect( openBluRayAct, SIGNAL(triggered()),
     357             this, SLOT(openBluRay()));
     358
     359        openBluRayFolderAct = new MyAction( this, "open_bluray_folder" );
     360        connect( openBluRayFolderAct, SIGNAL(triggered()),
     361             this, SLOT(openBluRayFromFolder()));
     362#endif
     363
    344364        openURLAct = new MyAction( QKeySequence("Ctrl+U"), this, "open_url" );
    345365        connect( openURLAct, SIGNAL(triggered()),
     
    405425
    406426        playOrPauseAct = new MyAction( Qt::Key_MediaPlay, this, "play_or_pause" );
     427        playOrPauseAct->addShortcut(QKeySequence("Toggle Media Play/Pause")); // MCE remote key
    407428        connect( playOrPauseAct, SIGNAL(triggered()),
    408429             core, SLOT(play_or_pause()) );
    409430
    410431        pauseAct = new MyAction( Qt::Key_Space, this, "pause" );
     432        pauseAct->addShortcut(QKeySequence("Media Pause")); // MCE remote key
    411433        connect( pauseAct, SIGNAL(triggered()),
    412434             core, SLOT(pause()) );
     
    425447
    426448        rewind1Act = new MyAction( Qt::Key_Left, this, "rewind1" );
     449        rewind1Act->addShortcut(QKeySequence("Shift+Ctrl+B")); // MCE remote key
    427450        connect( rewind1Act, SIGNAL(triggered()),
    428451             core, SLOT(srewind()) );
     
    437460
    438461        forward1Act = new MyAction( Qt::Key_Right, this, "forward1" );
     462        forward1Act->addShortcut(QKeySequence("Shift+Ctrl+F")); // MCE remote key
    439463        connect( forward1Act, SIGNAL(triggered()),
    440464             core, SLOT(sforward()) );
     
    509533        // Menu Video
    510534        fullscreenAct = new MyAction( Qt::Key_F, this, "fullscreen" );
     535        fullscreenAct->addShortcut(QKeySequence("Ctrl+T")); // MCE remote key
    511536        fullscreenAct->setCheckable( true );
    512537        connect( fullscreenAct, SIGNAL(toggled(bool)),
     
    600625
    601626        muteAct = new MyAction( Qt::Key_M, this, "mute" );
     627        muteAct->addShortcut(Qt::Key_VolumeMute); // MCE remote key
    602628        muteAct->setCheckable( true );
    603629        connect( muteAct, SIGNAL(toggled(bool)),
     
    607633        decVolumeAct = new MyAction( this, "decrease_volume" );
    608634        decVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("9,/") );
     635        decVolumeAct->addShortcut(Qt::Key_VolumeDown); // MCE remote key
    609636#else
    610637        decVolumeAct = new MyAction( Qt::Key_9, this, "dec_volume" );
     
    616643        incVolumeAct = new MyAction( this, "increase_volume" );
    617644        incVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("0,*") );
     645        incVolumeAct->addShortcut(Qt::Key_VolumeUp); // MCE remote key
    618646#else
    619647        incVolumeAct = new MyAction( Qt::Key_0, this, "inc_volume" );
     
    792820#endif
    793821
    794         aboutQtAct = new MyAction( this, "about_qt" );
    795         connect( aboutQtAct, SIGNAL(triggered()),
    796              this, SLOT(helpAboutQt()) );
    797 
    798822        aboutThisAct = new MyAction( this, "about_smplayer" );
    799823        connect( aboutThisAct, SIGNAL(triggered()),
    800824             this, SLOT(helpAbout()) );
    801825
     826#ifdef SHARE_MENU
    802827        facebookAct = new MyAction (this, "facebook");
    803828        twitterAct = new MyAction (this, "twitter");
     
    816841        connect( yahooAct, SIGNAL(triggered()),
    817842             this, SLOT(shareSMPlayer()) );
    818 
     843#endif
    819844
    820845        // Playlist
    821846        playNextAct = new MyAction(Qt::Key_Greater, this, "play_next");
     847        playNextAct->addShortcut(Qt::Key_MediaNext); // MCE remote key
    822848        connect( playNextAct, SIGNAL(triggered()), playlist, SLOT(playNext()) );
    823849
    824850        playPrevAct = new MyAction(Qt::Key_Less, this, "play_prev");
     851        playPrevAct->addShortcut(Qt::Key_MediaPrevious); // MCE remote key
    825852        connect( playPrevAct, SIGNAL(triggered()), playlist, SLOT(playPrev()) );
    826853
     
    931958
    932959        resetVideoEqualizerAct = new MyAction( this, "reset_video_equalizer");
    933         connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer2, SLOT(reset()) );
     960        connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer, SLOT(reset()) );
    934961
    935962        resetAudioEqualizerAct = new MyAction( this, "reset_audio_equalizer");
     
    10351062        aspectDetectAct = new MyActionGroupItem(this, aspectGroup, "aspect_detect", MediaSettings::AspectAuto);
    10361063        aspect11Act = new MyActionGroupItem(this, aspectGroup, "aspect_1:1", MediaSettings::Aspect11 );
     1064        aspect54Act = new MyActionGroupItem(this, aspectGroup, "aspect_5:4", MediaSettings::Aspect54 );
     1065        aspect43Act = new MyActionGroupItem(this, aspectGroup, "aspect_4:3", MediaSettings::Aspect43);
     1066        aspect118Act = new MyActionGroupItem(this, aspectGroup, "aspect_11:8", MediaSettings::Aspect118 );
     1067        aspect1410Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:10", MediaSettings::Aspect1410 );
    10371068        aspect32Act = new MyActionGroupItem(this, aspectGroup, "aspect_3:2", MediaSettings::Aspect32);
    1038         aspect43Act = new MyActionGroupItem(this, aspectGroup, "aspect_4:3", MediaSettings::Aspect43);
    1039         aspect54Act = new MyActionGroupItem(this, aspectGroup, "aspect_5:4", MediaSettings::Aspect54 );
    10401069        aspect149Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:9", MediaSettings::Aspect149 );
    1041         aspect1410Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:10", MediaSettings::Aspect1410 );
     1070        aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 );
    10421071        aspect169Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:9", MediaSettings::Aspect169 );
    1043         aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 );
    10441072        aspect235Act = new MyActionGroupItem(this, aspectGroup, "aspect_2.35:1", MediaSettings::Aspect235 );
    10451073        {
     
    10771105        screenGroup = new MyActionGroup(this);
    10781106        screenDefaultAct = new MyActionGroupItem(this, screenGroup, "screen_default", -1);
    1079 #ifdef Q_OS_WIN
     1107        #ifdef Q_OS_WIN
    10801108        DeviceList display_devices = DeviceInfo::displayDevices();
    10811109        if (!display_devices.isEmpty()) {
     
    10831111                        int id = display_devices[n].ID().toInt();
    10841112                        QString desc = display_devices[n].desc();
    1085                         MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toAscii().constData(), id);
     1113                        MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toLatin1().constData(), id);
    10861114                        screen_item->change( "&"+QString::number(n) + " - " + desc);
    10871115                }
    10881116        }
    10891117        else
    1090 #endif // Q_OS_WIN
     1118        #endif // Q_OS_WIN
    10911119        for (int n = 1; n <= 4; n++) {
    1092                 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toAscii().constData(), n);
     1120                MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toLatin1().constData(), n);
    10931121                screen_item->change( "&"+QString::number(n) );
    10941122        }
     
    14651493        openDVDAct->change( Images::icon("dvd"), tr("&DVD from drive") );
    14661494        openDVDFolderAct->change( Images::icon("dvd_hd"), tr("D&VD from folder...") );
     1495#ifdef BLURAY_SUPPORT
     1496        openBluRayAct->change( Images::icon("bluray"), tr("&Blu-ray from drive") );
     1497        openBluRayFolderAct->change( Images::icon("bluray_hd"), tr("Blu-&ray from folder...") );
     1498#endif
    14671499        openURLAct->change( Images::icon("url"), tr("&URL...") );
    14681500        exitAct->change( Images::icon("close"), tr("C&lose") );
     
    15131545        // Submenu speed
    15141546        normalSpeedAct->change( tr("&Normal speed") );
    1515         halveSpeedAct->change( tr("&Halve speed") );
     1547        halveSpeedAct->change( tr("&Half speed") );
    15161548        doubleSpeedAct->change( tr("&Double speed") );
    15171549        decSpeed10Act->change( tr("Speed &-10%") );
     
    15291561        screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") );
    15301562#ifdef VIDEOPREVIEW
    1531         videoPreviewAct->change( Images::icon("video_preview"), tr("Pre&view...") );
     1563        videoPreviewAct->change( Images::icon("video_preview"), tr("Thumb&nail Generator...") );
    15321564#endif
    15331565        flipAct->change( Images::icon("flip"), tr("Fli&p image") );
     
    15981630
    15991631#ifdef FIND_SUBTITLES
    1600         showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles on &OpenSubtitles.org...") );
     1632        showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles at &OpenSubtitles.org...") );
    16011633        openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") );
    16021634#endif
     
    16461678        donateAct->change( Images::icon("donate"), tr("&Donate") );
    16471679#endif
    1648         aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );
    16491680        aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") );
    16501681
     1682#ifdef SHARE_MENU
    16511683        facebookAct->change("&Facebook");
    16521684        twitterAct->change("&Twitter");
     
    16541686        hotmailAct->change("&Hotmail");
    16551687        yahooAct->change("&Yahoo!");
    1656 
     1688#endif
    16571689
    16581690        // Playlist
     
    17971829        aspect32Act->change( "&3:2" );
    17981830        aspect43Act->change( "&4:3" );
     1831        aspect118Act->change( "11:&8" );
    17991832        aspect54Act->change( "&5:4" );
    18001833        aspect149Act->change( "&14:9" );
     
    19021935        osd_menu->menuAction()->setIcon( Images::icon("osd") );
    19031936
     1937#ifdef SHARE_MENU
    19041938        share_menu->menuAction()->setText( tr("S&hare SMPlayer with your friends") );
    19051939        share_menu->menuAction()->setIcon( Images::icon("share") );
     1940#endif
    19061941
    19071942#if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
     
    19972032        connect( core, SIGNAL(mediaLoaded()),
    19982033             this, SLOT(enableActionsOnPlaying()) );
     2034
     2035        connect( core, SIGNAL(noFileToPlay()), this, SLOT(gotNoFileToPlay()) );
     2036
    19992037#if NOTIFY_AUDIO_CHANGES
    20002038        connect( core, SIGNAL(audioTracksChanged()),
     
    20552093            this, SLOT(YTNoSignature(const QString &)));
    20562094#endif
     2095        connect(core, SIGNAL(receivedForbidden()), this, SLOT(gotForbidden()));
    20572096}
    20582097
     
    20642103#endif
    20652104        mplayerwindow->allowVideoMovement( pref->allow_video_movement );
     2105        mplayerwindow->delayLeftClick(pref->delay_left_click);
    20662106
    20672107#if LOGO_ANIMATION
     
    20942134        connect( mplayerwindow, SIGNAL(xbutton2Clicked()),
    20952135             this, SLOT(xbutton2ClickFunction()) );
    2096         connect( mplayerwindow, SIGNAL(mouseMoved(QPoint)),
    2097              this, SLOT(checkMousePos(QPoint)) );
    2098 
    2099         if (pref->move_when_dragging) {
    2100                 connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)),
    2101                      this, SLOT(moveWindow(QPoint)));
    2102         }
     2136
     2137        connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)),
     2138             this, SLOT(moveWindowDiff(QPoint)), Qt::QueuedConnection );
     2139        mplayerwindow->activateMouseDragTracking(pref->move_when_dragging);
    21032140}
    21042141
    21052142void BaseGui::createVideoEqualizer() {
    21062143        // Equalizer
    2107         video_equalizer2 = new VideoEqualizer2(this);
    2108         connect( video_equalizer2, SIGNAL(contrastChanged(int)),
     2144        video_equalizer = new VideoEqualizer(this);
     2145        connect( video_equalizer, SIGNAL(contrastChanged(int)),
    21092146             core, SLOT(setContrast(int)) );
    2110         connect( video_equalizer2, SIGNAL(brightnessChanged(int)),
     2147        connect( video_equalizer, SIGNAL(brightnessChanged(int)),
    21112148             core, SLOT(setBrightness(int)) );
    2112         connect( video_equalizer2, SIGNAL(hueChanged(int)),
     2149        connect( video_equalizer, SIGNAL(hueChanged(int)),
    21132150             core, SLOT(setHue(int)) );
    2114         connect( video_equalizer2, SIGNAL(saturationChanged(int)),
     2151        connect( video_equalizer, SIGNAL(saturationChanged(int)),
    21152152             core, SLOT(setSaturation(int)) );
    2116         connect( video_equalizer2, SIGNAL(gammaChanged(int)),
     2153        connect( video_equalizer, SIGNAL(gammaChanged(int)),
    21172154             core, SLOT(setGamma(int)) );
    21182155
    2119         connect( video_equalizer2, SIGNAL(visibilityChanged()),
     2156        connect( video_equalizer, SIGNAL(visibilityChanged()),
    21202157             this, SLOT(updateWidgets()) );
    2121         connect( video_equalizer2, SIGNAL(requestToChangeDefaultValues()),
     2158        connect( video_equalizer, SIGNAL(requestToChangeDefaultValues()),
    21222159             this, SLOT(setDefaultValuesFromVideoEqualizer()) );
    2123         connect( video_equalizer2, SIGNAL(bySoftwareChanged(bool)),
     2160        connect( video_equalizer, SIGNAL(bySoftwareChanged(bool)),
    21242161             this, SLOT(changeVideoEqualizerBySoftware(bool)) );
    21252162}
     
    21892226
    21902227        // panel
    2191         panel->setAutoFillBackground(TRUE);
     2228        /*
     2229        panel->setAutoFillBackground(true);
    21922230        ColorUtils::setBackgroundColor( panel, QColor(0,0,0) );
     2231        */
    21932232}
    21942233
     
    22422281        disc_menu->addAction(openDVDAct);
    22432282        disc_menu->addAction(openDVDFolderAct);
     2283#ifdef BLURAY_SUPPORT
     2284        disc_menu->addAction(openBluRayAct);
     2285        disc_menu->addAction(openBluRayFolderAct);
     2286#endif
    22442287        disc_menu->addAction(openVCDAct);
    22452288        disc_menu->addAction(openAudioCDAct);
     
    26132656        // HELP MENU
    26142657        // Share submenu
     2658#ifdef SHARE_MENU
    26152659        share_menu = new QMenu(this);
    26162660        share_menu->addAction(facebookAct);
     
    26222666        helpMenu->addMenu(share_menu);
    26232667        helpMenu->addSeparator();
     2668#endif
     2669
    26242670        helpMenu->addAction(showFirstStepsAct);
    26252671        helpMenu->addAction(showFAQAct);
     
    26372683        helpMenu->addSeparator();
    26382684#endif
    2639         helpMenu->addAction(aboutQtAct);
    26402685        helpMenu->addAction(aboutThisAct);
    26412686
     
    27032748
    27042749void BaseGui::showVideoEqualizer() {
    2705         showVideoEqualizer( !video_equalizer2->isVisible() );
     2750        showVideoEqualizer( !video_equalizer->isVisible() );
    27062751}
    27072752
    27082753void BaseGui::showVideoEqualizer(bool b) {
    27092754        if (!b) {
    2710                 video_equalizer2->hide();
     2755                video_equalizer->hide();
    27112756        } else {
    27122757                // Exit fullscreen, otherwise dialog is not visible
    27132758                exitFullscreenIfNeeded();
    2714                 video_equalizer2->show();
     2759                video_equalizer->show();
    27152760        }
    27162761        updateWidgets();
     
    27672812        pref_dialog->getData(pref);
    27682813
     2814        // Change application font
    27692815        if (!pref->default_font.isEmpty()) {
    27702816                QFont f;
    27712817                f.fromString( pref->default_font );
    2772                 qApp->setFont(f);
     2818                if (QApplication::font() != f) {
     2819                        qDebug("BaseGui::applyNewPreferences: setting new font: %s", pref->default_font.toLatin1().constData());
     2820                        QApplication::setFont(f);
     2821                }
    27732822        }
    27742823
     
    27942843        }
    27952844
    2796         if (pref->move_when_dragging) {
    2797                 connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), this, SLOT(moveWindow(QPoint)));
    2798         } else {
    2799                 disconnect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), this, SLOT(moveWindow(QPoint)));
    2800         }
     2845        mplayerwindow->activateMouseDragTracking(pref->move_when_dragging);
     2846        mplayerwindow->delayLeftClick(pref->delay_left_click);
    28012847
    28022848#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
     
    28282874                mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() );
    28292875        }
     2876        if (advanced->lavfDemuxerChanged()) {
     2877                core->mset.forced_demuxer = pref->use_lavf_demuxer ? "lavf" : "";
     2878        }
    28302879
    28312880        // Update playlist preferences
     
    29342983#undef TEST_AND_SET
    29352984#define TEST_AND_SET( Pref, Dialog ) \
    2936         if ( Pref != Dialog ) { Pref = Dialog; need_restart = TRUE; }
     2985        if ( Pref != Dialog ) { Pref = Dialog; need_restart = true; }
    29372986
    29382987        QString prev_demuxer = core->mset.forced_demuxer;
     
    30303079        }*/
    30313080
    3032         if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist) && (pref->add_to_playlist_consecutive_files)) {
    3033                 // Look for consecutive files
    3034                 QStringList files_to_add = Helper::searchForConsecutiveFiles(core->mdat.filename);
     3081        // Automatically add files to playlist
     3082        if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist)) {
     3083                //qDebug("BaseGui::newMediaLoaded: playlist count: %d", playlist->count());
     3084                QStringList files_to_add;
     3085                if (playlist->count() == 1) {
     3086                        files_to_add = Helper::filesForPlaylist(core->mdat.filename, pref->media_to_add_to_playlist);
     3087                }
    30353088                if (!files_to_add.empty()) playlist->addFiles(files_to_add);
    30363089        }
     3090}
     3091
     3092void BaseGui::gotNoFileToPlay() {
     3093        //qDebug("BaseGui::gotNoFileToPlay");
     3094        playlist->resumePlay();
    30373095}
    30383096
     
    34223480
    34233481        // Video equalizer
    3424         videoEqualizerAct->setChecked( video_equalizer2->isVisible() );
    3425         video_equalizer2->setBySoftware( pref->use_soft_video_eq );
     3482        videoEqualizerAct->setChecked( video_equalizer->isVisible() );
     3483        video_equalizer->setBySoftware( pref->use_soft_video_eq );
    34263484
    34273485        // Audio equalizer
     
    34773535void BaseGui::updateVideoEqualizer() {
    34783536        // Equalizer
    3479         video_equalizer2->setContrast( core->mset.contrast );
    3480         video_equalizer2->setBrightness( core->mset.brightness );
    3481         video_equalizer2->setHue( core->mset.hue );
    3482         video_equalizer2->setSaturation( core->mset.saturation );
    3483         video_equalizer2->setGamma( core->mset.gamma );
     3537        video_equalizer->setContrast( core->mset.contrast );
     3538        video_equalizer->setBrightness( core->mset.brightness );
     3539        video_equalizer->setHue( core->mset.hue );
     3540        video_equalizer->setSaturation( core->mset.saturation );
     3541        video_equalizer->setGamma( core->mset.gamma );
    34843542}
    34853543
    34863544void BaseGui::updateAudioEqualizer() {
    34873545        // Audio Equalizer
    3488         for (int n = 0; n < 10; n++) {
    3489                 audio_equalizer->eq[n]->setValue( core->mset.audio_equalizer[n].toInt() );
    3490         }
     3546        AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : core->mset.audio_equalizer;
     3547        audio_equalizer->setEqualizer(l);
    34913548}
    34923549
     
    34943551        qDebug("BaseGui::setDefaultValuesFromVideoEqualizer");
    34953552
    3496         pref->initial_contrast = video_equalizer2->contrast();
    3497         pref->initial_brightness = video_equalizer2->brightness();
    3498         pref->initial_hue = video_equalizer2->hue();
    3499         pref->initial_saturation = video_equalizer2->saturation();
    3500         pref->initial_gamma = video_equalizer2->gamma();
     3553        pref->initial_contrast = video_equalizer->contrast();
     3554        pref->initial_brightness = video_equalizer->brightness();
     3555        pref->initial_hue = video_equalizer->hue();
     3556        pref->initial_saturation = video_equalizer->saturation();
     3557        pref->initial_gamma = video_equalizer->gamma();
    35013558
    35023559        QMessageBox::information(this, tr("Information"),
     
    35863643        qDebug("BaseGui::openFiles");
    35873644        if (files.empty()) return;
     3645
     3646        #ifdef Q_OS_WIN
     3647        files = Helper::resolveSymlinks(files); // Check for Windows shortcuts
     3648        #endif
    35883649
    35893650        if (files.count()==1) {
     
    38133874}
    38143875
     3876#ifdef BLURAY_SUPPORT
     3877/**
     3878 * Minimal BaseGui abstraction for calling openBluRay. It's called from
     3879 * OpenBluRayFromFolder()
     3880 */
     3881void BaseGui::openBluRayFromFolder(QString directory) {
     3882        pref->last_dvd_directory = directory;
     3883        core->openBluRay( DiscName::join(DiscName::BLURAY, 1, directory) );
     3884}
     3885
     3886/**
     3887 * Attempts to open a bluray from pref->bluray_device. If not set, calls configureDiscDevices.
     3888 * If successful, calls Core::OpenBluRay(QString)
     3889 */
     3890void BaseGui::openBluRay() {
     3891        qDebug("BaseGui::openBluRay");
     3892
     3893        if ( (pref->dvd_device.isEmpty()) ||
     3894         (pref->cdrom_device.isEmpty()) || pref->bluray_device.isEmpty())
     3895        {
     3896                configureDiscDevices();
     3897        } else {
     3898                core->openBluRay( DiscName::join(DiscName::BLURAY, 1, pref->bluray_device) );
     3899        }
     3900}
     3901
     3902void BaseGui::openBluRayFromFolder() {
     3903        qDebug("BaseGui::openBluRayFromFolder");
     3904
     3905        if (playlist->maybeSave()) {
     3906                QString dir = QFileDialog::getExistingDirectory(this, tr("Select the Blu-ray folder"),
     3907                          pref->last_dvd_directory, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
     3908                if (!dir.isEmpty()) {
     3909                        openBluRayFromFolder(dir);
     3910                }
     3911        }
     3912}
     3913#endif
     3914
    38153915void BaseGui::openDirectory() {
    38163916        qDebug("BaseGui::openDirectory");
     
    39114011#ifdef REMINDER_ACTIONS
    39124012void BaseGui::helpDonate() {
    3913         QMessageBox d(QMessageBox::NoIcon, tr("Donate"),
    3914                 tr("If you like SMPlayer and want to support its development, you can send a donation. Even the smallest one is highly appreciated."),
    3915                 QMessageBox::Ok | QMessageBox::Cancel, this);
    3916         d.setIconPixmap( Images::icon("logo", 64) );
    3917         d.button(QMessageBox::Ok)->setText(tr("Yes, I want to donate"));
    3918         d.setDefaultButton(QMessageBox::Ok);
    3919         if ( d.exec() == QMessageBox::Ok ) {
    3920                 QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=185512"));
    3921 
     4013        ShareDialog d(this);
     4014        d.showRemindCheck(false);
     4015        d.exec();
     4016        int action = d.actions();
     4017        qDebug("BaseGui::helpDonate: action: %d", action);
     4018
     4019        if (action > 0) {
    39224020                QSettings * set = Global::settings;
    39234021                set->beginGroup("reminder");
    3924                 set->setValue("action", 1);
     4022                set->setValue("action", action);
    39254023                set->endGroup();
    39264024        }
     
    39334031}
    39344032
    3935 void BaseGui::helpAboutQt() {
    3936         QMessageBox::aboutQt(this, tr("About Qt") );
    3937 }
    3938 
     4033#ifdef SHARE_MENU
    39394034void BaseGui::shareSMPlayer() {
    39404035        QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+");
     
    39684063        }
    39694064}
     4065#endif
    39704066
    39714067void BaseGui::showGotoDialog() {
     
    39824078void BaseGui::showAudioDelayDialog() {
    39834079        bool ok;
     4080        #if QT_VERSION >= 0x050000
     4081        int delay = QInputDialog::getInt(this, tr("SMPlayer - Audio delay"),
     4082                                     tr("Audio delay (in milliseconds):"), core->mset.audio_delay,
     4083                                     -3600000, 3600000, 1, &ok);
     4084        #else
    39844085        int delay = QInputDialog::getInteger(this, tr("SMPlayer - Audio delay"),
    39854086                                         tr("Audio delay (in milliseconds):"), core->mset.audio_delay,
    39864087                                         -3600000, 3600000, 1, &ok);
     4088        #endif
    39874089        if (ok) {
    39884090                core->setAudioDelay(delay);
     
    39924094void BaseGui::showSubDelayDialog() {
    39934095        bool ok;
     4096        #if QT_VERSION >= 0x050000
     4097        int delay = QInputDialog::getInt(this, tr("SMPlayer - Subtitle delay"),
     4098                                     tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay,
     4099                                     -3600000, 3600000, 1, &ok);
     4100        #else
    39944101        int delay = QInputDialog::getInteger(this, tr("SMPlayer - Subtitle delay"),
    39954102                                         tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay,
    39964103                                         -3600000, 3600000, 1, &ok);
     4104        #endif
    39974105        if (ok) {
    39984106                core->setSubDelay(delay);
     
    43264434        set->setValue("count", count);
    43274435        int action = set->value("action", 0).toInt();
     4436        bool dont_show = set->value("dont_show_anymore", false).toBool();
    43284437        set->endGroup();
     4438
     4439#if 1
     4440        if (dont_show) return;
    43294441
    43304442        if (action != 0) return;
    43314443        if ((count != 25) && (count != 45)) return;
    4332 
    4333         QMessageBox box(this);
    4334         box.setIcon(QMessageBox::Question);
    4335         box.setIconPixmap( Images::icon("donate_big") );
    4336         box.setWindowTitle(tr("Help SMPlayer"));
    4337         box.setText(
    4338                 tr("If you like SMPlayer and want to support its development, you can send a donation. Even the smallest one is highly appreciated.") + "<br>"+
    4339                 tr("Or you maybe you want to share SMPlayer with your friends in Facebook.") + "<br>" +
    4340                 tr("What would you like to do?") );
    4341         QPushButton * donate_button = box.addButton(tr("&Donate"), QMessageBox::ActionRole);
    4342         QPushButton * facebook_button = box.addButton(tr("&Share with my friends"), QMessageBox::ActionRole);
    4343         QPushButton * cancel_button = box.addButton(QMessageBox::Cancel);
    4344 
    4345         box.exec();
    4346         if (box.clickedButton() == donate_button) {
    4347                 QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=185512"));
    4348                 action = 1;
    4349         }
    4350         else
    4351         if (box.clickedButton() == facebook_button) {
    4352                 QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+");
    4353                 QString url = "http://smplayer.sourceforge.net";
    4354                 QDesktopServices::openUrl(QUrl("http://www.facebook.com/sharer.php?u=" + url + "&t=" + text));
    4355                 action = 2;
    4356         }
    4357         else
    4358         if (box.clickedButton() == cancel_button) {
     4444#endif
     4445
     4446        ShareDialog d(this);
     4447        //d.showRemindCheck(false);
     4448        d.exec();
     4449        action = d.actions();
     4450        qDebug("BaseGui::checkReminder: action: %d", action);
     4451
     4452        if (!d.isRemindChecked()) {
     4453                set->beginGroup("reminder");
     4454                set->setValue("dont_show_anymore", true);
     4455                set->endGroup();
    43594456        }
    43604457
     
    43644461                set->endGroup();
    43654462        }
     4463
     4464        //qDebug() << "size:" << d.size();
    43664465}
    43674466#endif
     
    43724471
    43734472        QString t = title;
    4374         t.replace(" - YouTube", "");
     4473
     4474        QString info_text;
     4475        if (title.isEmpty()) {
     4476                info_text = tr("Unfortunately due to changes in the Youtube page, this video can't be played.");
     4477        } else {
     4478                t.replace(" - YouTube", "");
     4479                info_text = tr("Unfortunately due to changes in the Youtube page, the video '%1' can't be played.").arg(t);
     4480        }
    43754481
    43764482        #ifdef YT_USE_SCRIPT
    43774483        int ret = QMessageBox::question(this, tr("Problems with Youtube"),
    4378                                 tr("Unfortunately due to changes in the Youtube page, the video '%1' can't be played.").arg(t) + "<br><br>" +
     4484                                info_text + "<br><br>" +
    43794485                                tr("Do you want to update the Youtube code? This may fix the problem."),
    43804486                                QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
     
    43844490        #else
    43854491        QMessageBox::warning(this, tr("Problems with Youtube"),
    4386                 tr("Unfortunately due to changes in the Youtube page, the video '%1' can't be played.").arg(t) + "<br><br>" +
     4492                info_text + "<br><br>" +
    43874493                tr("Maybe updating SMPlayer could fix the problem."));
    43884494        #endif
     
    43934499        static CodeDownloader * downloader = 0;
    43944500        if (!downloader) downloader = new CodeDownloader(this);
    4395         downloader->saveAs(Paths::configPath() + "/ytcode.script");
     4501        downloader->saveAs(Paths::configPath() + "/yt.js");
    43964502        downloader->show();
    4397         downloader->download(QUrl("http://updates.smplayer.info/ytcode.script"));
     4503        downloader->download(QUrl("http://updates.smplayer.info/yt.js"));
    43984504}
    43994505#endif // YT_USE_SCRIPT
    44004506#endif //YOUTUBE_SUPPORT
     4507
     4508void BaseGui::gotForbidden() {
     4509        qDebug("BaseGui::gotForbidden");
     4510        static bool busy = false;
     4511
     4512        if (busy) return;
     4513
     4514        busy = true;
     4515#ifdef YOUTUBE_SUPPORT
     4516        if (core->mdat.filename.contains("youtube.com")) {
     4517                YTNoSignature("");
     4518        } else
     4519#endif
     4520        {
     4521                QMessageBox::warning(this, tr("Error detected"),
     4522                        tr("Unfortunately this video can't be played.") +"<br>"+
     4523                        tr("The server returned '%1'").arg("403: Forbidden"));
     4524        }
     4525        busy = false;
     4526}
    44014527
    44024528void BaseGui::dragEnterEvent( QDragEnterEvent *e ) {
     
    44384564        qDebug( "BaseGui::dropEvent: count: %d", files.count());
    44394565        if (files.count() > 0) {
     4566                #ifdef Q_OS_WIN
     4567                files = Helper::resolveSymlinks(files); // Check for Windows shortcuts
     4568                #endif
     4569
    44404570                if (files.count() == 1) {
    44414571                        QFileInfo fi( files[0] );
     
    45144644*/
    45154645
     4646/*
    45164647void BaseGui::wheelEvent( QWheelEvent * e ) {
    45174648        qDebug("BaseGui::wheelEvent: delta: %d", e->delta());
     
    45274658        }
    45284659}
    4529 
     4660*/
    45304661
    45314662// Called when a video has started to play
     
    45354666        if (arg_start_in_fullscreen != 0) {
    45364667                if ( (arg_start_in_fullscreen == 1) || (pref->start_in_fullscreen) ) {
    4537                         if (!pref->fullscreen) toggleFullscreen(TRUE);
     4668                        if (!pref->fullscreen) toggleFullscreen(true);
    45384669                }
    45394670        }
     
    45434674void BaseGui::exitFullscreenOnStop() {
    45444675    if (pref->fullscreen) {
    4545                 toggleFullscreen(FALSE);
     4676                toggleFullscreen(false);
    45464677        }
    45474678}
     
    48254956        /*
    48264957        if (pref->fullscreen) {
    4827                 toggleFullscreen(FALSE);
     4958                toggleFullscreen(false);
    48284959        }
    48294960        */
    4830 }
    4831 
    4832 void BaseGui::checkMousePos(QPoint p) {
    4833         //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
    4834 
    4835         bool compact = (pref->floating_display_in_compact_mode && pref->compact_mode);
    4836 
    4837         if (!pref->fullscreen && !compact) return;
    4838 
    4839         #define MARGIN 70
    4840 
    4841         int margin = MARGIN + pref->floating_control_margin;
    4842 
    4843         if (p.y() > mplayerwindow->height() - margin) {
    4844                 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
    4845                 if (!near_bottom) {
    4846                         emit cursorNearBottom(p);
    4847                         near_bottom = true;
    4848                 }
    4849         } else {
    4850                 if (near_bottom) {
    4851                         emit cursorFarEdges();
    4852                         near_bottom = false;
    4853                 }
    4854         }
    4855 
    4856         if (p.y() < margin) {
    4857                 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());
    4858                 if (!near_top) {
    4859                         emit cursorNearTop(p);
    4860                         near_top = true;
    4861                 }
    4862         } else {
    4863                 if (near_top) {
    4864                         emit cursorFarEdges();
    4865                         near_top = false;
    4866                 }
    4867         }
    48684961}
    48694962
     
    49265019}
    49275020
    4928 void BaseGui::moveWindow(QPoint diff) {
     5021void BaseGui::moveWindowDiff(QPoint diff) {
    49295022        if (pref->fullscreen || isMaximized()) {
    49305023                return;
    49315024        }
     5025
     5026#if QT_VERSION >= 0x050000
     5027        // Move the window with some delay.
     5028        // Seems to work better with Qt 5
     5029
     5030        static QPoint d;
     5031        static int count = 0;
     5032
     5033        d += diff;
     5034        count++;
     5035
     5036        if (count > 3) {
     5037                //qDebug() << "BaseGui::moveWindowDiff:" << d;
     5038                QPoint new_pos = pos() + d;
     5039                if (new_pos.y() < 0) new_pos.setY(0);
     5040                if (new_pos.x() < 0) new_pos.setX(0);
     5041                //qDebug() << "BaseGui::moveWindowDiff: new_pos:" << new_pos;
     5042                move(new_pos);
     5043                count = 0;
     5044                d = QPoint(0,0);
     5045        }
     5046#else
     5047        //qDebug() << "BaseGui::moveWindowDiff:" << diff;
    49325048        move(pos() + diff);
     5049#endif
    49335050}
    49345051
     
    50365153
    50375154void BaseGui::openUploadSubtitlesPage() {       
    5038         //QDesktopServices::openUrl( QUrl("http://ds6.ovh.org/hashsubtitles/upload.php") );
    5039         //QDesktopServices::openUrl( QUrl("http://www.opensubtitles.com/upload") );
    5040         QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/uploadjava") );
     5155        QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/upload") );
    50415156}
    50425157#endif
     
    51025217
    51035218#ifdef Q_OS_WIN
     5219#ifdef AVOID_SCREENSAVER
    51045220/* Disable screensaver by event */
    51055221bool BaseGui::winEvent ( MSG * m, long * result ) {
     
    51315247}
    51325248#endif
     5249#endif
    51335250
    51345251#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
Note: See TracChangeset for help on using the changeset viewer.