File indexing completed on 2025-01-05 04:29:51

0001 /**
0002  * SPDX-FileCopyrightText: 2022-2023 Bart De Vries <bart@mogwai.be>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include "kmediasession_export.h"
0010 
0011 #include <QObject>
0012 #include <QQmlEngine>
0013 #include <QString>
0014 #include <QUrl>
0015 
0016 class KMEDIASESSION_EXPORT MetaData : public QObject
0017 {
0018     Q_OBJECT
0019     QML_ELEMENT
0020 
0021     Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
0022     Q_PROPERTY(QString artist READ artist WRITE setArtist NOTIFY artistChanged)
0023     Q_PROPERTY(QString album READ album WRITE setAlbum NOTIFY albumChanged)
0024     Q_PROPERTY(QUrl artworkUrl READ artworkUrl WRITE setArtworkUrl NOTIFY artworkUrlChanged)
0025 
0026 public:
0027     explicit MetaData(QObject *parent = nullptr);
0028 
0029     QString title() const;
0030     QString artist() const;
0031     QString album() const;
0032     QUrl artworkUrl() const;
0033 
0034 Q_SIGNALS:
0035     void titleChanged(const QString &title);
0036     void artistChanged(const QString &artist);
0037     void albumChanged(const QString &album);
0038     void artworkUrlChanged(const QUrl &artworkUrl);
0039 
0040     void metaDataChanged(MetaData *metaData);
0041 
0042 public Q_SLOTS:
0043     void setTitle(const QString &title);
0044     void setArtist(const QString &artist);
0045     void setAlbum(const QString &album);
0046     void setArtworkUrl(const QUrl &artworkUrl);
0047 
0048     Q_INVOKABLE void clear();
0049 
0050 private:
0051     QString m_title;
0052     QString m_artist;
0053     QString m_album;
0054     QUrl m_artworkUrl;
0055 
0056     void signalMetaDataChanged();
0057 };