For media file open dialog add different file filters

On top of the file filter for all media files add a file filter
for images only, one for videos only and one for all files.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2018-07-13 21:06:28 +02:00 committed by Dirk Hohndel
parent 669277d490
commit bb2dfdfe54
3 changed files with 25 additions and 6 deletions

View file

@ -1215,11 +1215,22 @@ const QStringList videoExtensionsList = {
".avi", ".mp4", ".mov", ".mpeg", ".mpg", ".wmv"
};
QStringList imageExtensionFilters() {
QStringList mediaExtensionFilters()
{
return imageExtensionFilters() + videoExtensionFilters();
}
QStringList imageExtensionFilters()
{
QStringList filters;
foreach (const QString &format, QImageReader::supportedImageFormats())
filters.append("*." + format);
return filters;
}
QStringList videoExtensionFilters()
{
QStringList filters;
foreach (QString format, QImageReader::supportedImageFormats()) {
filters.append(QString("*.").append(format));
}
foreach (const QString &format, videoExtensionsList)
filters.append("*" + format);
return filters;

View file

@ -43,7 +43,9 @@ void setCurrentAppState(const QByteArray &state);
void init_proxy();
QString getUUID();
extern const QStringList videoExtensionsList;
QStringList mediaExtensionFilters();
QStringList imageExtensionFilters();
QStringList videoExtensionFilters();
char *intdup(int index);
char *copy_qstring(const QString &);
QString get_depth_string(depth_t depth, bool showunit = false, bool showdecimal = true);

View file

@ -922,11 +922,17 @@ void DiveListView::shiftTimes()
void DiveListView::loadImages()
{
QStringList filters = imageExtensionFilters();
QStringList m_filters = mediaExtensionFilters();
QStringList i_filters = imageExtensionFilters();
QStringList v_filters = videoExtensionFilters();
QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open media files"),
lastUsedImageDir(),
tr("Media files (%1)").arg(filters.join(" ")));
QString("%1 (%2);;%3 (%4);;%5 (%6);;%7 (*.*)")
.arg(tr("Media files"), m_filters.join(" ")
, tr("Image files"), i_filters.join(" ")
, tr("Video files"), v_filters.join(" ")
, tr("All files")));
if (fileNames.isEmpty())
return;