From ddc485b0154251f864cbdb0e52ec8e98b049865f Mon Sep 17 00:00:00 2001 From: APTX Date: Mon, 21 Feb 2022 22:19:45 +0900 Subject: [PATCH] Add displayTitle --- core/player.cpp | 11 +++++++++++ core/player.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/core/player.cpp b/core/player.cpp index 73654fe..559c774 100644 --- a/core/player.cpp +++ b/core/player.cpp @@ -50,6 +50,9 @@ Player::Player(BackendPluginBase *backendPlugin, QObject *parent) Q_CHECK_PTR(m_playlist); connect(m_playlist, SIGNAL(currentChanged(PlaylistEntry)), this, SLOT(playPlaylistEntry(PlaylistEntry))); + + connect(this, SIGNAL(currentSourceChanged(QUrl)), this, + SLOT(notifyDisplayTitleChanged())); } Player::~Player() { @@ -67,6 +70,10 @@ QUrl Player::currentSource() const { return m_currentSource; } QUrl Player::nextSource() const { return m_nextSource; } +QString Player::displayTitle() const { + return currentSource().isValid() ? currentSource().fileName() : tr("none"); +} + Player::PlayState Player::state() const { return m_state; } Player::Volume Player::volume() const { return m_volume; } @@ -376,6 +383,10 @@ void Player::playNextPlaylistEntryOnEndOfFile() { m_playlist->next(); } +void Player::notifyDisplayTitleChanged() { + emit displayTitleChanged(displayTitle()); +} + bool Player::canLoadVideoNow() const { return m_backendInstanceReady && m_renderer && m_rendererReady; } diff --git a/core/player.h b/core/player.h index b6d2918..6d891cd 100644 --- a/core/player.h +++ b/core/player.h @@ -24,6 +24,9 @@ class Player : public QObject, Q_PROPERTY(QUrl nextSource READ nextSource WRITE setNextSource NOTIFY nextSourceChanged) + Q_PROPERTY(QString displayTitle READ displayTitle NOTIFY displayTitleChanged + STORED false) + Q_PROPERTY(double duration READ duration NOTIFY durationChanged) Q_PROPERTY(double position READ position WRITE seek NOTIFY positionChanged) @@ -84,6 +87,8 @@ public: QUrl currentSource() const; QUrl nextSource() const; + QString displayTitle() const; + PlayState state() const; Volume volume() const; Volume maxVolume() const; @@ -127,6 +132,8 @@ signals: void currentSourceChanged(QUrl currentSource); void nextSourceChanged(QUrl nextSource); + void displayTitleChanged(QString displayTitle); + void durationChanged(double duration); void positionChanged(double position); @@ -200,6 +207,7 @@ private slots: void onNewFrame(); void playPlaylistEntry(const PlaylistEntry &entry); void playNextPlaylistEntryOnEndOfFile(); + void notifyDisplayTitleChanged(); private: bool canLoadVideoNow() const; -- 2.52.0