chore: add webp to default image queue filter list

This commit is contained in:
Gary Wang 2021-02-26 00:57:12 +08:00
parent 6316431dcc
commit 9c460f2ede
4 changed files with 22 additions and 5 deletions

View File

@ -37,12 +37,12 @@ int main(int argc, char *argv[])
parser.process(a);
QStringList urlStrList = parser.positionalArguments();
QList<QUrl> && urlList = PlaylistManager::convertToUrlList(urlStrList);
MainWindow w;
w.show();
QStringList urlStrList = parser.positionalArguments();
QList<QUrl> && urlList = PlaylistManager::convertToUrlList(urlStrList);
if (!urlList.isEmpty()) {
w.showUrls(urlList);
w.adjustWindowSizeBySceneRect();

View File

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

View File

@ -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,7 +60,8 @@ 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"},
QStringList entryList = dir.entryList(
m_autoLoadSuffix,
QDir::Files | QDir::NoSymLinks, QDir::NoSort);
QCollator collator;

View File

@ -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<QUrl> & urls);
@ -40,5 +43,6 @@ private:
PlaylistType m_type;
QString m_currentDir;
int m_currentIndex = -1;
QStringList m_autoLoadSuffix = {};
};