Revert "Fix for screenshot tool not grabbing videos"

This reverts commit b6f41165a6.
preferencesAboutTextFull
Clément Fauconnier 7 years ago
parent 8a9edb36cc
commit 698193a85f
  1. 29
      src/board/UBBoardController.cpp

@ -2127,28 +2127,29 @@ QUrl UBBoardController::expandWidgetToTempDir(const QByteArray& pZipedData, cons
} }
/**
* @brief Take a screenshot of part of the scene
* @param pSceneRect The area to capture, in the active scene's coordinates
*/
void UBBoardController::grabScene(const QRectF& pSceneRect) void UBBoardController::grabScene(const QRectF& pSceneRect)
{ {
if (mActiveScene) if (mActiveScene)
{ {
// Ideally we should render the scene directly to a QImage rather than use grabWindow; QImage image(pSceneRect.width(), pSceneRect.height(), QImage::Format_ARGB32);
// this was the previous solution but it couldn't grab videos (QGraphicsVideoItem), so it image.fill(Qt::transparent);
// was changed to this admittedly more sketchy way of doing it.
QRectF targetRect(0, 0, pSceneRect.width(), pSceneRect.height());
QPainter painter(&image);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.setRenderHint(QPainter::Antialiasing);
mActiveScene->setRenderingContext(UBGraphicsScene::NonScreen);
mActiveScene->setRenderingQuality(UBItem::RenderingQualityHigh);
UBBoardView* view = mActiveScene->controlView(); mActiveScene->render(&painter, targetRect, pSceneRect);
QPoint pos = view->viewport()->mapFromGlobal(view->mapToGlobal(view->mapFromScene(pSceneRect.topLeft()))) + QPoint(1,1);
qreal scale = systemScaleFactor(); mActiveScene->setRenderingContext(UBGraphicsScene::Screen);
QScreen * screen = UBApplication::controlScreen(); // mActiveScene->setRenderingQuality(UBItem::RenderingQualityNormal);
mActiveScene->setRenderingQuality(UBItem::RenderingQualityHigh);
QPixmap image = screen->grabWindow(view->viewport()->winId(),
pos.x(), pos.y(), pSceneRect.width()*scale - 1, pSceneRect.height()*scale - 1);
mPaletteManager->addItem(image, QPointF(0,0), 1/scale); mPaletteManager->addItem(QPixmap::fromImage(image));
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
} }

Loading…
Cancel
Save