feat: able to show file name in window title

This commit is contained in:
Gary Wang 2023-05-29 23:59:45 +08:00
parent 5aeb0f821f
commit 6a992f4c1f
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760
3 changed files with 14 additions and 0 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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<QUrl> m_playlist;