Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpadx/src/applet/touchpadengine.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2013 Alexander Mezin <mezin.alexander@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | #include "touchpadengine.h" | ||||
19 | | ||||
20 | #include <QDBusConnection> | ||||
21 | #include <QDBusInterface> | ||||
22 | | ||||
23 | #include "touchpadinterface.h" | ||||
24 | #include "touchpadservice.h" | ||||
25 | #include "kded5interface.h" | ||||
26 | | ||||
27 | TouchpadEngine::TouchpadEngine(QObject *parent, const QVariantList &args) | ||||
28 | : Plasma::DataEngine(parent, args), m_source("touchpad"), m_daemon(0) | ||||
29 | { | ||||
30 | init(); | ||||
31 | } | ||||
32 | | ||||
33 | void TouchpadEngine::init() | ||||
34 | { | ||||
35 | OrgKdeKded5Interface kded(QLatin1String("org.kde.kded5"), | ||||
36 | QLatin1String("/kded"), | ||||
37 | QDBusConnection::sessionBus()); | ||||
38 | kded.loadModule("touchpad").waitForFinished(); | ||||
39 | | ||||
40 | m_daemon = new OrgKdeTouchpadInterface("org.kde.kded5", "/modules/touchpad", | ||||
41 | QDBusConnection::sessionBus(), this); | ||||
42 | if (!m_daemon->isValid()) { | ||||
43 | return; | ||||
44 | } | ||||
45 | | ||||
46 | connect(m_daemon, SIGNAL(workingTouchpadFoundChanged(bool)), SLOT(workingTouchpadFoundChanged(bool))); | ||||
47 | connect(m_daemon, SIGNAL(enabledChanged(bool)), SLOT(enabledChanged(bool))); | ||||
48 | connect(m_daemon, SIGNAL(mousePluggedInChanged(bool)), | ||||
49 | SLOT(mousePluggedInChanged(bool))); | ||||
50 | | ||||
51 | workingTouchpadFoundChanged(m_daemon->workingTouchpadFound()); | ||||
52 | enabledChanged(m_daemon->isEnabled()); | ||||
53 | mousePluggedInChanged(m_daemon->isMousePluggedIn()); | ||||
54 | } | ||||
55 | | ||||
56 | void TouchpadEngine::workingTouchpadFoundChanged(bool value) | ||||
57 | { | ||||
58 | setData(m_source, "workingTouchpadFound", value); | ||||
59 | } | ||||
60 | | ||||
61 | void TouchpadEngine::mousePluggedInChanged(bool value) | ||||
62 | { | ||||
63 | setData(m_source, "mousePluggedIn", value); | ||||
64 | } | ||||
65 | | ||||
66 | void TouchpadEngine::enabledChanged(bool value) | ||||
67 | { | ||||
68 | setData(m_source, "enabled", value); | ||||
69 | } | ||||
70 | | ||||
71 | Plasma::Service *TouchpadEngine::serviceForSource(const QString &source) | ||||
72 | { | ||||
73 | if (source == m_source) { | ||||
74 | return new TouchpadService(m_daemon, source, this); | ||||
75 | } | ||||
76 | | ||||
77 | return Plasma::DataEngine::serviceForSource(source); | ||||
78 | } | ||||
79 | | ||||
80 | TouchpadEngine::~TouchpadEngine() | ||||
81 | { | ||||
82 | } | ||||
83 | | ||||
84 | K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(touchpad, TouchpadEngine, "plasma-dataengine-touchpad.json") | ||||
85 | | ||||
86 | #include "touchpadengine.moc" |