Ignore:
Timestamp:
Dec 22, 2011, 6:27:52 PM (14 years ago)
Author:
Silvan Scherrer
Message:

smplayer vendor udate

File:
1 edited

Legend:

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

    r90 r118  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
     2    Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    8585#include "prefinput.h"
    8686#include "prefadvanced.h"
     87#include "prefplaylist.h"
    8788
    8889#include "myaction.h"
    8990#include "myactiongroup.h"
     91#include "playlist.h"
    9092
    9193#include "constants.h"
     
    9597#ifdef Q_OS_WIN
    9698#include "deviceinfo.h"
     99#include <QSysInfo>
    97100#endif
    98101
     
    104107                near_bottom(false)
    105108{
    106 #ifdef Q_OS_WIN
     109#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    107110        /* Disable screensaver by event */
    108111        just_stopped = false;
     
    208211        connect(server, SIGNAL(receivedLoadSubtitle(QString)), 
    209212            this, SLOT(remoteLoadSubtitle(QString)));
     213        connect(server, SIGNAL(receivedPlayItem(int)),
     214                        this, SLOT(remotePlayItem(int)));
     215        connect(server, SIGNAL(receivedRemoveItem(int)),
     216                        this, SLOT(remoteRemoveItem(int)));
     217        connect(server, SIGNAL(receivedViewPlaylist(QString*)),
     218                        this, SLOT(remoteViewPlaylist(QString*)));
     219        connect(server, SIGNAL(receivedViewStatus(QString*)),
     220                        this, SLOT(remoteViewStatus(QString*)));
     221        connect(server, SIGNAL(receivedViewClipInfo(QString*)),
     222                        this, SLOT(remoteViewClipInfo(QString*)));
     223        connect(server, SIGNAL(receivedSeek(double)),
     224                        this, SLOT(remoteSeek(double)));
     225        connect(server, SIGNAL(receivedGetChecked(QString,QString*)),
     226                        this, SLOT(remoteGetChecked(QString,QString*)));
     227        connect(server, SIGNAL(receivedMoveItem(int,int)),
     228                        this, SLOT(remoteMoveItem(int,int)));
     229        connect(server, SIGNAL(receivedGetVolume(int*)),
     230                        this, SLOT(remoteGetVolume(int*)));
     231        connect(server, SIGNAL(receivedSetVolume(int)),
     232                        core, SLOT(setVolume(int)));
    210233
    211234        if (pref->use_single_instance) {
     
    222245}
    223246
     247void BaseGui::remotePlayItem(int index){
     248        qDebug("BaseGui::remotePlay: '%s'", QString::number((index)).toUtf8().data());
     249        if (isMinimized()) showNormal();
     250        if (!isVisible()) show();
     251        raise();
     252        activateWindow();
     253        playlist->playItem(index);
     254}
     255
     256void BaseGui::remoteRemoveItem(int index){
     257        qDebug("BaseGui::remoteRemove: '%s'", QString::number((index)).toUtf8().data());
     258        if (isMinimized()) showNormal();
     259        if (!isVisible()) show();
     260        raise();
     261        activateWindow();
     262
     263        if(index == -1)
     264                playlist->removeAll();
     265        else
     266                playlist->remove(index);
     267}
     268
     269void BaseGui::remoteMoveItem(int index, int shift){
     270        qDebug("BaseGui::remoteRemove: '%s'", QString::number((index)).toUtf8().data());
     271        if (isMinimized()) showNormal();
     272        if (!isVisible()) show();
     273        raise();
     274        activateWindow();
     275
     276        int step = shift / abs(shift);
     277        for(int i = index; i != (index + shift); i += step){
     278                if(step == -1 && index == 0) break;
     279                if(step == +1 && index == (playlist->count() - 1)) break;
     280
     281                if(step == -1) playlist->moveItemUp(index);
     282                if(step == +1) playlist->moveItemDown(index);
     283        } //end for
     284}
     285
    224286void BaseGui::remoteOpen(QString file) {
    225287        qDebug("BaseGui::remoteOpen: '%s'", file.toUtf8().data());
     
    259321                core->loadSub(file);
    260322        }
     323}
     324
     325void BaseGui::remoteViewPlaylist(QString * output){
     326        qDebug("BaseGui::remoteViewPlaylist");
     327        *output += playlist->print("\t");
     328}
     329
     330void BaseGui::remoteViewStatus(QString * output){
     331        qDebug("BaseGui::remoteViewStatus");
     332        *output = core->stateToString();
     333}
     334
     335void BaseGui::remoteViewClipInfo(QString * output){
     336        qDebug("BaseGui::remoteViewClipInfo");
     337
     338        *output += QString("%1\t%2\r\n").arg("Filename", core->mdat.filename);
     339        *output += QString("%1\t%2\r\n").arg("Position", QString::number(core->mset.current_sec));
     340        *output += QString("%1\t%2\r\n").arg("Duration", QString::number(core->mdat.duration));
     341
     342        *output += QString("%1\t%2\r\n").arg("Title", core->mdat.clip_name);
     343        *output += QString("%1\t%2\r\n").arg("Artist", core->mdat.clip_artist);
     344        *output += QString("%1\t%2\r\n").arg("Author", core->mdat.clip_author);
     345        *output += QString("%1\t%2\r\n").arg("Album", core->mdat.clip_album);
     346        *output += QString("%1\t%2\r\n").arg("Genre", core->mdat.clip_genre);
     347        *output += QString("%1\t%2\r\n").arg("Date", core->mdat.clip_date);
     348        *output += QString("%1\t%2\r\n").arg("Track", core->mdat.clip_track);
     349        *output += QString("%1\t%2\r\n").arg("Copyright", core->mdat.clip_copyright);
     350        *output += QString("%1\t%2\r\n").arg("Comment", core->mdat.clip_comment);
     351        *output += QString("%1\t%2\r\n").arg("Software", core->mdat.clip_software);
     352}
     353
     354void BaseGui::remoteSeek(double sec){
     355        qDebug("BaseGui::remoteSeek");
     356        core->goToSec(sec);
     357}
     358
     359void BaseGui::remoteGetChecked(QString function, QString* output){
     360        qDebug("BaseGui::remoteGet");
     361
     362        QAction* action = ActionsEditor::findAction(this, function);
     363        if(! action) action = ActionsEditor::findAction(playlist, function);
     364        if(! action) return;
     365
     366        bool value = (action->isCheckable() ? action->isChecked() : action->isEnabled());
     367        *output = (value ? "true" : "false");
     368}
     369
     370void BaseGui::remoteGetVolume(int *vol){
     371        *vol = (pref->global_volume ? pref->volume : core->mset.volume);
    261372}
    262373
     
    512623             core, SLOT(toggleMirror(bool)) );
    513624
    514         motionVectorsAct = new MyAction( this, "motion_vectors" );
    515         motionVectorsAct->setCheckable( true );
    516         connect( motionVectorsAct, SIGNAL(toggled(bool)),
    517              core, SLOT(visualizeMotionVectors(bool)) );
    518 
    519625
    520626        // Submenu filter
     
    670776        connect( useAssAct, SIGNAL(toggled(bool)), core, SLOT(changeUseAss(bool)) );
    671777
    672         useClosedCaptionAct = new MyAction(this, "use_closed_caption");
    673         useClosedCaptionAct->setCheckable(true);
    674         connect( useClosedCaptionAct, SIGNAL(toggled(bool)), core, SLOT(toggleClosedCaption(bool)) );
    675 
    676778        useForcedSubsOnlyAct = new MyAction(this, "use_forced_subs_only");
    677779        useForcedSubsOnlyAct->setCheckable(true);
     
    726828        connect( showTipsAct, SIGNAL(triggered()),
    727829             this, SLOT(helpTips()) );
     830
     831        donateAct = new MyAction( this, "donate" );
     832        connect( donateAct, SIGNAL(triggered()),
     833             this, SLOT(helpDonate()) );
    728834
    729835        aboutQtAct = new MyAction( this, "about_qt" );
     
    10261132                 core, SLOT(changeSubtitle(int)) );
    10271133
     1134        ccGroup = new MyActionGroup(this);
     1135        ccNoneAct = new MyActionGroupItem(this, ccGroup, "cc_none", 0);
     1136        ccChannel1Act = new MyActionGroupItem(this, ccGroup, "cc_ch_1", 1);
     1137        ccChannel2Act = new MyActionGroupItem(this, ccGroup, "cc_ch_2", 2);
     1138        ccChannel3Act = new MyActionGroupItem(this, ccGroup, "cc_ch_3", 3);
     1139        ccChannel4Act = new MyActionGroupItem(this, ccGroup, "cc_ch_4", 4);
     1140        connect( ccGroup, SIGNAL(activated(int)),
     1141             core, SLOT(changeClosedCaptionChannel(int)) );
     1142
    10281143        // Titles
    10291144        titleGroup = new MyActionGroup(this);
     
    12781393#ifndef Q_OS_WIN
    12791394        // Disable video filters if using vdpau
    1280         if ((pref->disable_video_filters_with_vdpau) && (pref->vo.startsWith("vdpau"))) {
     1395        if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) {
    12811396                screenshotAct->setEnabled(false);
    12821397                screenshotsAct->setEnabled(false);
     
    14081523        flipAct->change( Images::icon("flip"), tr("Fli&p image") );
    14091524        mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") );
    1410         motionVectorsAct->change( Images::icon("motion_vectors"),
    1411                               tr("Visualize &motion vectors") );
    14121525
    14131526        decZoomAct->change( tr("Zoom &-") );
     
    14691582                           tr("N&ext line in subtitles") );
    14701583        useAssAct->change( Images::icon("use_ass_lib"), tr("Use SSA/&ASS library") );
    1471         useClosedCaptionAct->change( Images::icon("closed_caption"), tr("Enable &closed caption") );
    14721584        useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") );
    14731585
     
    14761588        showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles on &OpenSubtitles.org...") );
    14771589        openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") );
     1590
     1591        ccNoneAct->change( tr("&Off") );
     1592        ccChannel1Act->change( "&1" );
     1593        ccChannel2Act->change( "&2" );
     1594        ccChannel3Act->change( "&3" );
     1595        ccChannel4Act->change( "&4" );
    14781596
    14791597        // Menu Options
     
    14901608        showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") );
    14911609        showTipsAct->change( Images::icon("tips"), tr("&Tips") );
     1610        donateAct->change( Images::icon("donate"), tr("&Donate") );
    14921611        aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );
    14931612        aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") );
     
    16911810        subtitlestrack_menu->menuAction()->setIcon( Images::icon("sub") );
    16921811
     1812        closed_captions_menu->menuAction()->setText( tr("&Closed captions") );
     1813        closed_captions_menu->menuAction()->setIcon( Images::icon("closed_caption") );
     1814
    16931815        // Menu Browse
    16941816        titles_menu->menuAction()->setText( tr("&Title") );
     
    21812303        videoMenu->addSeparator();
    21822304        videoMenu->addAction(videoPreviewAct);
    2183         videoMenu->addSeparator();
    2184         videoMenu->addAction(motionVectorsAct);
    21852305
    21862306
     
    22412361        subtitlesMenu->addAction(unloadSubsAct);
    22422362        subtitlesMenu->addSeparator();
     2363
     2364        closed_captions_menu = new QMenu(this);
     2365        closed_captions_menu->menuAction()->setObjectName("closed_captions_menu");
     2366        closed_captions_menu->addAction( ccNoneAct);
     2367        closed_captions_menu->addAction( ccChannel1Act);
     2368        closed_captions_menu->addAction( ccChannel2Act);
     2369        closed_captions_menu->addAction( ccChannel3Act);
     2370        closed_captions_menu->addAction( ccChannel4Act);
     2371        subtitlesMenu->addMenu(closed_captions_menu);
     2372        subtitlesMenu->addSeparator();
     2373
    22432374        subtitlesMenu->addAction(decSubDelayAct);
    22442375        subtitlesMenu->addAction(incSubDelayAct);
     
    22552386        subtitlesMenu->addAction(incSubStepAct);
    22562387        subtitlesMenu->addSeparator();
    2257         subtitlesMenu->addAction(useClosedCaptionAct);
    22582388        subtitlesMenu->addAction(useForcedSubsOnlyAct);
    22592389        subtitlesMenu->addSeparator();
     
    23292459        helpMenu->addAction(showCLOptionsAct);
    23302460        helpMenu->addAction(showTipsAct);
     2461        helpMenu->addAction(donateAct);
    23312462        helpMenu->addSeparator();
    23322463        helpMenu->addAction(aboutQtAct);
     
    24402571        pref_dialog->mod_input()->actions_editor->addActions(playlist);
    24412572#endif
     2573
     2574        // Set playlist preferences
     2575        PrefPlaylist * pl = pref_dialog->mod_playlist();
     2576        pl->setDirectoryRecursion(playlist->directoryRecursion());
     2577        pl->setAutoGetInfo(playlist->autoGetInfo());
     2578        pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit());
     2579        pl->setPlayFilesFromStart(playlist->playFilesFromStart());
     2580
    24422581        pref_dialog->show();
    24432582}
     
    25162655        }
    25172656
     2657        // Update playlist preferences
     2658        PrefPlaylist * pl = pref_dialog->mod_playlist();
     2659        playlist->setDirectoryRecursion(pl->directoryRecursion());
     2660        playlist->setAutoGetInfo(pl->autoGetInfo());
     2661        playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit());
     2662        playlist->setPlayFilesFromStart(pl->playFilesFromStart());
     2663
     2664
    25182665        if (need_update_language) {
    25192666                translator->load(pref->language);
     
    26472794        }
    26482795
    2649         setWindowCaption( core->mdat.displayName() + " - SMPlayer" );
     2796        setWindowCaption( core->mdat.displayName(pref->show_tag_in_window_title) + " - SMPlayer" );
    26502797
    26512798        emit videoInfoChanged(core->mdat.video_width, core->mdat.video_height, core->mdat.video_fps.toDouble());
     
    29613108        // Disable the unload subs action if there's no external subtitles
    29623109        unloadSubsAct->setEnabled( !core->mset.external_subtitles.isEmpty() );
     3110
     3111        // Closed caption menu
     3112        ccGroup->setChecked( core->mset.closed_caption_channel );
    29633113       
    29643114        // Audio menu
     
    30843234#endif
    30853235
    3086         // Motion vectors
    3087         motionVectorsAct->setChecked( pref->show_motion_vectors );
    3088 
    30893236        // Compact mode
    30903237        compactAct->setChecked( pref->compact_mode );
     
    31023249        useAssAct->setChecked( pref->use_ass_subtitles );
    31033250
    3104         // Closed caption and forces subs
    3105         useClosedCaptionAct->setChecked( pref->use_closed_caption_subs );
     3251        // Forced subs
    31063252        useForcedSubsOnlyAct->setChecked( pref->use_forced_subs_only );
    31073253
     
    31133259              (core->mset.current_sub_id != MediaSettings::NoneSelected));
    31143260
    3115         if (pref->use_closed_caption_subs) e = true; // Enable if using closed captions
     3261        if (core->mset.closed_caption_channel !=0 ) e = true; // Enable if using closed captions
    31163262
    31173263        decSubDelayAct->setEnabled(e);
     
    35143660
    35153661void BaseGui::helpTips() {
    3516         QDesktopServices::openUrl( QUrl("http://smplayer.berlios.de/forum/viewforum.php?f=12") );
     3662        QDesktopServices::openUrl( QUrl("http://smplayer.sf.net/forum/viewforum.php?f=12") );
     3663}
     3664
     3665void BaseGui::helpDonate() {
     3666        QMessageBox d(QMessageBox::NoIcon, tr("Donate"),
     3667                tr("If you like SMPlayer, a really good way to support it is by sending a donation, even the smallest one is highly appreciated.") + "<br>" +
     3668        tr("You can send your donation using %1.").arg("<a href=\"https://sourceforge.net/donate/index.php?group_id=185512\">"+tr("this form")),
     3669                QMessageBox::Ok, this);
     3670        d.setIconPixmap( Images::icon("logo", 64) );
     3671        d.exec();
    35173672}
    35183673
     
    36033758
    36043759                #ifdef Q_OS_WIN
    3605                 // Avoid the video to pause
    3606                 if (!pref->pause_when_hidden) hide();
     3760                // Hack to avoid the windows taskbar to be visible on Windows XP
     3761                if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
     3762                        if (!pref->pause_when_hidden) hide();
     3763                }
    36073764                #endif
    36083765
     
    36103767
    36113768        } else {
    3612                 #ifdef Q_OS_WIN
    3613                 // Avoid the video to pause
    3614                 if (!pref->pause_when_hidden) hide();
    3615                 #endif
    3616 
    36173769                showNormal();
    36183770
     
    37073859        qDebug("BaseGui::processFunction: '%s'", function.toUtf8().data());
    37083860
     3861        //parse args for checkable actions
     3862        QRegExp func_rx("(.*) (true|false)");
     3863        bool value = false;
     3864        bool checkableFunction = false;
     3865
     3866        if(func_rx.indexIn(function) > -1){
     3867                function = func_rx.cap(1);
     3868                value = (func_rx.cap(2) == "true");
     3869                checkableFunction = true;
     3870        } //end if
     3871
    37093872        QAction * action = ActionsEditor::findAction(this, function);
    37103873        if (!action) action = ActionsEditor::findAction(playlist, function);
     
    37123875        if (action) {
    37133876                qDebug("BaseGui::processFunction: action found");
    3714                 if (action->isCheckable())
    3715                         //action->toggle();
     3877
     3878                if (!action->isEnabled()) {
     3879                        qDebug("BaseGui::processFunction: action is disabled, doing nothing");
     3880                        return;
     3881                }
     3882
     3883                if (action->isCheckable()){
     3884                        if(checkableFunction)
     3885                                action->setChecked(value);
     3886                        else
     3887                                //action->toggle();
     3888                                action->trigger();
     3889                }else{
    37163890                        action->trigger();
    3717                 else
    3718                         action->trigger();
     3891                }
    37193892        }
    37203893}
     
    37263899
    37273900        QAction * action;
    3728         QStringList l = actions.split(" ");
    3729 
    3730         for (int n = 0; n < l.count(); n++) {
    3731                 QString a = l[n];
    3732                 QString par = "";
    3733 
    3734                 if ( (n+1) < l.count() ) {
    3735                         if ( (l[n+1].toLower() == "true") || (l[n+1].toLower() == "false") ) {
    3736                                 par = l[n+1].toLower();
     3901        QStringList actionsList = actions.split(" ");
     3902
     3903        for (int n = 0; n < actionsList.count(); n++) {
     3904                QString actionStr = actionsList[n];
     3905                QString par = ""; //the parameter which the action takes
     3906
     3907                //set par if the next word is a boolean value
     3908                if ( (n+1) < actionsList.count() ) {
     3909                        if ( (actionsList[n+1].toLower() == "true") || (actionsList[n+1].toLower() == "false") ) {
     3910                                par = actionsList[n+1].toLower();
    37373911                                n++;
    3738                         }
    3739                 }
    3740 
    3741                 action = ActionsEditor::findAction(this, a);
    3742                 if (!action) action = ActionsEditor::findAction(playlist, a);
     3912                        } //end if
     3913                } //end if
     3914
     3915                action = ActionsEditor::findAction(this, actionStr);
     3916                if (!action) action = ActionsEditor::findAction(playlist, actionStr);
    37433917
    37443918                if (action) {
    37453919                        qDebug("BaseGui::runActions: running action: '%s' (par: '%s')",
    3746                    a.toUtf8().data(), par.toUtf8().data() );
     3920                                   actionStr.toUtf8().data(), par.toUtf8().data() );
    37473921
    37483922                        if (action->isCheckable()) {
     
    37523926                                } else {
    37533927                                        action->setChecked( (par == "true") );
    3754                                 }
    3755                         }
    3756                         else {
     3928                                } //end if
     3929                        } else {
    37573930                                action->trigger();
    3758                         }
     3931                        } //end if
    37593932                } else {
    3760                         qWarning("BaseGui::runActions: action: '%s' not found",a.toUtf8().data());
    3761                 }
    3762         }
     3933                        qWarning("BaseGui::runActions: action: '%s' not found",actionStr.toUtf8().data());
     3934                } //end if
     3935        } //end for
    37633936}
    37643937
     
    39834156        if (state == Core::Stopped) setWindowCaption( "SMPlayer" );
    39844157
    3985 #ifdef Q_OS_WIN
     4158#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    39864159        /* Disable screensaver by event */
    39874160        just_stopped = false;
     
    44984671        return false;
    44994672}
    4500 
     4673#endif
     4674
     4675#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    45014676void BaseGui::clear_just_stopped() {
    45024677        qDebug("BaseGui::clear_just_stopped");
Note: See TracChangeset for help on using the changeset viewer.