From 019c3f7b55ef40e5ad704e49f7538c5efe469caf Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Sun, 5 May 2019 23:22:09 +0000 Subject: Qt5 make Qt5Widdget's frame a private reference Kind of a regression from commit 4d382636b0b1 ("qt5: Add basic a11y support"), which made it public for a single call. Change-Id: I631a861a98388223770cfca2704c3ddee6a0a8a0 Reviewed-on: https://gerrit.libreoffice.org/71836 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski (cherry picked from commit 8c71d28069acffa2d4590a4acf95a98d1415b563) Reviewed-on: https://gerrit.libreoffice.org/73650 Reviewed-by: Michael Weghorn --- vcl/inc/qt5/Qt5Widget.hxx | 5 ++- vcl/qt5/Qt5AccessibleWidget.cxx | 2 +- vcl/qt5/Qt5Widget.cxx | 79 ++++++++++++++++++++--------------------- 3 files changed, 43 insertions(+), 43 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx index d96afa64aeb0..30998a8a1c6d 100644 --- a/vcl/inc/qt5/Qt5Widget.hxx +++ b/vcl/inc/qt5/Qt5Widget.hxx @@ -42,6 +42,8 @@ class Qt5Widget : public QWidget { Q_OBJECT + Qt5Frame& m_rFrame; + bool handleKeyEvent(QKeyEvent*, bool); void handleMouseButtonEvent(QMouseEvent*, bool); @@ -71,7 +73,8 @@ public slots: public: Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags()); - Qt5Frame* m_pFrame; + + Qt5Frame& getFrame() const { return m_rFrame; } void startDrag(sal_Int8 nSourceActions); }; diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx index e2cc0a31765c..9757eab27837 100644 --- a/vcl/qt5/Qt5AccessibleWidget.cxx +++ b/vcl/qt5/Qt5AccessibleWidget.cxx @@ -718,7 +718,7 @@ QAccessibleInterface* Qt5AccessibleWidget::customFactory(const QString& classnam if (classname == QLatin1String("Qt5Widget") && object && object->isWidgetType()) { Qt5Widget* pWidget = static_cast(object); - vcl::Window* pWindow = pWidget->m_pFrame->GetWindow(); + vcl::Window* pWindow = pWidget->getFrame().GetWindow(); if (pWindow) return new Qt5AccessibleWidget(pWindow->GetAccessible()); diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 62d02e58565d..2137109beac7 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -47,12 +47,12 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent) { QPainter p(this); - if (!m_pFrame->m_bNullRegion) - p.setClipRegion(m_pFrame->m_aRegion); + if (!m_rFrame.m_bNullRegion) + p.setClipRegion(m_rFrame.m_aRegion); - if (m_pFrame->m_bUseCairo) + if (m_rFrame.m_bUseCairo) { - cairo_surface_t* pSurface = m_pFrame->m_pSurface.get(); + cairo_surface_t* pSurface = m_rFrame.m_pSurface.get(); cairo_surface_flush(pSurface); QImage aImage(cairo_image_surface_get_data(pSurface), size().width(), size().height(), @@ -60,55 +60,55 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent) p.drawImage(pEvent->rect().topLeft(), aImage, pEvent->rect()); } else - p.drawImage(pEvent->rect().topLeft(), *m_pFrame->m_pQImage, pEvent->rect()); + p.drawImage(pEvent->rect().topLeft(), *m_rFrame.m_pQImage, pEvent->rect()); } void Qt5Widget::resizeEvent(QResizeEvent* pEvent) { - if (m_pFrame->m_bUseCairo) + if (m_rFrame.m_bUseCairo) { int width = size().width(); int height = size().height(); - if (m_pFrame->m_pSvpGraphics) + if (m_rFrame.m_pSvpGraphics) { cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); cairo_surface_set_user_data(pSurface, SvpSalGraphics::getDamageKey(), - &m_pFrame->m_aDamageHandler, nullptr); - m_pFrame->m_pSvpGraphics->setSurface(pSurface, basegfx::B2IVector(width, height)); - UniqueCairoSurface old_surface(m_pFrame->m_pSurface.release()); - m_pFrame->m_pSurface.reset(pSurface); + &m_rFrame.m_aDamageHandler, nullptr); + m_rFrame.m_pSvpGraphics->setSurface(pSurface, basegfx::B2IVector(width, height)); + UniqueCairoSurface old_surface(m_rFrame.m_pSurface.release()); + m_rFrame.m_pSurface.reset(pSurface); int min_width = qMin(pEvent->oldSize().width(), pEvent->size().width()); int min_height = qMin(pEvent->oldSize().height(), pEvent->size().height()); SalTwoRect rect(0, 0, min_width, min_height, 0, 0, min_width, min_height); - m_pFrame->m_pSvpGraphics->copySource(rect, old_surface.get()); + m_rFrame.m_pSvpGraphics->copySource(rect, old_surface.get()); } } else { QImage* pImage = nullptr; - if (m_pFrame->m_pQImage) + if (m_rFrame.m_pQImage) pImage = new QImage( - m_pFrame->m_pQImage->copy(0, 0, pEvent->size().width(), pEvent->size().height())); + m_rFrame.m_pQImage->copy(0, 0, pEvent->size().width(), pEvent->size().height())); else { pImage = new QImage(size(), Qt5_DefaultFormat32); pImage->fill(Qt::transparent); } - m_pFrame->m_pQt5Graphics->ChangeQImage(pImage); - m_pFrame->m_pQImage.reset(pImage); + m_rFrame.m_pQt5Graphics->ChangeQImage(pImage); + m_rFrame.m_pQImage.reset(pImage); } - m_pFrame->maGeometry.nWidth = size().width(); - m_pFrame->maGeometry.nHeight = size().height(); + m_rFrame.maGeometry.nWidth = size().width(); + m_rFrame.maGeometry.nHeight = size().height(); - m_pFrame->CallCallback(SalEvent::Resize, nullptr); + m_rFrame.CallCallback(SalEvent::Resize, nullptr); } void Qt5Widget::handleMouseButtonEvent(QMouseEvent* pEvent, bool bReleased) @@ -139,7 +139,7 @@ void Qt5Widget::handleMouseButtonEvent(QMouseEvent* pEvent, bool bReleased) nEventType = SalEvent::MouseButtonUp; else nEventType = SalEvent::MouseButtonDown; - m_pFrame->CallCallback(nEventType, &aEvent); + m_rFrame.CallCallback(nEventType, &aEvent); } void Qt5Widget::mousePressEvent(QMouseEvent* pEvent) { handleMouseButtonEvent(pEvent, false); } @@ -157,7 +157,7 @@ void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent) aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons()); aEvent.mnButton = 0; - m_pFrame->CallCallback(SalEvent::MouseMove, &aEvent); + m_rFrame.CallCallback(SalEvent::MouseMove, &aEvent); pEvent->accept(); } @@ -185,7 +185,7 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent) aEvent.mnNotchDelta = nDelta > 0 ? 1 : -1; aEvent.mnScrollLines = 3; - m_pFrame->CallCallback(SalEvent::WheelMouse, &aEvent); + m_rFrame.CallCallback(SalEvent::WheelMouse, &aEvent); pEvent->accept(); } @@ -212,7 +212,7 @@ void Qt5Widget::dragMoveEvent(QDragMoveEvent* event) { QPoint point = event->pos(); - m_pFrame->draggingStarted(point.x(), point.y(), event->possibleActions(), event->mimeData()); + m_rFrame.draggingStarted(point.x(), point.y(), event->possibleActions(), event->mimeData()); QWidget::dragMoveEvent(event); } @@ -220,22 +220,22 @@ void Qt5Widget::dropEvent(QDropEvent* event) { QPoint point = event->pos(); - m_pFrame->dropping(point.x(), point.y(), event->mimeData()); + m_rFrame.dropping(point.x(), point.y(), event->mimeData()); QWidget::dropEvent(event); } -void Qt5Widget::moveEvent(QMoveEvent*) { m_pFrame->CallCallback(SalEvent::Move, nullptr); } +void Qt5Widget::moveEvent(QMoveEvent*) { m_rFrame.CallCallback(SalEvent::Move, nullptr); } void Qt5Widget::showEvent(QShowEvent*) { - QSize aSize(m_pFrame->GetQWidget()->size()); + QSize aSize(m_rFrame.GetQWidget()->size()); SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height(), true); - m_pFrame->CallCallback(SalEvent::Paint, &aPaintEvt); + m_rFrame.CallCallback(SalEvent::Paint, &aPaintEvt); } void Qt5Widget::closeEvent(QCloseEvent* /*pEvent*/) { - m_pFrame->CallCallback(SalEvent::Close, nullptr); + m_rFrame.CallCallback(SalEvent::Close, nullptr); } static sal_uInt16 GetKeyCode(int keyval, Qt::KeyboardModifiers modifiers) @@ -395,9 +395,9 @@ bool Qt5Widget::handleKeyEvent(QKeyEvent* pEvent, bool bDown) bool bStopProcessingKey; if (bDown) - bStopProcessingKey = m_pFrame->CallCallback(SalEvent::KeyInput, &aEvent); + bStopProcessingKey = m_rFrame.CallCallback(SalEvent::KeyInput, &aEvent); else - bStopProcessingKey = m_pFrame->CallCallback(SalEvent::KeyUp, &aEvent); + bStopProcessingKey = m_rFrame.CallCallback(SalEvent::KeyUp, &aEvent); return bStopProcessingKey; } @@ -427,12 +427,9 @@ void Qt5Widget::keyReleaseEvent(QKeyEvent* pEvent) pEvent->accept(); } -void Qt5Widget::focusInEvent(QFocusEvent*) { m_pFrame->CallCallback(SalEvent::GetFocus, nullptr); } +void Qt5Widget::focusInEvent(QFocusEvent*) { m_rFrame.CallCallback(SalEvent::GetFocus, nullptr); } -void Qt5Widget::focusOutEvent(QFocusEvent*) -{ - m_pFrame->CallCallback(SalEvent::LoseFocus, nullptr); -} +void Qt5Widget::focusOutEvent(QFocusEvent*) { m_rFrame.CallCallback(SalEvent::LoseFocus, nullptr); } void Qt5Widget::showTooltip(const OUString& rTooltip) { @@ -442,7 +439,7 @@ void Qt5Widget::showTooltip(const OUString& rTooltip) Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f) : QWidget(Q_NULLPTR, f) - , m_pFrame(&rFrame) + , m_rFrame(rFrame) { create(); setMouseTracking(true); @@ -476,13 +473,13 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent) if (!pEvent->commitString().isEmpty()) { - vcl::DeletionListener aDel(m_pFrame); + vcl::DeletionListener aDel(&m_rFrame); aInputEvent.maText = toOUString(pEvent->commitString()); aInputEvent.mnCursorPos = aInputEvent.maText.getLength(); - m_pFrame->CallCallback(SalEvent::ExtTextInput, &aInputEvent); + m_rFrame.CallCallback(SalEvent::ExtTextInput, &aInputEvent); pEvent->accept(); if (!aDel.isDeleted()) - m_pFrame->CallCallback(SalEvent::EndExtTextInput, nullptr); + m_rFrame.CallCallback(SalEvent::EndExtTextInput, nullptr); } else { @@ -531,7 +528,7 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent) } } - m_pFrame->CallCallback(SalEvent::ExtTextInput, &aInputEvent); + m_rFrame.CallCallback(SalEvent::ExtTextInput, &aInputEvent); pEvent->accept(); } } @@ -543,7 +540,7 @@ QVariant Qt5Widget::inputMethodQuery(Qt::InputMethodQuery property) const case Qt::ImCursorRectangle: { SalExtTextInputPosEvent aPosEvent; - m_pFrame->CallCallback(SalEvent::ExtTextInputPos, &aPosEvent); + m_rFrame.CallCallback(SalEvent::ExtTextInputPos, &aPosEvent); return QVariant( QRect(aPosEvent.mnX, aPosEvent.mnY, aPosEvent.mnWidth, aPosEvent.mnHeight)); } -- cgit v1.2.3