Warning, file /plasma/khotkeys/kcm_hotkeys/helper_widgets/gesture_recorder.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-only
0003     SPDX-FileCopyrightText: 2003 Mike Pilone <mpilone@slac.com>
0004     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0005     SPDX-FileCopyrightText: 2009 Michael Jansen <kde@michael-jansen.biz>
0006  */
0007 
0008 #include <QColor>
0009 #include <QEvent>
0010 #include <QMouseEvent>
0011 
0012 #include "gesture_recorder.h"
0013 
0014 GestureRecorder::GestureRecorder(QWidget *parent, const char *name)
0015     : QFrame(parent)
0016     , _mouseButtonDown(false)
0017 {
0018     setObjectName(name);
0019     QPalette p;
0020     p.setColor(backgroundRole(), palette().color(QPalette::Base));
0021     setPalette(p);
0022     setFrameStyle(QFrame::Sunken | QFrame::Panel);
0023     setLineWidth(2);
0024     setMidLineWidth(0);
0025     setMinimumSize(200, 200);
0026 }
0027 
0028 GestureRecorder::~GestureRecorder()
0029 {
0030 }
0031 
0032 void GestureRecorder::mousePressEvent(QMouseEvent *ev)
0033 {
0034     if (ev->button() == Qt::LeftButton) {
0035         _mouseButtonDown = true;
0036         stroke.reset();
0037         QPoint pos = ev->pos();
0038         stroke.record(pos.x(), pos.y());
0039     }
0040 }
0041 
0042 void GestureRecorder::mouseReleaseEvent(QMouseEvent *ev)
0043 {
0044     if ((ev->button() == Qt::LeftButton) && (_mouseButtonDown)) {
0045         QPoint pos = ev->pos();
0046         stroke.record(pos.x(), pos.y());
0047         KHotKeys::StrokePoints data(stroke.processData());
0048 
0049         if (!data.isEmpty())
0050             emit recorded(data);
0051     }
0052 }
0053 
0054 void GestureRecorder::mouseMoveEvent(QMouseEvent *ev)
0055 {
0056     if (_mouseButtonDown) {
0057         QPoint pos = ev->pos();
0058         stroke.record(pos.x(), pos.y());
0059     }
0060 }
0061 
0062 void GestureRecorder::paintEvent(QPaintEvent *)
0063 {
0064 }
0065 
0066 #include "moc_gesture_recorder.cpp"