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

📄 amarokdcophandler.cpp

📁 Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 经过两年开发后
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    void DcopPlayerHandler::play()    {        EngineController::instance() ->play();    }    void DcopPlayerHandler::playPause()    {        EngineController::instance() ->playPause();    }    void DcopPlayerHandler::prev()    {        EngineController::instance() ->previous();    }    void DcopPlayerHandler::queueForTransfer( KURL url )    {        MediaBrowser::queue()->addURL( url );        MediaBrowser::queue()->URLsAdded();    }    void DcopPlayerHandler::seek(int s)    {        if ( s > 0 && EngineController::engine()->state() != Engine::Empty )            EngineController::instance()->seek( s * 1000 );    }    void DcopPlayerHandler::seekRelative(int s)    {        EngineController::instance() ->seekRelative( s * 1000 );    }    void DcopPlayerHandler::setEqualizer(int preamp, int band60, int band170, int band310,        int band600, int band1k, int band3k, int band6k, int band12k, int band14k, int band16k)    {        if( EngineController::hasEngineProperty( "HasEqualizer" ) ) {            bool instantiated = EqualizerSetup::isInstantiated();            EqualizerSetup* eq = EqualizerSetup::instance();            QValueList<int> gains;            gains << band60 << band170 << band310 << band600 << band1k                  << band3k << band6k << band12k << band14k << band16k;            eq->setBands( preamp, gains );            if( !instantiated )                delete eq;        }    }    void DcopPlayerHandler::setEqualizerEnabled( bool active )    {        EngineController::engine()->setEqualizerEnabled( active );        AmarokConfig::setEqualizerEnabled( active );        if( EqualizerSetup::isInstantiated() )            EqualizerSetup::instance()->setActive( active );    }    void DcopPlayerHandler::setEqualizerPreset( QString name )    {        if( EngineController::hasEngineProperty( "HasEqualizer" ) ) {            bool instantiated = EqualizerSetup::isInstantiated();            EqualizerSetup* eq = EqualizerSetup::instance();            eq->setPreset( name );            if ( !instantiated )                delete eq;        }    }    void DcopPlayerHandler::setLyricsByPath( const QString& url, const QString& lyrics )    {        CollectionDB::instance()->setLyrics( url, lyrics );    }    void DcopPlayerHandler::setScore( float score )    {        const QString &url = EngineController::instance()->bundle().url().path();        CollectionDB::instance()->setSongPercentage(url, score);    }    void DcopPlayerHandler::setScoreByPath( const QString &url, float score )    {        CollectionDB::instance()->setSongPercentage(url, score);    }    void DcopPlayerHandler::setBpm( float bpm )    {        MetaBundle bundle = EngineController::instance()->bundle();        bundle.setBpm( bpm );        bundle.save();        CollectionDB::instance()->updateTags( bundle.url().path(), bundle, true );    }    void DcopPlayerHandler::setBpmByPath( const QString &url, float bpm )    {        MetaBundle bundle( url );        bundle.setBpm(bpm);        bundle.save();        CollectionDB::instance()->updateTags( bundle.url().path(), bundle, true );    }    void DcopPlayerHandler::setRating( int rating )    {        const QString &url = EngineController::instance()->bundle().url().path();        CollectionDB::instance()->setSongRating(url, rating);    }    void DcopPlayerHandler::setRatingByPath( const QString &url, int rating )    {        CollectionDB::instance()->setSongRating(url, rating);    }    void DcopPlayerHandler::setVolume(int volume)    {        EngineController::instance()->setVolume(volume);    }    void DcopPlayerHandler::setVolumeRelative(int ticks)    {        EngineController::instance()->increaseVolume(ticks);    }    void DcopPlayerHandler::showBrowser( QString browser )    {        if ( browser == "context" )            PlaylistWindow::self()->showBrowser( "ContextBrowser" );        if ( browser == "collection" )            PlaylistWindow::self()->showBrowser( "CollectionBrowser" );        if ( browser == "playlist" )            PlaylistWindow::self()->showBrowser( "PlaylistBrowser" );        if ( browser == "media" )            PlaylistWindow::self()->showBrowser( "MediaBrowser" );        if ( browser == "file" )            PlaylistWindow::self()->showBrowser( "FileBrowser" );    }    void DcopPlayerHandler::showOSD()    {        Amarok::OSD::instance()->forceToggleOSD();    }    void DcopPlayerHandler::stop()    {        EngineController::instance() ->stop();    }    void DcopPlayerHandler::transferDeviceFiles()    {        if ( MediaBrowser::instance()->currentDevice() )            MediaBrowser::instance()->currentDevice()->transferFiles();    }    void DcopPlayerHandler::volumeDown()    {        EngineController::instance()->decreaseVolume();    }    void DcopPlayerHandler::volumeUp()    {        EngineController::instance()->increaseVolume();    }    void DcopPlayerHandler::transferCliArgs( QStringList args )    {        DEBUG_BLOCK        //stop startup cursor animation - do not mess with this, it's carefully crafted        //NOTE I have no idea why we need to do this, I never get startup notification from        //the amarok binary anyway --mxcl        debug() << "Startup ID: " << args.first() << endl;        kapp->setStartupId( args.first().local8Bit() );#ifdef Q_WS_X11        // currently X11 only        KStartupInfo::appStarted();#endif        args.pop_front();        const int argc = args.count() + 1;        char **argv = new char*[argc];        QStringList::ConstIterator it = args.constBegin();        for( int i = 1; i < argc; ++i, ++it ) {            argv[i] = qstrdup( (*it).local8Bit() );            debug() << "Extracted: " << argv[i] << endl;        }        // required, loader doesn't add it        argv[0] = qstrdup( "amarokapp" );        // re-initialize KCmdLineArgs with the new arguments        App::initCliArgs( argc, argv );        App::handleCliArgs();        //FIXME are we meant to leave this around?        //FIXME are we meant to allocate it all on the heap?        //NOTE we allow the memory leak because I think there are        // some very mysterious crashes due to deleting this        //delete[] argv;    }/////////////////////////////////////////////////////////////////////////////////////// class DcopPlaylistHandler/////////////////////////////////////////////////////////////////////////////////////    DcopPlaylistHandler::DcopPlaylistHandler()        : DCOPObject( "playlist" )        , QObject( kapp )    {}    int  DcopPlaylistHandler::getActiveIndex()    {        return Playlist::instance()->currentTrackIndex( false );    }    int  DcopPlaylistHandler::getTotalTrackCount()    {        return Playlist::instance()->totalTrackCount();    }    QString DcopPlaylistHandler::saveCurrentPlaylist()    {        Playlist::instance()->saveXML( Playlist::defaultPlaylistPath() );        return Playlist::defaultPlaylistPath();    }    void DcopPlaylistHandler::addMedia(const KURL &url)    {        Playlist::instance()->appendMedia(url);    }    void DcopPlaylistHandler::addMediaList(const KURL::List &urls)    {        Playlist::instance()->insertMedia(urls);    }    void DcopPlaylistHandler::clearPlaylist()    {        Playlist::instance()->clear();    }    void DcopPlaylistHandler::playByIndex(int index)    {        Playlist::instance()->activateByIndex( index );    }    void DcopPlaylistHandler::playMedia( const KURL &url )    {        Playlist::instance()->insertMedia( url, Playlist::DirectPlay | Playlist::Unique);    }    void DcopPlaylistHandler::popupMessage( const QString& msg )    {        StatusBar::instance()->longMessageThreadSafe( msg );    }    void DcopPlaylistHandler::removeCurrentTrack()    {        PlaylistItem* const item = Playlist::instance()->currentTrack();        if ( item ) {            if( item->isBeingRenamed() )                item->setDeleteAfterEditing( true );            else            {                Playlist::instance()->removeItem( item );                delete item;            }        }    }    void DcopPlaylistHandler::removeByIndex( int index )    {        PlaylistItem* const item =            static_cast<PlaylistItem*>( Playlist::instance()->itemAtIndex( index ) );        if ( item ) {            Playlist::instance()->removeItem( item );            delete item;        }    }    void DcopPlaylistHandler::repopulate()    {        Playlist::instance()->repopulate();    }    void DcopPlaylistHandler::saveM3u( const QString& path, bool relativePaths )    {        Playlist::instance()->saveM3U( path, relativePaths );    }    void DcopPlaylistHandler::setStopAfterCurrent( bool on )    {        Playlist::instance()->setStopAfterCurrent( on );    }    void DcopPlaylistHandler::shortStatusMessage(const QString& msg)    {        StatusBar::instance()->shortMessage( msg );    }    void DcopPlaylistHandler::shufflePlaylist()    {        Playlist::instance()->shuffle();    }    void DcopPlaylistHandler::togglePlaylist()    {        PlaylistWindow::self()->showHide();    }    QStringList DcopPlaylistHandler::filenames()    {        Playlist *p_inst = Playlist::instance();        QStringList songlist;        if (!p_inst)                return songlist;        PlaylistItem *p_item = p_inst->firstChild();        while (p_item)        {                songlist.append(p_item->filename());                p_item = p_item->nextSibling();        }        return songlist;    }    QString DcopPlaylistHandler::currentTrackUniqueId()    {        if( Playlist::instance()->currentItem() )            return Playlist::instance()->currentItem()->uniqueId();        return QString();    }/////////////////////////////////////////////////////////////////////////////////////// class DcopPlaylistBrowserHandler/////////////////////////////////////////////////////////////////////////////////////    DcopPlaylistBrowserHandler::DcopPlaylistBrowserHandler()        : DCOPObject( "playlistbrowser" )        , QObject( kapp )    {}    void DcopPlaylistBrowserHandler::addPodcast( const QString &url )    {        PlaylistBrowser::instance()->addPodcast( url );    }    void DcopPlaylistBrowserHandler::scanPodcasts()    {

⌨️ 快捷键说明

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