diff --git a/app/main.cpp b/app/main.cpp index be7be91..0796711 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -37,12 +37,12 @@ int main(int argc, char *argv[]) parser.process(a); - QStringList urlStrList = parser.positionalArguments(); - QList && urlList = PlaylistManager::convertToUrlList(urlStrList); - MainWindow w; w.show(); + QStringList urlStrList = parser.positionalArguments(); + QList && urlList = PlaylistManager::convertToUrlList(urlStrList); + if (!urlList.isEmpty()) { w.showUrls(urlList); w.adjustWindowSizeBySceneRect(); diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index f44b4ce..be120c8 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -41,6 +41,8 @@ MainWindow::MainWindow(QWidget *parent) this->setWindowIcon(QIcon(":/icons/app-icon.svg")); this->setMouseTracking(true); + m_pm->setAutoLoadFilterSuffix({"*.jpg", "*.jpeg", "*.jfif", "*.png", "*.gif", "*.svg", "*.bmp", "*.webp"}); + m_fadeOutAnimation = new QPropertyAnimation(this, "windowOpacity"); m_fadeOutAnimation->setDuration(300); m_fadeOutAnimation->setStartValue(1); diff --git a/app/playlistmanager.cpp b/app/playlistmanager.cpp index 6afbcbf..b25bd3a 100644 --- a/app/playlistmanager.cpp +++ b/app/playlistmanager.cpp @@ -27,6 +27,16 @@ PlaylistManager::PlaylistType PlaylistManager::playlistType() const return m_type; } +QStringList PlaylistManager::autoLoadFilterSuffix() const +{ + return m_autoLoadSuffix; +} + +void PlaylistManager::setAutoLoadFilterSuffix(const QStringList & nameFilters) +{ + m_autoLoadSuffix = nameFilters; +} + void PlaylistManager::clear() { m_currentIndex = -1; @@ -50,8 +60,9 @@ void PlaylistManager::setCurrentFile(const QString & filePath) int index = indexOf(filePath); m_currentIndex = index == -1 ? appendFile(filePath) : index; } else { - QStringList entryList = dir.entryList({"*.jpg", "*.jpeg", "*.jfif", "*.png", "*.gif", "*.svg", "*.bmp"}, - QDir::Files | QDir::NoSymLinks, QDir::NoSort); + QStringList entryList = dir.entryList( + m_autoLoadSuffix, + QDir::Files | QDir::NoSymLinks, QDir::NoSort); QCollator collator; collator.setNumericMode(true); diff --git a/app/playlistmanager.h b/app/playlistmanager.h index 4d72690..0711629 100644 --- a/app/playlistmanager.h +++ b/app/playlistmanager.h @@ -17,6 +17,9 @@ public: void setPlaylistType(PlaylistType type); PlaylistType playlistType() const; + QStringList autoLoadFilterSuffix() const; + void setAutoLoadFilterSuffix(const QStringList &nameFilters); + void clear(); void setPlaylist(const QList & urls); @@ -40,5 +43,6 @@ private: PlaylistType m_type; QString m_currentDir; int m_currentIndex = -1; + QStringList m_autoLoadSuffix = {}; };