ksnapshot: use the same pixmap size as KPixmapWidget for the drag

because the preview pixmap size depends on the size of ksnapshot itself
it may be very big and the drag pixmap itself may be big covering way too
much screen space if not down-scaled to a reasonable size

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-30 22:17:35 +03:00
parent e24e22a4af
commit 089a085061

View file

@ -347,7 +347,13 @@ void KSnapshot::slotDragSnapshot()
drag->setMimeData(new QMimeData);
drag->mimeData()->setImageData(snapshot);
drag->mimeData()->setData("application/x-kde-suggestedfilename", filename.fileName().toUtf8());
drag->setPixmap(preview());
const QPixmap previewPixmap = preview();
if (!previewPixmap.isNull()) {
// NOTE: keep in sync with:
// kdelibs/kdeui/widgets/kpixmapwidget.cpp
drag->setPixmap(previewPixmap.scaled(QSize(96, 96), Qt::KeepAspectRatio));
drag->setHotSpot(QPoint(-5,-7));
}
QList<QUrl> urls;
urls << urlToOpen();
drag->mimeData()->setUrls(urls);