NowPlaying::NowPlaying(QObject *parent, const QVariantList &args)
    : Plasma::Applet(parent, args),
      m_controller(0),
      m_state(NoPlayer),
      m_currentLayout(NoLayout),
      m_volume(0),
      m_length(0),
      m_textPanel(new InfoPanel)
{
    resize(300, 200); // ideal planar size

    connect(this, SIGNAL(metadataChanged(QMap<QString,QString>)),
            m_textPanel, SLOT(updateMetadata(QMap<QString,QString>)));
    connect(this, SIGNAL(coverChanged(QPixmap)),
            m_textPanel, SLOT(updateArtwork(QPixmap)));
}
示例#2
0
void MainWindow::openM3UFile()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("M3UPlaylist öffnen"),
                                            QDir::homePath(), tr("Playlists (*.m3u)"));
    if (fileName.isEmpty())
        return;
    if (_currPlaylist != 0)
        m3uList.prepend(_currPlaylist);
    delete _cover;
    _currPlaylist = new M3UPlaylist(fileName);
    _cover = new Cover(_currPlaylist);
    _songListView->setPlaylist(_currPlaylist);
    _saveCoverAct->setDisabled(FALSE);
    _savePlaylistAct->setDisabled(FALSE);
    _formatAlignmentAct->setDisabled(FALSE);
    _formatSizeColorAct->setDisabled(FALSE);
    connect(_cover,SIGNAL(coverChanged()),this, SLOT(updateCoverView()));    _coverView->setScene(_cover->scene());
    connect(_songListView, SIGNAL(addToCover(QString)), _cover, SLOT(addText(QString)));
    updateCoverView();
}
示例#3
0
void SizeSettings::createLayout()
{
    setWindowTitle(tr("Größe und Farbe"));
    _mainLayout = new QVBoxLayout(this);

    _coverSizeLayout = new QHBoxLayout;

    _coverSizeLabel = new QLabel(tr("Covergröße"));
    _coverSizeBox = new QSpinBox;

    _coverSizeLayout->addWidget(_coverSizeLabel);
    _coverSizeLayout->addWidget(_coverSizeBox);

    _mainLayout->addLayout(_coverSizeLayout);

    _coverColorLayout = new QHBoxLayout;

    _coverColorLabel = new QLabel(tr("Hintergrundfarbe"));
    _coverColorPreview = new QPushButton;

    _coverColorLayout->addWidget(_coverColorLabel);
    _coverColorLayout->addWidget(_coverColorPreview);

    _mainLayout->addLayout(_coverColorLayout);

    _singleCoverSizeLayout = new QHBoxLayout;

    _singleCoverSizeLabel = new QLabel(tr("Einzelcovergröße"));
    _singleCoverSizeAutoBox = new QCheckBox(tr("automatisch"));
    _singleCoverSizeWidthBox = new QSpinBox;
    _singleCoverSizeHeightBox = new QSpinBox;
    _singleCoverSizeChainBox = new QCheckBox(tr("Quadrat"));

    _singleCoverSizeLayout->addWidget(_singleCoverSizeLabel);
    _singleCoverSizeLayout->addWidget(_singleCoverSizeWidthBox);
    _singleCoverSizeLayout->addWidget(_singleCoverSizeHeightBox);
    _singleCoverSizeLayout->addWidget(_singleCoverSizeChainBox);

    _mainLayout->addLayout(_singleCoverSizeLayout);
    _mainLayout->addWidget(_singleCoverSizeAutoBox);

    _singleCoverAlphaLayout = new QHBoxLayout;

    _singleCoverAlphaLabel = new QLabel(tr("Transparenz"));
    _singleCoverAlphaBox = new QSpinBox;

    _singleCoverAlphaLayout->addWidget(_singleCoverAlphaLabel);
    _singleCoverAlphaLayout->addWidget(_singleCoverAlphaBox);

    _mainLayout->addLayout(_singleCoverAlphaLayout);

    connect(_coverColorPreview,SIGNAL(clicked()),this,SLOT(setCoverColor()));
    connect(_coverSizeBox,SIGNAL(valueChanged(int)),_cover,SLOT(setCoverSize(int)));
    connect(_singleCoverAlphaBox,SIGNAL(valueChanged(int)),_cover,SLOT(setSingleCoverAlpha(int)));
    connect(_singleCoverSizeWidthBox, SIGNAL(valueChanged(int)),
            this, SLOT(setSingleCoverSizeWidth(int)));
    connect(_singleCoverSizeHeightBox,SIGNAL(valueChanged(int)),
            this, SLOT(setSingleCoverSizeHeight(int)));
    connect(_singleCoverSizeAutoBox,SIGNAL(toggled(bool)),
            _cover, SLOT(setAutoSingleCoverSize(bool)));
    connect(_singleCoverSizeAutoBox,SIGNAL(toggled(bool)),
            _singleCoverSizeWidthBox, SLOT(setDisabled(bool)));
    connect(_singleCoverSizeAutoBox,SIGNAL(toggled(bool)),
            _singleCoverSizeHeightBox, SLOT(setDisabled(bool)));
    connect(_singleCoverSizeAutoBox,SIGNAL(toggled(bool)),
            _singleCoverSizeChainBox, SLOT(setDisabled(bool)));
    connect(_singleCoverSizeAutoBox,SIGNAL(toggled(bool)),
            _singleCoverSizeChainBox, SLOT(setChecked(bool)));
    connect(_singleCoverSizeChainBox,SIGNAL(toggled(bool)),
            _singleCoverSizeHeightBox, SLOT(setDisabled(bool)));
    connect(_cover,SIGNAL(coverChanged()),this,SLOT(init()));

}
void NowPlaying::dataUpdated(const QString &name,
                             const Plasma::DataEngine::Data &data)
{
                    //i18n("No media player found")
                    //i18nc("The state of a music player", "Stopped")
    if (name != m_watchingPlayer) {
        kDebug() << "Wasn't expecting an update from" << name << " but watching " << m_watchingPlayer;
        return;
    }
    if (data.isEmpty()) {
        kDebug() << "Got no data";
        findPlayer();
        return;
    }

    State newstate;
    if (data["State"].toString() == "playing") {
        newstate = Playing;
    } else if (data["State"].toString() == "paused") {
        newstate = Paused;
    } else {
        newstate = Stopped;
    }
    if (newstate != m_state) {
        emit stateChanged(newstate);
        m_state = newstate;
    }

    QString timeText;
    int length = data["Length"].toInt();
    if (length != m_length) {
        m_length = length;
    }
    if (length != 0) {
        int pos = data["Position"].toInt();
        timeText = QString::number(pos / 60) + ':' +
                   QString::number(pos % 60).rightJustified(2, '0') + " / " +
                   QString::number(length / 60) + ':' +
                   QString::number(length % 60).rightJustified(2, '0');
    }

    QMap<QString,QString> metadata;
    metadata["Artist"] = data["Artist"].toString();
    metadata["Album"] = data["Album"].toString();
    metadata["Title"] = data["Title"].toString();
    metadata["Time"] = timeText;
    metadata["Track number"] = QString::number(data["Track number"].toInt());
    metadata["Comment"] = data["Comment"].toString();
    metadata["Genre"] = data["Genre"].toString();

    // the time should usually have changed
    emit metadataChanged(metadata);

    // used for seeing when the track has changed
    if ((metadata["Title"] != m_title) || (metadata["Artist"] != m_artist))
    {
        m_title = metadata["Title"];
        m_artist = metadata["Artist"];
        m_artwork = data["Artwork"].value<QPixmap>();
        emit coverChanged(m_artwork);
        if(Plasma::ToolTipManager::self()->isVisible(this)) {
            toolTipAboutToShow();
        }
    }

    update();
}