From 81e6526005d7c31e2e5f2d0554dabe1e863fb8be Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 7 Dec 2020 16:19:30 +0200 Subject: Use custom icons in webviewcontextmenu --- src/autogen/util.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/autogen/util.cpp (limited to 'src/autogen/util.cpp') diff --git a/src/autogen/util.cpp b/src/autogen/util.cpp new file mode 100644 index 0000000..0120be2 --- /dev/null +++ b/src/autogen/util.cpp @@ -0,0 +1,47 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#include "util.h" +#include +#include +#include + +#define ListSeparator QLatin1String(";") + +const QStringList Util::files(const QString &location, const QStringList &nameFilters) +{ + if(location.isEmpty()) return QStringList(); + + QStringList filelist; + + // check if location is a list of locations (contains a ';') + if(location.contains(ListSeparator)) { + const QStringList locations = location.split(ListSeparator); + + for(const QString &l : locations) { + filelist.append(Util::files(l, nameFilters)); + } + + return filelist; + } + + const QFileInfo info(location); + + // check if location is a folder + if(info.isDir()) { + const auto entryList = QDir(info.absoluteFilePath()).entryInfoList(nameFilters, QDir::Files | QDir::Readable, QDir::Time); + for(const QFileInfo &entryInfo : entryList) { + filelist.append(entryInfo.absoluteFilePath()); + } + } else if(info.isFile()) { + filelist.append(info.absoluteFilePath()); + } + + return filelist; +} + -- cgit v1.2.1