diff options
-rw-r--r-- | core/qthelper.cpp | 14 | ||||
-rw-r--r-- | core/qthelper.h | 1 | ||||
-rw-r--r-- | desktop-widgets/divelistview.cpp | 7 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 1 |
4 files changed, 18 insertions, 5 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 79fc0effc..0cf37fffb 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -1173,9 +1173,18 @@ extern "C" void cache_picture(struct picture *picture) QtConcurrent::run(hashPicture, clone_picture(picture)); } +QStringList imageExtensionFilters() { + QStringList filters; + foreach (QString format, QImageReader::supportedImageFormats()) { + filters.append(QString("*.").append(format)); + } + return filters; +} + void learnImages(const QDir dir, int max_recursions) { - QStringList filters, files; + QStringList files; + QStringList filters = imageExtensionFilters(); if (max_recursions) { foreach (QString dirname, dir.entryList(QStringList(), QDir::NoDotAndDotDot | QDir::Dirs)) { @@ -1183,9 +1192,6 @@ void learnImages(const QDir dir, int max_recursions) } } - foreach (QString format, QImageReader::supportedImageFormats()) { - filters.append(QString("*.").append(format)); - } foreach (QString file, dir.entryList(filters, QDir::Files)) { files.append(dir.absoluteFilePath(file)); diff --git a/core/qthelper.h b/core/qthelper.h index 9788bb55d..e0e4da0c5 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -46,5 +46,6 @@ extern "C" enum deco_mode decoMode(); extern "C" void subsurface_mkdir(const char *dir); void init_proxy(); QString getUUID(); +QStringList imageExtensionFilters(); #endif // QTHELPER_H diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 9c7c30578..a92afadbd 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -917,7 +917,12 @@ void DiveListView::shiftTimes() void DiveListView::loadImages() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open image files"), lastUsedImageDir(), tr("Image files (*.jpg *.jpeg *.pnm *.tif *.tiff)")); + QStringList filters = imageExtensionFilters(); + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open image files"), + lastUsedImageDir(), + tr("Image files (%1)").arg(filters.join(" "))); + if (fileNames.isEmpty()) return; updateLastUsedImageDir(QFileInfo(fileNames[0]).dir().path()); diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index f985a0f01..e6bbe87d9 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -19,6 +19,7 @@ #include "core/display.h" #include "profile-widget/profilewidget2.h" #include "desktop-widgets/undocommands.h" +#include "core/qthelper.h" class MinMaxAvgWidgetPrivate { public: |