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>
This commit is contained in:
parent
b61ab2b425
commit
32a26f1714
@ -49,6 +49,15 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QWindow>
|
#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 bool optIgnoreTouch = false;
|
||||||
static QList<Qt::GestureType> optGestures;
|
static QList<Qt::GestureType> optGestures;
|
||||||
|
|
||||||
@ -410,6 +419,62 @@ void TouchTestWidget::paintEvent(QPaintEvent *)
|
|||||||
gp->draw(geom, painter);
|
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
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -425,6 +490,9 @@ public slots:
|
|||||||
void appendToLog(const QString &text) { m_logTextEdit->appendPlainText(text); }
|
void appendToLog(const QString &text) { m_logTextEdit->appendPlainText(text); }
|
||||||
void dumpTouchDevices();
|
void dumpTouchDevices();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void settingsDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateScreenLabel();
|
void updateScreenLabel();
|
||||||
void newWindow() { MainWindow::createMainWindow(); }
|
void newWindow() { MainWindow::createMainWindow(); }
|
||||||
@ -495,6 +563,15 @@ MainWindow::MainWindow()
|
|||||||
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
||||||
toolBar->addAction(quitAction);
|
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);
|
QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this);
|
||||||
|
|
||||||
m_touchWidget->setObjectName(QStringLiteral("TouchWidget"));
|
m_touchWidget->setObjectName(QStringLiteral("TouchWidget"));
|
||||||
@ -510,6 +587,14 @@ MainWindow::MainWindow()
|
|||||||
dumpTouchDevices();
|
dumpTouchDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::settingsDialog()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
SettingsDialog dialog(this);
|
||||||
|
dialog.exec();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::setVisible(bool visible)
|
void MainWindow::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
QMainWindow::setVisible(visible);
|
QMainWindow::setVisible(visible);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
QT = core gui widgets
|
QT = core gui gui-private widgets
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user