diff options
Diffstat (limited to 'tests/manual/qtabletevent')
13 files changed, 174 insertions, 234 deletions
diff --git a/tests/manual/qtabletevent/.prev_CMakeLists.txt b/tests/manual/qtabletevent/.prev_CMakeLists.txt deleted file mode 100644 index 06a0bab2d8..0000000000 --- a/tests/manual/qtabletevent/.prev_CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Generated from qtabletevent.pro. - -add_subdirectory(device_information) -add_subdirectory(event_compression) -add_subdirectory(regular_widgets) diff --git a/tests/manual/qtabletevent/CMakeLists.txt b/tests/manual/qtabletevent/CMakeLists.txt index 422664e2a4..df4a66c8f1 100644 --- a/tests/manual/qtabletevent/CMakeLists.txt +++ b/tests/manual/qtabletevent/CMakeLists.txt @@ -1,5 +1,6 @@ -# Generated from qtabletevent.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -#add_subdirectory(device_information) # special case no member named 'staticQtMetaObject' +#add_subdirectory(device_information) # TODO: no member named 'staticQtMetaObject' add_subdirectory(event_compression) add_subdirectory(regular_widgets) diff --git a/tests/manual/qtabletevent/device_information/CMakeLists.txt b/tests/manual/qtabletevent/device_information/CMakeLists.txt index 8a13e6e730..a0583b1f93 100644 --- a/tests/manual/qtabletevent/device_information/CMakeLists.txt +++ b/tests/manual/qtabletevent/device_information/CMakeLists.txt @@ -1,15 +1,20 @@ -# Generated from device_information.pro. - -##################################################################### -## device_information Binary: -##################################################################### - -qt_add_manual_test(device_information - GUI - SOURCES - main.cpp - tabletwidget.cpp tabletwidget.h - PUBLIC_LIBRARIES - Qt::Gui - Qt::Widgets +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +project(tablet_device_info) +cmake_minimum_required(VERSION 3.19) + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_add_executable(tablet_device_info + main.cpp + tabletwidget.h tabletwidget.cpp +) + +set_target_properties(tablet_device_info PROPERTIES + AUTOMOC TRUE +) + +target_link_libraries(tablet_device_info PUBLIC + Qt::Widgets ) diff --git a/tests/manual/qtabletevent/device_information/main.cpp b/tests/manual/qtabletevent/device_information/main.cpp index d1ccd28928..cb18e79eac 100644 --- a/tests/manual/qtabletevent/device_information/main.cpp +++ b/tests/manual/qtabletevent/device_information/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QApplication> #include <QDebug> diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index c4d706d4eb..747c807e02 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "tabletwidget.h" #include <QPainter> @@ -82,6 +57,8 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mPos = event->pos(); mGPos = event->globalPosition(); mTimestamp = event->timestamp(); + if (isVisible()) + update(); } break; case QEvent::Wheel: @@ -132,11 +109,11 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("Device info missing"); } else { eventInfo << QString("Seat: %1").arg(mDev->seatName()); + eventInfo << QString("Name: %1").arg(mDev->name()); eventInfo << QString("Device type: %1").arg(deviceTypeToString(mDev->type())); eventInfo << QString("Pointer type: %1").arg(pointerTypeToString(mDev->pointerType())); eventInfo << QString("Capabilities: %1").arg(pointerCapabilitiesToString(mDev->capabilities())); eventInfo << QString("Unique Id: %1").arg(QString::number(mDev->uniqueId().numericId(), 16)); - eventInfo << QString("System Id: %1").arg(mDev->id()); } eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16); eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16); diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index b58442ccda..477ae55b1b 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TABLETWIDGET_H #define TABLETWIDGET_H diff --git a/tests/manual/qtabletevent/event_compression/CMakeLists.txt b/tests/manual/qtabletevent/event_compression/CMakeLists.txt index 1f959a51e2..74fa0fb790 100644 --- a/tests/manual/qtabletevent/event_compression/CMakeLists.txt +++ b/tests/manual/qtabletevent/event_compression/CMakeLists.txt @@ -1,14 +1,15 @@ -# Generated from event_compression.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## event_compression Binary: ##################################################################### -qt_add_manual_test(event_compression +qt_internal_add_manual_test(event_compression SOURCES main.cpp mousestatwidget.cpp mousestatwidget.h - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Test Qt::Widgets diff --git a/tests/manual/qtabletevent/event_compression/main.cpp b/tests/manual/qtabletevent/event_compression/main.cpp index 10a26a976a..13edf8e704 100644 --- a/tests/manual/qtabletevent/event_compression/main.cpp +++ b/tests/manual/qtabletevent/event_compression/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "mousestatwidget.h" diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp index a26c62d2e1..483ce0019d 100644 --- a/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp +++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "mousestatwidget.h" diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.h b/tests/manual/qtabletevent/event_compression/mousestatwidget.h index 78294c2d25..f204a753a3 100644 --- a/tests/manual/qtabletevent/event_compression/mousestatwidget.h +++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef MOUSESTATWIDGET_H #define MOUSESTATWIDGET_H diff --git a/tests/manual/qtabletevent/regular_widgets/CMakeLists.txt b/tests/manual/qtabletevent/regular_widgets/CMakeLists.txt index f4630a3789..d95c33df18 100644 --- a/tests/manual/qtabletevent/regular_widgets/CMakeLists.txt +++ b/tests/manual/qtabletevent/regular_widgets/CMakeLists.txt @@ -1,17 +1,17 @@ -# Generated from regular_widgets.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## regular_widgets Binary: ##################################################################### -qt_add_manual_test(regular_widgets +qt_internal_add_manual_test(regular_widgets GUI SOURCES main.cpp - PUBLIC_LIBRARIES + LIBRARIES + Qt::CorePrivate Qt::Gui + Qt::GuiPrivate Qt::Widgets ) - -#### Keys ignored in scope 1:.:.:regular_widgets.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp index 056ff88dac..3aee2bcdba 100644 --- a/tests/manual/qtabletevent/regular_widgets/main.cpp +++ b/tests/manual/qtabletevent/regular_widgets/main.cpp @@ -1,35 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QAction> #include <QApplication> #include <QCursor> #include <QDebug> +#include <QDialog> +#include <QDialogButtonBox> #include <QList> #include <QMainWindow> #include <QMenu> @@ -37,8 +14,18 @@ #include <QMouseEvent> #include <QPainter> #include <QPainterPath> +#include <QPlainTextEdit> +#include <QPointingDevice> +#include <QPointer> +#include <QPushButton> #include <QStatusBar> #include <QTabletEvent> +#include <QVBoxLayout> + +#ifdef Q_OS_WIN +# include <QtGui/private/qguiapplication_p.h> +# include <QtGui/qpa/qplatformintegration.h> +#endif enum TabletPointType { TabletButtonPress, @@ -46,6 +33,22 @@ enum TabletPointType { TabletMove }; +#ifdef Q_OS_WIN +using QWindowsApplication = QNativeInterface::Private::QWindowsApplication; + +static void setWinTabEnabled(bool e) +{ + if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) + nativeWindowsApp->setWinTabEnabled(e); +} + +static bool isWinTabEnabled() +{ + auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration()); + return nativeWindowsApp && nativeWindowsApp->isWinTabEnabled(); +} +#endif // Q_OS_WIN + struct TabletPoint { TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove, Qt::MouseButton b = Qt::LeftButton, @@ -149,7 +152,7 @@ void EventReportWidget::paintEvent(QPaintEvent *) p.setPen(Qt::white); QPainterPath ellipse; ellipse.addEllipse(0, 0, halfLineSpacing * 5, halfLineSpacing); - for (const TabletPoint &t : qAsConst(m_points)) { + for (const TabletPoint &t : std::as_const(m_points)) { if (geom.contains(t.pos)) { QPainterPath pp; pp.addEllipse(t.pos, halfLineSpacing, halfLineSpacing); @@ -244,7 +247,7 @@ bool EventReportWidget::event(QEvent *event) case QEvent::TouchUpdate: event->accept(); m_touchPoints.clear(); - for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints()) + for (const QEventPoint &p : static_cast<const QPointerEvent *>(event)->points()) m_touchPoints.append(p.position()); update(); break; @@ -275,25 +278,108 @@ void EventReportWidget::timerEvent(QTimerEvent *) m_paintEventCount = 0; } -int main(int argc, char *argv[]) +class DevicesDialog : public QDialog { - QApplication app(argc, argv); + Q_OBJECT +public: + explicit DevicesDialog(QWidget *p); - ProximityEventFilter *proximityEventFilter = new ProximityEventFilter(&app); - app.installEventFilter(proximityEventFilter); - QMainWindow mainWindow; - mainWindow.setWindowTitle(QString::fromLatin1("Tablet Test %1").arg(QT_VERSION_STR)); - EventReportWidget *widget = new EventReportWidget; +public slots: + void refresh(); + +private: + QPlainTextEdit *m_edit; +}; + +DevicesDialog::DevicesDialog(QWidget *p) : QDialog(p) +{ + auto layout = new QVBoxLayout(this); + m_edit = new QPlainTextEdit(this); + m_edit->setReadOnly(true); + layout->addWidget(m_edit); + auto box = new QDialogButtonBox(QDialogButtonBox::Close, this); + connect(box, &QDialogButtonBox::rejected, this, &QDialog::reject); + auto refreshButton = box->addButton("Refresh", QDialogButtonBox::ActionRole); + connect(refreshButton, &QAbstractButton::clicked, this, &DevicesDialog::refresh); + layout->addWidget(box); + setWindowTitle("Devices"); + refresh(); +} + +void DevicesDialog::refresh() +{ + QString text; + QDebug d(&text); + d.noquote(); + d.nospace(); + for (auto device : QInputDevice::devices()) + d << device<< "\n\n"; + m_edit->setPlainText(text); +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + explicit MainWindow(ProximityEventFilter *proximityEventFilter); + +public slots: + void showDevices(); + +private: + QPointer<DevicesDialog> m_devicesDialog; +}; + +MainWindow::MainWindow(ProximityEventFilter *proximityEventFilter) +{ + setWindowTitle(QString::fromLatin1("Tablet Test %1").arg(QT_VERSION_STR)); + auto widget = new EventReportWidget; QObject::connect(proximityEventFilter, &ProximityEventFilter::proximityChanged, widget, QOverload<>::of(&QWidget::update)); widget->setMinimumSize(640, 480); - QMenu *fileMenu = mainWindow.menuBar()->addMenu("File"); + auto fileMenu = menuBar()->addMenu("File"); fileMenu->addAction("Clear", widget, &EventReportWidget::clearPoints); + auto showAction = fileMenu->addAction("Show Devices", this, &MainWindow::showDevices); + showAction->setShortcut(Qt::CTRL | Qt::Key_D); QObject::connect(widget, &EventReportWidget::stats, - mainWindow.statusBar(), &QStatusBar::showMessage); + statusBar(), &QStatusBar::showMessage); QAction *quitAction = fileMenu->addAction("Quit", qApp, &QCoreApplication::quit); - quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); - mainWindow.setCentralWidget(widget); + quitAction->setShortcut(Qt::CTRL | Qt::Key_Q); + + auto settingsMenu = menuBar()->addMenu("Settings"); + auto winTabAction = settingsMenu->addAction("WinTab"); + winTabAction->setCheckable(true); +#ifdef Q_OS_WIN + winTabAction->setChecked(isWinTabEnabled()); + connect(winTabAction, &QAction::toggled, this, setWinTabEnabled); +#else + winTabAction->setEnabled(false); +#endif + + setCentralWidget(widget); +} + +void MainWindow::showDevices() +{ + if (m_devicesDialog.isNull()) { + m_devicesDialog = new DevicesDialog(nullptr); + m_devicesDialog->setModal(false); + m_devicesDialog->resize(500, 300); + m_devicesDialog->move(frameGeometry().topRight() + QPoint(20, 0)); + m_devicesDialog->setAttribute(Qt::WA_DeleteOnClose); + } + m_devicesDialog->show(); + m_devicesDialog->raise(); + m_devicesDialog->refresh(); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + ProximityEventFilter *proximityEventFilter = new ProximityEventFilter(&app); + app.installEventFilter(proximityEventFilter); + MainWindow mainWindow(proximityEventFilter); mainWindow.show(); return app.exec(); } diff --git a/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro b/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro index 8f1f4342ee..1428d10a04 100644 --- a/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro +++ b/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro @@ -1,4 +1,4 @@ TEMPLATE = app -QT += widgets +QT += widgets gui-private core-private SOURCES += main.cpp |