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

Adapt and enable tablet tester

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