Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/input/wintab/drawpile_tablettester/tablettester.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Drawpile - a collaborative drawing program. | ||||
3 | | ||||
4 | Copyright (C) 2017 Calle Laakkonen | ||||
5 | | ||||
6 | Drawpile is free software: you can redistribute it and/or modify | ||||
7 | it under the terms of the GNU General Public License as published by | ||||
8 | the Free Software Foundation, either version 3 of the License, or | ||||
9 | (at your option) any later version. | ||||
10 | | ||||
11 | Drawpile is distributed in the hope that it will be useful, | ||||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
14 | GNU General Public License for more details. | ||||
15 | | ||||
16 | You should have received a copy of the GNU General Public License | ||||
17 | along with Drawpile. If not, see <http://www.gnu.org/licenses/>. | ||||
18 | */ | ||||
19 | | ||||
20 | #include "tablettester.h" | ||||
21 | #include "tablettest.h" | ||||
22 | #include "ui_tablettest.h" | ||||
23 | | ||||
24 | TabletTestDialog::TabletTestDialog( QWidget *parent) : | ||||
25 | QDialog(parent, Qt::Window) | ||||
26 | { | ||||
27 | m_ui = new Ui_TabletTest; | ||||
28 | m_ui->setupUi(this); | ||||
29 | | ||||
30 | qApp->installEventFilter(this); | ||||
31 | } | ||||
32 | | ||||
33 | TabletTestDialog::~TabletTestDialog() | ||||
34 | { | ||||
35 | qApp->removeEventFilter(this); | ||||
36 | delete m_ui; | ||||
37 | } | ||||
38 | | ||||
39 | bool TabletTestDialog::eventFilter(QObject *watched, QEvent *e) { | ||||
40 | Q_UNUSED(watched); | ||||
41 | if(e->type() == QEvent::TabletEnterProximity || e->type() == QEvent::TabletLeaveProximity) { | ||||
42 | QTabletEvent *te = static_cast<QTabletEvent*>(e); | ||||
43 | bool isEraser = te->pointerType() == QTabletEvent::Eraser; | ||||
44 | bool isNear = e->type() == QEvent::TabletEnterProximity; | ||||
45 | QString msg; | ||||
46 | if(isEraser) { | ||||
47 | if (isNear) { | ||||
48 | msg = QStringLiteral("Eraser brought near"); | ||||
49 | } else { | ||||
50 | msg = QStringLiteral("Eraser taken away"); | ||||
51 | } | ||||
52 | } else { | ||||
53 | if (isNear) { | ||||
54 | msg = QStringLiteral("Pen tip brought near"); | ||||
55 | } else { | ||||
56 | msg = QStringLiteral("Pen tip taken away"); | ||||
57 | } | ||||
58 | } | ||||
59 | | ||||
60 | m_ui->logView->appendPlainText(msg); | ||||
61 | } | ||||
62 | return QDialog::eventFilter(watched, e); | ||||
63 | } |