Changeset View
Changeset View
Standalone View
Standalone View
src/context/applets/lyrics/plugin/LyricsEngine.h
Show All 12 Lines | |||||
13 | * * | 13 | * * | ||
14 | * You should have received a copy of the GNU General Public License along with * | 14 | * You should have received a copy of the GNU General Public License along with * | ||
15 | * this program. If not, see <http://www.gnu.org/licenses/>. * | 15 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||
16 | ****************************************************************************************/ | 16 | ****************************************************************************************/ | ||
17 | 17 | | |||
18 | #ifndef AMAROK_LYRICS_ENGINE | 18 | #ifndef AMAROK_LYRICS_ENGINE | ||
19 | #define AMAROK_LYRICS_ENGINE | 19 | #define AMAROK_LYRICS_ENGINE | ||
20 | 20 | | |||
21 | #include "context/LyricsManager.h" | | |||
22 | #include "core/meta/Meta.h" | 21 | #include "core/meta/Meta.h" | ||
23 | 22 | | |||
24 | #include <QObject> | 23 | #include <QObject> | ||
25 | #include <QString> | 24 | #include <QString> | ||
26 | #include <QVariantList> | 25 | #include <QVariantList> | ||
27 | 26 | | |||
28 | class LyricsEngine : public QObject, public LyricsObserver | 27 | class LyricsEngine : public QObject | ||
29 | { | 28 | { | ||
30 | Q_OBJECT | 29 | Q_OBJECT | ||
31 | Q_PROPERTY(QString text READ text NOTIFY lyricsChanged) | 30 | Q_PROPERTY(QString text READ text NOTIFY lyricsChanged) | ||
32 | Q_PROPERTY(bool fetching READ fetching NOTIFY fetchingChanged) | 31 | Q_PROPERTY(bool fetching READ fetching NOTIFY fetchingChanged) | ||
33 | Q_PROPERTY(QVariantList suggestions READ suggestions NOTIFY lyricsChanged) | 32 | Q_PROPERTY(QVariantList suggestions READ suggestions NOTIFY lyricsChanged) | ||
34 | Q_PROPERTY(qreal position READ position NOTIFY positionChanged) | 33 | Q_PROPERTY(qreal position READ position NOTIFY positionChanged) | ||
35 | Q_PROPERTY(qreal fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) | 34 | Q_PROPERTY(qreal fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) | ||
36 | Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) | 35 | Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) | ||
37 | Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged) | 36 | Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged) | ||
38 | 37 | | |||
39 | public: | 38 | public: | ||
40 | explicit LyricsEngine( QObject* parent = Q_NULLPTR ); | 39 | explicit LyricsEngine( QObject* parent = Q_NULLPTR ); | ||
41 | 40 | | |||
42 | // reimplemented from LyricsObserver | 41 | void newLyrics( const Meta::TrackPtr &track ); | ||
43 | void newLyrics( const LyricsData &lyrics ) Q_DECL_OVERRIDE; | 42 | void newSuggestions( const QVariantList &suggest ); | ||
44 | void newSuggestions( const QVariantList &suggest ) Q_DECL_OVERRIDE; | 43 | void lyricsMessage( const QString& key, const QString& val ); | ||
45 | void lyricsMessage( const QString& key, const QString& val ) Q_DECL_OVERRIDE; | | |||
46 | 44 | | |||
47 | QString text() const { return m_lyrics.text; } | 45 | QString text() const { return m_lyrics; } | ||
48 | QVariantList suggestions() const { return m_suggestions; } | 46 | QVariantList suggestions() const { return m_suggestions; } | ||
49 | bool fetching() const { return m_fetching; } | 47 | bool fetching() const { return m_fetching; } | ||
50 | qreal position() const; | 48 | qreal position() const; | ||
51 | qreal fontSize() const; | 49 | qreal fontSize() const; | ||
52 | void setFontSize( qreal fontSize ); | 50 | void setFontSize( qreal fontSize ); | ||
53 | int alignment() const; | 51 | int alignment() const; | ||
54 | void setAlignment( int alignment ); | 52 | void setAlignment( int alignment ); | ||
55 | QString font() const; | 53 | QString font() const; | ||
56 | void setFont( const QString &font ); | 54 | void setFont( const QString &font ); | ||
57 | 55 | | |||
58 | Q_INVOKABLE void refetchLyrics() const; | 56 | Q_INVOKABLE void refetchLyrics() const; | ||
59 | Q_INVOKABLE void fetchLyrics( const QString &artist, const QString &title, const QString &url ); | | |||
60 | Q_INVOKABLE QStringList availableFonts() const; | 57 | Q_INVOKABLE QStringList availableFonts() const; | ||
61 | 58 | | |||
62 | Q_SIGNALS: | 59 | Q_SIGNALS: | ||
63 | void lyricsChanged(); | 60 | void lyricsChanged(); | ||
64 | void newLyricsMessage( const QString& key, const QString &val ); | 61 | void newLyricsMessage( const QString& key, const QString &val ); | ||
65 | void positionChanged(); | 62 | void positionChanged(); | ||
66 | void fetchingChanged(); | 63 | void fetchingChanged(); | ||
67 | void fontSizeChanged(); | 64 | void fontSizeChanged(); | ||
68 | void alignmentChanged(); | 65 | void alignmentChanged(); | ||
69 | void fontChanged(); | 66 | void fontChanged(); | ||
70 | 67 | | |||
71 | private Q_SLOTS: | 68 | private Q_SLOTS: | ||
72 | void update(); | 69 | void update(); | ||
73 | void onTrackMetadataChanged( Meta::TrackPtr track ); | 70 | void onTrackMetadataChanged( Meta::TrackPtr track ); | ||
74 | 71 | | |||
75 | private: | 72 | private: | ||
76 | void setLyrics( const LyricsData &lyrics ); | | |||
77 | void clearLyrics(); | 73 | void clearLyrics(); | ||
78 | void refetchLyrics(); | | |||
79 | 74 | | |||
80 | LyricsData m_lyrics; | 75 | QString m_lyrics; | ||
81 | QVariantList m_suggestions; | 76 | QVariantList m_suggestions; | ||
82 | bool m_fetching; | 77 | bool m_fetching; | ||
83 | bool m_isUpdateInProgress; | 78 | bool m_isUpdateInProgress; | ||
84 | 79 | | |||
85 | struct trackMetadata { | 80 | struct trackMetadata { | ||
86 | QString artist; | 81 | QString artist; | ||
87 | QString title; | 82 | QString title; | ||
88 | } m_prevTrackMetadata; | 83 | } m_prevTrackMetadata; | ||
89 | }; | 84 | }; | ||
90 | 85 | | |||
91 | #endif | 86 | #endif |