qtabletevent/regular_widget manual test: Add a toggle for WinTab
Task-number: QTBUG-83218 Change-Id: I179f53c051c92dbb86fbac710d4a514c4e5d3c49 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
03c12974bb
commit
38a5b6212d
@ -4,12 +4,14 @@
|
|||||||
## regular_widgets Binary:
|
## regular_widgets Binary:
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
qt_internal_add_manual_test(regular_widgets
|
qt_internal_add_executable(regular_widgets
|
||||||
GUI
|
GUI
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
PUBLIC_LIBRARIES
|
PUBLIC_LIBRARIES
|
||||||
|
Qt::CorePrivate
|
||||||
Qt::Gui
|
Qt::Gui
|
||||||
|
Qt::GuiPrivate
|
||||||
Qt::Widgets
|
Qt::Widgets
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,12 +40,33 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QTabletEvent>
|
#include <QTabletEvent>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
# include <QtGui/private/qguiapplication_p.h>
|
||||||
|
# include <QtGui/qpa/qplatformintegration.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum TabletPointType {
|
enum TabletPointType {
|
||||||
TabletButtonPress,
|
TabletButtonPress,
|
||||||
TabletButtonRelease,
|
TabletButtonRelease,
|
||||||
TabletMove
|
TabletMove
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
using QWindowsApplication = QPlatformInterface::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
|
struct TabletPoint
|
||||||
{
|
{
|
||||||
TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove, Qt::MouseButton b = Qt::LeftButton,
|
TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove, Qt::MouseButton b = Qt::LeftButton,
|
||||||
@ -275,25 +296,46 @@ void EventReportWidget::timerEvent(QTimerEvent *)
|
|||||||
m_paintEventCount = 0;
|
m_paintEventCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit MainWindow(ProximityEventFilter *proximityEventFilter);
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
auto fileMenu = menuBar()->addMenu("File");
|
||||||
|
fileMenu->addAction("Clear", widget, &EventReportWidget::clearPoints);
|
||||||
|
QObject::connect(widget, &EventReportWidget::stats,
|
||||||
|
statusBar(), &QStatusBar::showMessage);
|
||||||
|
QAction *quitAction = fileMenu->addAction("Quit", qApp, &QCoreApplication::quit);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
ProximityEventFilter *proximityEventFilter = new ProximityEventFilter(&app);
|
ProximityEventFilter *proximityEventFilter = new ProximityEventFilter(&app);
|
||||||
app.installEventFilter(proximityEventFilter);
|
app.installEventFilter(proximityEventFilter);
|
||||||
QMainWindow mainWindow;
|
MainWindow mainWindow(proximityEventFilter);
|
||||||
mainWindow.setWindowTitle(QString::fromLatin1("Tablet Test %1").arg(QT_VERSION_STR));
|
|
||||||
EventReportWidget *widget = new EventReportWidget;
|
|
||||||
QObject::connect(proximityEventFilter, &ProximityEventFilter::proximityChanged,
|
|
||||||
widget, QOverload<>::of(&QWidget::update));
|
|
||||||
widget->setMinimumSize(640, 480);
|
|
||||||
QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
|
|
||||||
fileMenu->addAction("Clear", widget, &EventReportWidget::clearPoints);
|
|
||||||
QObject::connect(widget, &EventReportWidget::stats,
|
|
||||||
mainWindow.statusBar(), &QStatusBar::showMessage);
|
|
||||||
QAction *quitAction = fileMenu->addAction("Quit", qApp, &QCoreApplication::quit);
|
|
||||||
quitAction->setShortcut(Qt::CTRL | Qt::Key_Q);
|
|
||||||
mainWindow.setCentralWidget(widget);
|
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
QT += widgets
|
QT += widgets gui-private core-private
|
||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user