summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-05-05 21:13:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-06 08:07:16 -0700
commit462797396b082f31060df6706bfce416aebce037 (patch)
tree577ab4fc5450c068fb9146ebb72d1617f0fe1bd2
parent59bbaa78203fafe3f66ed34c281733fe6eea0940 (diff)
downloadsubsurface-462797396b082f31060df6706bfce416aebce037.tar.gz
File selector should filter images we can actually handle.
So better ask Qt about image formats known to it. Signed-off-by: Robert C. Helling <helling@atdotde.de>
-rw-r--r--core/qthelper.cpp14
-rw-r--r--core/qthelper.h1
-rw-r--r--desktop-widgets/divelistview.cpp7
-rw-r--r--desktop-widgets/simplewidgets.cpp1
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: