Hello,
Here are once again, the updated patches to the tasks data engine. They
are essentially the same patches that I submitted to this list in
September, but reworked in order to be applied to current trunk.
Here is the original email.
http://mail.kde.org/pipermail/plasma-devel/2008-September/001209.html
These patches fix the engine to comply with all of the changes to
libtaskmanager and add a service to the engine which enables interaction
with the tasks or windows (ex: maximize, minimize, activate...).
Order:
- apply tasks_cleanup.diff, then commit
- apply tasks_new.diff and tasks_existing.diff, then commit
Thanks,
Alain.
Index: tasksengine.h
===================================================================
--- tasksengine.h (revision 888911)
+++ tasksengine.h (working copy)
@@ -19,37 +19,45 @@
#ifndef TASKSENGINE_H
#define TASKSENGINE_H
-// Plasma
+// plasma
#include <Plasma/DataEngine>
+
+// libtaskmanager
#include <taskmanager/taskmanager.h>
using TaskManager::StartupPtr;
using TaskManager::TaskPtr;
/**
- * This class evaluates the basic expressions given in the interface.
+ * Tasks Data Engine
+ *
+ * This engine provides information regarding tasks (windows that are currently open)
+ * as well as startup tasks (windows that are about to open).
+ * Each task and startup is represented by a unique source. Sources are added and removed
+ * as windows are opened and closed. You cannot request a customized source.
*/
class TasksEngine : public Plasma::DataEngine
{
+
Q_OBJECT
public:
- TasksEngine(QObject* parent, const QVariantList& args);
+ TasksEngine(QObject *parent, const QVariantList &args);
protected:
virtual void init();
private slots:
+ void startupChanged();
+ void startupAdded(StartupPtr startup);
+ void startupRemoved(StartupPtr startup);
void taskChanged();
void taskAdded(TaskPtr task);
void taskRemoved(TaskPtr task);
- void startupChanged();
- void startupAdded(StartupPtr task);
- void startupRemoved(StartupPtr);
private:
+ void setDataForStartup(StartupPtr startup);
void setDataForTask(TaskPtr task);
- void setDataForStartup(StartupPtr task);
};
#endif // TASKSENGINE_H
Index: plasma-dataengine-tasks.desktop
===================================================================
--- plasma-dataengine-tasks.desktop (revision 888911)
+++ plasma-dataengine-tasks.desktop (working copy)
@@ -32,7 +32,7 @@
Name[zh_CN]=çªå£ä¿¡æ¯
Name[zh_TW]=è¦çªè³è¨
Type=Service
-Icon=alarmclock
+Icon=user-desktop
X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_tasks
@@ -44,5 +44,5 @@
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=Windows and Tasks
X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=LGPL
+X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Index: tasksengine.cpp
===================================================================
--- tasksengine.cpp (revision 888911)
+++ tasksengine.cpp (working copy)
@@ -20,30 +20,23 @@
#include <QMetaProperty>
-using namespace Plasma;
-
-TasksEngine::TasksEngine(QObject* parent, const QVariantList& args)
- : Plasma::DataEngine(parent, args)
+TasksEngine::TasksEngine(QObject *parent, const QVariantList &args) :
+ Plasma::DataEngine(parent, args)
{
Q_UNUSED(args);
}
void TasksEngine::init()
{
- foreach(const TaskPtr& task, TaskManager::TaskManager::self()->tasks()) {
- connect(task.constData(), SIGNAL(changed()),
- this, SLOT(taskChanged()));
+ foreach (const TaskPtr &task, TaskManager::TaskManager::self()->tasks()) {
+ connect(task.constData(), SIGNAL(changed()), this, SLOT(taskChanged()));
setDataForTask(task);
}
- connect(TaskManager::TaskManager::self(), SIGNAL(taskAdded(TaskPtr)),
- this, SLOT(taskAdded(TaskPtr)));
- connect(TaskManager::TaskManager::self(), SIGNAL(taskRemoved(TaskPtr)),
- this, SLOT(taskRemoved(TaskPtr)));
- connect(TaskManager::TaskManager::self(), SIGNAL(startupAdded(StartupPtr)),
- this, SLOT(startupAdded(StartupPtr)));
- connect(TaskManager::TaskManager::self(), SIGNAL(startupRemoved(StartupPtr)),
- this, SLOT(startupRemoved(StartupPtr)));
+ connect(TaskManager::TaskManager::self(), SIGNAL(startupAdded(StartupPtr)), this, SLOT(startupAdded(StartupPtr)));
+ connect(TaskManager::TaskManager::self(), SIGNAL(startupRemoved(StartupPtr)), this, SLOT(startupRemoved(StartupPtr)));
+ connect(TaskManager::TaskManager::self(), SIGNAL(taskAdded(TaskPtr)), this, SLOT(taskAdded(TaskPtr)));
+ connect(TaskManager::TaskManager::self(), SIGNAL(taskRemoved(TaskPtr)), this, SLOT(taskRemoved(TaskPtr)));
}
void TasksEngine::startupAdded(StartupPtr startup)
@@ -59,33 +52,16 @@
void TasksEngine::startupChanged()
{
- TaskManager::Startup* startup = qobject_cast<TaskManager::Startup*>(sender());
+ TaskManager::Startup *startup = qobject_cast<TaskManager::Startup*>(sender());
Q_ASSERT(startup);
setDataForStartup(StartupPtr(startup));
}
-void TasksEngine::setDataForStartup(StartupPtr startup)
-{
- Q_ASSERT(startup);
-
- QString name(startup->id().id());
-
- const QMetaObject* metaObject = startup->metaObject();
-
- for (int i = 0; i < metaObject->propertyCount(); i++) {
- QMetaProperty property = metaObject->property(i);
-
- setData(name, property.name(), property.read(startup.constData()));
- }
- setData(name, "TaskOrStartup", "startup");
-}
-
void TasksEngine::taskAdded(TaskPtr task)
{
- connect(task.constData(), SIGNAL(changed()),
- this, SLOT(taskChanged()));
+ connect(task.constData(), SIGNAL(changed()), this, SLOT(taskChanged()));
setDataForTask(task);
}
@@ -96,24 +72,38 @@
void TasksEngine::taskChanged()
{
- TaskManager::Task* task = qobject_cast<TaskManager::Task*>(sender());
+ TaskManager::Task *task = qobject_cast<TaskManager::Task*>(sender());
Q_ASSERT(task);
setDataForTask(TaskPtr(task));
}
+void TasksEngine::setDataForStartup(StartupPtr startup)
+{
+ Q_ASSERT(startup);
+
+ QString name(startup->id().id());
+
+ const QMetaObject *metaObject = startup->metaObject();
+
+ for (int i = 0; i < metaObject->propertyCount(); i++) {
+ QMetaProperty property = metaObject->property(i);
+ setData(name, property.name(), property.read(startup.constData()));
+ }
+ setData(name, "TaskOrStartup", "startup");
+}
+
void TasksEngine::setDataForTask(TaskPtr task)
{
Q_ASSERT(task);
QString name = QString::number(task->window());
- const QMetaObject* metaObject = task->metaObject();
+ const QMetaObject *metaObject = task->metaObject();
for (int i = 0; i < metaObject->propertyCount(); i++) {
QMetaProperty property = metaObject->property(i);
-
setData(name,property.name(),property.read(task.constData()));
}
setData(name, "WId", static_cast<qulonglong>(task->window()));
@@ -122,5 +112,4 @@
K_EXPORT_PLASMA_DATAENGINE(tasks, TasksEngine)
-
#include "tasksengine.moc"
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 888911)
+++ CMakeLists.txt (working copy)
@@ -3,9 +3,7 @@
)
kde4_add_plugin(plasma_engine_tasks ${tasks_engine_SRCS})
-target_link_libraries(plasma_engine_tasks ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS}
- taskmanager)
+target_link_libraries(plasma_engine_tasks ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} taskmanager)
install(TARGETS plasma_engine_tasks DESTINATION ${PLUGIN_INSTALL_DIR})
-install(FILES plasma-dataengine-tasks.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
-
+install(FILES plasma-dataengine-tasks.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff -u CMakeLists.txt CMakeLists.txt
--- CMakeLists.txt 2008-11-25 10:05:02.000000000 -0500
+++ CMakeLists.txt 2008-11-27 12:57:10.000000000 -0500
@@ -1,5 +1,8 @@
set(tasks_engine_SRCS
tasksengine.cpp
+ tasksource.cpp
+ taskservice.cpp
+ taskjob.cpp
)
kde4_add_plugin(plasma_engine_tasks ${tasks_engine_SRCS})
@@ -7,3 +10,4 @@
install(TARGETS plasma_engine_tasks DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-dataengine-tasks.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+install(FILES tasks.operations DESTINATION ${DATA_INSTALL_DIR}/plasma/services)
diff -u tasksengine.cpp tasksengine.cpp
--- tasksengine.cpp 2008-11-25 10:05:14.000000000 -0500
+++ tasksengine.cpp 2008-11-27 12:57:51.000000000 -0500
@@ -1,24 +1,24 @@
/*
- * Copyright (C) 2007 Robert Knight <[EMAIL PROTECTED]>
+ * Copyright 2007 Robert Knight <[EMAIL PROTECTED]>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License version 2 as
- * published by the Free Software Foundation
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tasksengine.h"
-#include <QMetaProperty>
+// own
+#include "tasksource.h"
TasksEngine::TasksEngine(QObject *parent, const QVariantList &args) :
Plasma::DataEngine(parent, args)
@@ -26,13 +26,43 @@
Q_UNUSED(args);
}
+TasksEngine::~TasksEngine()
+{
+}
+
+Plasma::Service *TasksEngine::serviceForSource(const QString &name)
+{
+ TaskSource *source = dynamic_cast<TaskSource*>(containerForSource(name));
+ // if source does not exist, return null service
+ if (!source) {
+ return Plasma::DataEngine::serviceForSource(name);
+ }
+ // if source represents a startup task, return null service
+ if (!source->isTask()) {
+ return Plasma::DataEngine::serviceForSource(name);
+ }
+ // if source represent a proper task, return task service
+ Plasma::Service *service = source->createService();
+ service->setParent(this);
+ return service;
+}
+
+const QString TasksEngine::getStartupName(StartupPtr startup)
+{
+ return startup->id().id();
+}
+
+const QString TasksEngine::getTaskName(TaskPtr task)
+{
+ return QString::number(task->window());
+}
+
void TasksEngine::init()
{
foreach (const TaskPtr &task, TaskManager::TaskManager::self()->tasks()) {
- connect(task.constData(), SIGNAL(changed()), this, SLOT(taskChanged()));
- setDataForTask(task);
+ Q_ASSERT(task);
+ addTask(task);
}
-
connect(TaskManager::TaskManager::self(), SIGNAL(startupAdded(StartupPtr)), this, SLOT(startupAdded(StartupPtr)));
connect(TaskManager::TaskManager::self(), SIGNAL(startupRemoved(StartupPtr)), this, SLOT(startupRemoved(StartupPtr)));
connect(TaskManager::TaskManager::self(), SIGNAL(taskAdded(TaskPtr)), this, SLOT(taskAdded(TaskPtr)));
@@ -41,73 +71,40 @@
void TasksEngine::startupAdded(StartupPtr startup)
{
- connect(startup.constData(), SIGNAL(changed()), this, SLOT(startupChanged()));
- setDataForStartup(startup);
+ Q_ASSERT(startup);
+ addStartup(startup);
}
void TasksEngine::startupRemoved(StartupPtr startup)
{
- removeSource(startup->id().id());
-}
-
-void TasksEngine::startupChanged()
-{
- TaskManager::Startup *startup = qobject_cast<TaskManager::Startup*>(sender());
-
Q_ASSERT(startup);
-
- setDataForStartup(StartupPtr(startup));
+ removeSource(getStartupName(startup));
}
void TasksEngine::taskAdded(TaskPtr task)
{
- connect(task.constData(), SIGNAL(changed()), this, SLOT(taskChanged()));
- setDataForTask(task);
+ Q_ASSERT(task);
+ addTask(task);
}
void TasksEngine::taskRemoved(TaskPtr task)
{
- removeSource(QString::number(task->window()));
-}
-
-void TasksEngine::taskChanged()
-{
- TaskManager::Task *task = qobject_cast<TaskManager::Task*>(sender());
-
Q_ASSERT(task);
-
- setDataForTask(TaskPtr(task));
+ removeSource(getTaskName(task));
}
-void TasksEngine::setDataForStartup(StartupPtr startup)
+void TasksEngine::addStartup(StartupPtr startup)
{
- Q_ASSERT(startup);
-
- QString name(startup->id().id());
-
- const QMetaObject *metaObject = startup->metaObject();
-
- for (int i = 0; i < metaObject->propertyCount(); i++) {
- QMetaProperty property = metaObject->property(i);
- setData(name, property.name(), property.read(startup.constData()));
- }
- setData(name, "TaskOrStartup", "startup");
+ TaskSource *taskSource = new TaskSource(startup, this);
+ connect(startup.constData(), SIGNAL(changed(::TaskManager::TaskChanges)), taskSource, SLOT(updateStartup(::TaskManager::TaskChanges)));
+ addSource(taskSource);
}
-void TasksEngine::setDataForTask(TaskPtr task)
+void TasksEngine::addTask(TaskPtr task)
{
- Q_ASSERT(task);
-
- QString name = QString::number(task->window());
-
- const QMetaObject *metaObject = task->metaObject();
-
- for (int i = 0; i < metaObject->propertyCount(); i++) {
- QMetaProperty property = metaObject->property(i);
- setData(name,property.name(),property.read(task.constData()));
- }
- setData(name, "WId", static_cast<qulonglong>(task->window()));
- setData(name, "TaskOrStartup", "task");
+ TaskSource *taskSource = new TaskSource(task, this);
+ connect(task.constData(), SIGNAL(changed(::TaskManager::TaskChanges)), taskSource, SLOT(updateTask(::TaskManager::TaskChanges)));
+ addSource(taskSource);
}
K_EXPORT_PLASMA_DATAENGINE(tasks, TasksEngine)
diff -u tasksengine.h tasksengine.h
--- tasksengine.h 2008-11-25 10:05:22.000000000 -0500
+++ tasksengine.h 2008-11-27 12:57:43.000000000 -0500
@@ -1,19 +1,18 @@
/*
- * Copyright (C) 2007 Robert Knight <[EMAIL PROTECTED]>
+ * Copyright 2007 Robert Knight <[EMAIL PROTECTED]>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License version 2 as
- * published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TASKSENGINE_H
@@ -21,10 +20,10 @@
// plasma
#include <Plasma/DataEngine>
+#include <Plasma/Service>
// libtaskmanager
#include <taskmanager/taskmanager.h>
-
using TaskManager::StartupPtr;
using TaskManager::TaskPtr;
@@ -35,6 +34,12 @@
* as well as startup tasks (windows that are about to open).
* Each task and startup is represented by a unique source. Sources are added and removed
* as windows are opened and closed. You cannot request a customized source.
+ *
+ * A service is also provided for each task. It exposes some operations that can be
+ * performed on the windows (ex: maximize, minimize, activate).
+ *
+ * The data and operations are provided and handled by the taskmanager library.
+ * It should be noted that only a subset of data and operations are exposed.
*/
class TasksEngine : public Plasma::DataEngine
{
@@ -43,21 +48,24 @@
public:
TasksEngine(QObject *parent, const QVariantList &args);
+ ~TasksEngine();
+ Plasma::Service *serviceForSource(const QString &name);
protected:
+ static const QString getStartupName(StartupPtr startup);
+ static const QString getTaskName(TaskPtr task);
virtual void init();
private slots:
- void startupChanged();
void startupAdded(StartupPtr startup);
void startupRemoved(StartupPtr startup);
- void taskChanged();
void taskAdded(TaskPtr task);
void taskRemoved(TaskPtr task);
private:
- void setDataForStartup(StartupPtr startup);
- void setDataForTask(TaskPtr task);
+ friend class TaskSource;
+ void addStartup(StartupPtr startup);
+ void addTask(TaskPtr task);
};
#endif // TASKSENGINE_H
Index: taskjob.h
===================================================================
--- taskjob.h (revision 0)
+++ taskjob.h (revision 0)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008 Alain Boyer <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TASKJOB_H
+#define TASKJOB_H
+
+// plasma
+#include <Plasma/ServiceJob>
+
+// own
+#include "tasksource.h"
+
+/**
+ * Task Job
+ */
+class TaskJob : public Plasma::ServiceJob
+{
+
+ Q_OBJECT
+
+ public:
+ TaskJob(TaskSource *source, const QString &operation, QMap<QString, QVariant> ¶meters, QObject *parent = NULL);
+ ~TaskJob();
+
+ protected:
+ void start();
+
+ private:
+ TaskSource *m_source;
+
+};
+
+#endif // TASKJOB_H
Index: tasksource.cpp
===================================================================
--- tasksource.cpp (revision 0)
+++ tasksource.cpp (revision 0)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2008 Alain Boyer <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "tasksource.h"
+
+// own
+#include "tasksengine.h"
+#include "taskservice.h"
+
+TaskSource::TaskSource(StartupPtr startup, QObject *parent) :
+ Plasma::DataContainer(parent),
+ m_startup(startup),
+ m_task(),
+ m_isTask(false)
+{
+ setObjectName(TasksEngine::getStartupName(m_startup));
+ setData("startup", true);
+ setData("task", false);
+ updateStartup(TaskManager::TaskUnchanged);
+}
+
+TaskSource::TaskSource(TaskPtr task, QObject *parent) :
+ Plasma::DataContainer(parent),
+ m_startup(),
+ m_task(task),
+ m_isTask(true)
+{
+ setObjectName(TasksEngine::getTaskName(m_task));
+ setData("startup", false);
+ setData("task", true);
+ updateTask(TaskManager::EverythingChanged);
+}
+
+TaskSource::~TaskSource()
+{
+}
+
+Plasma::Service *TaskSource::createService()
+{
+ return new TaskService(this);
+}
+
+TaskPtr TaskSource::getTask()
+{
+ return m_task;
+}
+
+bool TaskSource::isTask()
+{
+ return m_isTask;
+}
+
+void TaskSource::updateStartup(::TaskManager::TaskChanges startupChanges)
+{
+ switch (startupChanges) {
+ case TaskManager::TaskUnchanged:
+ setData("text", m_startup->text());
+ setData("bin", m_startup->bin());
+ setData("icon", m_startup->icon());
+ }
+ checkForUpdate();
+}
+
+void TaskSource::updateTask(::TaskManager::TaskChanges taskChanges)
+{
+ // only a subset of task information is exported
+ switch (taskChanges) {
+ case TaskManager::EverythingChanged:
+ setData("name", m_task->name());
+ setData("visibleName", m_task->visibleName());
+ setData("visibleNameWithState", m_task->visibleNameWithState());
+ setData("maximized", m_task->isMaximized());
+ setData("minimized", m_task->isMinimized());
+ setData("shaded", m_task->isShaded());
+ setData("fullScreen", m_task->isFullScreen());
+ setData("alwaysOnTop", m_task->isAlwaysOnTop());
+ setData("keptBelowOthers", m_task->isKeptBelowOthers());
+ setData("active", m_task->isActive());
+ setData("onTop", m_task->isOnTop());
+ setData("onCurrentDesktop", m_task->isOnCurrentDesktop());
+ setData("onAllDesktops", m_task->isOnAllDesktops());
+ setData("desktop", m_task->desktop());
+ break;
+ case TaskManager::NameChanged:
+ setData("name", m_task->name());
+ setData("visibleName", m_task->visibleName());
+ setData("visibleNameWithState", m_task->visibleNameWithState());
+ break;
+ case TaskManager::StateChanged:
+ setData("maximized", m_task->isMaximized());
+ setData("minimized", m_task->isMinimized());
+ setData("shaded", m_task->isShaded());
+ setData("fullScreen", m_task->isFullScreen());
+ setData("alwaysOnTop", m_task->isAlwaysOnTop());
+ setData("keptBelowOthers", m_task->isKeptBelowOthers());
+ setData("active", m_task->isActive());
+ setData("onTop", m_task->isOnTop());
+ break;
+ case TaskManager::DesktopChanged:
+ setData("onCurrentDesktop", m_task->isOnCurrentDesktop());
+ setData("onAllDesktops", m_task->isOnAllDesktops());
+ setData("desktop", m_task->desktop());
+ break;
+ default:
+ break;
+ }
+ checkForUpdate();
+}
+
+#include "tasksource.moc"
Index: taskservice.cpp
===================================================================
--- taskservice.cpp (revision 0)
+++ taskservice.cpp (revision 0)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Alain Boyer <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "taskservice.h"
+
+// own
+#include "taskjob.h"
+
+TaskService::TaskService(TaskSource *source) :
+ Plasma::Service(source),
+ m_source(source)
+{
+ setName("tasks");
+}
+
+TaskService::~TaskService()
+{
+}
+
+Plasma::ServiceJob *TaskService::createJob(const QString &operation, QMap<QString, QVariant> ¶meters)
+{
+ return new TaskJob(m_source, operation, parameters, this);
+}
+
+#include "taskservice.moc"
Index: tasks.operations
===================================================================
--- tasks.operations (revision 0)
+++ tasks.operations (revision 0)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
+<kcfg>
+ <group name="setMaximized">
+ <entry name="maximized" type="bool" />
+ </group>
+ <group name="setMinimized">
+ <entry name="minimized" type="bool" />
+ </group>
+ <group name="setShaded">
+ <entry name="shaded" type="bool" />
+ </group>
+ <group name="setFullScreen">
+ <entry name="fullScreen" type="bool" />
+ </group>
+ <group name="setAlwaysOnTop">
+ <entry name="alwaysOnTop" type="bool" />
+ </group>
+ <group name="setKeptBelowOthers">
+ <entry name="keptBelowOthers" type="bool" />
+ </group>
+ <group name="toggleMaximized" />
+ <group name="toggleMinimized" />
+ <group name="toggleShaded" />
+ <group name="toggleFullScreen" />
+ <group name="toggleAlwaysOnTop" />
+ <group name="toggleKeptBelowOthers" />
+ <group name="restore" />
+ <group name="raise" />
+ <group name="lower" />
+ <group name="activate" />
+ <group name="activateRaiseOrMaximize" />
+ <group name="toDesktop">
+ <entry name="desktop" type="int" />
+ </group>
+ <group name="toCurrentDesktop" />
+</kcfg>
Index: tasksource.h
===================================================================
--- tasksource.h (revision 0)
+++ tasksource.h (revision 0)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008 Alain Boyer <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TASKSOURCE_H
+#define TASKSOURCE_H
+
+// plasma
+#include <Plasma/DataContainer>
+
+// libtaskmanager
+#include <taskmanager/taskmanager.h>
+using TaskManager::StartupPtr;
+using TaskManager::TaskPtr;
+
+/**
+ * Task Source
+ *
+ * This custom DataContainer represents a task or startup task as a unique source.
+ * It holds a shared pointer to the task or startup task and is responsible for setting
+ * and updating the data exposed by the source.
+ */
+class TaskSource : public Plasma::DataContainer
+{
+
+ Q_OBJECT
+
+ public:
+ TaskSource(StartupPtr startup, QObject *parent);
+ TaskSource(TaskPtr task, QObject *parent);
+ ~TaskSource();
+
+ protected:
+ Plasma::Service *createService();
+ TaskPtr getTask();
+ bool isTask();
+
+ private slots:
+ void updateStartup(::TaskManager::TaskChanges startupChanges);
+ void updateTask(::TaskManager::TaskChanges taskChanges);
+
+ private:
+ friend class TasksEngine;
+ friend class TaskJob;
+ StartupPtr m_startup;
+ TaskPtr m_task;
+ bool m_isTask;
+
+};
+
+#endif // TASKSOURCE_H
Index: taskservice.h
===================================================================
--- taskservice.h (revision 0)
+++ taskservice.h (revision 0)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008 Alain Boyer <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TASKSERVICE_H
+#define TASKSERVICE_H
+
+// plasma
+#include <Plasma/Service>
+#include <Plasma/ServiceJob>
+
+// own
+#include "tasksource.h"
+
+/**
+ * Task Service
+ */
+class TaskService : public Plasma::Service
+{
+
+ Q_OBJECT
+
+ public:
+ TaskService(TaskSource *source);
+ ~TaskService();
+
+ protected:
+ Plasma::ServiceJob *createJob(const QString &operation, QMap<QString, QVariant> ¶meters);
+
+ private:
+ TaskSource *m_source;
+};
+
+#endif // TASKSERVICE_H
Index: taskjob.cpp
===================================================================
--- taskjob.cpp (revision 0)
+++ taskjob.cpp (revision 0)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2008 Alain Boyer <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "taskjob.h"
+
+TaskJob::TaskJob(TaskSource *source, const QString &operation, QMap<QString, QVariant> ¶meters, QObject *parent) :
+ ServiceJob(source->objectName(), operation, parameters, parent),
+ m_source(source)
+{
+}
+
+TaskJob::~TaskJob()
+{
+}
+
+void TaskJob::start()
+{
+ // only a subset of task operations are exported
+ QString operation = operationName();
+ if (operation.startsWith("set")) {
+ if (operation == "setMaximized") {
+ m_source->getTask()->setMaximized(parameters().value("maximized").toBool());
+ setResult(true);
+ return;
+ }
+ else if (operation == "setMinimized") {
+ m_source->getTask()->setIconified(parameters().value("minimized").toBool());
+ setResult(true);
+ return;
+ }
+ else if (operation == "setShaded") {
+ m_source->getTask()->setShaded(parameters().value("shaded").toBool());
+ setResult(true);
+ return;
+ }
+ else if (operation == "setFullScreen") {
+ m_source->getTask()->setFullScreen(parameters().value("fullScreen").toBool());
+ setResult(true);
+ return;
+ }
+ else if (operation == "setAlwaysOnTop") {
+ m_source->getTask()->setAlwaysOnTop(parameters().value("alwaysOnTop").toBool());
+ setResult(true);
+ return;
+ }
+ else if (operation == "setKeptBelowOthers") {
+ m_source->getTask()->setKeptBelowOthers(parameters().value("keptBelowOthers").toBool());
+ setResult(true);
+ return;
+ }
+ }
+ else if (operation.startsWith("toggle")) {
+ if (operation == "toggleMaximized") {
+ m_source->getTask()->toggleMaximized();
+ setResult(true);
+ return;
+ }
+ else if (operation == "toggleMinimized") {
+ m_source->getTask()->toggleIconified();
+ setResult(true);
+ return;
+ }
+ else if (operation == "toggleShaded") {
+ m_source->getTask()->toggleShaded();
+ setResult(true);
+ return;
+ }
+ else if (operation == "toggleFullScreen") {
+ m_source->getTask()->toggleFullScreen();
+ setResult(true);
+ return;
+ }
+ else if (operation == "toggleAlwaysOnTop") {
+ m_source->getTask()->toggleAlwaysOnTop();
+ setResult(true);
+ return;
+ }
+ else if (operation == "toggleKeptBelowOthers") {
+ m_source->getTask()->toggleKeptBelowOthers();
+ setResult(true);
+ return;
+ }
+ }
+ else {
+ if (operation == "restore") {
+ m_source->getTask()->restore();
+ setResult(true);
+ return;
+ }
+ else if (operation == "raise") {
+ m_source->getTask()->raise();
+ setResult(true);
+ return;
+ }
+ else if (operation == "lower") {
+ m_source->getTask()->lower();
+ setResult(true);
+ return;
+ }
+ else if (operation == "activate") {
+ m_source->getTask()->activate();
+ setResult(true);
+ return;
+ }
+ else if (operation == "activateRaiseOrMaximize") {
+ m_source->getTask()->activateRaiseOrIconify();
+ setResult(true);
+ return;
+ }
+ else if (operation == "toDesktop") {
+ m_source->getTask()->toDesktop(parameters().value("desktop").toInt());
+ setResult(true);
+ return;
+ }
+ else if (operation == "toCurrentDesktop") {
+ m_source->getTask()->toCurrentDesktop();
+ setResult(true);
+ return;
+ }
+ }
+ setResult(false);
+}
+
+#include "taskjob.moc"
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel