Example #1
0
void PlayMusicWindow::songsChanged() {
    Song* currentSong = player->getCurrentSong();
    if (currentSong != NULL) {
        ui->lblCurrentCoverBackground->setVisible(true);
        ui->lblCurrentCover->setVisible(true);
        if (currentSong->getCoverArtFilename() != currentCoverFile) {
            ui->lblCurrentCover->setPixmap(QPixmap(":/theme/gen/RES/loader.png"));
            coverHelper->getPathForCover(currentSong->getCoverArtFilename());
            currentCoverFile = currentSong->getCoverArtFilename();
        }
        if (!player->isStopped()) {
            enableAll();
            wasPlaying = true;
        } else {
            makePlayButton();
            enablePlay();
            disableControls();
        }
        ui->lblCurrentSong->setText(QString::fromStdString(currentSong->getArtistName() + " - " + currentSong->getSongName()));
    } else {
        ui->lblCurrentCoverBackground->setVisible(false);
        ui->lblCurrentCover->setVisible(false);
        ui->lblCurrentSong->setText("No song playing");
        makePlayButton();
        enablePlay();
        disableControls();
    }
    Song* songBefore = player->getSongBefore();
    if (songBefore != NULL) {
        ui->lblCoverBeforeBackground->setVisible(true);
        ui->lblBeforeCover->setVisible(true);
        if (songBefore->getCoverArtFilename() != prevCoverFile) {
            ui->lblBeforeCover->setPixmap(QPixmap(":/theme/gen/RES/loader.png"));
            coverHelper->getPathForCover(songBefore->getCoverArtFilename());
            prevCoverFile = songBefore->getCoverArtFilename();
        }
        ui->btnPrev->setEnabled(true);
    } else {
        ui->lblCoverBeforeBackground->setVisible(false);
        ui->lblBeforeCover->setVisible(false);
        ui->btnPrev->setEnabled(false);
    }
    Song* songAfter = player->getSongAfter();
    if (songAfter != NULL) {
        ui->lblCoverAfterBackground->setVisible(true);
        ui->lblAfterCover->setVisible(true);
        if (songAfter->getCoverArtFilename() != nextCoverFile) {
            ui->lblAfterCover->setPixmap(QPixmap(":/theme/gen/RES/loader.png"));
            coverHelper->getPathForCover(songAfter->getCoverArtFilename());
            nextCoverFile = songAfter->getCoverArtFilename();
        }
        ui->btnNext->setEnabled(true);
    } else {
        ui->lblCoverAfterBackground->setVisible(false);
        ui->lblAfterCover->setVisible(false);
        ui->btnNext->setEnabled(false);
    }
}
Example #2
0
TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
    : QSystemTrayIcon( parent )
    , m_currentAnimationFrame( 0 )
    , m_showWindowAction( 0 )
{
    QIcon icon( RESPATH "icons/tomahawk-icon-128x128.png" );
    setIcon( icon );

    refreshToolTip();

    m_contextMenu = new QMenu();
    setContextMenu( m_contextMenu );

    ActionCollection *ac = ActionCollection::instance();
    m_contextMenu->addAction( ac->getAction( "playPause" ) );
    m_contextMenu->addAction( ac->getAction( "stop" ) );
    m_contextMenu->addSeparator();
    m_contextMenu->addAction( ac->getAction( "previousTrack" ) );
    m_contextMenu->addAction( ac->getAction( "nextTrack" ) );
    m_contextMenu->addSeparator();
    m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );

#ifdef Q_WS_MAC
    // On mac you can close the windows while leaving the app open. We then need a way to show the main window again
    m_contextMenu->addSeparator();
    m_showWindowAction = m_contextMenu->addAction( tr( "Hide Tomahawk Window" ) );
    m_showWindowAction->setData( true );
    connect( m_showWindowAction, SIGNAL( triggered() ), this, SLOT( showWindow() ) );
#endif

    m_contextMenu->addSeparator();
    m_contextMenu->addAction( ac->getAction( "quit" ) );

    connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) );
    connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( enablePause() ) );
    connect( AudioEngine::instance(), SIGNAL( resumed() ), this, SLOT( enablePause() ) );
    connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( enablePlay() ) );
    connect( AudioEngine::instance(), SIGNAL( paused() ),  this, SLOT( enablePlay() ) );

    connect( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) );
    connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) );

    show();
}
Example #3
0
void PlayMusicWindow::playlistsChanged(std::vector<std::string> playlists) {
    playlistsRefreshing = true;
    ui->cmbPlaylists->clear();
    for (unsigned int i = 0; i < playlists.size(); i++) {
        ui->cmbPlaylists->addItem(QString::fromStdString(playlists.at(i)));
    }
    std::string searchString = player->getPlaylist();
    for (int i = 0; i < ui->cmbPlaylists->count(); i++) {
        if (ui->cmbPlaylists->itemText(i).toStdString() == searchString) {
            ui->cmbPlaylists->setCurrentIndex(i);
        }
    }
    if (searchString == "") {
        disablePlay();
    } else {
        enablePlay();
    }
    playlistsRefreshing = false;
}
Example #4
0
void PlayMusicWindow::enableAll() {
    ui->btnNext->setEnabled(true);
    ui->btnPrev->setEnabled(true);
    ui->btnStop->setEnabled(true);
    enablePlay();
}