| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2007 Leo Franchi <[email protected]> * |
| 3 |
* * |
| 4 |
* This program is free software; you can redistribute it and/or modify it under * |
| 5 |
* the terms of the GNU General Public License as published by the Free Software * |
| 6 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 7 |
* version. * |
| 8 |
* * |
| 9 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 10 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 11 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 12 |
* * |
| 13 |
* You should have received a copy of the GNU General Public License along with * |
| 14 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 15 |
****************************************************************************************/ |
| 16 |
|
| 17 |
#ifndef AMAROK_CURRENT_ENGINE |
| 18 |
#define AMAROK_CURRENT_ENGINE |
| 19 |
|
| 20 |
#include "core/meta/Meta.h" |
| 21 |
|
| 22 |
#include <QObject> |
| 23 |
#include <QPixmap> |
| 24 |
#include <QVariant> |
| 25 |
|
| 26 |
class CurrentEngine : public QObject |
| 27 |
{ |
| 28 |
Q_OBJECT |
| 29 |
Q_PROPERTY(QString artist READ artist NOTIFY trackChanged) |
| 30 |
Q_PROPERTY(QString track READ track NOTIFY trackChanged) |
| 31 |
Q_PROPERTY(QString album READ album NOTIFY trackChanged) |
| 32 |
Q_PROPERTY(int rating READ rating WRITE setRating NOTIFY trackChanged) |
| 33 |
Q_PROPERTY(int score READ score NOTIFY trackChanged) |
| 34 |
Q_PROPERTY(int length READ length NOTIFY trackChanged) |
| 35 |
Q_PROPERTY(QString lastPlayed READ lastPlayed NOTIFY trackChanged) |
| 36 |
Q_PROPERTY(int timesPlayed READ timesPlayed NOTIFY trackChanged) |
| 37 |
Q_PROPERTY(QVariant cover READ cover NOTIFY albumChanged) |
| 38 |
Q_PROPERTY(bool hasValidCover READ hasValidCover NOTIFY albumChanged) |
| 39 |
|
| 40 |
public: |
| 41 |
explicit CurrentEngine( QObject* parent = nullptr ); |
| 42 |
~CurrentEngine() override; |
| 43 |
|
| 44 |
QString artist() const; |
| 45 |
QString track() const; |
| 46 |
QString album() const; |
| 47 |
int rating() const; |
| 48 |
void setRating( int rating ); |
| 49 |
int score() const; |
| 50 |
int length() const; |
| 51 |
QString lastPlayed() const; |
| 52 |
int timesPlayed() const; |
| 53 |
QVariant cover() const { return QVariant(m_cover); } |
| 54 |
bool hasValidCover() const { return !m_cover.isNull(); } |
| 55 |
Q_INVOKABLE void displayCover(); |
| 56 |
|
| 57 |
Q_SIGNALS: |
| 58 |
void trackChanged(); |
| 59 |
void albumChanged(); |
| 60 |
void coverWidthChanged(); |
| 61 |
|
| 62 |
private Q_SLOTS: |
| 63 |
void slotAlbumMetadataChanged(const Meta::AlbumPtr &album ); |
| 64 |
void slotTrackMetadataChanged( Meta::TrackPtr track ); |
| 65 |
void slotTrackChanged( const Meta::TrackPtr &track ); |
| 66 |
void stopped(); |
| 67 |
|
| 68 |
private: |
| 69 |
void update( Meta::TrackPtr track ); |
| 70 |
void update( Meta::AlbumPtr album ); |
| 71 |
|
| 72 |
QPixmap m_cover; |
| 73 |
Meta::TrackPtr m_currentTrack; |
| 74 |
|
| 75 |
private Q_SLOTS: |
| 76 |
|
| 77 |
}; |
| 78 |
|
| 79 |
|
| 80 |
#endif |