Commit fc43b0de authored by Alvin Wong's avatar Alvin Wong

Replace tabs with spaces

parent 39e15d60
...@@ -27,111 +27,111 @@ namespace widgets { ...@@ -27,111 +27,111 @@ namespace widgets {
#endif #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)
{ {
} }
void TabletTester::clear() void TabletTester::clear()
{ {
m_mousePath.clear(); m_mousePath.clear();
m_tabletPath.clear(); m_tabletPath.clear();
update(); update();
} }
void TabletTester::paintEvent(QPaintEvent *e) void TabletTester::paintEvent(QPaintEvent *e)
{ {
Q_UNUSED(e); Q_UNUSED(e);
const int w = width(); const int w = width();
const int h = height(); const int h = height();
QPainter p(this); QPainter p(this);
p.fillRect(0, 0, w, h, QColor(200, 200, 200)); p.fillRect(0, 0, w, h, QColor(200, 200, 200));
p.setPen(QColor(128, 128, 128)); p.setPen(QColor(128, 128, 128));
// Draw grid // Draw grid
for(int i=w/8;i<w;i+=w/8) for(int i=w/8;i<w;i+=w/8)
p.drawLine(i, 0, i, h); p.drawLine(i, 0, i, h);
for(int i=h/8;i<h;i+=h/8) for(int i=h/8;i<h;i+=h/8)
p.drawLine(0, i, w, i); p.drawLine(0, i, w, i);
// Draw paths // Draw paths
if(!m_mousePath.isEmpty()) { if(!m_mousePath.isEmpty()) {
p.setPen(QPen(Qt::red, 3)); p.setPen(QPen(Qt::red, 3));
p.drawPolyline(m_mousePath); p.drawPolyline(m_mousePath);
} }
if(!m_tabletPath.isEmpty()) { if(!m_tabletPath.isEmpty()) {
p.setPen(QPen(Qt::blue, 2)); p.setPen(QPen(Qt::blue, 2));
p.drawPolyline(m_tabletPath); p.drawPolyline(m_tabletPath);
} }
} }
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())); 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();
} }
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())); 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();
} }
void TabletTester::mouseReleaseEvent(QMouseEvent *e) void TabletTester::mouseReleaseEvent(QMouseEvent *e)
{ {
Q_UNUSED(e); Q_UNUSED(e);
emit eventReport(QString("Mouse release")); emit eventReport(QString("Mouse release"));
m_mouseDown = false; m_mouseDown = false;
} }
void TabletTester::tabletEvent(QTabletEvent *e) void TabletTester::tabletEvent(QTabletEvent *e)
{ {
e->accept(); e->accept();
QString msg; QString msg;
switch(e->device()) { switch(e->device()) {
case QTabletEvent::Stylus: msg = "Stylus"; break; case QTabletEvent::Stylus: msg = "Stylus"; break;
default: msg = QString("Device(%1)").arg(e->device()); break; default: msg = QString("Device(%1)").arg(e->device()); break;
} }
switch(e->type()) { switch(e->type()) {
case QEvent::TabletMove: case QEvent::TabletMove:
msg += " move"; msg += " move";
break; break;
case QEvent::TabletPress: case QEvent::TabletPress:
msg += " press"; msg += " press";
m_tabletPath.clear(); m_tabletPath.clear();
m_tabletDown = true; m_tabletDown = true;
break; break;
case QEvent::TabletRelease: case QEvent::TabletRelease:
msg += " release"; msg += " release";
m_tabletDown = false; m_tabletDown = false;
break; break;
default: default:
msg += QString(" event-%1").arg(e->type()); msg += QString(" event-%1").arg(e->type());
break; break;
} }
msg += QString(" X=%1 Y=%2 B=%3 P=%4%") msg += QString(" X=%1 Y=%2 B=%3 P=%4%")
.arg(e->posF().x(), 0, 'f', 2) .arg(e->posF().x(), 0, 'f', 2)
.arg(e->posF().y(), 0, 'f', 2) .arg(e->posF().y(), 0, 'f', 2)
.arg(e->buttons()) .arg(e->buttons())
.arg(e->pressure()*100, 0, 'f', 1) .arg(e->pressure()*100, 0, 'f', 1)
; ;
if(e->type() == QEvent::TabletMove) { if(e->type() == QEvent::TabletMove) {
if(m_tabletDown) { if(m_tabletDown) {
msg += " (DRAW)"; msg += " (DRAW)";
m_tabletPath << e->pos(); m_tabletPath << e->pos();
update(); update();
} else { } else {
msg += " (HOVER)"; msg += " (HOVER)";
} }
} }
emit eventReport(msg); emit eventReport(msg);
} }
#ifndef DESIGNER_PLUGIN #ifndef DESIGNER_PLUGIN
......
...@@ -31,29 +31,29 @@ namespace widgets { ...@@ -31,29 +31,29 @@ namespace widgets {
#endif #endif
class PLUGIN_EXPORT TabletTester : public QWidget { class PLUGIN_EXPORT TabletTester : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
TabletTester(QWidget *parent=nullptr); TabletTester(QWidget *parent=nullptr);
public slots: public slots:
void clear(); void clear();
signals: signals:
void eventReport(const QString &msg); void eventReport(const QString &msg);
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void tabletEvent(QTabletEvent *e) override; void tabletEvent(QTabletEvent *e) override;
private: private:
QPolygon m_mousePath; QPolygon m_mousePath;
QPolygon m_tabletPath; QPolygon m_tabletPath;
bool m_mouseDown; bool m_mouseDown;
bool m_tabletDown; bool m_tabletDown;
}; };
#ifndef DESIGNER_PLUGIN #ifndef DESIGNER_PLUGIN
...@@ -62,4 +62,3 @@ private: ...@@ -62,4 +62,3 @@ private:
#endif #endif
...@@ -27,26 +27,25 @@ using widgets::TabletTester; // work around missing namespace in UIC generated c ...@@ -27,26 +27,25 @@ using widgets::TabletTester; // work around missing namespace in UIC generated c
namespace dialogs { namespace dialogs {
TabletTestDialog::TabletTestDialog( QWidget *parent) : TabletTestDialog::TabletTestDialog( QWidget *parent) :
QDialog(parent) QDialog(parent)
{ {
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) { connect(static_cast<DrawpileApp*>(qApp), &DrawpileApp::eraserNear, this, [this](bool near) {
QString msg; QString msg;
if(near) if(near)
msg = QStringLiteral("Eraser brought near"); msg = QStringLiteral("Eraser brought near");
else else
msg = QStringLiteral("Eraser taken away"); msg = QStringLiteral("Eraser taken away");
m_ui->logView->appendPlainText(msg); m_ui->logView->appendPlainText(msg);
}); });
} }
TabletTestDialog::~TabletTestDialog() TabletTestDialog::~TabletTestDialog()
{ {
delete m_ui; delete m_ui;
} }
} }
...@@ -27,17 +27,16 @@ namespace dialogs { ...@@ -27,17 +27,16 @@ 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();
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