Drop picture files on a folio to add them

Picture files (png, jpg, bmp, svg) dragged from the file manager onto a
folio are added there: the first centred on the drop point, the others
cascaded from it, and one undo step removes them all. A picture larger
than the visible part of the folio is scaled down to fit it. Files that
cannot be used are listed once after the others have been placed, and a
drop holding only other files (a .qet project) still reaches the main
window, which opens it.

The checks a picture must pass before it is embedded in the project
move into ImageDrop::load and are now shared by the drop, the add image
dialog and the script API: a regular file of at most 10 MB, and at most
64 megapixels, read from the header before any pixel is allocated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Beat Hangartner
2026-10-04 19:01:05 +02:00
parent e89c69719a
commit 034013ff67
9 changed files with 447 additions and 18 deletions
@@ -17,6 +17,7 @@
*/
#include "diagrameventaddimage.h"
#include "../imagedrop.h"
#include "../qetapp.h"
#include "../qetdiagrameditor.h"
@@ -341,10 +342,11 @@ void DiagramEventAddImage::openDialog()
if (fileName.isEmpty()) return;
QImage image(fileName);
QString error;
const QImage image = ImageDrop::load(fileName, &error);
if(image.isNull())
{
QMessageBox::critical(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Error"), QObject::tr("Unable to load the image."));
QMessageBox::critical(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Error"), QObject::tr("Unable to load the image.") + "\n" + error);
return;
}