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

📄 contextbrowser.cpp

📁 Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 经过两年开发后
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    connect( m_wikiPage->browserExtension(),         SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ),             this,                                   SLOT( openURLRequest( const KURL & ) ) );    connect( m_currentTrackPage, SIGNAL( popupMenu( const QString&, const QPoint& ) ),             this,               SLOT( slotContextMenu( const QString&, const QPoint& ) ) );    connect( m_lyricsPage,       SIGNAL( popupMenu( const QString&, const QPoint& ) ),             this,               SLOT( slotContextMenu( const QString&, const QPoint& ) ) );    connect( m_wikiPage,         SIGNAL( popupMenu( const QString&, const QPoint& ) ),             this,               SLOT( slotContextMenu( const QString&, const QPoint& ) ) );    connect( m_lyricsToolBar->getButton( LYRICS_ADD ),     SIGNAL(clicked( int )), SLOT(lyricsAdd()) );    connect( m_lyricsToolBar->getButton( LYRICS_EDIT ),    SIGNAL(toggled( int )), SLOT(lyricsEditToggle()) );    connect( m_lyricsToolBar->getButton( LYRICS_SEARCH ),  SIGNAL(clicked( int )), SLOT(lyricsSearch()) );    connect( m_lyricsToolBar->getButton( LYRICS_REFRESH ), SIGNAL(clicked( int )), SLOT(lyricsRefresh()) );    connect( m_lyricsToolBar->getButton( LYRICS_BROWSER ), SIGNAL(clicked( int )), SLOT(lyricsExternalPage()) );    connect( m_wikiToolBar->getButton( WIKI_BACK    ), SIGNAL(clicked( int )), SLOT(wikiHistoryBack()) );    connect( m_wikiToolBar->getButton( WIKI_FORWARD ), SIGNAL(clicked( int )), SLOT(wikiHistoryForward()) );    connect( m_wikiToolBar->getButton( WIKI_ARTIST  ), SIGNAL(clicked( int )), SLOT(wikiArtistPage()) );    connect( m_wikiToolBar->getButton( WIKI_ALBUM   ), SIGNAL(clicked( int )), SLOT(wikiAlbumPage()) );    connect( m_wikiToolBar->getButton( WIKI_TITLE   ), SIGNAL(clicked( int )), SLOT(wikiTitlePage()) );    connect( m_wikiToolBar->getButton( WIKI_BROWSER ), SIGNAL(clicked( int )), SLOT(wikiExternalPage()) );    connect( m_wikiToolBar->getButton( WIKI_CONFIG  ), SIGNAL(clicked( int )), SLOT(wikiConfig()) );    connect( m_wikiBackPopup,    SIGNAL(activated( int )), SLOT(wikiBackPopupActivated( int )) );    connect( m_wikiForwardPopup, SIGNAL(activated( int )), SLOT(wikiForwardPopupActivated( int )) );    connect( CollectionDB::instance(), SIGNAL( scanStarted() ), SLOT( collectionScanStarted() ) );    connect( CollectionDB::instance(), SIGNAL( scanDone( bool ) ), SLOT( collectionScanDone( bool ) ) );    connect( CollectionDB::instance(), SIGNAL( databaseEngineChanged() ), SLOT( renderView() ) );    connect( CollectionDB::instance(), SIGNAL( coverFetched( const QString&, const QString& ) ),             this, SLOT( coverFetched( const QString&, const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( coverChanged( const QString&, const QString& ) ),             this, SLOT( coverRemoved( const QString&, const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( similarArtistsFetched( const QString& ) ),             this, SLOT( similarArtistsFetched( const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( tagsChanged( const MetaBundle& ) ),             this, SLOT( tagsChanged( const MetaBundle& ) ) );    connect( CollectionDB::instance(), SIGNAL( tagsChanged( const QString&, const QString& ) ),             this, SLOT( tagsChanged( const QString&, const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( ratingChanged( const QString&, int ) ),             this, SLOT( ratingOrScoreOrLabelsChanged( const QString& ) ) );    connect( StarManager::instance(), SIGNAL( ratingsColorsChanged() ),             this, SLOT( ratingOrScoreOrLabelsChanged( const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( scoreChanged( const QString&, float ) ),             this, SLOT( ratingOrScoreOrLabelsChanged( const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( labelsChanged( const QString& ) ),             this, SLOT( ratingOrScoreOrLabelsChanged( const QString& ) ) );    connect( CollectionDB::instance(), SIGNAL( imageFetched( const QString& ) ),             this, SLOT( imageFetched( const QString& ) ) );    connect( App::instance(), SIGNAL( useScores( bool ) ),             this, SLOT( refreshCurrentTrackPage() ) );    connect( App::instance(), SIGNAL( useRatings( bool ) ),             this, SLOT( refreshCurrentTrackPage() ) );    connect( MountPointManager::instance(), SIGNAL( mediumConnected( int ) ),             this, SLOT( renderView() ) );    connect( MountPointManager::instance(), SIGNAL( mediumRemoved( int ) ),             this, SLOT( renderView() ) );    showContext( KURL( "current://track" ) );//     setMinimumHeight( AmarokConfig::coverPreviewSize() + (fontMetrics().height()+2)*5 + tabBar()->height() );}ContextBrowser::~ContextBrowser(){    DEBUG_BLOCK    ThreadManager::instance()->abortAllJobsNamed( "CurrentTrackJob" );    // Ensure the KHTMLPart dies before its KHTMLView dies,    // because KHTMLPart's dtoring relies on its KHTMLView still being alive    // (see bug 130494).    delete m_currentTrackPage;    delete m_lyricsPage;    delete m_wikiPage;    m_cuefile->clear();}//////////////////////////////////////////////////////////////////////////////////////////// PUBLIC METHODS//////////////////////////////////////////////////////////////////////////////////////////void ContextBrowser::setFont( const QFont &newFont ){    QWidget::setFont( newFont );    reloadStyleSheet();}//////////////////////////////////////////////////////////////////////////////////////////// PUBLIC SLOTS//////////////////////////////////////////////////////////////////////////////////////////void ContextBrowser::openURLRequest( const KURL &url ){    QString artist, album, track;    Amarok::albumArtistTrackFromUrl( url.path(), artist, album, track );    // All http links should be loaded inside wikipedia tab, as that is the only tab that should contain them.    // Streams should use stream:// protocol.    if ( url.protocol() == "http" )    {        if ( url.hasHTMLRef() )        {            KURL base = url;            base.setRef(QString::null);            // Wikipedia also has links to otherpages with Anchors, so we have to check if it's for the current one            if ( m_wikiCurrentUrl == base.url() ) {                m_wikiPage->gotoAnchor( url.htmlRef() );                return;            }        }        // new page        m_dirtyWikiPage = true;        m_wikiCurrentEntry = QString::null;        showWikipedia( url.url() );    }    else if ( url.protocol() == "show" )    {        if ( url.path().contains( "suggestLyric-" ) )        {            QString _url = url.url().mid( url.url().find( QString( "-" ) ) +1 );            debug() << "Clicked lyrics URL: " << _url << endl;            m_dirtyLyricsPage = true;            showLyrics( _url );        }        else if ( url.path() == "collectionSetup" )        {            CollectionView::instance()->setupDirs();        }        else if ( url.path() == "scriptmanager" )        {            ScriptManager::instance()->show();            ScriptManager::instance()->raise();        }        else if ( url.path() == "editLabels" )        {            showLabelsDialog();        }        // Konqueror sidebar needs these        if (url.path() == "context") { m_dirtyCurrentTrackPage=true; showContext( KURL( "current://track" ) ); saveHtmlData(); }        if (url.path() == "wiki") { m_dirtyWikiPage=true; showWikipedia(); saveHtmlData(); }        if (url.path() == "lyrics") { m_dirtyLyricsPage=true; m_wikiJob=false; showLyrics(); saveHtmlData(); }    }    else if ( url.protocol() == "runscript" )    {        ScriptManager::instance()->runScript( url.path() );    }    // When left-clicking on cover image, open browser with amazon site    else if ( url.protocol() == "fetchcover" )    {        QString albumPath = CollectionDB::instance()->albumImage(artist, album, false, 0 );        if ( albumPath == CollectionDB::instance()->notAvailCover( false, 0 ) )        {            CollectionDB::instance()->fetchCover( this, artist, album, false );            return;        }        QImage img( albumPath );        const QString amazonUrl = img.text( "amazon-url" );        if ( amazonUrl.isEmpty() )            KMessageBox::information( this, i18n( "<p>There is no product information available for this image.<p>Right-click on image for menu." ) );        else            Amarok::invokeBrowser( amazonUrl );    }    /* open konqueror with musicbrainz search result for artist-album */    else if ( url.protocol() == "musicbrainz" )    {        const QString url = "http://www.musicbrainz.org/taglookup.html?artist=%1&album=%2&track=%3";        Amarok::invokeBrowser( url.arg( KURL::encode_string_no_slash( artist, 106 /*utf-8*/ ),        KURL::encode_string_no_slash( album, 106 /*utf-8*/ ),        KURL::encode_string_no_slash( track, 106 /*utf-8*/ ) ) );    }    else if ( url.protocol() == "externalurl" )        Amarok::invokeBrowser( url.url().replace( QRegExp( "^externalurl:" ), "http:") );    else if ( url.protocol() == "lastfm" )    {        LastFm::WebService *lfm = LastFm::Controller::instance()->getService();        if      ( url.path() == "skip" ) lfm->skip();        else if ( url.path() == "love" ) lfm->love();        else if ( url.path() == "ban"  ) lfm->ban();    }    else if ( url.protocol() == "togglebox" )    {        if      ( url.path() == "ra" ) m_relatedOpen     ^= true;        else if ( url.path() == "ss" ) m_suggestionsOpen ^= true;        else if ( url.path() == "ft" ) m_favoritesOpen  ^= true;        else if ( url.path() == "sl" ) m_labelsOpen ^= true;    }    else if ( url.protocol() == "seek" )    {        EngineController::instance()->seek(url.path().toLong());    }    // browse albums of a related artist.  Don't do this if we are viewing Home tab    else if ( url.protocol() == "artist" || url.protocol() == "current" || url.protocol() == "showlabel")    {        if( EngineController::engine()->loaded() ) // song must be active            showContext( url );    }    else if( url.protocol() == "artistback" )    {        contextHistoryBack();    }    else if ( url.protocol() == "wikipedia" )    {        m_dirtyWikiPage = true;        QString entry = unescapeHTMLAttr( url.path() );        showWikipediaEntry( entry );    }    else if( url.protocol() == "ggartist" )    {        const QString url2 = QString( "http://www.google.com/musicsearch?q=%1&res=artist" )            .arg( KURL::encode_string_no_slash( unescapeHTMLAttr( url.path() ).replace( " ", "+" ), 106 /*utf-8*/ ) );        Amarok::invokeBrowser( url2 );    }    else if( url.protocol() == "file" )    {        Playlist::instance()->insertMedia( url, Playlist::DefaultOptions );    }    else if( url.protocol() == "stream" )    {        Playlist::instance()->insertMedia( KURL::fromPathOrURL( url.url().replace( QRegExp( "^stream:" ), "http:" ) ), Playlist::DefaultOptions );    }    else if( url.protocol() == "compilationdisc" || url.protocol() == "albumdisc" )    {        Playlist::instance()->insertMedia( expandURL( url ) , Playlist::DefaultOptions );    }    else        HTMLView::openURLRequest( url );}void ContextBrowser::collectionScanStarted(){    m_emptyDB = CollectionDB::instance()->isEmpty();    if( m_emptyDB && currentPage() == m_contextTab )        showCurrentTrack();}void ContextBrowser::collectionScanDone( bool changed ){    if ( CollectionDB::instance()->isEmpty() )    {        m_emptyDB = true;        if ( currentPage() == m_contextTab )            showCurrentTrack();    }    else if ( m_emptyDB )    {        m_emptyDB = false;        PlaylistWindow::self()->showBrowser("CollectionBrowser");    }    else if( changed && currentPage() == m_contextTab )    {        m_dirtyCurrentTrackPage = true;        showCurrentTrack();    }}void ContextBrowser::renderView(){    m_dirtyCurrentTrackPage = true;    m_dirtyLyricsPage = true;    m_dirtyWikiPage = true;    m_emptyDB = CollectionDB::instance()->isEmpty();    showCurrentTrack();}void ContextBrowser::lyricsChanged( const QString &url ) {    if ( url == EngineController::instance()->bundle().url().path() ) {        m_dirtyLyricsPage = true;        if ( currentPage() == m_lyricsTab )            showLyrics();    }}void ContextBrowser::lyricsScriptChanged() {    m_dirtyLyricsPage = true;    if ( currentPage() == m_lyricsTab )        showLyrics();}//////////////////////////////////////////////////////////////////////////////////////////// PROTECTED//////////////////////////////////////////////////////////////////////////////////////////void ContextBrowser::engineNewMetaData( const MetaBundle& bundle, bool trackChanged ){    bool newMetaData = false;    m_dirtyCurrentTrackPage = true;    m_dirtyLyricsPage = true;    m_wikiJob = 0; //New metadata, so let's forget previous wiki-fetching jobs    if ( MetaBundle( m_currentURL ).artist() != bundle.artist() )        m_dirtyWikiPage = true;    // Prepend stream metadata history item to list    if ( !m_metadataHistory.first().contains( bundle.prettyTitle() ) )

⌨️ 快捷键说明

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