summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-22 12:48:11 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-22 19:46:09 +0200
commit32a26f1714054f196fb9fea20d7d7d8596d65241 (patch)
tree35e620bfbb480e48409cccbfeeaa49f701fb27a3 /tests/manual
parentb61ab2b425627be68ee04e11016fafd07f0617c3 (diff)
Manual touch test: Add a settings dialog for windows
Exercise the touch settings of the native interface. Task-number: QTBUG-41433 Task-number: QTBUG-48849 Task-number: QTBUG-83252 Change-Id: I5ae95a79c00b55236dbbed9d8549f4fdf5b10b8e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/touch/main.cpp85
-rw-r--r--tests/manual/touch/touch.pro2
2 files changed, 86 insertions, 1 deletions
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
index 37bbbcb7f8..b6a42f0019 100644
--- a/tests/manual/touch/main.cpp
+++ b/tests/manual/touch/main.cpp
@@ -49,6 +49,15 @@
#include <QToolBar>
#include <QWindow>
+#ifdef Q_OS_WIN
+# include <QCheckBox>
+# include <QDialog>
+# include <QDialogButtonBox>
+# include <QVBoxLayout>
+# include <QtGui/private/qguiapplication_p.h>
+# include <QtGui/qpa/qplatformintegration.h>
+#endif
+
static bool optIgnoreTouch = false;
static QList<Qt::GestureType> optGestures;
@@ -410,6 +419,62 @@ void TouchTestWidget::paintEvent(QPaintEvent *)
gp->draw(geom, painter);
}
+#ifdef Q_OS_WIN
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit SettingsDialog(QWidget *parent);
+
+private slots:
+ void touchTypeToggled();
+
+private:
+ using QWindowsApplication = QPlatformInterface::Private::QWindowsApplication;
+ using TouchWindowTouchType = QWindowsApplication::TouchWindowTouchType;
+ using TouchWindowTouchTypes = QWindowsApplication::QWindowsApplication::TouchWindowTouchTypes;
+
+ QCheckBox *m_fineCheckBox;
+ QCheckBox *m_palmCheckBox;
+};
+
+SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
+{
+ setWindowTitle("Settings");
+ auto layout = new QVBoxLayout(this);
+
+ TouchWindowTouchTypes touchTypes;
+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration()))
+ touchTypes = nativeWindowsApp->touchWindowTouchType();
+
+ m_fineCheckBox = new QCheckBox("Fine Touch", this);
+ m_fineCheckBox->setChecked(touchTypes.testFlag(TouchWindowTouchType::FineTouch));
+ layout->addWidget(m_fineCheckBox);
+ connect(m_fineCheckBox, &QAbstractButton::toggled, this, &SettingsDialog::touchTypeToggled);
+ m_palmCheckBox = new QCheckBox("Palm Touch", this);
+ connect(m_palmCheckBox, &QAbstractButton::toggled, this, &SettingsDialog::touchTypeToggled);
+ m_palmCheckBox->setChecked(touchTypes.testFlag(TouchWindowTouchType::WantPalmTouch));
+ layout->addWidget(m_palmCheckBox);
+
+ auto box = new QDialogButtonBox(QDialogButtonBox::Close);
+ connect(box, &QDialogButtonBox::rejected, this, &QDialog::reject);
+ layout->addWidget(box);
+}
+
+void SettingsDialog::touchTypeToggled()
+{
+ TouchWindowTouchTypes types;
+ if (m_fineCheckBox->isChecked())
+ types.setFlag(TouchWindowTouchType::FineTouch);
+ if (m_palmCheckBox->isChecked())
+ types.setFlag(TouchWindowTouchType::WantPalmTouch);
+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration()))
+ nativeWindowsApp->setTouchWindowTouchType(types);
+ else
+ qWarning("Missing Interface QWindowsApplication");
+}
+#endif // Q_OS_WIN
+
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -425,6 +490,9 @@ public slots:
void appendToLog(const QString &text) { m_logTextEdit->appendPlainText(text); }
void dumpTouchDevices();
+private slots:
+ void settingsDialog();
+
private:
void updateScreenLabel();
void newWindow() { MainWindow::createMainWindow(); }
@@ -495,6 +563,15 @@ MainWindow::MainWindow()
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
toolBar->addAction(quitAction);
+ auto settingsMenu = menuBar()->addMenu("Settings");
+ auto settingsAction = settingsMenu->addAction("Settings",
+ this, &MainWindow::settingsDialog);
+#ifdef Q_OS_WIN
+ Q_UNUSED(settingsAction);
+#else
+ settingsAction->setEnabled(false);
+#endif
+
QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this);
m_touchWidget->setObjectName(QStringLiteral("TouchWidget"));
@@ -510,6 +587,14 @@ MainWindow::MainWindow()
dumpTouchDevices();
}
+void MainWindow::settingsDialog()
+{
+#ifdef Q_OS_WIN
+ SettingsDialog dialog(this);
+ dialog.exec();
+#endif
+}
+
void MainWindow::setVisible(bool visible)
{
QMainWindow::setVisible(visible);
diff --git a/tests/manual/touch/touch.pro b/tests/manual/touch/touch.pro
index 08e3fdcd71..67420decca 100644
--- a/tests/manual/touch/touch.pro
+++ b/tests/manual/touch/touch.pro
@@ -1,4 +1,4 @@
TEMPLATE = app
-QT = core gui widgets
+QT = core gui gui-private widgets
CONFIG -= app_bundle
SOURCES += main.cpp