Commit 512be25c authored by Alvin Wong's avatar Alvin Wong

Adapt and enable tablet tester

parent fc43b0de
......@@ -421,6 +421,8 @@ endif()
canvas/kis_animation_player.cpp
kis_animation_importer.cpp
KisSyncedAudioPlayback.cpp
input/wintab/drawpile_tablettester/tablettester.cpp
input/wintab/drawpile_tablettester/tablettest.cpp
)
if(UNIX)
......@@ -522,6 +524,7 @@ ki18n_wrap_ui(kritaui_LIB_SRCS
wdgsplash.ui
input/wintab/kis_screen_size_choice_dialog.ui
input/wintab/drawpile_tablettester/tablettest.ui
)
......
......@@ -82,6 +82,7 @@
#include <kis_signals_blocker.h>
#include "input/config/kis_input_configuration_page.h"
#include "input/wintab/drawpile_tablettester/tablettester.h"
#ifdef Q_OS_WIN
# include <kis_tablet_support_win8.h>
......@@ -663,6 +664,13 @@ TabletSettingsTab::TabletSettingsTab(QWidget* parent, const char* name): QWidget
#else
m_page->grpTabletApi->setVisible(false);
#endif
connect(m_page->btnTabletTest, SIGNAL(clicked()), SLOT(slotTabletTest()));
}
void TabletSettingsTab::slotTabletTest()
{
TabletTestDialog tabletTestDialog(this);
tabletTestDialog.exec();
}
......
......@@ -195,6 +195,9 @@ class TabletSettingsTab : public QWidget {
public:
TabletSettingsTab(QWidget *parent = 0, const char *name = 0);
private Q_SLOTS:
void slotTabletTest();
public:
void setDefault();
WdgTabletSettings *m_page;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>569</width>
<height>366</height>
<height>433</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -152,7 +152,7 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -165,6 +165,13 @@
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="btnTabletTest">
<property name="text">
<string>Open Tablet Tester...</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="grpTabletApi">
<property name="title">
......
......@@ -22,10 +22,6 @@
#include <QPaintEvent>
#include <QPainter>
#ifndef DESIGNER_PLUGIN
namespace widgets {
#endif
TabletTester::TabletTester(QWidget *parent)
: QWidget(parent), m_mouseDown(false), m_tabletDown(false)
{
......@@ -66,7 +62,7 @@ void TabletTester::paintEvent(QPaintEvent *e)
void TabletTester::mousePressEvent(QMouseEvent *e)
{
emit eventReport(QString("Mouse press X=%1 Y=%2 B=%3").arg(e->x()).arg(e->y()).arg(e->button()));
Q_EMIT eventReport(QString("Mouse press X=%1 Y=%2 B=%3").arg(e->x()).arg(e->y()).arg(e->button()));
m_mouseDown = true;
m_mousePath.clear();
update();
......@@ -74,7 +70,7 @@ void TabletTester::mousePressEvent(QMouseEvent *e)
void TabletTester::mouseMoveEvent(QMouseEvent *e)
{
emit eventReport(QString("Mouse move X=%1 Y=%2 B=%3").arg(e->x()).arg(e->y()).arg(e->buttons()));
Q_EMIT eventReport(QString("Mouse move X=%1 Y=%2 B=%3").arg(e->x()).arg(e->y()).arg(e->buttons()));
m_mousePath << e->pos();
update();
}
......@@ -82,7 +78,7 @@ void TabletTester::mouseMoveEvent(QMouseEvent *e)
void TabletTester::mouseReleaseEvent(QMouseEvent *e)
{
Q_UNUSED(e);
emit eventReport(QString("Mouse release"));
Q_EMIT eventReport(QString("Mouse release"));
m_mouseDown = false;
}
......@@ -131,9 +127,5 @@ void TabletTester::tabletEvent(QTabletEvent *e)
}
}
emit eventReport(msg);
}
#ifndef DESIGNER_PLUGIN
Q_EMIT eventReport(msg);
}
#endif
......@@ -22,23 +22,15 @@
#include <QWidget>
#ifndef DESIGNER_PLUGIN
namespace widgets {
#define PLUGIN_EXPORT
#else
#include <QtUiPlugin/QDesignerExportWidget>
#define PLUGIN_EXPORT QDESIGNER_WIDGET_EXPORT
#endif
class PLUGIN_EXPORT TabletTester : public QWidget {
class TabletTester : public QWidget {
Q_OBJECT
public:
TabletTester(QWidget *parent=nullptr);
public slots:
public Q_SLOTS:
void clear();
signals:
Q_SIGNALS:
void eventReport(const QString &msg);
protected:
......@@ -56,9 +48,4 @@ private:
bool m_tabletDown;
};
#ifndef DESIGNER_PLUGIN
}
#endif
#endif
......@@ -41,7 +41,7 @@
<customwidget>
<class>TabletTester</class>
<extends>QWidget</extends>
<header>widgets/tablettest.h</header>
<header>input/wintab/drawpile_tablettester/tablettest.h</header>
<container>1</container>
</customwidget>
</customwidgets>
......
......@@ -18,34 +18,36 @@
*/
#include "tablettester.h"
#include "widgets/tablettest.h"
using widgets::TabletTester; // work around missing namespace in UIC generated code
#include "tablettest.h"
#include "ui_tablettest.h"
#include "../main.h"
namespace dialogs {
TabletTestDialog::TabletTestDialog( QWidget *parent) :
QDialog(parent)
QDialog(parent, Qt::Window)
{
m_ui = new Ui_TabletTest;
m_ui->setupUi(this);
connect(static_cast<DrawpileApp*>(qApp), &DrawpileApp::eraserNear, this, [this](bool near) {
QString msg;
if(near)
msg = QStringLiteral("Eraser brought near");
else
msg = QStringLiteral("Eraser taken away");
m_ui->logView->appendPlainText(msg);
});
qApp->installEventFilter(this);
}
TabletTestDialog::~TabletTestDialog()
{
qApp->removeEventFilter(this);
delete m_ui;
}
bool TabletTestDialog::eventFilter(QObject *watched, QEvent *e) {
Q_UNUSED(watched);
if(e->type() == QEvent::TabletEnterProximity || e->type() == QEvent::TabletLeaveProximity) {
QTabletEvent *te = static_cast<QTabletEvent*>(e);
bool near = te->pointerType()==QTabletEvent::Eraser;
QString msg;
if(near)
msg = QStringLiteral("Eraser brought near");
else
msg = QStringLiteral("Eraser taken away");
m_ui->logView->appendPlainText(msg);
}
return QDialog::eventFilter(watched, e);
}
......@@ -23,20 +23,17 @@
class Ui_TabletTest;
namespace dialogs {
class TabletTestDialog : public QDialog
{
Q_OBJECT
public:
TabletTestDialog(QWidget *parent=nullptr);
~TabletTestDialog();
bool eventFilter(QObject *watched, QEvent *event) override;
private:
Ui_TabletTest *m_ui;
};
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment