diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-06-11 13:21:32 +0300 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-06-11 13:31:01 +0300 |
| commit | 3cd4e0aa7961889eb06374885ed648f5b9bd85bc (patch) | |
| tree | 6a089aedea155b1f1a74b553f4d1b57c70554a8f /src/webenginewidgets/ui/touchhandlewidget.cpp | |
| parent | 6d029165d1593c514db08c34d6b08a00a4435d5e (diff) | |
| parent | 38063a6332b9f948a0381763271e9a9ac7af0999 (diff) | |
Merge tag 'v6.2.9-lts' into tqtc/lts-6.2-opensource6.2.9
Qt 6.2.9-lts release
Conflicts solved:
dependencies.yaml
examples/webenginewidgets/push-notifications/CMakeLists.txt
Change-Id: I0127c2575369f6939df89f3301659470d481b9bf
Diffstat (limited to 'src/webenginewidgets/ui/touchhandlewidget.cpp')
| -rw-r--r-- | src/webenginewidgets/ui/touchhandlewidget.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/webenginewidgets/ui/touchhandlewidget.cpp b/src/webenginewidgets/ui/touchhandlewidget.cpp new file mode 100644 index 000000000..88af0ff36 --- /dev/null +++ b/src/webenginewidgets/ui/touchhandlewidget.cpp @@ -0,0 +1,59 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "touchhandlewidget_p.h" +#include "qwebengineview.h" + +#include <QBoxLayout> +#include <QGraphicsOpacityEffect> +#include <QLabel> +#include <QWidget> + +namespace QtWebEngineWidgetUI { +TouchHandleWidget::TouchHandleWidget(QWebEngineView *view, const QMap<int, QImage> &images) + : m_widget(new QWidget(view)) + , m_label(new QLabel(m_widget)) + , m_opacityEffect(new QGraphicsOpacityEffect(m_widget)) + , m_images(images) +{ + m_widget->setAttribute(Qt::WA_AcceptTouchEvents, true); + m_widget->setAttribute(Qt::WA_TransparentForMouseEvents, true); +} + +TouchHandleWidget::~TouchHandleWidget() +{ +} + +void TouchHandleWidget::setImage(int orientation) +{ + const QImage &img = m_images[orientation]; + m_label->setPixmap(QPixmap::fromImage(img)); + m_label->setFrameStyle(QFrame::NoFrame); + m_label->resize(img.size()); + m_label->setVisible(true); + + QVBoxLayout layout; + layout.setSpacing(0); + layout.setContentsMargins(QMargins()); + layout.addWidget(m_label); + layout.setParent(m_widget); + m_widget->setLayout(&layout); + m_widget->resize(img.size()); +} + +void TouchHandleWidget::setBounds(const QRect &bounds) +{ + m_widget->setGeometry(bounds); +} + +void TouchHandleWidget::setVisible(bool visible) +{ + m_widget->setVisible(visible); +} + +void TouchHandleWidget::setOpacity(float opacity) +{ + m_opacityEffect->setOpacity(opacity); + m_widget->setGraphicsEffect(m_opacityEffect); +} +} // namespace QtWebEngineWidgetUI |
