Gui: fix image handling:

* Change FileHandlder to accepts all image format supported by Qt
* Make sure image object is not touched after accepting or rejecting changes
* Make option 'Keep aspect ratio' the default
* Fix WhatThis text of command
This commit is contained in:
wmayer
2023-03-22 17:55:55 +01:00
parent 3e3540192b
commit 6ae787cc6b
4 changed files with 15 additions and 5 deletions

View File

@@ -1982,7 +1982,7 @@ StdViewLoadImage::StdViewLoadImage()
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Load image...");
sToolTipText= QT_TR_NOOP("Loads a image");
sWhatsThis = "Std_ViewLoadPicture";
sWhatsThis = "Std_ViewLoadImage";
sStatusTip = QT_TR_NOOP("Loads a image");
sPixmap = "image-open";
eType = 0;

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QFileInfo>
# include <QImageReader>
# include <QStringList>
# include <Inventor/SoInput.h>
#endif
@@ -146,10 +147,14 @@ bool FileHandler::openInternal()
return true;
}
if (hasExtension(QStringList() << QLatin1String("bmp")
<< QLatin1String("jpg")
<< QLatin1String("png")
<< QLatin1String("xpm"))) {
QStringList supportedFormats;
auto imageFormats = QImageReader::supportedImageFormats();
std::transform(imageFormats.cbegin(), imageFormats.cend(),
std::back_inserter(supportedFormats), [](const QByteArray& format) {
return QString::fromLatin1(format);
});
if (hasExtension(supportedFormats)) {
openImage();
return true;
}

View File

@@ -69,6 +69,9 @@
<property name="text">
<string>Keep aspect ratio</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@@ -72,6 +72,7 @@ void TaskOrientation::accept()
if (!feature.expired()) {
App::Document* doc = feature->getDocument();
doc->commitTransaction();
doc->recompute();
}
}
@@ -80,6 +81,7 @@ void TaskOrientation::reject()
if (!feature.expired()) {
App::Document* doc = feature->getDocument();
doc->abortTransaction();
feature->purgeTouched();
}
}