From 6ae787cc6b1d1fc6b0df80aa44ab089ac85ff2b2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 22 Mar 2023 17:55:55 +0100 Subject: [PATCH] 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 --- src/Gui/CommandView.cpp | 2 +- src/Gui/FileHandler.cpp | 13 +++++++++---- src/Gui/TaskView/TaskImageScale.ui | 3 +++ src/Gui/TaskView/TaskOrientation.cpp | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 8ef15b3530..f8d9b3502f 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -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; diff --git a/src/Gui/FileHandler.cpp b/src/Gui/FileHandler.cpp index 80dd914e57..9ddf982012 100644 --- a/src/Gui/FileHandler.cpp +++ b/src/Gui/FileHandler.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ # include +# include # include # include #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; } diff --git a/src/Gui/TaskView/TaskImageScale.ui b/src/Gui/TaskView/TaskImageScale.ui index 687b281bdc..314e558bef 100644 --- a/src/Gui/TaskView/TaskImageScale.ui +++ b/src/Gui/TaskView/TaskImageScale.ui @@ -69,6 +69,9 @@ Keep aspect ratio + + true + diff --git a/src/Gui/TaskView/TaskOrientation.cpp b/src/Gui/TaskView/TaskOrientation.cpp index fe80f48935..62577899a8 100644 --- a/src/Gui/TaskView/TaskOrientation.cpp +++ b/src/Gui/TaskView/TaskOrientation.cpp @@ -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(); } }