⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contextbrowser.cpp

📁 Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 经过两年开发后
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        }        if ( url.protocol() == "album" )        {            urls = expandURL( url );            menu.changeTitle( TITLE, i18n("Album") );            menu.changeItem( INFO,   i18n("Edit Album &Information..." ) );            menu.changeItem( ASNEXT, i18n("&Queue Album") );        }        if ( url.protocol() == "albumdisc" )        {            urls = expandURL( url );            menu.changeTitle( TITLE, i18n("Album Disc") );            menu.changeItem( INFO,   i18n("Edit Album Disc &Information..." ) );            menu.changeItem( ASNEXT, i18n("&Queue Album Disc") );        }        if ( url.protocol() == "compilation" )        {            urls = expandURL( url );            menu.changeTitle( TITLE, i18n("Compilation") );            menu.changeItem( INFO,   i18n("Edit Album &Information..." ) );            menu.changeItem( ASNEXT, i18n("&Queue Album") );        }        if ( url.protocol() == "compilationdisc" )        {            urls = expandURL( url );            menu.changeTitle( TITLE, i18n("Compilation Disc") );            menu.changeItem( INFO,   i18n("Edit Compilation Disc &Information..." ) );            menu.changeItem( ASNEXT, i18n("&Queue Compilation Disc") );        }        if( urls.count() == 0 )        {            menu.setItemEnabled( MAKE, false );            menu.setItemEnabled( APPEND, false );            menu.setItemEnabled( ASNEXT, false );            menu.setItemEnabled( MEDIA_DEVICE, false );            menu.setItemEnabled( INFO, false );        }    }    //Not all these are used in the menu, it depends on the context    switch( menu.exec( point ) )    {    case RELATED:        m_showRelated = !menu.isItemChecked( RELATED );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowRelated", m_showRelated );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;    case SUGGEST:        m_showSuggested = !menu.isItemChecked( SUGGEST );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowSuggested", m_showSuggested );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;    case FAVES:        m_showFaves = !menu.isItemChecked( FAVES );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowFaves", m_showFaves );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;   case LABELS:        m_showLabels = !menu.isItemChecked( LABELS );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowLabels", m_showLabels );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;   case FRESHPODCASTS:        m_showFreshPodcasts = !menu.isItemChecked( FRESHPODCASTS );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowFreshPodcasts", m_showFreshPodcasts );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;   case NEWALBUMS:        m_showNewestAlbums = !menu.isItemChecked( NEWALBUMS );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowNewestAlbums", m_showNewestAlbums );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;   case FAVALBUMS:        m_showFavoriteAlbums = !menu.isItemChecked( FAVALBUMS );        Amarok::config( "ContextBrowser" )->writeEntry( "ShowFavoriteAlbums", m_showFavoriteAlbums );        m_dirtyCurrentTrackPage = true;        showCurrentTrack();        break;    case ASNEXT:        Playlist::instance()->insertMedia( urls, Playlist::Queue );        break;    case INFO:    {        if ( urls.count() > 1 )        {            TagDialog* dialog = new TagDialog( urls, instance() );            dialog->show();        }        else if ( !urls.isEmpty() )        {            TagDialog* dialog = new TagDialog( urls.first(), instance() );            dialog->show();        }        break;    }    case MAKE:        Playlist::instance()->clear();        //FALL_THROUGH    case APPEND:        Playlist::instance()->insertMedia( urls, Playlist::Append );        break;    case MEDIA_DEVICE:        MediaBrowser::queue()->addURLs( urls );        break;    }}//////////////////////////////////////////////////////////////////////////////////////////// Current-Tab///////////////////////////////////////////////////////////////////////////////////////////** This is the slowest part of track change, so we thread it */class CurrentTrackJob : public ThreadManager::DependentJob{public:    CurrentTrackJob( ContextBrowser *parent )        : ThreadManager::DependentJob( parent, "CurrentTrackJob" )        , b( parent )        , m_currentTrack( QDeepCopy<MetaBundle>( EngineController::instance()->bundle() ) )        , m_isStream( EngineController::engine()->isStream() )    {        for( QStringList::iterator it = b->m_metadataHistory.begin();                it != b->m_metadataHistory.end();                ++it )        {            m_metadataHistory += QDeepCopy<QString>( *it );        }        m_amarokIconPath = QDeepCopy<QString>(KGlobal::iconLoader()->iconPath( "amarok",                    -KIcon::SizeEnormous ) );        m_musicBrainIconPath = QDeepCopy<QString>(locate( "data", "amarok/images/musicbrainz.png" )                );        m_lastfmIcon = "file://" + locate( "data","amarok/images/lastfm.png" );    }private:    virtual bool doJob();    void addMetaHistory();    void showLastFm( const MetaBundle &currentTrack );    void showStream( const MetaBundle &currentTrack );    void showPodcast( const MetaBundle &currentTrack );    void showBrowseArtistHeader( const QString &artist );    void showBrowseLabelHeader( const QString &label );    void showCurrentArtistHeader( const MetaBundle &currentTrack );    void showRelatedArtists( const QString &artist, const QStringList &relArtists );    void showSuggestedSongs( const QStringList &relArtists );    void showSongsWithLabel( const QString &label );    void showArtistsFaves( const QString &artistName, uint artist_id );    void showArtistsAlbums( const QString &artist, uint artist_id, uint album_id );    void showArtistsCompilations( const QString &artist, uint artist_id, uint album_id );    void showHome();    void showUserLabels( const MetaBundle &currentTrack );    QString fetchLastfmImage( const QString& url );    QStringList showHomeByAlbums();    void constructHTMLAlbums( const QStringList &albums, QString &htmlCode, const QString &idPrefix );    static QString statsHTML( int score, int rating, bool statsbox = true ); // meh.    virtual void completeJob()    {        // are we still showing the currentTrack page?//         if( b->currentPage() != b->m_contextTab )//             return;        b->m_shownAlbums.clear();        for( QStringList::iterator it = m_shownAlbums.begin();                it != m_shownAlbums.end();                ++it )            b->m_shownAlbums.append( QDeepCopy<QString>( *it ) );        b->m_HTMLSource = QDeepCopy<QString>( m_HTMLSource );        b->m_currentTrackPage->set( m_HTMLSource );        b->m_dirtyCurrentTrackPage = false;        b->saveHtmlData(); // Send html code to file    }    QString m_HTMLSource;    QString m_amarokIconPath;    QString m_musicBrainIconPath;    QString m_lastfmIcon;    ContextBrowser *b;    MetaBundle m_currentTrack;    bool m_isStream;    QStringList m_shownAlbums;    QStringList m_metadataHistory;};voidContextBrowser::showContext( const KURL &url, bool fromHistory ){    if ( currentPage() != m_contextTab )    {        blockSignals( true );        showPage( m_contextTab );        blockSignals( false );    }    m_dirtyCurrentTrackPage = true;    m_contextURL = url.url();    if( url.protocol() == "current" )    {        m_browseArtists = false;        m_browseLabels = false;        m_label = QString::null;        m_artist = QString::null;        m_contextBackHistory.clear();        m_contextBackHistory.push_back( "current://track" );    }    else if( url.protocol() == "artist" )    {        m_browseArtists = true;        m_browseLabels = false;        m_label = QString::null;        m_artist = unescapeHTMLAttr( url.path() );    }    else if( url.protocol() == "showlabel" )    {        m_browseLabels = true;        m_browseArtists = false;        m_artist = QString::null;        m_label = unescapeHTMLAttr( url.path() );    }    // Append new URL to history    if ( !fromHistory ) {        m_contextBackHistory += m_contextURL.url();    }    // Limit number of items in history    if ( m_contextBackHistory.count() > CONTEXT_MAX_HISTORY )        m_contextBackHistory.pop_front();    showCurrentTrack();}voidContextBrowser::contextHistoryBack() //SLOT{    if( m_contextBackHistory.size() > 0 )    {        m_contextBackHistory.pop_back();        m_dirtyCurrentTrackPage = true;        showContext( KURL( m_contextBackHistory.last() ), true );    }}void ContextBrowser::showCurrentTrack() //SLOT{#if 0    if( BrowserBar::instance()->currentBrowser() != this )    {        debug() << "current browser is not context, aborting showCurrentTrack()" << endl;        m_dirtyCurrentTrackPage = true;        m_currentTrackPage->set( QString( "<html><body><div class='box-body'>%1</div></body></html>" )                                 .arg( i18n( "Updating..." ) ) );        return;    }#endif    if ( currentPage() != m_contextTab ) {        blockSignals( true );        showPage( m_contextTab );        blockSignals( false );    }    // TODO: Show CurrentTrack or Lyric tab if they were selected    // If it's not a streaming, check for a collection    if ( !EngineController::engine()->isStream() )    {        if ( m_emptyDB && CollectionDB::instance()->isValid() && !MountPointManager::instance()->collectionFolders().isEmpty() )        {            showScanning();            return;        }        else if ( CollectionDB::instance()->isEmpty() || !CollectionDB::instance()->isValid() )        {            showIntroduction();            return;        }    }    if( !m_dirtyCurrentTrackPage )        return;    m_currentURL = EngineController::instance()->bundle().url();    m_currentTrackPage->write( QString::null );    ThreadManager::instance()->onlyOneJob( new CurrentTrackJob( this ) );}//////////////////////////////////////////////////////////////////////////////////////////// Shows the statistics summary when no track is playing//////////////////////////////////////////////////////////////////////////////////////////void CurrentTrackJob::showHome()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -