Ignore:
Timestamp:
May 3, 2016, 2:14:41 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update vendor to version 16.4

File:
1 edited

Legend:

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

    r168 r175  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    4040#include <QClipboard>
    4141#include <QMimeData>
     42#include <QDesktopWidget>
    4243
    4344#include <cmath>
     
    6869#include "errordialog.h"
    6970#include "timedialog.h"
     71#include "stereo3ddialog.h"
     72
     73#ifdef BOOKMARKS
     74#include "inputbookmark.h"
     75#include "bookmarkdialog.h"
     76#endif
     77
    7078#include "clhelp.h"
    7179#include "mplayerversion.h"
     
    98106
    99107#include "constants.h"
     108#include "links.h"
     109
     110#ifdef MPRIS2
     111#include "mpris2/mpris2.h"
     112#endif
    100113
    101114#include "extensions.h"
     
    107120#endif
    108121
     122#ifdef UPDATE_CHECKER
    109123#include "updatechecker.h"
    110 
    111 #ifdef YT_USE_SCRIPT
    112 #include "codedownloader.h"
    113 #endif
    114 
    115 #ifdef REMINDER_ACTIONS
     124#endif
     125
     126#ifdef YOUTUBE_SUPPORT
     127  #ifdef YT_USE_YTSIG
     128  #include "codedownloader.h"
     129  #endif
     130#endif
     131
     132#ifdef SHARE_ACTIONS
    116133#include "sharedialog.h"
     134#endif
     135
     136#ifdef SHARE_WIDGET
     137#include "sharewidget.h"
    117138#endif
    118139
     
    126147BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
    127148        : QMainWindow( parent, flags )
     149#if QT_VERSION >= 0x050000
     150        , was_minimized(false)
     151#endif
     152#ifdef UPDATE_CHECKER
     153        , update_checker(0)
     154#endif
     155#ifdef MG_DELAYED_SEEK
     156        , delayed_seek_timer(0)
     157        , delayed_seek_value(0)
     158#endif
    128159{
    129160#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     
    174205             core, SLOT(wheelDown()) );
    175206
    176         // Set style before changing color of widgets:
    177         // Set style
    178207#if STYLE_SWITCHING
    179         qDebug( "Style name: '%s'", qApp->style()->objectName().toUtf8().data() );
    180         qDebug( "Style class name: '%s'", qApp->style()->metaObject()->className() );
    181 
     208        qApp->setStyleSheet("");
    182209        default_style = qApp->style()->objectName();
    183         if (!pref->style.isEmpty()) {
    184                 qApp->setStyle( pref->style );
    185         }
     210        #ifdef Q_OS_LINUX
     211        // Some controls aren't displayed correctly with the adwaita style
     212        // so try to prevent to use it as the default style
     213        if (default_style.toLower() == "adwaita") default_style = "gtk+";
     214        #endif
     215        qDebug() << "BaseGui::BaseGui: default_style:" << default_style;
     216        //qDebug() << "BaseGui::BaseGui: qApp->style:" << qApp->style();
    186217#endif
    187218
     
    216247        panel->setFocus();
    217248
     249        setupNetworkProxy();
    218250        initializeGui();
    219251
    220252#ifdef UPDATE_CHECKER
    221253        update_checker = new UpdateChecker(this, &pref->update_checker_data);
    222         connect(update_checker, SIGNAL(newVersionFound(QString)),
    223             this, SLOT(reportNewVersionAvailable(QString)));
    224254#endif
    225255
     
    228258#endif
    229259
    230 #ifdef REMINDER_ACTIONS
     260#if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET)
    231261        QTimer::singleShot(1000, this, SLOT(checkReminder()));
     262#endif
     263
     264#ifdef MPRIS2
     265        if (pref->use_mpris2) new Mpris2(this, this);
    232266#endif
    233267}
     
    236270        if (pref->compact_mode) toggleCompactMode(true);
    237271        changeStayOnTop(pref->stay_on_top);
    238 
    239 #if ALLOW_CHANGE_STYLESHEET
    240         changeStyleSheet(pref->iconset);
    241 #endif
    242272
    243273        updateRecents();
     
    250280        // Single instance
    251281        /* Deleted */
     282}
     283
     284void BaseGui::setupNetworkProxy() {
     285        qDebug("BaseGui::setupNetworkProxy");
     286
     287        QNetworkProxy proxy;
     288
     289        if ( (pref->use_proxy) && (!pref->proxy_host.isEmpty()) ) {
     290                proxy.setType((QNetworkProxy::ProxyType) pref->proxy_type);
     291                proxy.setHostName(pref->proxy_host);
     292                proxy.setPort(pref->proxy_port);
     293                if ( (!pref->proxy_username.isEmpty()) && (!pref->proxy_password.isEmpty()) ) {
     294                        proxy.setUser(pref->proxy_username);
     295                        proxy.setPassword(pref->proxy_password);
     296                }
     297                qDebug("BaseGui::setupNetworkProxy: using proxy: host: %s, port: %d, type: %d",
     298               pref->proxy_host.toUtf8().constData(), pref->proxy_port, pref->proxy_type);
     299        } else {
     300                // No proxy
     301                proxy.setType(QNetworkProxy::NoProxy);
     302                qDebug("BaseGui::setupNetworkProxy: no proxy");
     303        }
     304
     305        QNetworkProxy::setApplicationProxy(proxy);
    252306}
    253307
     
    278332                        /* if (core->state() == Core::Stopped) { emit openFileRequested(); } */
    279333                        playlist->addFiles(file_list);
     334                }
     335                else
     336                if (command == "media_title") {
     337                        QStringList list = arg.split(" <<sep>> ");
     338                        core->addForcedTitle(list[0], list[1]);
    280339                }
    281340                else
     
    453512             core, SLOT(frameStep()) );
    454513
     514        frameBackStepAct = new MyAction( Qt::Key_Comma, this, "frame_back_step" );
     515        connect( frameBackStepAct, SIGNAL(triggered()),
     516             core, SLOT(frameBackStep()) );
     517
    455518        rewind1Act = new MyAction( Qt::Key_Left, this, "rewind1" );
    456519        rewind1Act->addShortcut(QKeySequence("Shift+Ctrl+B")); // MCE remote key
     
    565628             core, SLOT(screenshots()) );
    566629
     630#ifdef CAPTURE_STREAM
     631        capturingAct = new MyAction( /*Qt::Key_C,*/ this, "capture_stream");
     632        connect( capturingAct, SIGNAL(triggered()),
     633             core, SLOT(switchCapturing()) );
     634#endif
     635
    567636#ifdef VIDEOPREVIEW
    568637        videoPreviewAct = new MyAction( this, "video_preview" );
     
    581650             core, SLOT(toggleMirror(bool)) );
    582651
     652        stereo3dAct = new MyAction( this, "stereo_3d_filter" );
     653        connect( stereo3dAct, SIGNAL(triggered()),
     654             this, SLOT(showStereo3dDialog()) );
    583655
    584656        // Submenu filter
     
    684756             core, SLOT(toggleExtrastereo(bool)) );
    685757
     758#ifdef MPLAYER_SUPPORT
    686759        karaokeAct = new MyAction( this, "karaoke_filter" );
    687760        karaokeAct->setCheckable( true );
    688761        connect( karaokeAct, SIGNAL(toggled(bool)),
    689762             core, SLOT(toggleKaraoke(bool)) );
     763#endif
    690764
    691765        volnormAct = new MyAction( this, "volnorm_filter" );
     
    730804        connect( incSubScaleAct, SIGNAL(triggered()),
    731805             core, SLOT(incSubScale()) );
    732    
     806
    733807        decSubStepAct = new MyAction( Qt::Key_G, this, "dec_sub_step" );
    734808        connect( decSubStepAct, SIGNAL(triggered()),
     
    739813             core, SLOT(incSubStep()) );
    740814
    741         useAssAct = new MyAction(this, "use_ass_lib");
    742         useAssAct->setCheckable(true);
    743         connect( useAssAct, SIGNAL(toggled(bool)), core, SLOT(changeUseAss(bool)) );
     815#ifdef MPV_SUPPORT
     816        seekNextSubAct = new MyAction(Qt::CTRL | Qt::Key_Right, this, "seek_next_sub");
     817        connect(seekNextSubAct, SIGNAL(triggered()),
     818            core, SLOT(seekToNextSub()));
     819
     820        seekPrevSubAct = new MyAction(Qt::CTRL | Qt::Key_Left, this, "seek_prev_sub");
     821        connect(seekPrevSubAct, SIGNAL(triggered()),
     822            core, SLOT(seekToPrevSub()));
     823#endif
     824
     825        useCustomSubStyleAct = new MyAction(this, "use_custom_sub_style");
     826        useCustomSubStyleAct->setCheckable(true);
     827        connect( useCustomSubStyleAct, SIGNAL(toggled(bool)), core, SLOT(changeUseCustomSubStyle(bool)) );
    744828
    745829        useForcedSubsOnlyAct = new MyAction(this, "use_forced_subs_only");
     
    811895             this, SLOT(helpCheckUpdates()) );
    812896
    813 #if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT)
     897#if defined(YOUTUBE_SUPPORT) && defined(YT_USE_YTSIG)
    814898        updateYTAct = new MyAction( this, "update_youtube" );
    815899        connect( updateYTAct, SIGNAL(triggered()),
     
    821905             this, SLOT(helpShowConfig()) );
    822906
    823 #ifdef REMINDER_ACTIONS
     907#ifdef SHARE_ACTIONS
    824908        donateAct = new MyAction( this, "donate" );
    825909        connect( donateAct, SIGNAL(triggered()),
     
    850934#endif
    851935
     936        // OSD
     937        incOSDScaleAct = new MyAction(Qt::SHIFT | Qt::Key_U, this, "inc_osd_scale");
     938        connect(incOSDScaleAct, SIGNAL(triggered()), core, SLOT(incOSDScale()));
     939
     940        decOSDScaleAct = new MyAction(Qt::SHIFT | Qt::Key_Y, this, "dec_osd_scale");
     941        connect(decOSDScaleAct, SIGNAL(triggered()), core, SLOT(decOSDScale()));
     942
     943
    852944        // Playlist
    853945        playNextAct = new MyAction(Qt::Key_Greater, this, "play_next");
     
    890982        autoZoom235Act = new MyAction(Qt::SHIFT | Qt::Key_S, this, "zoom_235");
    891983        connect( autoZoom235Act, SIGNAL(triggered()), core, SLOT(autoZoomFor235()) );
    892 
    893 #if USE_MPLAYER_PANSCAN
    894         incPanscanAct = new MyAction(Qt::SHIFT | Qt::Key_M, this, "inc_panscan");
    895         connect( incPanscanAct, SIGNAL(triggered()), core, SLOT(incPanscan()) );
    896 
    897         decPanscanAct = new MyAction(Qt::SHIFT | Qt::Key_N, this, "dec_panscan");
    898         connect( decPanscanAct, SIGNAL(triggered()), core, SLOT(decPanscan()) );
    899 #endif
    900984
    901985
     
    9841068        showFilenameAct = new MyAction(Qt::SHIFT | Qt::Key_I, this, "show_filename");
    9851069        connect( showFilenameAct, SIGNAL(triggered()), core, SLOT(showFilenameOnOSD()) );
     1070
     1071        showTimeAct = new MyAction(Qt::Key_I, this, "show_time");
     1072        connect( showTimeAct, SIGNAL(triggered()), core, SLOT(showTimeOnOSD()) );
    9861073
    9871074        toggleDeinterlaceAct = new MyAction(Qt::Key_D, this, "toggle_deinterlacing");
     
    11521239        // Subtitle track
    11531240        subtitleTrackGroup = new MyActionGroup(this);
    1154     connect( subtitleTrackGroup, SIGNAL(activated(int)),
     1241        connect( subtitleTrackGroup, SIGNAL(activated(int)),
    11551242                 core, SLOT(changeSubtitle(int)) );
     1243
     1244#ifdef MPV_SUPPORT
     1245        // Secondary subtitle track
     1246        secondarySubtitleTrackGroup = new MyActionGroup(this);
     1247        connect( secondarySubtitleTrackGroup, SIGNAL(activated(int)),
     1248                 core, SLOT(changeSecondarySubtitle(int)) );
     1249#endif
    11561250
    11571251        ccGroup = new MyActionGroup(this);
     
    11901284                         core, SLOT(changeChapter(int)) );
    11911285
     1286#ifdef BOOKMARKS
     1287        // Bookmarks
     1288        bookmarkGroup = new MyActionGroup(this);
     1289        connect( bookmarkGroup, SIGNAL(activated(int)),
     1290                         core, SLOT(goToSec(int)) );
     1291
     1292        addBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_A, this, "add_bookmark");
     1293        connect(addBookmarkAct, SIGNAL(triggered()), this, SLOT(showAddBookmarkDialog()));
     1294
     1295        editBookmarksAct = new MyAction(this, "edit_bookmarks");
     1296        connect(editBookmarksAct, SIGNAL(triggered()), this, SLOT(showBookmarkDialog()));
     1297
     1298        prevBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_B, this, "prev_bookmark");
     1299        connect(prevBookmarkAct, SIGNAL(triggered()), core, SLOT(prevBookmark()));
     1300
     1301        nextBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_N, this, "next_bookmark");
     1302        connect(nextBookmarkAct, SIGNAL(triggered()), core, SLOT(nextBookmark()));
     1303#endif
     1304
    11921305#if DVDNAV_SUPPORT
    11931306        dvdnavUpAct = new MyAction(Qt::SHIFT | Qt::Key_Up, this, "dvdnav_up");
     
    12271340        stopAct->setEnabled(b);
    12281341        frameStepAct->setEnabled(b);
     1342        frameBackStepAct->setEnabled(b);
    12291343        rewind1Act->setEnabled(b);
    12301344        rewind2Act->setEnabled(b);
     
    12511365        screenshotAct->setEnabled(b);
    12521366        screenshotsAct->setEnabled(b);
     1367#ifdef CAPTURE_STREAM
     1368        capturingAct->setEnabled(b);
     1369#endif
    12531370        flipAct->setEnabled(b);
    12541371        mirrorAct->setEnabled(b);
     1372        stereo3dAct->setEnabled(b);
    12551373        postProcessingAct->setEnabled(b);
    12561374        phaseAct->setEnabled(b);
     
    12711389        audioDelayAct->setEnabled(b);
    12721390        extrastereoAct->setEnabled(b);
     1391#ifdef MPLAYER_SUPPORT
    12731392        karaokeAct->setEnabled(b);
     1393#endif
    12741394        volnormAct->setEnabled(b);
    12751395        loadAudioAct->setEnabled(b);
     
    12881408        incSubScaleAct->setEnabled(b);
    12891409        decSubScaleAct->setEnabled(b);
     1410#ifdef MPV_SUPPORT
     1411        seekNextSubAct->setEnabled(b);
     1412        seekPrevSubAct->setEnabled(b);
     1413#endif
    12901414
    12911415        // Actions not in menus
     
    13631487        screenshotsAct->setEnabled( screenshots_enabled );
    13641488
     1489#ifdef CAPTURE_STREAM
     1490        capturingAct->setEnabled(!pref->capture_directory.isEmpty() && QFileInfo(pref->capture_directory).isDir());
     1491#endif
     1492
    13651493        // Disable the compact action if not using video window
    13661494        compactAct->setEnabled( panel->isVisible() );
     
    13791507                audioDelayAct->setEnabled(false);
    13801508                extrastereoAct->setEnabled(false);
     1509#ifdef MPLAYER_SUPPORT
    13811510                karaokeAct->setEnabled(false);
     1511#endif
    13821512                volnormAct->setEnabled(false);
    13831513                channelsGroup->setActionsEnabled(false);
     
    13901520                screenshotAct->setEnabled(false);
    13911521                screenshotsAct->setEnabled(false);
     1522#ifdef CAPTURE_STREAM
     1523                capturingAct->setEnabled(false);
     1524#endif
    13921525                flipAct->setEnabled(false);
    13931526                mirrorAct->setEnabled(false);
     1527                stereo3dAct->setEnabled(false);
    13941528                postProcessingAct->setEnabled(false);
    13951529                phaseAct->setEnabled(false);
     
    14361570                flipAct->setEnabled(false);
    14371571                mirrorAct->setEnabled(false);
     1572                stereo3dAct->setEnabled(false);
    14381573                postProcessingAct->setEnabled(false);
    14391574                phaseAct->setEnabled(false);
     
    14661601        }
    14671602#endif
     1603
     1604
     1605#ifdef BOOKMARKS
     1606        if (pref->dont_remember_media_settings || core->mdat.type != TYPE_FILE) {
     1607                addBookmarkAct->setEnabled(false);
     1608                editBookmarksAct->setEnabled(false);
     1609        } else {
     1610                addBookmarkAct->setEnabled(true);
     1611                editBookmarksAct->setEnabled(true);
     1612        }
     1613#endif
    14681614}
    14691615
     
    14771623        stopAct->setEnabled(true);
    14781624}
     1625#endif // AUTODISABLE_ACTIONS
    14791626
    14801627void BaseGui::togglePlayAction(Core::State state) {
    14811628        qDebug("BaseGui::togglePlayAction");
     1629
     1630#if AUTODISABLE_ACTIONS
    14821631        if (state == Core::Playing)
    14831632                playAct->setEnabled(false);
    14841633        else
    14851634                playAct->setEnabled(true);
    1486 }
    1487 #endif // AUTODISABLE_ACTIONS
     1635#endif
     1636}
    14881637
    14891638void BaseGui::retranslateStrings() {
     
    15341683        stopAct->change( Images::icon("stop"), tr("&Stop") );
    15351684        frameStepAct->change( Images::icon("frame_step"), tr("&Frame step") );
     1685        frameBackStepAct->change( Images::icon("frame_back_step"), tr("Fra&me back step") );
    15361686
    15371687        playOrPauseAct->change( tr("Play / Pause") );
     
    15671717        screenshotAct->change( Images::icon("screenshot"), tr("&Screenshot") );
    15681718        screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") );
     1719#ifdef CAPTURE_STREAM
     1720        capturingAct->change(Images::icon("record"), tr("Start/stop capturing stream"));
     1721#endif
    15691722#ifdef VIDEOPREVIEW
    15701723        videoPreviewAct->change( Images::icon("video_preview"), tr("Thumb&nail Generator...") );
     
    15721725        flipAct->change( Images::icon("flip"), tr("Fli&p image") );
    15731726        mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") );
     1727        stereo3dAct->change( Images::icon("stereo3d"), tr("Stereo &3D filter") );
    15741728
    15751729        decZoomAct->change( tr("Zoom &-") );
     
    15831737        moveUpAct->change( tr("Move &up") );
    15841738        moveDownAct->change( tr("Move &down") );
    1585 
    1586 #if USE_MPLAYER_PANSCAN
    1587         decPanscanAct->change( "Panscan -" );
    1588         incPanscanAct->change( "Panscan +" );
    1589 #endif
    15901739
    15911740        // Submenu Filters
     
    16141763        // Submenu Filters
    16151764        extrastereoAct->change( tr("&Extrastereo") );
     1765#ifdef MPLAYER_SUPPORT
    16161766        karaokeAct->change( tr("&Karaoke") );
     1767#endif
    16171768        volnormAct->change( tr("Volume &normalization") );
    16181769
     
    16311782        incSubStepAct->change( Images::icon("inc_sub_step"),
    16321783                           tr("N&ext line in subtitles") );
    1633         useAssAct->change( Images::icon("use_ass_lib"), tr("Use SSA/&ASS library") );
     1784#ifdef MPV_SUPPORT
     1785        seekNextSubAct->change(Images::icon("seek_next_sub"), tr("Seek to next subtitle"));
     1786        seekPrevSubAct->change(Images::icon("seek_prev_sub"), tr("Seek to previous subtitle"));
     1787#endif
     1788        useCustomSubStyleAct->change( Images::icon("use_custom_sub_style"), tr("Use custo&m style") );
    16341789        useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") );
    16351790
     
    16651820        // Submenu Logs
    16661821#ifdef LOG_MPLAYER
    1667         showLogMplayerAct->change( "MPlayer" );
     1822        showLogMplayerAct->change(PLAYER_NAME);
    16681823#endif
    16691824#ifdef LOG_SMPLAYER
     
    16771832        showCheckUpdatesAct->change( Images::icon("check_updates"), tr("Check for &updates") );
    16781833
    1679 #if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT)
     1834#if defined(YOUTUBE_SUPPORT) && defined(YT_USE_YTSIG)
    16801835        updateYTAct->change( Images::icon("update_youtube"), tr("Update &Youtube code") );
    16811836#endif
    16821837
    16831838        showConfigAct->change( Images::icon("show_config"), tr("&Open configuration folder") );
    1684 #ifdef REMINDER_ACTIONS
     1839#ifdef SHARE_ACTIONS
    16851840        donateAct->change( Images::icon("donate"), tr("&Donate / Share with your friends") );
    16861841#endif
     
    16941849        yahooAct->change("&Yahoo!");
    16951850#endif
     1851
     1852        // OSD
     1853        incOSDScaleAct->change(tr("Size &+"));
     1854        decOSDScaleAct->change(tr("Size &-"));
    16961855
    16971856        // Playlist
     
    17361895
    17371896        showFilenameAct->change( tr("Show filename on OSD") );
     1897        showTimeAct->change( tr("Show playback time on OSD") );
    17381898        toggleDeinterlaceAct->change( tr("Toggle deinterlacing") );
    17391899
     
    19022062
    19032063        // Menu Subtitle
    1904         subtitlestrack_menu->menuAction()->setText( tr("&Select") );
    1905         subtitlestrack_menu->menuAction()->setIcon( Images::icon("sub") );
     2064#ifdef MPV_SUPPORT
     2065        subtitles_track_menu->menuAction()->setText( tr("Prim&ary track") );
     2066#else
     2067        subtitles_track_menu->menuAction()->setText( tr("&Select") );
     2068#endif
     2069        subtitles_track_menu->menuAction()->setIcon( Images::icon("sub") );
     2070
     2071#ifdef MPV_SUPPORT
     2072        secondary_subtitles_track_menu->menuAction()->setText( tr("Secondary trac&k") );
     2073        secondary_subtitles_track_menu->menuAction()->setIcon( Images::icon("secondary_sub") );
     2074#endif
    19062075
    19072076        closed_captions_menu->menuAction()->setText( tr("&Closed captions") );
     
    19212090        angles_menu->menuAction()->setIcon( Images::icon("angle") );
    19222091
     2092#ifdef BOOKMARKS
     2093        bookmark_menu->menuAction()->setText( tr("&Bookmarks") );
     2094        bookmark_menu->menuAction()->setIcon( Images::icon("bookmarks") );
     2095#endif
     2096
    19232097#if PROGRAM_SWITCH
    19242098        programtrack_menu->menuAction()->setText( tr("P&rogram", "program") );
     
    19262100#endif
    19272101
     2102#ifdef BOOKMARKS
     2103        addBookmarkAct->change(Images::icon("add_bookmark"), tr("&Add new bookmark"));
     2104        editBookmarksAct->change(Images::icon("edit_bookmarks"), tr("&Edit bookmarks"));
     2105        prevBookmarkAct->change(Images::icon("prev_bookmark"), tr("Previous bookmark"));
     2106        nextBookmarkAct->change(Images::icon("next_bookmark"), tr("Next bookmark"));
     2107#endif
    19282108
    19292109#if DVDNAV_SUPPORT
     
    19572137        // Other things
    19582138#ifdef LOG_MPLAYER
    1959         mplayer_log_window->setWindowTitle( tr("SMPlayer - MPlayer log") );
     2139        mplayer_log_window->setWindowTitle( tr("%1 log").arg(PLAYER_NAME) );
    19602140#endif
    19612141#ifdef LOG_SMPLAYER
    1962         smplayer_log_window->setWindowTitle( tr("SMPlayer - SMPlayer log") );
     2142        smplayer_log_window->setWindowTitle( tr("SMPlayer log") );
    19632143#endif
    19642144
     
    20192199             this, SLOT(resizeWindow(int,int)) );
    20202200
     2201        connect( core, SIGNAL(needResize(int, int)),
     2202             this, SLOT(centerWindow()) );
     2203
    20212204        connect( core, SIGNAL(showMessage(QString,int)),
    20222205             this, SLOT(displayMessage(QString,int)) );
     
    20992282        connect(core, SIGNAL(signatureNotFound(const QString &)),
    21002283            this, SLOT(YTNoSignature(const QString &)));
     2284        connect(core, SIGNAL(noSslSupport()),
     2285            this, SLOT(YTNoSslSupport()));
    21012286#endif
    21022287        connect(core, SIGNAL(receivedForbidden()), this, SLOT(gotForbidden()));
     
    21142299#if LOGO_ANIMATION
    21152300        mplayerwindow->setAnimatedLogo( pref->animated_logo);
     2301#endif
     2302
     2303#ifdef SHARE_WIDGET
     2304        sharewidget = new ShareWidget(Global::settings, mplayerwindow);
     2305        mplayerwindow->setCornerWidget(sharewidget);
     2306        #ifdef SHARE_ACTIONS
     2307        connect(sharewidget, SIGNAL(supportClicked()), this, SLOT(helpDonate()));
     2308        #endif
    21162309#endif
    21172310
     
    21432336
    21442337        connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)),
    2145              this, SLOT(moveWindowDiff(QPoint)), Qt::QueuedConnection );
    2146         mplayerwindow->activateMouseDragTracking(pref->move_when_dragging);
     2338             this, SLOT(processMouseMovedDiff(QPoint)), Qt::QueuedConnection );
     2339#ifdef MOUSE_GESTURES
     2340        mplayerwindow->activateMouseDragTracking(true);
     2341#else
     2342        mplayerwindow->activateMouseDragTracking(pref->drag_function == Preferences::MoveWindow);
     2343#endif
    21472344}
    21482345
     
    21972394             core, SLOT(setAudioAudioEqualizerRestart(AudioEqualizerList)) );
    21982395
     2396        connect( audio_equalizer, SIGNAL(valuesChanged(AudioEqualizerList)),
     2397             core, SLOT(setAudioEqualizer(AudioEqualizerList)) );
     2398
    21992399        connect( audio_equalizer, SIGNAL(visibilityChanged()),
    22002400             this, SLOT(updateWidgets()) );
     
    22502450
    22512451void BaseGui::createFilePropertiesDialog() {
     2452        qDebug("BaseGui::createFilePropertiesDialog");
    22522453        QApplication::setOverrideCursor(Qt::WaitCursor);
    22532454        file_dialog = new FilePropertiesDialog(this);
     
    22752476
    22762477        recentfiles_menu = new QMenu(this);
     2478        /*
    22772479        recentfiles_menu->addAction( clearRecentsAct );
    22782480        recentfiles_menu->addSeparator();
     2481        */
    22792482
    22802483        openMenu->addMenu( recentfiles_menu );
     
    23112514        playMenu->addAction(stopAct);
    23122515        playMenu->addAction(frameStepAct);
     2516        playMenu->addAction(frameBackStepAct);
    23132517        playMenu->addSeparator();
    23142518        playMenu->addAction(rewind1Act);
     
    24552659        videoMenu->addAction(flipAct);
    24562660        videoMenu->addAction(mirrorAct);
     2661        videoMenu->addAction(stereo3dAct);
    24572662        videoMenu->addSeparator();
    24582663        videoMenu->addAction(videoEqualizerAct);
     
    24882693        audiofilter_menu->menuAction()->setObjectName("audiofilter_menu");
    24892694        audiofilter_menu->addAction(extrastereoAct);
     2695#ifdef MPLAYER_SUPPORT
    24902696        audiofilter_menu->addAction(karaokeAct);
     2697#endif
    24912698        audiofilter_menu->addAction(volnormAct);
    24922699
     
    25212728        // SUBTITLES MENU
    25222729        // Track submenu
    2523         subtitlestrack_menu = new QMenu(this);
    2524         subtitlestrack_menu->menuAction()->setObjectName("subtitlestrack_menu");
    2525 
    2526         subtitlesMenu->addMenu(subtitlestrack_menu);
     2730        subtitles_track_menu = new QMenu(this);
     2731        subtitles_track_menu->menuAction()->setObjectName("subtitlestrack_menu");
     2732
     2733#ifdef MPV_SUPPORT
     2734        secondary_subtitles_track_menu = new QMenu(this);
     2735        secondary_subtitles_track_menu->menuAction()->setObjectName("secondary_subtitles_track_menu");
     2736#endif
     2737
     2738        subtitlesMenu->addMenu(subtitles_track_menu);
     2739#ifdef MPV_SUPPORT
     2740        subtitlesMenu->addMenu(secondary_subtitles_track_menu);
     2741#endif
    25272742        subtitlesMenu->addSeparator();
    25282743
     
    25652780        subtitlesMenu->addAction(decSubStepAct);
    25662781        subtitlesMenu->addAction(incSubStepAct);
     2782#ifdef MPV_SUPPORT
     2783        subtitlesMenu->addSeparator();
     2784        subtitlesMenu->addAction(seekPrevSubAct);
     2785        subtitlesMenu->addAction(seekNextSubAct);
     2786#endif
    25672787        subtitlesMenu->addSeparator();
    25682788        subtitlesMenu->addAction(useForcedSubsOnlyAct);
     
    25702790        subtitlesMenu->addAction(subVisibilityAct);
    25712791        subtitlesMenu->addSeparator();
    2572         subtitlesMenu->addAction(useAssAct);
     2792        subtitlesMenu->addAction(useCustomSubStyleAct);
    25732793#ifdef FIND_SUBTITLES
    25742794        subtitlesMenu->addSeparator(); //turbos
     
    25952815
    25962816        browseMenu->addMenu(angles_menu);
     2817
     2818#ifdef BOOKMARKS
     2819        // Bookmarks submenu
     2820        bookmark_menu = new QMenu(this);
     2821        bookmark_menu->menuAction()->setObjectName("bookmarks_menu");
     2822
     2823        browseMenu->addMenu(bookmark_menu);
     2824#endif
    25972825
    25982826#if DVDNAV_SUPPORT
     
    26382866        osd_menu->menuAction()->setObjectName("osd_menu");
    26392867        osd_menu->addActions(osdGroup->actions());
     2868        osd_menu->addSeparator();
     2869        osd_menu->addAction(decOSDScaleAct);
     2870        osd_menu->addAction(incOSDScaleAct);
     2871
    26402872
    26412873        optionsMenu->addMenu(osd_menu);
     
    26802912        helpMenu->addSeparator();
    26812913        helpMenu->addAction(showCheckUpdatesAct);
    2682 #if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT)
     2914#if defined(YOUTUBE_SUPPORT) && defined(YT_USE_YTSIG)
    26832915        helpMenu->addAction(updateYTAct);
    26842916#endif
     
    26862918        helpMenu->addAction(showConfigAct);
    26872919        helpMenu->addSeparator();
    2688 #ifdef REMINDER_ACTIONS
     2920#ifdef SHARE_ACTIONS
    26892921        helpMenu->addAction(donateAct);
    26902922        helpMenu->addSeparator();
     
    28073039        pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit());
    28083040        pl->setPlayFilesFromStart(playlist->playFilesFromStart());
     3041        pl->setIgnorePlayerErrors(playlist->ignorePlayerErrors());
    28093042
    28103043        pref_dialog->show();
     
    28173050        bool need_update_language = false;
    28183051
     3052        PlayerID::Player old_player_type = PlayerID::player(pref->mplayer_bin);
     3053
    28193054        pref_dialog->getData(pref);
     3055
     3056        // Setup proxy
     3057        setupNetworkProxy();
    28203058
    28213059        // Change application font
     
    28453083                need_update_language = true;
    28463084                // Stylesheet
    2847 #if ALLOW_CHANGE_STYLESHEET
    2848                 changeStyleSheet(pref->iconset);
    2849 #endif
    2850         }
    2851 
    2852         mplayerwindow->activateMouseDragTracking(pref->move_when_dragging);
     3085                #if ALLOW_CHANGE_STYLESHEET
     3086                if (!_interface->guiChanged()) applyStyles();
     3087                #endif
     3088        }
     3089
     3090#ifdef MOUSE_GESTURES
     3091        mplayerwindow->activateMouseDragTracking(true);
     3092#else
     3093        mplayerwindow->activateMouseDragTracking(pref->drag_function == Preferences::MoveWindow);
     3094#endif
    28533095        mplayerwindow->delayLeftClick(pref->delay_left_click);
    28543096
     
    28813123                mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() );
    28823124        }
     3125#if ALLOW_DEMUXER_CODEC_CHANGE
    28833126        if (advanced->lavfDemuxerChanged()) {
    28843127                core->mset.forced_demuxer = pref->use_lavf_demuxer ? "lavf" : "";
    28853128        }
     3129#endif
    28863130
    28873131        // Update playlist preferences
     
    28913135        playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit());
    28923136        playlist->setPlayFilesFromStart(pl->playFilesFromStart());
     3137        playlist->setIgnorePlayerErrors(pl->ignorePlayerErrors());
    28933138
    28943139
     
    29023147#if STYLE_SWITCHING
    29033148        if (_interface->styleChanged()) {
    2904                 qDebug( "selected style: '%s'", pref->style.toUtf8().data() );
    2905                 if ( !pref->style.isEmpty()) {
    2906                         qApp->setStyle( pref->style );
    2907                 } else {
    2908                         qDebug("setting default style: '%s'", default_style.toUtf8().data() );
    2909                         qApp->setStyle( default_style );
    2910                 }
     3149                applyStyles();
    29113150        }
    29123151#endif
     
    29343173#endif
    29353174        }
     3175
     3176        if (old_player_type != PlayerID::player(pref->mplayer_bin)) {
     3177                qDebug("BaseGui::applyNewPreferences: player changed!");
     3178                // Hack, simulate a change of GUI to restart the interface
     3179                // FIXME: try to create a new Core::proc in the future
     3180                #ifdef GUI_CHANGE_ON_RUNTIME
     3181                core->stop();
     3182                emit guiChanged(pref->gui);
     3183                #endif
     3184        }
    29363185}
    29373186
     
    29523201
    29533202void BaseGui::setDataToFileProperties() {
     3203#if ALLOW_DEMUXER_CODEC_CHANGE
     3204        InfoReader *i = InfoReader::obj();
     3205        i->getInfo();
     3206        file_dialog->setCodecs( i->vcList(), i->acList(), i->demuxerList() );
     3207
    29543208        // Save a copy of the original values
    29553209        if (core->mset.original_demuxer.isEmpty())
     
    29743228        file_dialog->setAudioCodec(ac, core->mset.original_audio_codec);
    29753229        file_dialog->setVideoCodec(vc, core->mset.original_video_codec);
     3230#endif
    29763231
    29773232        file_dialog->setMplayerAdditionalArguments( core->mset.mplayer_additional_options );
     
    29863241
    29873242        bool need_restart = false;
    2988         bool demuxer_changed = false;
    29893243
    29903244#undef TEST_AND_SET
    29913245#define TEST_AND_SET( Pref, Dialog ) \
    29923246        if ( Pref != Dialog ) { Pref = Dialog; need_restart = true; }
     3247
     3248#if ALLOW_DEMUXER_CODEC_CHANGE
     3249        bool demuxer_changed = false;
    29933250
    29943251        QString prev_demuxer = core->mset.forced_demuxer;
     
    30123269        if (vc == core->mset.original_video_codec) vc="";
    30133270        TEST_AND_SET(core->mset.forced_video_codec, vc);
     3271#endif
    30143272
    30153273        TEST_AND_SET(core->mset.mplayer_additional_options, file_dialog->mplayerAdditionalArguments());
     
    30173275        TEST_AND_SET(core->mset.mplayer_additional_audio_filters, file_dialog->mplayerAdditionalAudioFilters());
    30183276
     3277#if ALLOW_DEMUXER_CODEC_CHANGE
    30193278        // Restart the video to apply
    30203279        if (need_restart) {
     
    30253284                }
    30263285        }
     3286#endif
    30273287}
    30283288
    30293289
    30303290void BaseGui::updateMediaInfo() {
    3031     qDebug("BaseGui::updateMediaInfo");
     3291        qDebug("BaseGui::updateMediaInfo");
    30323292
    30333293        if (file_dialog) {
     
    31463406
    31473407void BaseGui::showMplayerLog() {
    3148     qDebug("BaseGui::showMplayerLog");
     3408        qDebug("BaseGui::showMplayerLog");
    31493409
    31503410        exitFullscreenIfNeeded();
    31513411
    3152     mplayer_log_window->setText( mplayer_log );
     3412        mplayer_log_window->setText( mplayer_log );
    31533413        mplayer_log_window->show();
    31543414}
     
    31933453                a->setData(n);
    31943454        }
    3195         subtitlestrack_menu->addActions( subtitleTrackGroup->actions() );
     3455        subtitles_track_menu->addActions( subtitleTrackGroup->actions() );
     3456
     3457#ifdef MPV_SUPPORT
     3458        // Secondary Subtitles
     3459        secondarySubtitleTrackGroup->clear(true);
     3460        QAction * subSecNoneAct = secondarySubtitleTrackGroup->addAction( tr("&None") );
     3461        subSecNoneAct->setData(MediaSettings::SubNone);
     3462        subSecNoneAct->setCheckable(true);
     3463        for (n=0; n < core->mdat.subs.numItems(); n++) {
     3464                QAction *a = new QAction(secondarySubtitleTrackGroup);
     3465                a->setCheckable(true);
     3466                a->setText(core->mdat.subs.itemAt(n).displayName());
     3467                a->setData(n);
     3468        }
     3469        secondary_subtitles_track_menu->addActions( secondarySubtitleTrackGroup->actions() );
     3470#endif
    31963471
    31973472        // Audio
     
    32673542        // Chapters
    32683543        chapterGroup->clear(true);
     3544        //qDebug("BaseGui::initializeMenus: mdat.chapters.numItems: %d", core->mdat.chapters.numItems());
    32693545        if (core->mdat.chapters.numItems() > 0) {
    32703546                for (n=0; n < core->mdat.chapters.numItems(); n++) {
    32713547                        QAction *a = new QAction(chapterGroup);
    32723548                        //a->setCheckable(true);
     3549                        //qDebug("BaseGui::initializeMenus: chapter %d name: %s", n, core->mdat.chapters.itemAt(n).name().toUtf8().constData());
    32733550                        a->setText(core->mdat.chapters.itemAt(n).name());
    32743551                        a->setData(core->mdat.chapters.itemAt(n).ID());
     
    33093586        }
    33103587        angles_menu->addActions( angleGroup->actions() );
    3311 }
     3588
     3589#ifdef BOOKMARKS
     3590        updateBookmarks();
     3591#endif
     3592}
     3593
     3594#ifdef BOOKMARKS
     3595void BaseGui::updateBookmarks() {
     3596        qDebug("BaseGui::updateBookmarks");
     3597
     3598        // Bookmarks
     3599        bookmarkGroup->clear(true);
     3600        int n_bookmarks = core->mset.bookmarks.size();
     3601        if (n_bookmarks > 0) {
     3602                QMap<int, QString>::const_iterator i = core->mset.bookmarks.constBegin();
     3603                while (i != core->mset.bookmarks.constEnd()) {
     3604                        QString name = i.value();
     3605                        int time = i.key();
     3606                        QAction *a = new QAction(bookmarkGroup);
     3607                        QString text;
     3608                        if (name.isEmpty()) {
     3609                                text = Helper::formatTime(time);
     3610                        } else {
     3611                                text = QString("%1 (%2)").arg(name).arg(Helper::formatTime(time));
     3612                        }
     3613                        a->setCheckable(false);
     3614                        a->setText(text);
     3615                        a->setData(time);
     3616                        i++;
     3617                }
     3618        }
     3619        bookmark_menu->clear();
     3620        bookmark_menu->addAction(addBookmarkAct);
     3621        bookmark_menu->addAction(editBookmarksAct);
     3622        bookmark_menu->addSeparator();
     3623        bookmark_menu->addActions(bookmarkGroup->actions());
     3624}
     3625#endif
    33123626
    33133627void BaseGui::updateRecents() {
    33143628        qDebug("BaseGui::updateRecents");
    33153629
    3316         // Not clear the first 2 items
    3317         while (recentfiles_menu->actions().count() > 2) {
    3318                 QAction * a = recentfiles_menu->actions()[2];
    3319                 recentfiles_menu->removeAction( a );
    3320                 a->deleteLater();
    3321         }
     3630        recentfiles_menu->clear();
    33223631
    33233632        int current_items = 0;
     
    33543663
    33553664        recentfiles_menu->menuAction()->setVisible( current_items > 0 );
     3665        if (current_items  > 0) {
     3666                recentfiles_menu->addSeparator();
     3667                recentfiles_menu->addAction( clearRecentsAct );
     3668        }
    33563669}
    33573670
     
    33733686        // Subtitles menu
    33743687        subtitleTrackGroup->setChecked( core->mset.current_sub_id );
     3688
     3689#ifdef MPV_SUPPORT
     3690        // Secondary subtitles menu
     3691        secondarySubtitleTrackGroup->setChecked( core->mset.current_secondary_sub_id );
     3692#endif
    33753693
    33763694        // Disable the unload subs action if there's no external subtitles
     
    34163734        titleGroup->setChecked( core->mset.current_title_id );
    34173735
    3418         // Chapters
    3419         chapterGroup->setChecked( core->mset.current_chapter_id );
    3420 
    34213736        // Angles
    34223737        angleGroup->setChecked( core->mset.current_angle_id );
     
    34773792        muteAct->setChecked( (pref->global_volume ? pref->mute : core->mset.mute) );
    34783793
     3794#ifdef MPLAYER_SUPPORT
    34793795        // Karaoke menu option
    34803796        karaokeAct->setChecked( core->mset.karaoke_filter );
     3797#endif
    34813798
    34823799        // Extrastereo menu option
     
    35263843        mirrorAct->setChecked( core->mset.mirror );
    35273844
    3528         // Use ass lib
    3529         useAssAct->setChecked( pref->use_ass_subtitles );
     3845        // Use custom style
     3846        useCustomSubStyleAct->setChecked( pref->enable_ass_styles );
    35303847
    35313848        // Forced subs
     
    35503867        decSubStepAct->setEnabled(e);
    35513868        incSubStepAct->setEnabled(e);
     3869#ifdef MPV_SUPPORT
     3870        seekNextSubAct->setEnabled(e);
     3871        seekPrevSubAct->setEnabled(e);
     3872#endif
    35523873}
    35533874
     
    36423963                playlist->load_pls(file);
    36433964        }
    3644         else
     3965        else
     3966        if (extension=="xspf") {
     3967                playlist->loadXSPF(file);
     3968        }
     3969        else
    36453970        if (QFileInfo(file).isDir()) {
    36463971                openDirectory(file);
     
    37914116                }
    37924117                else
     4118                if (extension=="xspf") {
     4119                        playlist->loadXSPF(file);
     4120                }
     4121                else
    37934122                if (extension=="iso") {
    37944123                        if (playlist->maybeSave()) {
     
    38604189                if (playlist->maybeSave()) {
    38614190#if DVDNAV_SUPPORT
    3862                         core->openDVD( DiscName::joinDVD(pref->use_dvdnav ? 0: 1, pref->dvd_device, pref->use_dvdnav) );
     4191                        int first_title = 0;
     4192                        if (!pref->use_dvdnav) first_title = core->firstDVDTitle();
     4193                        core->openDVD( DiscName::joinDVD(first_title, pref->dvd_device, pref->use_dvdnav) );
    38634194#else
    3864                         core->openDVD( DiscName::joinDVD(1, pref->dvd_device, false) );
     4195                        core->openDVD( DiscName::joinDVD(core->firstDVDTitle(), pref->dvd_device, false) );
    38654196#endif
    38664197                }
     
    38874218        pref->last_dvd_directory = directory;
    38884219#if DVDNAV_SUPPORT
    3889         core->openDVD( DiscName::joinDVD(pref->use_dvdnav ? 0: 1, directory, pref->use_dvdnav) );
     4220        int first_title = 0;
     4221        if (!pref->use_dvdnav) first_title = core->firstDVDTitle();
     4222        core->openDVD( DiscName::joinDVD(first_title, directory, pref->use_dvdnav) );
    38904223#else
    3891         core->openDVD( DiscName::joinDVD(1, directory, false) );
     4224        core->openDVD( DiscName::joinDVD(core->firstDVDTitle(), directory, false) );
    38924225#endif
    38934226}
     
    39004233void BaseGui::openBluRayFromFolder(QString directory) {
    39014234        pref->last_dvd_directory = directory;
    3902         core->openBluRay( DiscName::join(DiscName::BLURAY, 1, directory) );
     4235        core->openBluRay( DiscName::join(DiscName::BLURAY, core->firstBlurayTitle(), directory) );
    39034236}
    39044237
     
    39154248                configureDiscDevices();
    39164249        } else {
    3917                 core->openBluRay( DiscName::join(DiscName::BLURAY, 1, pref->bluray_device) );
     4250                core->openBluRay( DiscName::join(DiscName::BLURAY, core->firstBlurayTitle(), pref->bluray_device) );
    39184251        }
    39194252}
     
    40004333
    40014334void BaseGui::helpFirstSteps() {
    4002         QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/first-steps.php?version=%1").arg(Version::printable()));
     4335        QDesktopServices::openUrl(QString(URL_FIRST_STEPS "?version=%1").arg(Version::printable()));
    40034336}
    40044337
    40054338void BaseGui::helpFAQ() {
    4006         QString url = "http://smplayer.sourceforge.net/faq.php";
     4339        QString url = URL_FAQ;
    40074340        /* if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); */
    40084341        QDesktopServices::openUrl( QUrl(url) );
     
    40194352
    40204353void BaseGui::helpCheckUpdates() {
    4021         QString url = "http://smplayer.sourceforge.net/changes.php";
    4022         /* if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); */
     4354#ifdef UPDATE_CHECKER
     4355        update_checker->check();
     4356#else
     4357        QString url = QString(URL_CHANGES "?version=%1").arg(Version::with_revision());
    40234358        QDesktopServices::openUrl( QUrl(url) );
     4359#endif
    40244360}
    40254361
     
    40284364}
    40294365
    4030 #ifdef REMINDER_ACTIONS
     4366#ifdef SHARE_ACTIONS
    40314367void BaseGui::helpDonate() {
    40324368        ShareDialog d(this);
    40334369        d.showRemindCheck(false);
     4370
     4371        #ifdef SHARE_WIDGET
     4372        d.setActions(sharewidget->actions());
     4373        #endif
     4374
    40344375        d.exec();
    40354376        int action = d.actions();
     
    40374378
    40384379        if (action > 0) {
     4380                #ifdef SHARE_WIDGET
     4381                sharewidget->setActions(action);
     4382                #else
    40394383                QSettings * set = Global::settings;
    40404384                set->beginGroup("reminder");
    40414385                set->setValue("action", action);
    40424386                set->endGroup();
     4387                #endif
    40434388        }
    40444389}
     
    40534398void BaseGui::shareSMPlayer() {
    40544399        QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+");
    4055         QString url = "http://smplayer.sourceforge.net";
     4400        QString url = URL_HOMEPAGE;
    40564401
    40574402        if (sender() == twitterAct) {
     
    40744419                QDesktopServices::openUrl(QUrl("http://www.facebook.com/sharer.php?u=" + url + "&t=" + text));
    40754420
    4076                 #ifdef REMINDER_ACTIONS
     4421                #ifdef SHARE_ACTIONS
    40774422                QSettings * set = Global::settings;
    40784423                set->beginGroup("reminder");
     
    41274472}
    41284473
     4474void BaseGui::showStereo3dDialog() {
     4475        Stereo3dDialog d(this);
     4476        d.setInputFormat(core->mset.stereo3d_in);
     4477        d.setOutputFormat(core->mset.stereo3d_out);
     4478
     4479        if (d.exec() == QDialog::Accepted) {
     4480                core->changeStereo3d(d.inputFormat(), d.outputFormat());
     4481        }
     4482}
     4483
     4484#ifdef BOOKMARKS
     4485void BaseGui::showAddBookmarkDialog() {
     4486        InputBookmark d(this);
     4487        d.setTime( (int) core->mset.current_sec);
     4488        if (d.exec() == QDialog::Accepted) {
     4489                core->mset.bookmarks.insert(d.time(), d.name());
     4490                updateBookmarks();
     4491        }
     4492}
     4493
     4494void BaseGui::showBookmarkDialog() {
     4495        qDebug("BaseGui::showBookmarkDialog");
     4496        BookmarkDialog d(this);
     4497        d.setBookmarks(core->mset.bookmarks);
     4498        if (d.exec() == QDialog::Accepted) {
     4499                core->mset.bookmarks = d.bookmarks();
     4500                updateBookmarks();
     4501        }
     4502}
     4503#endif
     4504
    41294505void BaseGui::exitFullscreen() {
    41304506        if (pref->fullscreen) {
     
    41524528        // If using mplayer window
    41534529        if (pref->use_mplayer_window) {
    4154                 core->tellmp("vo_fullscreen " + QString::number(b) );
     4530                core->changeFullscreenMode(b);
    41554531                updateWidgets();
    41564532                return;
     
    42014577        (!core->mset.add_letterbox))
    42024578        {
    4203                 core->restart();
     4579                core->changeLetterboxOnFullscreen(b);
     4580                /* core->restart(); */
    42044581        }
    42054582
     
    42094586
    42104587void BaseGui::aboutToEnterFullscreen() {
     4588        if (pref->stay_on_top == Preferences::WhilePlayingOnTop && core->state() == Core::Playing) {
     4589                setStayOnTop(false);
     4590        }
     4591
    42114592        if (!pref->compact_mode) {
    42124593                menuBar()->hide();
     
    42194600                menuBar()->show();
    42204601                statusBar()->show();
     4602        }
     4603
     4604        if (pref->stay_on_top == Preferences::WhilePlayingOnTop) {
     4605                #if QT_VERSION < 0x050000
     4606                qApp->processEvents();
     4607                #endif
     4608                setStayOnTop(core->state() == Core::Playing);
    42214609        }
    42224610}
     
    44044792#endif
    44054793
    4406 #ifdef UPDATE_CHECKER
    4407 void BaseGui::reportNewVersionAvailable(QString new_version) {
    4408         QMessageBox::StandardButton button = QMessageBox::information(this, tr("New version available"),
    4409                 tr("A new version of SMPlayer is available.") + "<br><br>" +
    4410                 tr("Installed version: %1").arg(Version::with_revision()) + "<br>" +
    4411                 tr("Available version: %1").arg(new_version) + "<br><br>" +
    4412                 tr("Would you like to know more about this new version?"),
    4413                 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
    4414 
    4415         if (button == QMessageBox::Yes) {
    4416                 QDesktopServices::openUrl(QUrl("http://smplayer.sourceforge.net/changes.php"));
    4417         }
    4418 
    4419         update_checker->saveVersion(new_version);
    4420 }
    4421 #endif
    4422 
    44234794#ifdef CHECK_UPGRADED
    44244795void BaseGui::checkIfUpgraded() {
     
    44354806                os = "linux";
    44364807                #endif
    4437                 QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/thank-you.php?version=%1&so=%2").arg(Version::printable()).arg(os));
     4808                QDesktopServices::openUrl(QString(URL_THANK_YOU "?version=%1&so=%2").arg(Version::printable()).arg(os));
    44384809        }
    44394810        pref->smplayer_stable_version = Version::stable();
     
    44414812#endif
    44424813
    4443 #ifdef REMINDER_ACTIONS
     4814#if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET)
    44444815void BaseGui::checkReminder() {
    44454816        qDebug("BaseGui::checkReminder");
     
    44864857
    44874858#ifdef YOUTUBE_SUPPORT
     4859void BaseGui::YTNoSslSupport() {
     4860        qDebug("BaseGui::YTNoSslSupport");
     4861        QMessageBox::warning(this, tr("Connection failed"),
     4862                tr("The video you requested needs to open a HTTPS connection.") +"<br>"+
     4863                tr("Unfortunately the OpenSSL component, required for it, is not available in your system.") +"<br>"+
     4864                tr("Please, visit %1 to know how to fix this problem.")
     4865                        .arg("<a href=\"" URL_OPENSSL_INFO "\">" + tr("this link") + "</a>") );
     4866}
     4867
    44884868void BaseGui::YTNoSignature(const QString & title) {
    44894869        qDebug("BaseGui::YTNoSignature: %s", title.toUtf8().constData());
     
    44994879        }
    45004880
    4501         #ifdef YT_USE_SCRIPT
     4881        #ifdef YT_USE_YTSIG
    45024882        int ret = QMessageBox::question(this, tr("Problems with Youtube"),
    45034883                                info_text + "<br><br>" +
     
    45144894}
    45154895
    4516 #ifdef YT_USE_SCRIPT
     4896#ifdef YT_USE_YTSIG
    45174897void BaseGui::YTUpdateScript() {
    45184898        static CodeDownloader * downloader = 0;
     
    45204900        downloader->saveAs(Paths::configPath() + "/yt.js");
    45214901        downloader->show();
    4522         downloader->download(QUrl("http://updates.smplayer.info/yt.js"));
    4523 }
    4524 #endif // YT_USE_SCRIPT
     4902        downloader->download(QUrl(URL_YT_CODE));
     4903}
     4904#endif // YT_USE_YTSIG
    45254905#endif //YOUTUBE_SUPPORT
    45264906
    45274907void BaseGui::gotForbidden() {
    45284908        qDebug("BaseGui::gotForbidden");
     4909
     4910        if (!pref->report_mplayer_crashes) {
     4911                qDebug("BaseGui::gotForbidden: not displaying error dialog");
     4912                return;
     4913        }
     4914
    45294915        static bool busy = false;
    45304916
     
    47255111
    47265112void BaseGui::displayState(Core::State state) {
    4727         qDebug("BaseGui::displayState: %s", core->stateToString().toUtf8().data());
     5113        qDebug() << "BaseGui::displayState:" << core->stateToString();
     5114
    47285115        switch (state) {
    4729                 case Core::Playing:     statusBar()->showMessage( tr("Playing %1").arg(core->mdat.filename), 2000); break;
     5116                //case Core::Playing:   statusBar()->showMessage( tr("Playing %1").arg(core->mdat.filename), 2000); break;
     5117                case Core::Playing:     statusBar()->showMessage(""); break;
    47305118                case Core::Paused:      statusBar()->showMessage( tr("Pause") ); break;
    47315119                case Core::Stopped:     statusBar()->showMessage( tr("Stop") , 2000); break;
    4732         }
     5120                case Core::Buffering: /* statusBar()->showMessage(tr("Buffering...")); */ break;
     5121        }
     5122
    47335123        if (state == Core::Stopped) setWindowCaption( "SMPlayer" );
    47345124
     
    48355225#endif
    48365226
     5227        qDebug("BaseGui::resizeWindow: new_width: %d new_height: %d", new_width, new_height);
     5228
     5229#if 0
     5230        QSize desktop_size = DesktopInfo::desktop_size(this);
     5231        //desktop_size.setWidth(1000); desktop_size.setHeight(1000); // test
     5232        if (new_width > desktop_size.width()) {
     5233                double aspect = (double) new_width / new_height;
     5234                qDebug("BaseGui::resizeWindow: width (%d) is larger than desktop width (%d)", new_width, desktop_size.width());
     5235                new_width = desktop_size.width();
     5236                /*
     5237                new_height = new_width / aspect;
     5238                qDebug() << "BaseGui::resizeWindow: aspect:" << aspect;
     5239                qDebug("BaseGui::resizeWindow: height: %d", new_height);
     5240                */
     5241        }
     5242        if (new_height > desktop_size.height()) {
     5243                qDebug("BaseGui::resizeWindow: height (%d) is larger than desktop height (%d)", new_height, desktop_size.height());
     5244                new_height = desktop_size.height();
     5245        }
     5246#endif
     5247
    48375248        resize(new_width, new_height);
    48385249
     
    48425253           panel->size().height() );
    48435254        qDebug("BaseGui::resizeWindow: done: mplayerwindow->size: %d, %d",
    4844            mplayerwindow->size().width(), 
     5255           mplayerwindow->size().width(),
    48455256           mplayerwindow->size().height() );
     5257
     5258        // Check if a part of the window is outside of the desktop
     5259        // and center the window in that case
     5260        if ((pref->center_window_if_outside) && (!core->mdat.novideo)) {
     5261                QRect screen_rect = QApplication::desktop()->screenGeometry(this);
     5262                QPoint right_bottom = QPoint(this->pos().x() + this->width(), this->pos().y() + this->height());
     5263                qDebug("BaseGui::resizeWindow: right bottom point: %d, %d", right_bottom.x(), right_bottom.y());;
     5264                if (!screen_rect.contains(right_bottom) || !screen_rect.contains(this->pos())) {
     5265                        qDebug("BaseGui::resizeWindow: the window is outside of the desktop, it will be moved");
     5266                        //move(screen_rect.x(), screen_rect.y());
     5267                        int x = screen_rect.x() + ((screen_rect.width() - width()) / 2);
     5268                        int y = screen_rect.y() + ((screen_rect.height() - height()) / 2);
     5269                        move(x, y);
     5270                }
     5271        }
     5272
    48465273}
    48475274
     
    48515278        if (panel->isVisible()) {
    48525279                // Exit from fullscreen mode
    4853             if (pref->fullscreen) { toggleFullscreen(false); update(); }
     5280                if (pref->fullscreen) { toggleFullscreen(false); update(); }
    48545281
    48555282                // Exit from compact mode first
     
    48645291                // Disable compact mode
    48655292                //compactAct->setEnabled(false);
     5293        }
     5294}
     5295
     5296void BaseGui::centerWindow() {
     5297        qDebug("BaseGui::centerWindow");
     5298        if (pref->center_window && !pref->fullscreen && isVisible()) {
     5299                QRect r = QApplication::desktop()->screenGeometry(this);
     5300                // r.setX(500); r.setY(150); // Test
     5301                qDebug() << "BaseGui::centerWindow: desktop rect:" << r;
     5302                int x = r.x() + ((r.width() - width()) / 2);
     5303                int y = r.y() + ((r.height() - height()) / 2);
     5304                move(x, y);
    48665305        }
    48675306}
     
    49745413void BaseGui::checkStayOnTop(Core::State state) {
    49755414        qDebug("BaseGui::checkStayOnTop");
    4976     if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) {
     5415        if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) {
    49775416                setStayOnTop((state == Core::Playing));
    49785417        }
     
    49975436
    49985437#if ALLOW_CHANGE_STYLESHEET
    4999 void BaseGui::loadQss(QString filename) {
     5438QString BaseGui::loadQss(QString filename) {
     5439        qDebug("BaseGui::loadQss: %s", filename.toUtf8().constData());
     5440
    50005441        QFile file( filename );
    50015442        file.open(QFile::ReadOnly);
    5002         QString styleSheet = QLatin1String(file.readAll());
     5443        QString stylesheet = QLatin1String(file.readAll());
    50035444
    50045445#ifdef USE_RESOURCES
    50055446        Images::setTheme(pref->iconset);
    5006         QString path = ":/" + pref->iconset;
     5447        QString path;
     5448        if (Images::has_rcc) {
     5449                path = ":/" + pref->iconset;
     5450        } else {
     5451                QDir current = QDir::current();
     5452                QString td = Images::themesDirectory();
     5453                path = current.relativeFilePath(td);
     5454        }
    50075455#else
    50085456        QDir current = QDir::current();
     
    50105458        QString path = current.relativeFilePath(td);
    50115459#endif
    5012         styleSheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
     5460        stylesheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
    50135461                                                QString("url(%1\\1)").arg(path + "/"));
    5014         //qDebug("BaseGui::loadQss: styeSheet: %s", styleSheet.toUtf8().constData());
    5015         qApp->setStyleSheet(styleSheet);
     5462        //qDebug("BaseGui::loadQss: styleSheet: %s", stylesheet.toUtf8().constData());
     5463        return stylesheet;
    50165464}
    50175465
    50185466void BaseGui::changeStyleSheet(QString style) {
    5019         if (style.isEmpty())  {
    5020                 qApp->setStyleSheet("");
    5021         }
    5022         else {
    5023                 QString qss_file = Paths::configPath() + "/themes/" + pref->iconset +"/style.qss";
    5024                 //qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
     5467        qDebug("BaseGui::changeStyleSheet: %s", style.toUtf8().constData());
     5468
     5469        // Load default stylesheet
     5470        QString stylesheet = loadQss(":/default-theme/style.qss");
     5471
     5472        if (!style.isEmpty()) {
     5473                // Check main.css
     5474                QString qss_file = Paths::configPath() + "/themes/" + pref->iconset + "/main.css";
    50255475                if (!QFile::exists(qss_file)) {
    5026                         qss_file = Paths::themesPath() +"/"+ pref->iconset +"/style.qss";
    5027                 }
     5476                        qss_file = Paths::themesPath() +"/"+ pref->iconset + "/main.css";
     5477                }
     5478
     5479                // Check style.qss
     5480                if (!QFile::exists(qss_file)) {
     5481                        qss_file = Paths::configPath() + "/themes/" + pref->iconset + "/style.qss";
     5482                        if (!QFile::exists(qss_file)) {
     5483                                qss_file = Paths::themesPath() +"/"+ pref->iconset + "/style.qss";
     5484                        }
     5485                }
     5486
     5487                // Load style file
    50285488                if (QFile::exists(qss_file)) {
    50295489                        qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
    5030                         loadQss(qss_file);
    5031                 } else {
    5032                         qApp->setStyleSheet("");
    5033                 }
    5034         }
    5035 }
    5036 #endif
     5490                        stylesheet += loadQss(qss_file);
     5491                }
     5492        }
     5493
     5494        //qDebug("BaseGui::changeStyleSheet: styleSheet: %s", stylesheet.toUtf8().constData());
     5495        qApp->setStyleSheet(stylesheet);
     5496}
     5497#endif
     5498
     5499void BaseGui::applyStyles() {
     5500        qDebug("BaseGui::applyStyles");
     5501
     5502#if ALLOW_CHANGE_STYLESHEET
     5503        qDebug() << "BaseGui::applyStyles: stylesheet:" << pref->iconset;
     5504        changeStyleSheet(pref->iconset);
     5505#endif
     5506
     5507#if STYLE_SWITCHING
     5508        QString style = pref->style;
     5509        if (style.isEmpty()) style = default_style;
     5510        qDebug() << "BaseGui::applyStyles: style:" << style;
     5511        if (!style.isEmpty()) qApp->setStyle(style);
     5512#endif
     5513
     5514}
    50375515
    50385516void BaseGui::loadActions() {
     
    50585536}
    50595537
     5538void BaseGui::processMouseMovedDiff(QPoint diff) {
     5539        //qDebug() << "BaseGui::processMouseMovedDiff" << diff;
     5540
     5541#ifdef MOUSE_GESTURES
     5542        #ifdef MG_DELAYED_SEEK
     5543        if (delayed_seek_timer == 0) {
     5544                delayed_seek_timer = new QTimer(this);
     5545                delayed_seek_timer->setSingleShot(true);
     5546                delayed_seek_timer->setInterval(250);
     5547                connect(delayed_seek_timer, SIGNAL(timeout()), this, SLOT(delayedSeek()));
     5548        }
     5549        #endif
     5550
     5551        if (pref->drag_function == Preferences::Gestures) {
     5552                if (core->state() == Core::Stopped) return;
     5553
     5554                int t = 1;
     5555
     5556                int h_desp = qAbs(diff.x());
     5557                int v_desp = qAbs(diff.y());
     5558
     5559                if (h_desp > v_desp) {
     5560                        // Horizontal
     5561                        if (diff.x() > t) {
     5562                                #ifdef MG_DELAYED_SEEK
     5563                                delayed_seek_value += h_desp;
     5564                                delayed_seek_timer->start();
     5565                                #else
     5566                                core->sforward();
     5567                                #endif
     5568                        }
     5569                        else
     5570                        if (diff.x() < -t) {
     5571                                #ifdef MG_DELAYED_SEEK
     5572                                delayed_seek_value -= h_desp;
     5573                                delayed_seek_timer->start();
     5574                                #else
     5575                                core->srewind();
     5576                                #endif
     5577                        }
     5578                        #ifdef MG_DELAYED_SEEK
     5579                        int time = qAbs(delayed_seek_value);
     5580                        int minutes = time / 60;
     5581                        int seconds = time - (minutes * 60);
     5582                        QString s;
     5583                        if (delayed_seek_value >= 0) s = "+"; else s = "-";
     5584                        if (minutes > 0) s += QString("%1").arg(minutes, 2, 10, QChar('0')) + ":";
     5585                        s += QString("%1").arg(seconds, 2, 10, QChar('0'));
     5586                        if (pref->fullscreen) {
     5587                                core->displayTextOnOSD(s, 1000);
     5588                        } else {
     5589                                displayMessage(s, 1000);
     5590                        }
     5591                        #endif
     5592                } else {
     5593                        // Vertical
     5594                        if (diff.y() > t) core->decVolume(1);
     5595                        else
     5596                        if (diff.y() < -t) core->incVolume(1);
     5597                }
     5598        }
     5599#endif
     5600
     5601        if (pref->drag_function == Preferences::MoveWindow) {
     5602                moveWindowDiff(diff);
     5603        }
     5604}
     5605
    50605606void BaseGui::moveWindowDiff(QPoint diff) {
     5607        //qDebug() << "BaseGui::moveWindowDiff:" << diff;
     5608
    50615609        if (pref->fullscreen || isMaximized()) {
    50625610                return;
     
    50895637}
    50905638
     5639#ifdef MG_DELAYED_SEEK
     5640void BaseGui::delayedSeek() {
     5641        qDebug() << "BaseGui::delayedSeek:" << delayed_seek_value;
     5642        if (delayed_seek_value != 0) {
     5643                core->seek(delayed_seek_value);
     5644                delayed_seek_value = 0;
     5645        }
     5646}
     5647#endif
     5648
     5649
     5650#if QT_VERSION < 0x050000
    50915651void BaseGui::showEvent( QShowEvent * ) {
    50925652        qDebug("BaseGui::showEvent");
     
    51125672        }
    51135673}
     5674#else
     5675// Qt 5 doesn't call showEvent / hideEvent when the window is minimized or unminimized
     5676bool BaseGui::event(QEvent * e) {
     5677        //qDebug("BaseGui::event: %d", e->type());
     5678
     5679        bool result = QWidget::event(e);
     5680        if ((ignore_show_hide_events) || (!pref->pause_when_hidden)) return result;
     5681
     5682        if (e->type() == QEvent::WindowStateChange) {
     5683                qDebug("BaseGui::event: WindowStateChange");
     5684
     5685                if (isMinimized()) {
     5686                        was_minimized = true;
     5687                        if (core->state() == Core::Playing) {
     5688                                qDebug("BaseGui::event: pausing");
     5689                                core->pause();
     5690                        }
     5691                }
     5692        }
     5693
     5694        if ((e->type() == QEvent::ActivationChange) && (isActiveWindow())) {
     5695                qDebug("BaseGui::event: ActivationChange: %d", was_minimized);
     5696
     5697                if ((!isMinimized()) && (was_minimized)) {
     5698                        was_minimized = false;
     5699                        if (core->state() == Core::Paused) {
     5700                                qDebug("BaseGui::showEvent: unpausing");
     5701                                core->pause(); // Unpauses
     5702                        }
     5703                }
     5704        }
     5705
     5706        return result;
     5707}
     5708#endif
    51145709
    51155710void BaseGui::askForMplayerVersion(QString line) {
     
    51395734        if (exit_code != 255 ) {
    51405735                ErrorDialog d(this);
    5141                 d.setText(tr("MPlayer has finished unexpectedly.") + " " +
     5736                d.setWindowTitle(tr("%1 Error").arg(PLAYER_NAME));
     5737                d.setText(tr("%1 has finished unexpectedly.").arg(PLAYER_NAME) + " " +
    51425738                      tr("Exit code: %1").arg(exit_code));
    51435739#ifdef LOG_MPLAYER
     
    51525748
    51535749        if (!pref->report_mplayer_crashes) {
    5154                 qDebug("showErrorFromMplayer: not displaying error dialog");
     5750                qDebug("BaseGui::showErrorFromMplayer: not displaying error dialog");
    51555751                return;
    51565752        }
     
    51585754        if ((e == QProcess::FailedToStart) || (e == QProcess::Crashed)) {
    51595755                ErrorDialog d(this);
     5756                d.setWindowTitle(tr("%1 Error").arg(PLAYER_NAME));
    51605757                if (e == QProcess::FailedToStart) {
    5161                         d.setText(tr("MPlayer failed to start.") + " " +
    5162                          tr("Please check the MPlayer path in preferences."));
     5758                        d.setText(tr("%1 failed to start.").arg(PLAYER_NAME) + " " +
     5759                         tr("Please check the %1 path in preferences.").arg(PLAYER_NAME));
    51635760                } else {
    5164                         d.setText(tr("MPlayer has crashed.") + " " +
     5761                        d.setText(tr("%1 has crashed.").arg(PLAYER_NAME) + " " +
    51655762                      tr("See the log for more info."));
    51665763                }
     
    52365833void BaseGui::showTubeBrowser() {
    52375834        qDebug("BaseGui::showTubeBrowser");
    5238         QString exec = Paths::appPath() + "/smtube";
    5239         qDebug("BaseGui::showTubeBrowser: '%s'", exec.toUtf8().constData());
    5240         if (!QProcess::startDetached(exec, QStringList())) {
     5835        #ifdef Q_OS_WIN
     5836        QString exec = Paths::appPath() + "/smtube.exe";
     5837        #else
     5838        QString exec = Helper::findExecutable("smtube");
     5839        #endif
     5840
     5841        if (exec.isEmpty() || !QFile::exists(exec)) {
    52415842                QMessageBox::warning(this, "SMPlayer",
    5242                         tr("The YouTube Browser couldn't be launched.") +"<br>"+
    5243                         tr("Be sure %1 is installed.").arg("SMTube"));
     5843                        tr("The YouTube Browser is not installed.") +"<br>"+
     5844                        tr("Visit %1 to get it.").arg("<a href=http://www.smtube.org>http://www.smtube.org</a>"));
     5845                return;
     5846        }
     5847
     5848        QStringList args;
     5849        if (!pref->language.isEmpty()) args << "-lang" << pref->language;
     5850        qDebug() << "BaseGui::showTubeBrowser: exec:" << exec << "args:" << args;
     5851
     5852        if (!QProcess::startDetached(exec, args)) {
     5853                QMessageBox::warning(this, "SMPlayer",
     5854                        tr("The YouTube Browser failed to run.") +"<br>"+
     5855                        tr("Be sure it's installed correctly.") +"<br>"+
     5856                        tr("Visit %1 to get it.").arg("<a href=http://www.smtube.org>http://www.smtube.org</a>"));
    52445857        }
    52455858}
Note: See TracChangeset for help on using the changeset viewer.