Created attachment 49347 [details] amarok-scriptengine-make-bpm-accesible.patch Version: 2.3-GIT (using KDE 4.4.4) OS: Linux This patch exports BPM (beats-per-minute) to QtScript scripts. The access is read-only as this property is also read-only in Meta::Track. I have a script prepared that uses bpm property and I'm waiting to release it. It would be great if this patch made it into 2.3.2. Reproducible: Always
commit 1d994d228f5eb3c4a92735568c0b70fefd102edc Author: Kevin Funk <krf@electrostorm.net> Date: Wed Jul 28 16:40:10 2010 +0200 Export bpm to scripts (read-only). Patch by MatÄj Laitl. BUG: 245257 diff --git a/ChangeLog b/ChangeLog index 48e29b5..42b4265 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ VERSION 2.3.2-Beta 1 browser, e.g. "played:<3d". CHANGES: + * Let scripts access bpm property of tracks (read-only). (BR 245257) * Remote Meta+P global shortcut to avoid future problems with new keyboard drivers in notebooks. (BR 235204) * Fix size of Slim toolbar time labels. Thanks to Tijl Coosemans for the patch. diff --git a/src/scriptengine/MetaTypeExporter.cpp b/src/scriptengine/MetaTypeExporter.cpp index 1978179..3d3c9c5 100644 --- a/src/scriptengine/MetaTypeExporter.cpp +++ b/src/scriptengine/MetaTypeExporter.cpp @@ -191,6 +191,13 @@ MetaTrackPrototype::url() const return track ? track->playableUrl().url() : QString(); } +double +MetaTrackPrototype::bpm() const +{ + GET_TRACK + return track ? track->bpm() : 0.0; +} + QScriptValue MetaTrackPrototype::imagePixmap( int size ) const { @@ -302,7 +309,7 @@ MetaTrackPrototype::setTitle( const QString& title ) } void -MetaTrackPrototype::setImageUrl(const QString& imageUrl ) +MetaTrackPrototype::setImageUrl( const QString& imageUrl ) { GET_TRACK if ( track && track->album() ) track->album()->setImage( QPixmap(imageUrl) ); diff --git a/src/scriptengine/MetaTypeExporter.h b/src/scriptengine/MetaTypeExporter.h index ef4a7fe..fd9c96c 100644 --- a/src/scriptengine/MetaTypeExporter.h +++ b/src/scriptengine/MetaTypeExporter.h @@ -57,6 +57,7 @@ MetaTrackPrototype : public QObject, protected QScriptable Q_PROPERTY( QString lyrics WRITE setLyrics READ lyrics ) Q_PROPERTY( QString imageUrl WRITE setImageUrl READ imageUrl ) Q_PROPERTY( QString url READ url ) + Q_PROPERTY( double bpm READ bpm ) // setter not yet available in Meta::Track public: MetaTrackPrototype(); @@ -91,6 +92,7 @@ MetaTrackPrototype : public QObject, protected QScriptable QString title() const; QString imageUrl() const; QString url() const; + double bpm() const; void setScore( double score ); void setRating( int rating );