feat: able to show file name in window title
This commit is contained in:
parent
5aeb0f821f
commit
6a992f4c1f
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user