Example #1
0
void PresentationAudioPage::addItems(const QList<QUrl>& fileList)
{
    if (fileList.isEmpty())
        return;

    QList<QUrl> Files = fileList;

    for (QList<QUrl>::ConstIterator it = Files.constBegin(); it != Files.constEnd(); ++it)
    {
        QUrl currentFile              = *it;
        d->sharedData->soundtrackPath = currentFile;
        PresentationAudioListItem* const item         = new PresentationAudioListItem(m_SoundFilesListBox, currentFile);
        item->setName(currentFile.fileName());
        m_SoundFilesListBox->insertItem(m_SoundFilesListBox->count() - 1, item);

        d->soundItems->insert(currentFile, item);

        connect(d->soundItems->value(currentFile), SIGNAL(signalTotalTimeReady(QUrl,QTime)),
                this, SLOT(slotAddNewTime(QUrl,QTime)));

        d->urlList.append(currentFile);
    }

    m_SoundFilesListBox->setCurrentItem(m_SoundFilesListBox->item(m_SoundFilesListBox->count() - 1)) ;

    slotSoundFilesSelected(m_SoundFilesListBox->currentRow());
    m_SoundFilesListBox->scrollToItem(m_SoundFilesListBox->currentItem());
    m_previewButton->setEnabled(true);
}
void PresentationAudioListItem::slotMediaStateChanged(QMediaPlayer::MediaStatus status)
{
    if (status == QMediaPlayer::UnknownMediaStatus ||
        status == QMediaPlayer::NoMedia            ||
        status == QMediaPlayer::InvalidMedia)
    {
        showErrorDialog();
        return;
    }

    qint64 total = d->mediaObject->duration();
    int hours      = (int)(total  / (long int)( 60 * 60 * 1000 ));
    int mins       = (int)((total / (long int)( 60 * 1000 )) - (long int)(hours * 60));
    int secs       = (int)((total / (long int)1000) - (long int)(hours * 60 * 60) - (long int)(mins * 60));
    d->totalTime   = QTime(hours, mins, secs);
    d->artist      = (d->mediaObject->metaData(QMediaMetaData::Author)).toStringList().join(QString::fromLatin1(","));
    d->title       = (d->mediaObject->metaData(QMediaMetaData::Title)).toString();

    if ( d->artist.isEmpty() && d->title.isEmpty() )
        setText(d->url.fileName());
    else
        setText(i18nc("artist - title", "%1 - %2", artist(), title()));

    emit signalTotalTimeReady(d->url, d->totalTime);
}
void SoundtrackDialog::addItems(const KUrl::List& fileList)
{
    if (fileList.isEmpty())
        return;

    KUrl::List Files = fileList;

    for (KUrl::List::ConstIterator it = Files.constBegin(); it != Files.constEnd(); ++it)
    {
        KUrl currentFile             = *it;
        KUrl path                    = KUrl(currentFile.path().section('/', 0, -1));
        m_sharedData->soundtrackPath = path;
        SoundItem *item              = new SoundItem(m_SoundFilesListBox, path);
        item->setName(currentFile.path().section('/', -1));
        m_SoundFilesListBox->insertItem(m_SoundFilesListBox->count() - 1, item);

        m_soundItems->insert(path, item);

        connect(m_soundItems->value(path), SIGNAL(signalTotalTimeReady(KUrl,QTime)),
                this, SLOT(slotAddNewTime(KUrl,QTime)));

        m_urlList.append(path);
    }

    m_SoundFilesListBox->setCurrentItem(m_SoundFilesListBox->item(m_SoundFilesListBox->count() - 1)) ;

    slotSoundFilesSelected(m_SoundFilesListBox->currentRow());
    m_SoundFilesListBox->scrollToItem(m_SoundFilesListBox->currentItem());
    m_previewButton->setEnabled(true);
}
Example #4
0
void SoundItem::slotMediaStateChanged(Phonon::State newstate, Phonon::State /*oldstate*/)
{
    if ( newstate == Phonon::ErrorState )
    {
        KMessageBox::detailedError( (QWidget*)(this),
                                    i18n("%1 is damaged and may not be playable.", m_url.fileName()),
                                    m_mediaObject->errorString(),
                                    i18n("Phonon error")
                                  );
        m_artist = m_url.fileName();
        m_title  = i18n("This file is damaged and may not be playable.");
        setText(artist().append(" - ").append(title()));
        setBackground(QBrush(Qt::red));
        setForeground(QBrush(Qt::white));
        QFont errorFont = font();
        errorFont.setBold(true);
        errorFont.setItalic(true);
        setFont(errorFont);
        return;
    }

    if ( newstate != Phonon::StoppedState )
        return;

    long int total = m_mediaObject->totalTime();
    int hours      = (int)(total / (long int)( 60 * 60 * 1000 ));
    int mins       = (int)((total / (long int)( 60 * 1000 )) - (long int)(hours * 60));
    int secs       = (int)((total / (long int)1000) - (long int)(hours * 60 * 60) - (long int)(mins * 60));
    m_totalTime    = QTime(hours, mins, secs);
    m_artist       = (m_mediaObject->metaData(Phonon::ArtistMetaData)).join(",");
    m_title        = (m_mediaObject->metaData(Phonon::TitleMetaData)).join(",");

    if ( m_artist.isEmpty() && m_title.isEmpty() )
        setText(m_url.fileName());
    else
        setText(artist().append(" - ").append(title()));

    emit signalTotalTimeReady(m_url, m_totalTime);
}