~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to khotkeys/kcm_hotkeys/helper_widgets/gesture_recorder.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 
 
3
 KHotKeys
 
4
 
 
5
 Copyright (C) 2003 Mike Pilone <mpilone@slac.com>
 
6
 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
 
7
 
 
8
 Distributed under the terms of the GNU General Public License version 2.
 
9
 
 
10
****************************************************************************/
 
11
 
 
12
#include <QtCore/QEvent>
 
13
#include <QtGui/QColor>
 
14
#include <QtGui/QFrame>
 
15
#include <QtGui/QMouseEvent>
 
16
 
 
17
#include "gesture_recorder.h"
 
18
 
 
19
GestureRecorder::GestureRecorder(QWidget *parent, const char *name)
 
20
  : QFrame(parent), _mouseButtonDown(false)
 
21
    {
 
22
    setObjectName(name);
 
23
    QPalette p;
 
24
    p.setColor( backgroundRole(), palette().color( QPalette::Base ) );
 
25
    setPalette( p );
 
26
    setFrameStyle(QFrame::Sunken | QFrame::Panel);
 
27
    setLineWidth(2);
 
28
    setMidLineWidth(0);
 
29
    setMinimumSize(200,200);
 
30
    }
 
31
 
 
32
 
 
33
GestureRecorder::~GestureRecorder()
 
34
    {
 
35
    }
 
36
 
 
37
 
 
38
void GestureRecorder::mousePressEvent(QMouseEvent *ev)
 
39
    {
 
40
    if (ev->button() == Qt::LeftButton)
 
41
        {
 
42
        _mouseButtonDown = true;
 
43
        stroke.reset();
 
44
        QPoint pos = ev->pos();
 
45
        stroke.record(pos.x(), pos.y());
 
46
        }
 
47
    }
 
48
 
 
49
 
 
50
void GestureRecorder::mouseReleaseEvent(QMouseEvent *ev)
 
51
    {
 
52
    if ((ev->button() == Qt::LeftButton) && (_mouseButtonDown))
 
53
        {
 
54
        QPoint pos = ev->pos();
 
55
        stroke.record(pos.x(), pos.y());
 
56
        KHotKeys::StrokePoints data( stroke.processData() );
 
57
 
 
58
        if( !data.isEmpty())
 
59
            emit recorded(data);
 
60
        }
 
61
    }
 
62
 
 
63
 
 
64
void GestureRecorder::mouseMoveEvent(QMouseEvent *ev)
 
65
    {
 
66
    if (_mouseButtonDown)
 
67
        {
 
68
        QPoint pos = ev->pos();
 
69
        stroke.record(pos.x(), pos.y());
 
70
        }
 
71
    }
 
72
 
 
73
 
 
74
#include "moc_gesture_recorder.cpp"