From 5d12aa3b7e00cdcc7ba26c7af8ccac1656a296f9 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 6 Nov 2011 21:12:08 +0000 Subject: Improve the PlayerTestWidget class Auto-fill the TrackId field for SetPosition, add units for times and update the "last known time" field when Seeked is emitted. --- mpris2/playerinterfacetest.cpp | 10 +++++++--- mpris2/playertestwidget.cpp | 25 +++++++++++++++++++++---- mpris2/playertestwidget.h | 2 ++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/mpris2/playerinterfacetest.cpp b/mpris2/playerinterfacetest.cpp index 88e55cf..ee1225a 100644 --- a/mpris2/playerinterfacetest.cpp +++ b/mpris2/playerinterfacetest.cpp @@ -523,7 +523,7 @@ void PlayerInterfaceTest::_m_seeked(qint64 position, const QDBusMessage& message { m_pos = position; m_posLastUpdated = QTime::currentTime(); - properties()["Position"] = position; + props["Position"] = position; checkPosition(); emit Seeked(position); } @@ -737,8 +737,12 @@ void PlayerInterfaceTest::testSetPosition(const QDBusObjectPath& trackId, qint64 emit interfaceInfo(Method, "SetPosition", "SetPosition called, but CanSeek is false, so this should have no effect"); // TODO: check to see that Seeked is not emitted; PlaybackStatus does not change } else { - if (trackId.path() != props["mpris:trackid"].toString()) { - emit interfaceInfo(Method, "SetPosition", "SetPosition called with the wrong trackid; nothing should happen"); + if (trackId.path() != props["Metadata"].toMap()["mpris:trackid"].value().path()) { + emit interfaceInfo(Method, "SetPosition", "SetPosition called with the wrong trackid ('" + + trackId.path() + + "'; expecting '" + + props["mpris:trackid"].value().path() + + "'); nothing should happen"); // TODO: check to see that Seeked is not emitted; PlaybackStatus does not change } else if (position < 0.0) { emit interfaceInfo(Method, "SetPosition", "SetPosition called with a negative value; the media player should be at the start of the track"); diff --git a/mpris2/playertestwidget.cpp b/mpris2/playertestwidget.cpp index c35ee5c..b3832ff 100644 --- a/mpris2/playertestwidget.cpp +++ b/mpris2/playertestwidget.cpp @@ -35,6 +35,8 @@ PlayerTestWidget::PlayerTestWidget(PlayerInterfaceTest* test, QWidget* parent) this->test = test; connect(test, SIGNAL(propertiesChanged(QStringList)), this, SLOT(propertiesChanged(QStringList))); + connect(test, SIGNAL(Seeked(qint64)), + this, SLOT(Seeked(qint64))); estPosTimer = new QTimer(this); estPosTimer->setInterval(500); estPosTimer->setSingleShot(false); @@ -132,11 +134,11 @@ void PlayerTestWidget::propertiesChanged(const QStringList& properties) ui.volumeLbl->setEnabled(true); } if (test->properties().contains("Position")) { - ui.lastKnownPosLbl->setText(QString::number(test->properties().value("Position").toLongLong())); + ui.lastKnownPosLbl->setText(QString::number(test->properties().value("Position").toLongLong()) + "ns"); ui.lastKnownPosLbl->setEnabled(true); } if (test->predictedPosition() >= 0) { - ui.estPosLbl->setText(QString::number(test->predictedPosition())); + ui.estPosLbl->setText(QString::number(test->predictedPosition()) + "ns"); ui.estPosLbl->setEnabled(true); if (!estPosTimer->isActive()) estPosTimer->start(); @@ -145,14 +147,22 @@ void PlayerTestWidget::propertiesChanged(const QStringList& properties) if (test->properties().value("Metadata").type() != QVariant::Map) { qDebug() << "Metadata map was wrong type"; } - metadataModel->setMetadata(test->properties().value("Metadata").toMap()); + QVariantMap metadata = test->properties().value("Metadata").toMap(); + metadataModel->setMetadata(metadata); ui.metadataTableView->setEnabled(true); + if (ui.setPosTrackIdEdit->text().isEmpty() || + ui.setPosTrackIdEdit->text() == lastSetTrackId) + { + QString trackId = metadata.value("mpris:trackid").value().path(); + ui.setPosTrackIdEdit->setText(trackId); + lastSetTrackId = trackId; + } } } void PlayerTestWidget::updateEstPos() { - ui.estPosLbl->setText(QString::number(test->predictedPosition())); + ui.estPosLbl->setText(QString::number(test->predictedPosition()) + "ns"); } void PlayerTestWidget::testSeek() @@ -171,3 +181,10 @@ void PlayerTestWidget::testOpenUri() { test->testOpenUri(ui.openUriEdit->text()); } + +void PlayerTestWidget::Seeked(qint64 position) +{ + ui.lastKnownPosLbl->setText(QString::number(position) + "ns"); + ui.lastKnownPosLbl->setEnabled(true); +} + diff --git a/mpris2/playertestwidget.h b/mpris2/playertestwidget.h index 9c2f6b4..7ead34b 100644 --- a/mpris2/playertestwidget.h +++ b/mpris2/playertestwidget.h @@ -44,6 +44,7 @@ namespace Mpris2 { void testSeek(); void testSetPos(); void testOpenUri(); + void Seeked(qint64 position); private slots: void propertiesChanged(const QStringList& properties); @@ -54,6 +55,7 @@ namespace Mpris2 { PlayerInterfaceTest *test; QTimer *estPosTimer; MetadataModel *metadataModel; + QString lastSetTrackId; }; } -- cgit v1.2.3