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); parser.process(a);
QStringList urlStrList = parser.positionalArguments();
QList<QUrl> && urlList = PlaylistManager::convertToUrlList(urlStrList);
MainWindow w; MainWindow w;
w.show(); w.show();
QStringList urlStrList = parser.positionalArguments();
QList<QUrl> && urlList = PlaylistManager::convertToUrlList(urlStrList);
if (!urlList.isEmpty()) { if (!urlList.isEmpty()) {
w.showUrls(urlList); w.showUrls(urlList);
w.adjustWindowSizeBySceneRect(); w.adjustWindowSizeBySceneRect();

View File

@ -41,6 +41,8 @@ MainWindow::MainWindow(QWidget *parent)
this->setWindowIcon(QIcon(":/icons/app-icon.svg")); this->setWindowIcon(QIcon(":/icons/app-icon.svg"));
this->setMouseTracking(true); this->setMouseTracking(true);
m_pm->setAutoLoadFilterSuffix({"*.jpg", "*.jpeg", "*.jfif", "*.png", "*.gif", "*.svg", "*.bmp", "*.webp"});
m_fadeOutAnimation = new QPropertyAnimation(this, "windowOpacity"); m_fadeOutAnimation = new QPropertyAnimation(this, "windowOpacity");
m_fadeOutAnimation->setDuration(300); m_fadeOutAnimation->setDuration(300);
m_fadeOutAnimation->setStartValue(1); m_fadeOutAnimation->setStartValue(1);

View File

@ -27,6 +27,16 @@ PlaylistManager::PlaylistType PlaylistManager::playlistType() const
return m_type; return m_type;
} }
QStringList PlaylistManager::autoLoadFilterSuffix() const
{
return m_autoLoadSuffix;
}
void PlaylistManager::setAutoLoadFilterSuffix(const QStringList & nameFilters)
{
m_autoLoadSuffix = nameFilters;
}
void PlaylistManager::clear() void PlaylistManager::clear()
{ {
m_currentIndex = -1; m_currentIndex = -1;
@ -50,8 +60,9 @@ void PlaylistManager::setCurrentFile(const QString & filePath)
int index = indexOf(filePath); int index = indexOf(filePath);
m_currentIndex = index == -1 ? appendFile(filePath) : index; m_currentIndex = index == -1 ? appendFile(filePath) : index;
} else { } else {
QStringList entryList = dir.entryList({"*.jpg", "*.jpeg", "*.jfif", "*.png", "*.gif", "*.svg", "*.bmp"}, QStringList entryList = dir.entryList(
QDir::Files | QDir::NoSymLinks, QDir::NoSort); m_autoLoadSuffix,
QDir::Files | QDir::NoSymLinks, QDir::NoSort);
QCollator collator; QCollator collator;
collator.setNumericMode(true); collator.setNumericMode(true);

View File

@ -17,6 +17,9 @@ public:
void setPlaylistType(PlaylistType type); void setPlaylistType(PlaylistType type);
PlaylistType playlistType() const; PlaylistType playlistType() const;
QStringList autoLoadFilterSuffix() const;
void setAutoLoadFilterSuffix(const QStringList &nameFilters);
void clear(); void clear();
void setPlaylist(const QList<QUrl> & urls); void setPlaylist(const QList<QUrl> & urls);
@ -40,5 +43,6 @@ private:
PlaylistType m_type; PlaylistType m_type;
QString m_currentDir; QString m_currentDir;
int m_currentIndex = -1; int m_currentIndex = -1;
QStringList m_autoLoadSuffix = {};
}; };