예제 #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground);

    ui->horizontalSlider->setRange(0, 0);
    ui->tableWidget->hide();
    ui->tableWidget->hideColumn(2);
    volume=80;

    createContextMenu();
    createSystemTrayIcon();

    playList=new QMediaPlaylist;
    playList->setPlaybackMode(QMediaPlaylist::Loop);
    player=new QMediaPlayer;
    player->setPlaylist(playList);
    player->setVolume(volume);

    connect(ui->horizontalSlider, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));
    connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(playTo(int, int)));

    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(playList, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSongList(int)));

    connect(ui->action_SongList, SIGNAL(triggered()), this, SLOT(showOrHideSongList()));
    connect(ui->action_Import, SIGNAL(triggered()), this, SLOT(importSongs()));
    connect(ui->action_Last, SIGNAL(triggered()), this, SLOT(playLast()));
    connect(ui->action_Play, SIGNAL(triggered()), this, SLOT(playOrPause()));
    connect(ui->action_Stop, SIGNAL(triggered()), player, SLOT(stop()));
    connect(ui->action_Next, SIGNAL(triggered()), this, SLOT(playNext()));
    connect(ui->action_SoundPlus, SIGNAL(triggered()), this, SLOT(plusSound()));
    connect(ui->action_SoundReduce, SIGNAL(triggered()), this, SLOT(reduceSound()));
    connect(ui->action_Mode1, SIGNAL(triggered()), this, SLOT(setPlaybackMode1()));
    connect(ui->action_Mode2, SIGNAL(triggered()), this, SLOT(setPlaybackMode2()));
    connect(ui->action_Mode3, SIGNAL(triggered()), this, SLOT(setPlaybackMode3()));
    connect(ui->action_Mode4, SIGNAL(triggered()), this, SLOT(setPlaybackMode4()));
    connect(ui->action_Support, SIGNAL(triggered()), this, SLOT(support()));
    connect(ui->action_About, SIGNAL(triggered()), this, SLOT(aboutUs()));
    connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close()));

    connect(ui->toolButton_Last, SIGNAL(clicked()), this, SLOT(playLast()));
    connect(ui->toolButton_Play, SIGNAL(clicked()), this, SLOT(playOrPause()));
    connect(ui->toolButton_Stop, SIGNAL(clicked()), player, SLOT(stop()));
    connect(ui->toolButton_Next, SIGNAL(clicked()), this, SLOT(playNext()));
}
예제 #2
0
PlistsGroup::PlistsGroup(QObject *parent) :
    QObject(parent)
{
    if(m_instance)
            qFatal("Only one instance of PlistsGroup object is allowed");

    m_instance = this;

    m_Settings = Settings::instance();

    m_Auth = Auth::instance();

    // Create new widget for playlist
    m_widget = new PlistsGroupWidget();

    // init vars
    m_LastList = 0;
    m_LastTrack = 0;

    m_bLoadMeta = false;
    m_bUseMeta = false;

    m_shuffleMode = m_Settings->getValue("player/shuffle").toInt();
    m_repeatMode  = m_Settings->getValue("player/repeat").toInt();

    connect(m_widget, SIGNAL(createSearchList()), SLOT(createSearchList()));
    connect(m_widget, SIGNAL(createLibraryList()), SLOT(createLibraryList()));
    connect(m_widget, SIGNAL(createLocalList()), SLOT(createLocalList()));
    connect(m_widget, SIGNAL(createSuggestionsList()), SLOT(createSuggestionsList()));
    connect(m_widget, SIGNAL(createDbSearch()), SLOT(createDbSearch()));

    connect(m_widget, SIGNAL(tabMoved(int,int)), SLOT(listSwap(int,int)));
    connect(m_widget, SIGNAL(removeTab(int)), SLOT(deleteList(int)));
    connect(m_widget, SIGNAL(renameTab(int, QString)), SLOT(renameList(int, QString)));

    loadLists();

    if(m_LastList)
        connect(this, SIGNAL(playLast()), m_LastList, SLOT(playLast()));

    if(m_Settings->getValue("playing/play_on_start").toBool() && m_LastList)
        QTimer::singleShot(200, m_LastList, SLOT(playLast()));
}
void Shadows::update(){
    
    //  shadow bluring
    //
    blur.begin();
    ofPushStyle();
    ofClear(255,255);
    if ( countDown == 0){
        
        //  Play the shadows animation one by one from the last up to the first one
        //  Ever time a new shadow it´s made, the cicle start´s from the beginning.
        //
        ofFill();
        if (currentShadow != NULL){
            if (currentShadow->bActive){
                if ( currentShadow->draw() ){
                    if (bNew){
                        playLast();
                        bNew = false;
                    } else {
                        playNext();
                    }
                }
            }
        }
    } else {
        int clamp = nLastShadows;
        if (clamp > 5){
            clamp = 5;
        }
        for( map<int,AnimatedShadow*>::reverse_iterator rit = hands.rbegin(); rit != hands.rend(); rit++ ){
            if ((clamp > 0) || rit->second->getCurrentFrame() != 0){
                if ( rit->second->bActive ) {
                    rit->second->draw();
                    clamp--;
                }
            }
        }
        countDown--;
        if ((countDown == 0) && 
            (nLastShadows > 0) ){
            countDown = 100;
            nLastShadows--;
        }
    }
    ofPopStyle();
    blur.end();
    blur.update();
    
    //  Animate the text
    //
    text.update();
    textAnimation.update(text);
}
void Shadows::handDeleted(ofxBlob &_blob){
    
    if ( hands[ _blob.id ] == NULL ){
        hands.erase( _blob.id );
        
        //  If don't have record of this blob probably it's because it's a hole of a blob...
        //
        
    } else {
        
        //  So it seams like a shadow
        //
        
        if (!hands[ _blob.id ]->isHand() &&
            !hands[ _blob.id ]->size() < 30 ){
            
            //  if the shadow never gave a single finger or it didn't get enought frames
            //  probably it's just junk...
            //  ... so let's delet it
            //
            delete hands[ _blob.id ];
            hands.erase( _blob.id );
            //ofLog(OF_LOG_NOTICE,"Deleting shadow idº " + ofToString( _blob.id ));
            
        } else {
            
            //  if had fingers and enought frames let's keep it and play it!!!
            //
            hands[ _blob.id ]->bActive = true;  // this means it´s goign to be played and no longer edited
            bNew = true;                        // and the the sistem that we have a new one
            
            countDown = 100;
            nLastShadows++;
            
            //  When the game starts currentShadow it's just a NULL and nothing it´s going to happend
            //  until new blob arrive and take the place of currentShadow.
            //  If currentShadow it´s not NULL that just means that it's one been played 
            //
            if (currentShadow == NULL){
                playLast();
            }
        }
    }
}
void Shadows::playNext(){
    bool foundNext = false;
    bool currentPassed = false;
    
    for( map<int,AnimatedShadow*>::reverse_iterator rit = hands.rbegin(); rit != hands.rend(); rit++ ){
        if (currentPassed &&
            rit->second->isHand() && 
            rit->second->bActive ){
            currentShadow = rit->second;
            foundNext = true;
            break;
        }
        
        if (rit->second->getId() == currentShadow->getId() ){
            currentPassed = true;
        }
    }
    
    if ( !foundNext )
        playLast();
}