2
* Copyright © 2007 Fredrik Höglund <fredrik@kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the
15
* Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#include "mouseengine.h"
24
# include "cursornotificationhandler.h"
28
MouseEngine::MouseEngine(QObject* parent, const QVariantList& args)
29
: Plasma::DataEngine(parent, args), timerId(0)
38
MouseEngine::~MouseEngine()
48
QStringList MouseEngine::sources() const
52
list << QLatin1String("Position");
54
list << QLatin1String("Name");
61
void MouseEngine::init()
64
timerId = startTimer(40);
66
// Init cursor position
67
QPoint pos = QCursor::pos();
68
setData(QLatin1String("Position"), QVariant(pos));
72
handler = new CursorNotificationHandler;
73
connect(handler, SIGNAL(cursorNameChanged(QString)), SLOT(updateCursorName(QString)));
75
setData(QLatin1String("Name"), QVariant(handler->cursorName()));
78
scheduleSourcesUpdated();
82
void MouseEngine::timerEvent(QTimerEvent *)
84
QPoint pos = QCursor::pos();
86
if (pos != lastPosition)
88
setData(QLatin1String("Position"), QVariant(pos));
91
scheduleSourcesUpdated();
96
void MouseEngine::updateCursorName(const QString &name)
98
setData(QLatin1String("Name"), QVariant(name));
99
scheduleSourcesUpdated();
102
#include "mouseengine.moc"