mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
59bbaa7820
commit
462797396b
4 changed files with 18 additions and 5 deletions
|
@ -1173,9 +1173,18 @@ extern "C" void cache_picture(struct picture *picture)
|
||||||
QtConcurrent::run(hashPicture, clone_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)
|
void learnImages(const QDir dir, int max_recursions)
|
||||||
{
|
{
|
||||||
QStringList filters, files;
|
QStringList files;
|
||||||
|
QStringList filters = imageExtensionFilters();
|
||||||
|
|
||||||
if (max_recursions) {
|
if (max_recursions) {
|
||||||
foreach (QString dirname, dir.entryList(QStringList(), QDir::NoDotAndDotDot | QDir::Dirs)) {
|
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)) {
|
foreach (QString file, dir.entryList(filters, QDir::Files)) {
|
||||||
files.append(dir.absoluteFilePath(file));
|
files.append(dir.absoluteFilePath(file));
|
||||||
|
|
|
@ -46,5 +46,6 @@ extern "C" enum deco_mode decoMode();
|
||||||
extern "C" void subsurface_mkdir(const char *dir);
|
extern "C" void subsurface_mkdir(const char *dir);
|
||||||
void init_proxy();
|
void init_proxy();
|
||||||
QString getUUID();
|
QString getUUID();
|
||||||
|
QStringList imageExtensionFilters();
|
||||||
|
|
||||||
#endif // QTHELPER_H
|
#endif // QTHELPER_H
|
||||||
|
|
|
@ -917,7 +917,12 @@ void DiveListView::shiftTimes()
|
||||||
|
|
||||||
void DiveListView::loadImages()
|
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())
|
if (fileNames.isEmpty())
|
||||||
return;
|
return;
|
||||||
updateLastUsedImageDir(QFileInfo(fileNames[0]).dir().path());
|
updateLastUsedImageDir(QFileInfo(fileNames[0]).dir().path());
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "core/display.h"
|
#include "core/display.h"
|
||||||
#include "profile-widget/profilewidget2.h"
|
#include "profile-widget/profilewidget2.h"
|
||||||
#include "desktop-widgets/undocommands.h"
|
#include "desktop-widgets/undocommands.h"
|
||||||
|
#include "core/qthelper.h"
|
||||||
|
|
||||||
class MinMaxAvgWidgetPrivate {
|
class MinMaxAvgWidgetPrivate {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Reference in a new issue