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

+50
View File
@@ -29,6 +29,19 @@ class MpvItem : public MpvAbstractItem
// In seconds; applied to both subtitles so a translation stays in sync with its source.
Q_PROPERTY(double subtitleDelay READ subtitleDelay WRITE setSubtitleDelay NOTIFY subtitleDelayChanged)
// Audio tracks of the current file, each a map with id, title, lang and codec.
Q_PROPERTY(QVariantList audioTracks READ audioTracks NOTIFY audioTracksChanged)
Q_PROPERTY(int audioId READ audioId WRITE setAudioId NOTIFY audioTracksChanged)
// 0 to volumeMax (mpv's "volume-max", 130 unless mpv.conf changes it).
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(int volumeMax READ volumeMax NOTIFY volumeMaxChanged)
Q_PROPERTY(bool mute READ mute WRITE setMute NOTIFY muteChanged)
Q_PROPERTY(double speed READ speed WRITE setSpeed NOTIFY speedChanged)
// Chapters of the current file, each a map with title and time (in seconds).
Q_PROPERTY(QVariantList chapters READ chapters NOTIFY chaptersChanged)
// Index into chapters, -1 before the first chapter or without chapters.
Q_PROPERTY(int chapter READ chapter WRITE setChapter NOTIFY chapterChanged)
// Load the user's mpv.conf when mpv starts. Must be set before the item is shown.
Q_PROPERTY(bool loadUserConfig READ loadUserConfig WRITE setLoadUserConfig NOTIFY loadUserConfigChanged)
Q_PROPERTY(QString userConfigDir READ userConfigDir CONSTANT)
@@ -55,6 +68,19 @@ public:
void setSecondarySubtitleId(int id);
double subtitleDelay() const;
void setSubtitleDelay(double seconds);
QVariantList audioTracks() const;
int audioId() const;
void setAudioId(int id);
int volume() const;
void setVolume(int volume);
int volumeMax() const;
bool mute() const;
void setMute(bool mute);
double speed() const;
void setSpeed(double speed);
QVariantList chapters() const;
int chapter() const;
void setChapter(int chapter);
bool loadUserConfig() const;
void setLoadUserConfig(bool load);
QString userConfigDir() const;
@@ -62,8 +88,15 @@ public:
QStringList skippedUserOptions() const;
Q_INVOKABLE void loadFile(const QUrl &url);
// Unloads the current file.
Q_INVOKABLE void stop();
Q_INVOKABLE void togglePause();
Q_INVOKABLE void seek(double seconds);
// Seeks \a seconds forward, or backward when negative.
Q_INVOKABLE void seekBy(double seconds);
Q_INVOKABLE void frameStep(bool forward);
// Saves a screenshot the way mpv does (screenshot-directory, screenshot-format).
Q_INVOKABLE void screenshot();
// Adds an external subtitle file and makes it the primary subtitle.
Q_INVOKABLE void addSubtitleFile(const QUrl &url);
// Makes \a url the only subtitle shown, adding it first (named \a title) unless it is
@@ -81,6 +114,15 @@ Q_SIGNALS:
void fileLoadedChanged();
void subtitleTracksChanged();
void subtitleDelayChanged();
void audioTracksChanged();
void volumeChanged();
void volumeMaxChanged();
void muteChanged();
void speedChanged();
void chaptersChanged();
void chapterChanged();
// Playback reached the end of the file. The last frame stays on screen.
void endOfFile();
void loadUserConfigChanged();
// mpv.conf was queued for loading; options set after this take precedence over it.
void userConfigApplied();
@@ -104,6 +146,14 @@ private:
int m_subtitleId = 0;
int m_secondarySubtitleId = 0;
double m_subtitleDelay = 0.0;
QVariantList m_audioTracks;
int m_audioId = 0;
int m_volume = 100;
int m_volumeMax = 130;
bool m_mute = false;
double m_speed = 1.0;
QVariantList m_chapters;
int m_chapter = -1;
// File added by showTranslatedSubtitleFile() that should be shown once mpv lists it.
QString m_pendingTranslatedPath;
bool m_loadUserConfig = false;