void S60VideoDisplay::updateContentRect() { if (isPaintingEnabled()) { const int dx = qMax(0, extentRect().width() - nativeSize().width()); const int dy = qMax(0, extentRect().height() - nativeSize().height()); QRect contentRect(QPoint(dx/2, dy/2), nativeSize()); if (m_contentRect != contentRect) { m_contentRect = contentRect; emit contentRectChanged(m_contentRect); } } }
void IGraphicsItem::onWheelEvent(QGraphicsSceneWheelEvent *event) { if(!item_->isSelected()) return; int d = event->delta(); int w_delta; if(d >= 120) { w_delta = 10; } else if(d <= -120) { w_delta = -10; } else { return; } QSize s = size(); int w, h; if(aspectRatioMode() == Qt::KeepAspectRatio) { QSize n = nativeSize(); w = s.width() + w_delta; h = (w * n.height() + n.width()/2)/ n.width(); } else { w = s.width() + w_delta; h = (w * s.height() + s.width()/2)/ s.width(); } setSize(QSize(w, h)); update(); updatePos(); setGrabbersPosition(item_->boundingRect()); }
void IGraphicsItem::restoreDefaultSize() { setAspectRatioMode(Qt::KeepAspectRatio); setSize(nativeSize()); update(); updatePos(); }
void Evr9VideoWindowControl::repaint() { QSize size = nativeSize(); if (size.width() > 0 && size.height() > 0 && m_displayControl && SUCCEEDED(m_displayControl->RepaintVideo())) { return; } PAINTSTRUCT paint; if (HDC dc = ::BeginPaint(m_windowId, &paint)) { HPEN pen = ::CreatePen(PS_SOLID, 1, m_windowColor); HBRUSH brush = ::CreateSolidBrush(m_windowColor); ::SelectObject(dc, pen); ::SelectObject(dc, brush); ::Rectangle( dc, m_displayRect.left(), m_displayRect.top(), m_displayRect.right() + 1, m_displayRect.bottom() + 1); ::DeleteObject(pen); ::DeleteObject(brush); ::EndPaint(m_windowId, &paint); } }
void Evr9VideoWindowControl::setDisplayRect(const QRect &rect) { m_displayRect = rect; if (m_displayControl) { RECT displayRect = { rect.left(), rect.top(), rect.right() + 1, rect.bottom() + 1 }; QSize sourceSize = nativeSize(); RECT sourceRect = { 0, 0, sourceSize.width(), sourceSize.height() }; if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { QSize clippedSize = rect.size(); clippedSize.scale(sourceRect.right, sourceRect.bottom, Qt::KeepAspectRatio); sourceRect.left = (sourceRect.right - clippedSize.width()) / 2; sourceRect.top = (sourceRect.bottom - clippedSize.height()) / 2; sourceRect.right = sourceRect.left + clippedSize.width(); sourceRect.bottom = sourceRect.top + clippedSize.height(); } if (sourceSize.width() > 0 && sourceSize.height() > 0) { MFVideoNormalizedRect sourceNormRect; sourceNormRect.left = float(sourceRect.left) / float(sourceRect.right); sourceNormRect.top = float(sourceRect.top) / float(sourceRect.bottom); sourceNormRect.right = float(sourceRect.right) / float(sourceRect.right); sourceNormRect.bottom = float(sourceRect.bottom) / float(sourceRect.bottom); m_displayControl->SetVideoPosition(&sourceNormRect, &displayRect); } else { m_displayControl->SetVideoPosition(NULL, &displayRect); } } }
QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) { const QPlatformScreen *platformScreen = handle(); if (!platformScreen) { qWarning("invoked with handle==0"); return QPixmap(); } const qreal factor = QHighDpiScaling::factor(this); if (qFuzzyCompare(factor, 1)) return platformScreen->grabWindow(window, x, y, width, height); const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor); QSize nativeSize(width, height); if (nativeSize.isValid()) nativeSize = QHighDpi::toNative(nativeSize, factor); QPixmap result = platformScreen->grabWindow(window, nativePos.x(), nativePos.y(), nativeSize.width(), nativeSize.height()); result.setDevicePixelRatio(factor); return result; }
QRectF QDeclarativeVideoWindowBackend::adjustedViewport() const { // No viewport supported by QVideoWindowControl, so make the viewport the same size // as the source return QRectF(QPointF(0, 0), nativeSize()); }