feat: add playlist, recent files and MPRIS backends

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
triandClaude Opus 5.5 committed 2026-10-28 09:26:12 +07:00
1 parent 6dc9377de1
commit 54ad4eecf3
18 files changed
+2240 -4

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2026 George Florea Bănuș <georgefb899@gmail.com>
// SPDX-FileCopyrightText: 2026 Tri Vo Khac
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "mpvitem.h"
#include "playlistmodel.h"
#include <QObject>
#include <QPointer>
#include <QWindow>
#include <QtQml/qqmlregistration.h>
#include <memory>
class MprisController;
// Publishes the player on D-Bus (MPRIS), so Plasma's media controls, the lock screen
// and media keys can drive it. Adapted from Haruna's MprisItem.
class MprisItem : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(MpvItem *mpvItem READ mpvItem WRITE setMpvItem NOTIFY mpvItemChanged REQUIRED)
Q_PROPERTY(PlaylistModel *playlist READ playlist WRITE setPlaylist NOTIFY playlistChanged REQUIRED)
Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged REQUIRED)
public:
explicit MprisItem(QObject *parent = nullptr);
~MprisItem() override;
MpvItem *mpvItem() const;
void setMpvItem(MpvItem *mpv);
PlaylistModel *playlist() const;
void setPlaylist(PlaylistModel *playlist);
QWindow *window() const;
void setWindow(QWindow *window);
Q_SIGNALS:
void mpvItemChanged();
void playlistChanged();
void windowChanged();
void raiseRequested();
void openUriRequested(const QString &uri);
// Play the next/previous entry, the way the playlist actions would.
void nextRequested();
void previousRequested();
private:
void updatePlaybackStatus();
void updateNavigation();
std::unique_ptr<MprisController> m_controller;
QPointer<MpvItem> m_mpv;
QPointer<PlaylistModel> m_playlist;
QPointer<QWindow> m_window;
};