diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 0897ad1..2121354 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -140,6 +140,15 @@ MainWindow::MainWindow(QWidget *parent) m_nextButton->setVisible(galleryFileCount > 1); }); + connect(m_pm, &PlaylistManager::currentIndexChanged, this, [this]() { + int index; + QUrl url; + std::tie(index, url) = m_pm->currentFileUrl(); + if (index != -1) { + this->setWindowTitle(url.fileName()); + } + }); + QShortcut * fullscreenShorucut = new QShortcut(QKeySequence(QKeySequence::FullScreen), this); connect(fullscreenShorucut, &QShortcut::activated, this, &MainWindow::toggleFullscreen); diff --git a/app/playlistmanager.cpp b/app/playlistmanager.cpp index b748afe..3f808db 100644 --- a/app/playlistmanager.cpp +++ b/app/playlistmanager.cpp @@ -99,6 +99,7 @@ void PlaylistManager::setCurrentFile(const QString & filePath) break; } + emit currentIndexChanged(m_currentIndex); emit loaded(m_playlist.count()); } @@ -106,6 +107,7 @@ void PlaylistManager::setCurrentIndex(int index) { if (index < 0 || index >= m_playlist.count()) return; m_currentIndex = index; + emit currentIndexChanged(m_currentIndex); } int PlaylistManager::appendFile(const QString &filePath) diff --git a/app/playlistmanager.h b/app/playlistmanager.h index 45901f2..b6cc618 100644 --- a/app/playlistmanager.h +++ b/app/playlistmanager.h @@ -10,6 +10,8 @@ class PlaylistManager : public QObject { Q_OBJECT public: + Q_PROPERTY(int currentIndex MEMBER m_currentIndex NOTIFY currentIndexChanged) + enum PlaylistType { PL_USERPLAYLIST, // Regular playlist, managed by user. PL_SAMEFOLDER // PlaylistManager managed playlist, loaded from files from same folder. @@ -43,6 +45,7 @@ public: signals: void loaded(int length); + void currentIndexChanged(int index); private: QList m_playlist;