Ignore:
Timestamp:
Mar 15, 2012, 5:14:10 PM (13 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer 0.7.1: vendor update

File:
1 edited

Legend:

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

    r118 r121  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org>
     2    Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    102102using namespace Global;
    103103
    104 BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
     104BaseGui::BaseGui( bool use_server, QWidget* parent, Qt::WindowFlags flags )
    105105        : QMainWindow( parent, flags ),
    106106                near_top(false),
     
    115115        arg_close_on_finish = -1;
    116116        arg_start_in_fullscreen = -1;
     117        use_control_server = use_server;
    117118
    118119        setWindowTitle( "SMPlayer" );
     
    200201
    201202        // Single instance
    202         server = new MyServer(this);
    203         connect(server, SIGNAL(receivedOpen(QString)),
    204             this, SLOT(remoteOpen(QString)));
    205         connect(server, SIGNAL(receivedOpenFiles(QStringList)),
    206             this, SLOT(remoteOpenFiles(QStringList)));
    207         connect(server, SIGNAL(receivedAddFiles(QStringList)),
    208             this, SLOT(remoteAddFiles(QStringList)));
    209         connect(server, SIGNAL(receivedFunction(QString)),
    210             this, SLOT(processFunction(QString)));     
    211         connect(server, SIGNAL(receivedLoadSubtitle(QString)), 
    212             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)));
    233 
    234         if (pref->use_single_instance) {
    235                 int port = 0;
    236                 if (!pref->use_autoport) port = pref->connection_port;
    237                 if (server->listen(port)) {
    238                         pref->autoport = server->serverPort();
    239                         pref->save();
    240                         qDebug("BaseGui::initializeGui: server running on port %d", pref->autoport);
    241                 } else {
    242                         qWarning("BaseGui::initializeGui: server couldn't be started");
     203        if (use_control_server) {
     204                server = new MyServer(this);
     205                connect(server, SIGNAL(receivedOpen(QString)),
     206                    this, SLOT(remoteOpen(QString)));
     207                connect(server, SIGNAL(receivedOpenFiles(QStringList)),
     208                    this, SLOT(remoteOpenFiles(QStringList)));
     209                connect(server, SIGNAL(receivedAddFiles(QStringList)),
     210                    this, SLOT(remoteAddFiles(QStringList)));
     211                connect(server, SIGNAL(receivedFunction(QString)),
     212                    this, SLOT(processFunction(QString)));     
     213                connect(server, SIGNAL(receivedLoadSubtitle(QString)), 
     214                    this, SLOT(remoteLoadSubtitle(QString)));
     215                connect(server, SIGNAL(receivedPlayItem(int)),
     216                                this, SLOT(remotePlayItem(int)));
     217                connect(server, SIGNAL(receivedRemoveItem(int)),
     218                                this, SLOT(remoteRemoveItem(int)));
     219                connect(server, SIGNAL(receivedViewPlaylist(QString*)),
     220                                this, SLOT(remoteViewPlaylist(QString*)));
     221                connect(server, SIGNAL(receivedViewStatus(QString*)),
     222                                this, SLOT(remoteViewStatus(QString*)));
     223                connect(server, SIGNAL(receivedViewClipInfo(QString*)),
     224                                this, SLOT(remoteViewClipInfo(QString*)));
     225                connect(server, SIGNAL(receivedSeek(double)),
     226                                this, SLOT(remoteSeek(double)));
     227                connect(server, SIGNAL(receivedGetChecked(QString,QString*)),
     228                                this, SLOT(remoteGetChecked(QString,QString*)));
     229                connect(server, SIGNAL(receivedMoveItem(int,int)),
     230                                this, SLOT(remoteMoveItem(int,int)));
     231                connect(server, SIGNAL(receivedGetVolume(int*)),
     232                                this, SLOT(remoteGetVolume(int*)));
     233                connect(server, SIGNAL(receivedSetVolume(int)),
     234                                core, SLOT(setVolume(int)));
     235
     236                if (pref->use_single_instance) {
     237                        int port = 0;
     238                        if (!pref->use_autoport) port = pref->connection_port;
     239                        if (server->listen(port)) {
     240                                pref->autoport = server->serverPort();
     241                                pref->save();
     242                                qDebug("BaseGui::initializeGui: server running on port %d", pref->autoport);
     243                        } else {
     244                                qWarning("BaseGui::initializeGui: server couldn't be started");
     245                        }
    243246                }
    244247        }
     
    377380        delete smplayer_log_window;
    378381
     382        delete favorites;
    379383        delete tvlist;
    380384        delete radiolist;
     
    443447        connect( clearRecentsAct, SIGNAL(triggered()), this, SLOT(clearRecentsList()) );
    444448
     449        // Favorites
     450        favorites = new Favorites(Paths::configPath() + "/favorites.m3u8", this);
     451        favorites->menuAction()->setObjectName( "favorites_menu" );
     452        addAction(favorites->editAct());
     453        addAction(favorites->jumpAct());
     454        addAction(favorites->nextAct());
     455        addAction(favorites->previousAct());
     456        connect(favorites, SIGNAL(activated(QString)), this, SLOT(openFavorite(QString)));
     457        connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
     458            favorites, SLOT(getCurrentMedia(const QString &, const QString &)));
     459
    445460        // TV and Radio
    446461        tvlist = new TVList(pref->check_channels_conf_on_startup,
    447462                        TVList::TV, Paths::configPath() + "/tv.m3u8", this);
    448         tvlist->menu()->menuAction()->setObjectName( "tv_menu" );
     463        tvlist->menuAction()->setObjectName( "tv_menu" );
    449464        addAction(tvlist->editAct());
    450465        addAction(tvlist->jumpAct());
     
    458473        tvlist->jumpAct()->setObjectName("jump_tv_list");
    459474        connect(tvlist, SIGNAL(activated(QString)), this, SLOT(open(QString)));
     475        connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
     476            tvlist, SLOT(getCurrentMedia(const QString &, const QString &)));
    460477
    461478        radiolist = new TVList(pref->check_channels_conf_on_startup,
    462479                           TVList::Radio, Paths::configPath() + "/radio.m3u8", this);
    463         radiolist->menu()->menuAction()->setObjectName( "radio_menu" );
     480        radiolist->menuAction()->setObjectName( "radio_menu" );
    464481        addAction(radiolist->editAct());
    465482        addAction(radiolist->jumpAct());
     
    473490        radiolist->jumpAct()->setObjectName("jump_radio_list");
    474491        connect(radiolist, SIGNAL(activated(QString)), this, SLOT(open(QString)));
     492        connect(core, SIGNAL(mediaPlaying(const QString &, const QString &)),
     493            radiolist, SLOT(getCurrentMedia(const QString &, const QString &)));
    475494
    476495
     
    807826             this, SLOT(showPreferencesDialog()) );
    808827
     828        showTubeBrowserAct = new MyAction( Qt::Key_F11, this, "show_tube_browser" );
     829        connect( showTubeBrowserAct, SIGNAL(triggered()),
     830             this, SLOT(showTubeBrowser()) );
     831
    809832        // Submenu Logs
    810833        showLogMplayerAct = new MyAction( QKeySequence("Ctrl+M"), this, "show_mplayer_log" );
     
    825848             this, SLOT(helpCLOptions()) );
    826849
    827         showTipsAct = new MyAction( this, "tips" );
    828         connect( showTipsAct, SIGNAL(triggered()),
    829              this, SLOT(helpTips()) );
     850        showCheckUpdatesAct = new MyAction( this, "check_updates" );
     851        connect( showCheckUpdatesAct, SIGNAL(triggered()),
     852             this, SLOT(helpCheckUpdates()) );
    830853
    831854        donateAct = new MyAction( this, "donate" );
     
    14631486        exitAct->change( Images::icon("close"), tr("C&lose") );
    14641487
     1488        // Favorites
     1489        /*
     1490        favorites->editAct()->setText( tr("&Edit...") );
     1491        favorites->addCurrentAct()->setText( tr("&Add current media") );
     1492        */
     1493
    14651494        // TV & Radio submenus
     1495        /*
    14661496        tvlist->editAct()->setText( tr("&Edit...") );
    14671497        radiolist->editAct()->setText( tr("&Edit...") );
     1498        tvlist->addCurrentAct()->setText( tr("&Add current media") );
     1499        radiolist->addCurrentAct()->setText( tr("&Add current media") );
    14681500        tvlist->jumpAct()->setText( tr("&Jump...") );
    14691501        radiolist->jumpAct()->setText( tr("&Jump...") );
     
    14721504        radiolist->nextAct()->setText( tr("Next radio channel") );
    14731505        radiolist->previousAct()->setText( tr("Previous radio channel") );
    1474 
     1506        */
    14751507
    14761508        // Menu Play
     
    15991631        showPropertiesAct->change( Images::icon("info"), tr("View &info and properties...") );
    16001632        showPreferencesAct->change( Images::icon("prefs"), tr("P&references") );
     1633        showTubeBrowserAct->change( Images::icon("tubebrowser"), tr("&YouTube browser") );
    16011634
    16021635        // Submenu Logs
     
    16071640        showFAQAct->change( Images::icon("faq"), tr("&FAQ") );
    16081641        showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") );
    1609         showTipsAct->change( Images::icon("tips"), tr("&Tips") );
     1642        showCheckUpdatesAct->change( Images::icon("check_updates"), tr("Check for &updates") );
    16101643        donateAct->change( Images::icon("donate"), tr("&Donate") );
    16111644        aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );
     
    16941727        clearRecentsAct->change( Images::icon("delete"), tr("&Clear") );
    16951728
    1696         tvlist->menu()->menuAction()->setText( tr("&TV") );
    1697         tvlist->menu()->menuAction()->setIcon( Images::icon("open_tv") );
    1698 
    1699         radiolist->menu()->menuAction()->setText( tr("Radi&o") );
    1700         radiolist->menu()->menuAction()->setIcon( Images::icon("open_radio") );
     1729        disc_menu->menuAction()->setText( tr("&Disc") );
     1730        disc_menu->menuAction()->setIcon( Images::icon("open_disc") );
     1731
     1732        /* favorites->menuAction()->setText( tr("&Favorites") ); */
     1733        favorites->menuAction()->setText( tr("F&avorites") );
     1734        favorites->menuAction()->setIcon( Images::icon("open_favorites") );
     1735
     1736        tvlist->menuAction()->setText( tr("&TV") );
     1737        tvlist->menuAction()->setIcon( Images::icon("open_tv") );
     1738
     1739        radiolist->menuAction()->setText( tr("Radi&o") );
     1740        radiolist->menuAction()->setIcon( Images::icon("open_radio") );
    17011741
    17021742        // Menu Play
     
    19672007
    19682008        // Hide mplayer window
    1969         connect( core, SIGNAL(noVideo()),
    1970              this, SLOT(hidePanel()) );
     2009#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
     2010        if (pref->hide_video_window_on_audio_files) {
     2011                connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
     2012        } else {
     2013                connect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(showLogo()) );
     2014        }
     2015#else
     2016        connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
     2017#endif
    19712018
    19722019        // Log mplayer output
     
    21222169        audioMenu = menuBar()->addMenu("Audio");
    21232170        subtitlesMenu = menuBar()->addMenu("Subtitles");
    2124         browseMenu = menuBar()->addMenu("Browwse");
     2171        /* menuBar()->addMenu(favorites); */
     2172        browseMenu = menuBar()->addMenu("Browse");
    21252173        optionsMenu = menuBar()->addMenu("Options");
    21262174        helpMenu = menuBar()->addMenu("Help");
     
    21342182
    21352183        openMenu->addMenu( recentfiles_menu );
    2136 
     2184        openMenu->addMenu(favorites);
    21372185        openMenu->addAction(openDirectoryAct);
    21382186        openMenu->addAction(openPlaylistAct);
    2139         openMenu->addAction(openDVDAct);
    2140         openMenu->addAction(openDVDFolderAct);
    2141         openMenu->addAction(openVCDAct);
    2142         openMenu->addAction(openAudioCDAct);
     2187
     2188        // Disc submenu
     2189        disc_menu = new QMenu(this);
     2190        disc_menu->menuAction()->setObjectName("disc_menu");
     2191        disc_menu->addAction(openDVDAct);
     2192        disc_menu->addAction(openDVDFolderAct);
     2193        disc_menu->addAction(openVCDAct);
     2194        disc_menu->addAction(openAudioCDAct);
     2195
     2196        openMenu->addMenu(disc_menu);
     2197
    21432198        openMenu->addAction(openURLAct);
    2144         openMenu->addMenu(tvlist->menu());
    2145         openMenu->addMenu(radiolist->menu());
    2146 
     2199/* #ifndef Q_OS_WIN */
     2200        openMenu->addMenu(tvlist);
     2201        openMenu->addMenu(radiolist);
     2202/* #endif */
    21472203        openMenu->addSeparator();
    21482204        openMenu->addAction(exitAct);
     
    24322488        optionsMenu->addAction(showPropertiesAct);
    24332489        optionsMenu->addAction(showPlaylistAct);
     2490        // Check if the smplayer youtube browser is installed
     2491        {
     2492                QString tube_exec = Paths::appPath() + "/smtube";
     2493                #ifdef Q_OS_WIN
     2494                tube_exec += ".exe";
     2495                #endif
     2496                if (QFile::exists(tube_exec)) {
     2497                        optionsMenu->addAction(showTubeBrowserAct);
     2498                        qDebug("BaseGui::createMenus: %s does exist", tube_exec.toUtf8().constData());
     2499                } else {
     2500                        qDebug("BaseGui::createMenus: %s does not exist", tube_exec.toUtf8().constData());
     2501                }
     2502        }
    24342503
    24352504        // OSD submenu
     
    24582527        helpMenu->addAction(showFAQAct);
    24592528        helpMenu->addAction(showCLOptionsAct);
    2460         helpMenu->addAction(showTipsAct);
     2529        helpMenu->addAction(showCheckUpdatesAct);
    24612530        helpMenu->addAction(donateAct);
    24622531        helpMenu->addSeparator();
     
    24752544        popup->addMenu( audioMenu );
    24762545        popup->addMenu( subtitlesMenu );
     2546        popup->addMenu( favorites );
    24772547        popup->addMenu( browseMenu );
    24782548        popup->addMenu( optionsMenu );
     
    25792649        pl->setPlayFilesFromStart(playlist->playFilesFromStart());
    25802650
     2651        PrefInterface * pi = pref_dialog->mod_interface();
     2652        pi->setSingleInstanceTabEnabled( use_control_server );
     2653
    25812654        pref_dialog->show();
    25822655}
     
    26172690        }
    26182691
    2619         if (!pref->use_single_instance && server->isListening()) {
    2620                 server->close();
    2621                 qDebug("BaseGui::applyNewPreferences: server closed");
    2622         }
    2623         else
    2624         {
    2625                 bool server_requires_restart = _interface->serverPortChanged();
    2626                 if (pref->use_single_instance && !server->isListening())
    2627                         server_requires_restart=true;
    2628 
    2629                 if (server_requires_restart) {
     2692        if (use_control_server) {
     2693                if (!pref->use_single_instance && server->isListening()) {
    26302694                        server->close();
    2631                         int port = 0;
    2632                         if (!pref->use_autoport) port = pref->connection_port;
    2633                         if (server->listen(port)) {
    2634                                 pref->autoport = server->serverPort();
    2635                                 qDebug("BaseGui::applyNewPreferences: server running on port %d", pref->autoport);
    2636                         } else {
    2637                                 qWarning("BaseGui::applyNewPreferences: server couldn't be started");
     2695                        qDebug("BaseGui::applyNewPreferences: server closed");
     2696                }
     2697                else
     2698                {
     2699                        bool server_requires_restart = _interface->serverPortChanged();
     2700                        if (pref->use_single_instance && !server->isListening())
     2701                                server_requires_restart=true;
     2702
     2703                        if (server_requires_restart) {
     2704                                server->close();
     2705                                int port = 0;
     2706                                if (!pref->use_autoport) port = pref->connection_port;
     2707                                if (server->listen(port)) {
     2708                                        pref->autoport = server->serverPort();
     2709                                        qDebug("BaseGui::applyNewPreferences: server running on port %d", pref->autoport);
     2710                                } else {
     2711                                        qWarning("BaseGui::applyNewPreferences: server couldn't be started");
     2712                                }
    26382713                        }
    26392714                }
    26402715        }
     2716
     2717#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
     2718        if (pref->hide_video_window_on_audio_files) {
     2719                connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
     2720                disconnect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(hideLogo()) );
     2721        } else {
     2722                disconnect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) );
     2723                connect( core, SIGNAL(noVideo()), mplayerwindow, SLOT(showLogo()) );
     2724                if (!panel->isVisible()) {
     2725                        resize( width(), height() + 200);
     2726                        panel->show();
     2727                }
     2728        }
     2729#endif
    26412730
    26422731        PrefAdvanced *advanced = pref_dialog->mod_advanced();
     
    33813470}
    33823471
     3472void BaseGui::openFavorite(QString file) {
     3473        qDebug("BaseGui::openFavorite");
     3474
     3475        openFiles(QStringList() << file);
     3476}
     3477
    33833478void BaseGui::openURL() {
    33843479        qDebug("BaseGui::openURL");
     
    34063501
    34073502        for (int n=0; n < pref->history_urls->count(); n++) {
    3408                 d.setURL( pref->history_urls->url(n), pref->history_urls->isPlaylist(n) );
     3503                d.setURL( pref->history_urls->url(n) );
    34093504        }
    34103505
    34113506        if (d.exec() == QDialog::Accepted ) {
    34123507                QString url = d.url();
    3413                 bool is_playlist = d.isPlaylist();
    34143508                if (!url.isEmpty()) {
    3415                         pref->history_urls->addUrl(url, is_playlist);
    3416                         if (is_playlist) url = url + IS_PLAYLIST_TAG;
     3509                        pref->history_urls->addUrl(url);
    34173510                        openURL(url);
    34183511                }
     
    36593752}
    36603753
    3661 void BaseGui::helpTips() {
    3662         QDesktopServices::openUrl( QUrl("http://smplayer.sf.net/forum/viewforum.php?f=12") );
     3754void BaseGui::helpCheckUpdates() {
     3755        QString url = "http://smplayer.sourceforge.net/latest.php";
     3756        if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language);
     3757        QDesktopServices::openUrl( QUrl(url) );
    36633758}
    36643759
     
    42484343        qDebug("BaseGui::hidePanel");
    42494344
    4250 #if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
    4251         if (!pref->hide_video_window_on_audio_files) {
    4252                 mplayerwindow->showLogo(true);
    4253         }
    4254         else
    4255 #endif
    4256 
    42574345        if (panel->isVisible()) {
    42584346                // Exit from fullscreen mode
     
    44814569#endif
    44824570
    4483         //if (server)
    4484                 server->setActionsList( actions_list );
     4571        if (server) server->setActionsList( actions_list );
    44854572}
    44864573
     
    46304717                video_preview->show();
    46314718                video_preview->adjustWindowSize();
     4719        }
     4720}
     4721
     4722void BaseGui::showTubeBrowser() {
     4723        qDebug("BaseGui::showTubeBrowser");
     4724        if (!QProcess::startDetached("smtube", QStringList())) {
     4725                QMessageBox::warning(this, tr("An error happened - SMPlayer"), tr("The YouTube Browser couldn't be launched"));
    46324726        }
    46334727}
Note: See TracChangeset for help on using the changeset viewer.