[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bplasma-mobile/plasma/mart/qmlmobilesystray=5D_apple?=
From: Marco Martin <notmart () gmail ! com>
Date: 2011-02-19 22:40:43
Message-ID: 20110219224043.41476A609B () git ! kde ! org
[Download RAW message or body]
Git commit ae88f99a36cb4cc344c995c5b1522c8f91c97931 by Marco Martin.
Committed on 19/02/2011 at 23:40.
Pushed by mart into branch 'plasma/mart/qmlmobilesystray'.
remove all the core and protocol related stuff
M +1 -13 applets/mobilesystray/CMakeLists.txt
A +182 -0 applets/mobilesystray/applet.cpp [License: GPL (v2+)]
A +91 -0 applets/mobilesystray/applet.h [License: GPL (v2+)]
D +0 -127 applets/mobilesystray/core/manager.cpp
D +0 -107 applets/mobilesystray/core/manager.h
D +0 -35 applets/mobilesystray/core/protocol.cpp
D +0 -74 applets/mobilesystray/core/protocol.h
D +0 -199 applets/mobilesystray/core/task.cpp
D +0 -221 applets/mobilesystray/core/task.h
D +0 -99 applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.cpp \
D +0 -61 applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.h \
D +0 -355 applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.cpp \
D +0 -87 applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.h \
D +0 -201 applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.cpp \
D +0 -74 applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.h \
D +0 -194 applets/mobilesystray/protocols/plasmoid/plasmoidtask.cpp
D +0 -76 applets/mobilesystray/protocols/plasmoid/plasmoidtask.h
D +0 -122 applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.cpp
D +0 -69 applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.h
D +0 -182 applets/mobilesystray/ui/applet.cpp
D +0 -91 applets/mobilesystray/ui/applet.h
http://commits.kde.org/scratch/mart/plasma-mobile/ae88f99a36cb4cc344c995c5b1522c8f91c97931
diff --git a/applets/mobilesystray/CMakeLists.txt \
b/applets/mobilesystray/CMakeLists.txt index d404706..045cddc 100644
--- a/applets/mobilesystray/CMakeLists.txt
+++ b/applets/mobilesystray/CMakeLists.txt
@@ -14,19 +14,7 @@ include_directories(
# We add our source code here
set(mobilesystemtray_SRCS
-
- core/manager.cpp
- core/protocol.cpp
- core/task.cpp
-
- protocols/plasmoid/plasmoidtaskprotocol.cpp
- protocols/plasmoid/plasmoidtask.cpp
-
- protocols/dbussystemtray/dbussystemtraytask.cpp
- protocols/dbussystemtray/dbussystemtrayprotocol.cpp
- protocols/dbussystemtray/dbussystemtraywidget.cpp
-
- ui/applet.cpp
+ applet.cpp
)
# Now make sure all files get to the right place
diff --git a/applets/mobilesystray/applet.cpp b/applets/mobilesystray/applet.cpp
new file mode 100644
index 0000000..4da1df6
--- /dev/null
+++ b/applets/mobilesystray/applet.cpp
@@ -0,0 +1,182 @@
+/***************************************************************************
+ * applet.cpp *
+ * *
+ * Copyright (C) 2010 Lim Yuen Hoe <yuenhoe@hotmail.com> *
+ * Copyright (C) 2011 Marco Martin <mart@kde.org> *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+ ***************************************************************************/
+
+#include "applet.h"
+
+#include <QDeclarativeItem>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsSceneResizeEvent>
+#include <QTimer>
+
+#include <KIcon>
+#include <KIconLoader>
+#include <KStandardDirs>
+#include <KWindowSystem>
+
+#include <Plasma/Containment>
+#include <Plasma/Corona>
+#include <Plasma/DeclarativeWidget>
+#include <Plasma/Dialog>
+#include <Plasma/FrameSvg>
+
+
+namespace SystemTray
+{
+
+MobileTray::MobileTray(QObject *parent, const QVariantList &args)
+ : Plasma::Containment(parent, args),
+ m_appSwitcherDialog(0),
+ initDone(false)
+{
+ m_background = new Plasma::FrameSvg(this);
+ m_background->setImagePath("widgets/translucentbackground");
+ m_background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
+
+ // list of applets to "always show"
+ m_fixedList << "notifications" << "org.kde.fakebattery" << "org.kde.fakesignal" \
<< "digital-clock"; +
+ m_declarativeWidget = new Plasma::DeclarativeWidget(this);
+ m_declarativeWidget->setQmlPath(KStandardDirs::locate("data", \
"plasma-mobile/containments/mobilesystray/main.qml")); +
+ connect(this, SIGNAL(appletAdded(Plasma::Applet*,const QPointF&)),
+ this, SLOT(addTrayApplet(Plasma::Applet*)));
+
+ // use a timer to avoid repeated resizing
+ m_resizeTimer = new QTimer(this);
+ m_resizeTimer->setSingleShot(true);
+ connect(m_resizeTimer, SIGNAL(timeout()), this, SLOT(resizeContents()));
+}
+
+
+MobileTray::~MobileTray()
+{
+ if (m_appSwitcherDialog && m_appSwitcherDialog->graphicsWidget()) {
+ delete m_appSwitcherDialog->graphicsWidget();
+ }
+}
+
+void MobileTray::init()
+{
+ if (formFactor() != Plasma::Horizontal && formFactor() != Plasma::Vertical) {
+ setFormFactor(Plasma::Horizontal);
+ }
+
+ QDeclarativeItem *mainItem = \
qobject_cast<QDeclarativeItem*>(m_declarativeWidget->rootObject()); +
+ if (mainItem) {
+ connect(mainItem, SIGNAL(shrinkRequested()), this, \
SIGNAL(shrinkRequested())); + }
+
+ initDone = true;
+}
+
+void MobileTray::constraintsEvent(Plasma::Constraints constraints)
+{
+ if (constraints & Plasma::LocationConstraint) {
+ Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders;
+
+ switch (location()) {
+ case Plasma::LeftEdge:
+ borders ^= Plasma::FrameSvg::LeftBorder;
+ break;
+ case Plasma::RightEdge:
+ borders ^= Plasma::FrameSvg::RightBorder;
+ break;
+ case Plasma::TopEdge:
+ borders ^= Plasma::FrameSvg::TopBorder;
+ break;
+ case Plasma::BottomEdge:
+ borders ^= Plasma::FrameSvg::BottomBorder;
+ break;
+ default:
+ break;
+ }
+
+ m_background->setEnabledBorders(borders);
+ qreal left, top, right, bottom;
+ m_background->getMargins(left, top, right, bottom);
+ setContentsMargins(left, top, right, bottom);
+ m_declarativeWidget->setGeometry(contentsRect());
+ }
+}
+
+void MobileTray::resizeContents()
+{
+ m_declarativeWidget->setGeometry(contentsRect());
+ m_declarativeWidget->show();
+}
+
+void MobileTray::resizeEvent(QGraphicsSceneResizeEvent* event)
+{
+#define IMMEDIATE_RESIZE 1
+#if IMMEDIATE_RESIZE
+ m_declarativeWidget->setGeometry(contentsRect());
+#else
+ // resizing the contents seems slow, asynchronous, and thus jerky and \
potentially problematic, + // so we avoid resizing them continuously..
+ m_resizeTimer->start(500);
+ m_declarativeWidget->hide();
+#endif
+
+ m_background->resizeFrame(event->newSize());
+}
+
+// create plasmoidtasks out of applets added to the containment
+void MobileTray::addTrayApplet(Plasma::Applet* applet)
+{
+ //treat the appswitcher in a different way: it's wise?
+ if (!m_appSwitcherDialog && applet->pluginName() == "org.kde.appswitcher") {
+ applet->setParentItem(0);
+ corona()->addOffscreenWidget(applet);
+ m_appSwitcherDialog = new Plasma::Dialog();
+ m_appSwitcherDialog->setGraphicsWidget(applet);
+ KWindowSystem::setType(m_appSwitcherDialog->winId(), NET::Dock);
+ m_appSwitcherDialog->show();
+ applet->setMaximumSize(KIconLoader::SizeLarge, KIconLoader::SizeMedium);
+ } else {
+ QDeclarativeItem *mainItem = \
qobject_cast<QDeclarativeItem*>(m_declarativeWidget->rootObject()); +
+ if (mainItem) {
+ QDeclarativeItem *tasksList = \
mainItem->findChild<QDeclarativeItem*>("tasksList"); + if (tasksList) {
+ QDeclarativeListReference childrenRef(tasksList, "children");
+ childrenRef.append(applet);
+ }
+ }
+ }
+}
+
+void MobileTray::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ m_background->paintFrame(painter);
+}
+
+// This is the command that links your applet to the .desktop file
+K_EXPORT_PLASMA_APPLET(mobilesystemtray, MobileTray)
+
+}
+
+#include "applet.moc"
\ No newline at end of file
diff --git a/applets/mobilesystray/applet.h b/applets/mobilesystray/applet.h
new file mode 100644
index 0000000..bfa1d7a
--- /dev/null
+++ b/applets/mobilesystray/applet.h
@@ -0,0 +1,91 @@
+/***************************************************************************
+ * applet.h *
+ * *
+ * Copyright (C) 2010 Lim Yuen Hoe <yuenhoe@hotmail.com> *
+ * Copyright (C) 2011 Marco Martin <mart@kde.org> *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+ ***************************************************************************/
+
+#ifndef APPLET_H
+#define APPLET_H
+
+#include <Plasma/Containment>
+
+namespace Plasma
+{
+class DeclarativeWidget;
+class FrameSvg;
+class Dialog;
+}
+
+class QTimer;
+
+namespace SystemTray
+{
+
+class Manager;
+class Task;
+
+
+/**
+ * Main applet of the mobile version of the system tray.
+ *
+ * It has two modes - "active" and "passive", and switches between them depending on \
the + * width of the applet. "Active" mode is meant to be interactive and all icons \
are visible + * together with an additional cancel icon that hints to the parent to \
shrink it back to "passive" + * mode using the "shrinkRequested()" signal. "Passive" \
mode is meant to be non-interactive and + * some icons are hidden.
+ *
+ * The tray differentiates between two kinds of icons - fixed and cyclic. Fixed \
icons are always + * shown irregardless of mode, while cyclic icons can be hidden in \
"passive" mode. + */
+class MobileTray : public Plasma::Containment
+{
+ Q_OBJECT
+public:
+ // Basic Create/Destroy
+ MobileTray(QObject *parent, const QVariantList &args);
+ ~MobileTray();
+
+ void init();
+
+ void constraintsEvent(Plasma::Constraints constraints);
+
+signals:
+ void shrinkRequested(); // signal to parent to shrink the tray to "passive" mode
+
+protected:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget = 0);
+ void resizeEvent (QGraphicsSceneResizeEvent * event);
+
+protected slots:
+ void resizeContents();
+ void addTrayApplet(Plasma::Applet* ap);
+
+private:
+ Plasma::FrameSvg *m_background;
+ QList<QString> m_fixedList; // List of icon names that should be \
"fixed" +
+ Plasma::DeclarativeWidget *m_declarativeWidget;
+ QTimer *m_resizeTimer;
+ Plasma::Dialog *m_appSwitcherDialog;
+ bool initDone;
+};
+
+}
+#endif
\ No newline at end of file
diff --git a/applets/mobilesystray/core/manager.cpp \
b/applets/mobilesystray/core/manager.cpp deleted file mode 100644
index 1d41bd7..0000000
--- a/applets/mobilesystray/core/manager.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/***************************************************************************
- * manager.cpp *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * Copyright (C) 2010 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "manager.h"
-
-#include <KGlobal>
-
-#include <plasma/applet.h>
-
-#include "protocol.h"
-#include "task.h"
-
-//#include "../protocols/fdo/fdoprotocol.h"
-#include "../protocols/plasmoid/plasmoidtaskprotocol.h"
-#include "../protocols/dbussystemtray/dbussystemtrayprotocol.h"
-
-#include <QTimer>
-
-namespace SystemTray
-{
-
-class Manager::Private
-{
-public:
- Private(Manager *manager)
- : q(manager),
- plasmoidProtocol(0)
- {
- }
-
- void setupProtocol(Protocol *protocol);
-
- Manager *q;
- QList<Task *> tasks;
- PlasmoidProtocol *plasmoidProtocol;
-};
-
-
-Manager::Manager()
- : d(new Private(this))
-{
- d->plasmoidProtocol = new PlasmoidProtocol(this);
- d->setupProtocol(d->plasmoidProtocol);
- //d->setupProtocol(new SystemTray::FdoProtocol(this));
- d->setupProtocol(new SystemTray::DBusSystemTrayProtocol(this));
-}
-
-Manager::~Manager()
-{
- delete d;
-}
-
-
-QList<Task*> Manager::tasks() const
-{
- return d->tasks;
-}
-
-void Manager::addTask(Task *task)
-{
- connect(task, SIGNAL(destroyed(SystemTray::Task*)), this, \
SLOT(removeTask(SystemTray::Task*)));
- connect(task, SIGNAL(changed(SystemTray::Task*)), this, \
SIGNAL(taskChanged(SystemTray::Task*)));
-
- kDebug() << task->name() << "(" << task->typeId() << ")";
-
- d->tasks.append(task);
- emit taskAdded(task);
-}
-
-
-void Manager::removeTask(Task *task)
-{
- d->tasks.removeAll(task);
- disconnect(task, 0, this, 0);
- emit taskRemoved(task);
-}
-
-void Manager::forwardConstraintsEvent(Plasma::Constraints constraints, \
Plasma::Applet *host)
-{
- d->plasmoidProtocol->forwardConstraintsEvent(constraints, host);
-}
-
-void Manager::addApplet(Plasma::Applet *applet, Plasma::Applet *parent)
-{
- d->plasmoidProtocol->addApplet(applet, 0, parent);
-}
-
-void Manager::removeApplet(const QString appletName, Plasma::Applet *parent)
-{
- d->plasmoidProtocol->removeApplet(appletName, parent);
-}
-
-QStringList Manager::applets(Plasma::Applet *parent) const
-{
- return d->plasmoidProtocol->applets(parent);
-}
-
-
-void Manager::Private::setupProtocol(Protocol *protocol)
-{
- connect(protocol, SIGNAL(taskCreated(SystemTray::Task*)), q, \
SLOT(addTask(SystemTray::Task*)));
- protocol->init();
-}
-
-}
-
-
-#include "manager.moc"
diff --git a/applets/mobilesystray/core/manager.h \
b/applets/mobilesystray/core/manager.h deleted file mode 100644
index 9f2fcfc..0000000
--- a/applets/mobilesystray/core/manager.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/***************************************************************************
- * manager.h *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * Copyright (C) 2010 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef SYSTEMTRAYMANAGER_H
-#define SYSTEMTRAYMANAGER_H
-
-#include <QtCore/QObject>
-
-#include <KConfigGroup>
-
-#include <plasma/plasma.h>
-
-namespace Plasma
-{
-class Applet;
-}
-
-namespace SystemTray
-{
-
-class Applet;
-class Notification;
-class Task;
-class Job;
-
-/**
- * w
- * @short Creator and amalgamator of the supported system tray specifications
- **/
-class Manager : public QObject
-{
- Q_OBJECT
-
-public:
- Manager();
- ~Manager();
-
- /**
- * @return a list of all known Task instances
- **/
- QList<Task*> tasks() const;
-
- void forwardConstraintsEvent(Plasma::Constraints constraints, Plasma::Applet \
*host);
-
-// removed as loading applets from config is the containment's job now
-// void loadApplets(Plasma::Applet *parent);
-
-// removed as we should not need to add applet by name anymore.
-// void addApplet(const QString appletName, Plasma::Applet *parent);
-
- void addApplet(Plasma::Applet* applet, Plasma::Applet *parent);
-
- void removeApplet(const QString appletName, Plasma::Applet *parent);
-
- QStringList applets(Plasma::Applet *parent) const;
-
-signals:
- /**
- * Emitted when a new task has been added
- **/
- void taskAdded(SystemTray::Task *task);
-
- /**
- * Emitted when something about a task changes (such as it changing from
- * non-embeddable to embeddable)
- **/
- void taskChanged(SystemTray::Task *task);
-
- /**
- * Emitted when a task has been removed
- **/
- void taskRemoved(SystemTray::Task *task);
-
-private slots:
- void addTask(SystemTray::Task *task);
- void removeTask(SystemTray::Task *task);
-
-private:
- class Private;
- Private* const d;
-
- friend class Applet;
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/core/protocol.cpp \
b/applets/mobilesystray/core/protocol.cpp deleted file mode 100644
index a6af0c2..0000000
--- a/applets/mobilesystray/core/protocol.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- * taskprotocol.cpp *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "protocol.h"
-
-
-namespace SystemTray
-{
-
-Protocol::Protocol(QObject *parent)
- : QObject(parent)
-{
-}
-
-}
-
-#include "protocol.moc"
diff --git a/applets/mobilesystray/core/protocol.h \
b/applets/mobilesystray/core/protocol.h deleted file mode 100644
index a6a56b5..0000000
--- a/applets/mobilesystray/core/protocol.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/***************************************************************************
- * taskprotocol.h *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef SYSTEMTRAYPROTOCOL_H
-#define SYSTEMTRAYPROTOCOL_H
-
-#include <QtCore/QObject>
-
-namespace SystemTray
-{
- class Job;
- class Notification;
- class Task;
-}
-
-
-namespace SystemTray
-{
-
-/**
- * @short System tray protocol base class
- *
- * To support a new system tray protocol, this class and Task should be
- * subclassed and the subclass of this class registered with the global
- * Manager. The Protocol subclass should emit taskCreated() for each new
- * task created.
- **/
-class Protocol : public QObject
-{
- Q_OBJECT
-public:
- explicit Protocol(QObject *parent);
-
- virtual void init() = 0;
-
-signals:
- /**
- * Signals that a new task has been created
- **/
- void taskCreated(SystemTray::Task *task);
-
- /**
- * Signals that a new notification has been created
- **/
- void jobCreated(SystemTray::Job *job);
-
- /**
- * Signals that a new notification has been created
- **/
- void notificationCreated(SystemTray::Notification *notification);
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/core/task.cpp \
b/applets/mobilesystray/core/task.cpp deleted file mode 100644
index eb2bf36..0000000
--- a/applets/mobilesystray/core/task.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/***************************************************************************
- * task.cpp *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "task.h"
-
-#include <QtGui/QGraphicsWidget>
-
-
-namespace SystemTray
-{
-
-
-class Task::Private
-{
-public:
- Private()
- : hiddenState(Task::NotHidden),
- order(Task::Normal),
- status(Task::UnknownStatus),
- category(Task::UnknownCategory)
- {
- }
-
- QHash<Plasma::Applet *, QGraphicsWidget *> widgetsByHost;
- Task::HideStates hiddenState;
- Task::Order order;
- Task::Status status;
- Task::Category category;
-};
-
-
-Task::Task(QObject *parent)
- : QObject(parent),
- d(new Private)
-{
-}
-
-Task::~Task()
-{
- emit destroyed(this);
- foreach (QGraphicsWidget * widget, d->widgetsByHost) {
- disconnect(widget, 0, this, 0);
- delete widget;
- }
- delete d;
-}
-
-
-QGraphicsWidget* Task::widget(Plasma::Applet *host, bool createIfNecessary)
-{
- Q_ASSERT(host);
-
- QGraphicsWidget *widget = d->widgetsByHost.value(host);
-
- if (!widget && createIfNecessary) {
- widget = createWidget(host);
-
- if (widget) {
- d->widgetsByHost.insert(host, widget);
- connect(widget, SIGNAL(destroyed()), this, SLOT(widgetDeleted()));
- }
- }
-
- return widget;
-}
-
-bool Task::isEmbeddable(Plasma::Applet *host)
-{
- if (!host) {
- return false;
- }
-
- return d->widgetsByHost.value(host) || isEmbeddable();
-}
-
-QHash<Plasma::Applet *, QGraphicsWidget *> Task::widgetsByHost() const
-{
- return d->widgetsByHost;
-}
-
-void Task::widgetDeleted()
-{
- bool wasEmbeddable = isEmbeddable();
-
- QGraphicsWidget * w = static_cast<QGraphicsWidget*>(sender());
- QMutableHashIterator<Plasma::Applet *, QGraphicsWidget *> it(d->widgetsByHost);
- while (it.hasNext()) {
- it.next();
- if (it.value() == w) {
- it.remove();
- }
- }
-
- if (!wasEmbeddable && isEmbeddable()) {
- emit changed(this);
- }
-}
-
-bool Task::isHideable() const
-{
- return true;
-}
-
-void Task::setHidden(HideStates state)
-{
- d->hiddenState = state;
-}
-
-Task::HideStates Task::hidden() const
-{
- return d->hiddenState;
-}
-
-bool Task::isUsed() const
-{
- return !d->widgetsByHost.isEmpty();
-}
-
-Task::Order Task::order() const
-{
- return d->order;
-}
-
-void Task::setOrder(Order order)
-{
- d->order = order;
-}
-
-void Task::setCategory(Category category)
-{
- if (d->category == category) {
- return;
- }
-
- d->category = category;
- emit changed(this);
-}
-
-Task::Category Task::category() const
-{
- return d->category;
-}
-
-void Task::setStatus(Status status)
-{
- if (d->status == status) {
- return;
- }
-
- d->status = status;
- resetHiddenStatus();
- emit changed(this);
-}
-
-Task::Status Task::status() const
-{
- return d->status;
-}
-
-void Task::resetHiddenStatus()
-{
- if (d->status == NeedsAttention) {
- setOrder(First);
- if (hidden() & AutoHidden) {
- setHidden(hidden() ^ AutoHidden);
- }
- } else {
- if (d->status == Active && (hidden() & AutoHidden)) {
- setHidden(hidden() ^ AutoHidden);
- } else if (d->status == Passive) {
- setHidden(hidden() | AutoHidden);
- }
-
- setOrder(Normal);
- }
-}
-
-}
-
-
-#include "task.moc"
diff --git a/applets/mobilesystray/core/task.h b/applets/mobilesystray/core/task.h
deleted file mode 100644
index 53acaf4..0000000
--- a/applets/mobilesystray/core/task.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/***************************************************************************
- * task.h *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef SYSTEMTRAYTASK_H
-#define SYSTEMTRAYTASK_H
-
-#include <QtCore/QObject>
-
-#include <QtGui/QIcon>
-
-class QGraphicsWidget;
-
-namespace Plasma
-{
- class Applet;
-} // namespace Plasma
-
-namespace SystemTray
-{
-
-/**
- * @short System tray task base class
- *
- * To support a new system tray protocol, Protocol and this class should
- * be subclassed.
- **/
-class Task : public QObject
-{
- Q_OBJECT
-
-public:
- enum Order { First, Normal, Last };
-
- enum HideState {
- NotHidden = 0,
- UserHidden = 1,
- AutoHidden = 2
- };
- Q_DECLARE_FLAGS(HideStates, HideState)
-
- enum Status {
- UnknownStatus = 0,
- Passive = 1,
- Active = 2,
- NeedsAttention = 3
- };
- Q_ENUMS(Status)
-
- enum Category {
- UnknownCategory = 0,
- ApplicationStatus = 1,
- Communications = 2,
- SystemServices = 3,
- Hardware = 4
- };
- Q_ENUMS(Category)
-
-
-
- virtual ~Task();
-
- /**
- * Creates a new graphics widget for this task
- *
- * isEmbeddable() should be checked before creating a new widget.
- **/
- QGraphicsWidget* widget(Plasma::Applet *host, bool createIfNecessary = true);
-
- /**
- * @return whether this task is embeddable; true if there is already a widget
- * for this host.
- */
- bool isEmbeddable(Plasma::Applet *host);
-
- /**
- * Returns whether this task can be embeddable
- *
- * Depending on the protocol, there may be circumstances under which
- * a new widget can not be created. isEmbeddable() will return false
- * under these circumstances.
- **/
- virtual bool isEmbeddable() const = 0;
-
- /**
- * Returns the name of this task that should be presented to the user
- **/
- virtual QString name() const = 0;
-
- /**
- * Returns a unique identifier for this task
- *
- * The identifier is valid between restarts and so is safe to save
- **/
- virtual QString typeId() const = 0;
-
- /**
- * Returns an icon that can be associated with this task
- *
- * The icon returned is not necessarily the same icon that appears
- * in the tray icon itself.
- **/
- virtual QIcon icon() const = 0;
-
- /**
- * Returns whether the task is currently hideable by the user or not
- */
- virtual bool isHideable() const;
-
- /**
- * Make the task ask to be hidden. The systemtray may or may not fullfill that \
requirement
- */
- void setHidden(HideStates state);
-
- /**
- * Returns the state of the icon: visible, hidden by the user or hidden by \
itself
- */
- HideStates hidden() const;
-
- /**
- * @return true if this task is current being used, e.g. it has created
- * widgets for one or more hosts
- */
- bool isUsed() const;
-
- /**
- * Returns the order this Task should be placed in: first, normal or last
- */
- Order order() const;
-
- /**
- * Sets which order this task should be placed in, relative to other Tasks
- *
- * @arg order the order to set this Task to
- */
- void setOrder(Order order);
-
- /**
- * Sets the category of the task, UnknownCategory by default
- * @arg category the category for this task
- */
- void setCategory(Category category);
-
- /**
- * @return the category of this task
- */
- Category category() const;
-
- /**
- * Sets the status of the task, UnknownStatus by default.
- * @arg status the status for this task
- */
- void setStatus(Status status);
-
- /**
- * @return the status for this task
- */
- Status status() const;
-
- /**
- * Resets the hidden state based purely on the status. Will not emit a changed \
signal.
- */
- void resetHiddenStatus();
-
- QHash<Plasma::Applet *, QGraphicsWidget *> widgetsByHost() const;
-
-Q_SIGNALS:
- /**
- * Emitted when something about the task has changed
- **/
- //TODO: this should also state _what_ was changed so we can react more
- // precisely (and therefore with greater efficiency)
- void changed(SystemTray::Task *task);
-
- /**
- * Emitted when the task is about to be destroyed
- **/
- void destroyed(SystemTray::Task *task);
-
-protected:
- Task(QObject *parent = 0);
-
- /**
- * Called when a new widget is required
- *
- * Subclasses should implement this to return a graphics widget that
- * handles all user interaction with the task. Ownership of the
- * created widget is handled automatically so subclasses should not
- * delete the created widget.
- **/
- virtual QGraphicsWidget* createWidget(Plasma::Applet *host) = 0;
-
-private slots:
- void widgetDeleted();
-
-private:
- class Private;
- Private* const d;
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.cpp \
b/applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.cpp deleted \
file mode 100644 index 7cec38c..0000000
--- a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************************************
- * dbussystemtrayprotocol.cpp *
- * *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "dbussystemtraytask.h"
-#include "dbussystemtrayprotocol.h"
-
-#include <Plasma/DataEngineManager>
-
-
-namespace SystemTray
-{
-
-DBusSystemTrayProtocol::DBusSystemTrayProtocol(QObject *parent)
- : Protocol(parent),
- m_dataEngine(Plasma::DataEngineManager::self()->loadEngine("statusnotifieritem")),
- m_tasks()
-{
-}
-
-DBusSystemTrayProtocol::~DBusSystemTrayProtocol()
-{
- Plasma::DataEngineManager::self()->unloadEngine("statusnotifieritem");
-}
-
-void DBusSystemTrayProtocol::init()
-{
- if (m_dataEngine->isValid()) {
- initRegisteredServices();
- connect(m_dataEngine, SIGNAL(sourceAdded(const QString&)),
- this, SLOT(newTask(const QString&)));
- connect(m_dataEngine, SIGNAL(sourceRemoved(const QString&)),
- this, SLOT(cleanupTask(const QString&)));
- }
-}
-
-void DBusSystemTrayProtocol::newTask(const QString &service)
-{
- if (m_tasks.contains(service)) {
- return;
- }
-
- DBusSystemTrayTask *task = new DBusSystemTrayTask(service, \
m_dataEngine->serviceForSource(service), this);
-
- m_dataEngine->connectSource(service, task);
-
- if (!task->isValid()) {
- // we failed to load our task, *sob*
- delete task;
- return;
- }
-
- m_tasks[service] = task;
-// connect(task, SIGNAL(taskDeleted(QString)), this, SLOT(cleanupTask(QString)));
- emit taskCreated(task);
-}
-
-void DBusSystemTrayProtocol::cleanupTask(const QString &service)
-{
- DBusSystemTrayTask *task = m_tasks.value(service);
-
- if (task) {
- m_dataEngine->disconnectSource(service, task);
- m_tasks.remove(service);
- emit task->destroyed(task);
- task->deleteLater();
- }
-}
-
-void DBusSystemTrayProtocol::initRegisteredServices()
-{
- if (m_dataEngine->isValid()) {
- QStringList registeredItems = m_dataEngine->sources();
- foreach (const QString &service, registeredItems) {
- newTask(service);
- }
- }
-}
-
-}
-
-#include "dbussystemtrayprotocol.moc"
diff --git a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.h \
b/applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.h deleted \
file mode 100644 index aa6050e..0000000
--- a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtrayprotocol.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef DBUSSYSTEMTRAYPROTOCOL_H
-#define DBUSSYSTEMTRAYPROTOCOL_H
-
-#include "../../core/protocol.h"
-
-#include <Plasma/DataEngine>
-
-#include <QHash>
-
-#include <QDBusConnection>
-
-
-namespace SystemTray
-{
-
-class DBusSystemTrayTask;
-
-class DBusSystemTrayProtocol : public Protocol
-{
- Q_OBJECT
-
-public:
- DBusSystemTrayProtocol(QObject *parent);
- ~DBusSystemTrayProtocol();
- void init();
-
-protected:
- void initRegisteredServices();
-
-protected Q_SLOTS:
- void newTask(const QString &service);
- void cleanupTask(const QString &typeId);
-
-private:
- Plasma::DataEngine *m_dataEngine;
- QHash<QString, DBusSystemTrayTask*> m_tasks;
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.cpp \
b/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.cpp deleted file \
mode 100644 index 6007671..0000000
--- a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/***************************************************************************
- * *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "dbussystemtraytask.h"
-
-#include <QAction>
-#include <QDir>
-#include <QGraphicsWidget>
-#include <QGraphicsSceneContextMenuEvent>
-#include <QIcon>
-#include <QMovie>
-#include <QTimer>
-#include <QMetaEnum>
-
-#include <KAction>
-#include <KIcon>
-#include <KIconLoader>
-#include <KStandardDirs>
-
-#include <plasma/plasma.h>
-#include <Plasma/Corona>
-#include <Plasma/View>
-#include <Plasma/IconWidget>
-#include <Plasma/ToolTipContent>
-#include <Plasma/ToolTipManager>
-#include <Plasma/Applet>
-#include <Plasma/DataEngineManager>
-
-#include "dbussystemtraywidget.h"
-
-#include <netinet/in.h>
-
-namespace SystemTray
-{
-
-DBusSystemTrayTask::DBusSystemTrayTask(const QString &service, Plasma::Service \
*dataService, QObject *parent)
- : Task(parent),
- m_movie(0),
- m_blinkTimer(0),
- m_service(dataService),
- m_blink(false),
- m_valid(false),
- m_embeddable(false)
-{
- kDebug();
- m_typeId = service;
- m_name = service;
- m_service->setParent(this);
-
- //TODO: how to behave if its not m_valid?
- m_valid = !service.isEmpty();
-
- if (m_valid) {
- dataUpdated(service, Plasma::DataEngine::Data());
- }
-}
-
-DBusSystemTrayTask::~DBusSystemTrayTask()
-{
- delete m_movie;
- delete m_blinkTimer;
-}
-
-QGraphicsWidget* DBusSystemTrayTask::createWidget(Plasma::Applet *host)
-{
- kDebug();
- DBusSystemTrayWidget *m_iconWidget = new DBusSystemTrayWidget(host, m_service);
- m_iconWidget->show();
-
- // we don't deal with xembed in mobile, and unlike the desktop version we want \
to be able
- // to resize stuff freely, so we ommit code to fix the icon size here.
-
- //Delay because syncStatus needs that createWidget is done
-// QTimer::singleShot(0, this, SLOT(connectToData()));
- return m_iconWidget;
-}
-
-bool DBusSystemTrayTask::isValid() const
-{
- return m_valid;
-}
-
-bool DBusSystemTrayTask::isEmbeddable() const
-{
- return m_embeddable;
-}
-
-QString DBusSystemTrayTask::name() const
-{
- return m_name;
-}
-
-QString DBusSystemTrayTask::typeId() const
-{
- return m_typeId;
-}
-
-QIcon DBusSystemTrayTask::icon() const
-{
- return m_icon;
-}
-
-void DBusSystemTrayTask::dataUpdated(const QString &taskName, const \
Plasma::DataEngine::Data &properties)
-{
- Q_UNUSED(taskName);
-
- const QString oldTypeId = m_typeId;
-
- QString cat = properties["Category"].toString();
- if (!cat.isEmpty()) {
- int index = metaObject()->indexOfEnumerator("Category");
- int key = metaObject()->enumerator(index).keyToValue(cat.toLatin1());
-
- if (key != -1) {
- setCategory((Task::Category)key);
- }
- }
-
- if (properties["TitleChanged"].toBool()) {
- QString m_title = properties["Title"].toString();
- if (!m_title.isEmpty()) {
- m_name = m_title;
-
- if (m_typeId.isEmpty()) {
- m_typeId = m_title;
- }
- }
- }
-
- /*
- kDebug() << m_name
- << "status:" << properties["StatusChanged"].toBool() << "title:" << \
properties["TitleChanged"].toBool()
- << "icons:" << properties["IconsChanged"].toBool() << "tooltip:" << \
properties["ToolTipChanged"].toBool();
- */
-
- QString id = properties["Id"].toString();
- if (!id.isEmpty()) {
- m_typeId = id;
- }
-
- if (properties["IconsChanged"].toBool()) {
- syncIcons(properties);
- }
-
- if (properties["StatusChanged"].toBool()) {
- syncStatus(properties["Status"].toString());
- }
-
- if (properties["ToolTipChanged"].toBool()) {
- syncToolTip(properties["ToolTipTitle"].toString(),
- properties["ToolTipSubTitle"].toString(),
- properties["ToolTipIcon"].value<QIcon>());
- }
-
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- DBusSystemTrayWidget *iconWidget = qobject_cast<DBusSystemTrayWidget \
*>(widget);
- if (iconWidget) {
- iconWidget->setItemIsMenu(properties["WindowId"].toInt() == 0);
- }
- }
-
- if (m_typeId != oldTypeId) {
- QHash<Plasma::Applet *, QGraphicsWidget *>::const_iterator i = \
widgetsByHost().constBegin();
- while (i != widgetsByHost().constEnd()) {
- Plasma::IconWidget *icon = static_cast<Plasma::IconWidget *>(i.value());
- icon->action()->setObjectName(QString("Systemtray-%1-%2").arg(m_typeId).arg(i.key()->id()));
-
- KConfigGroup cg = i.key()->config();
- KConfigGroup shortcutsConfig = KConfigGroup(&cg, "Shortcuts");
- QString shortcutText = \
shortcutsConfig.readEntryUntranslated(icon->action()->objectName(), \
QString());
- KAction *action = qobject_cast<KAction *>(icon->action());
- if (action && !shortcutText.isEmpty()) {
- action->setGlobalShortcut(KShortcut(shortcutText),
- KAction::ShortcutTypes(KAction::ActiveShortcut | \
KAction::DefaultShortcut),
- KAction::NoAutoloading);
- }
-
- ++i;
- }
- }
-
- m_embeddable = true;
-
- if (oldTypeId != m_typeId || properties["StatusChanged"].toBool() || \
properties["TitleChanged"].toBool()) {
- //kDebug() << "signaling a change";
- emit changed(this);
- }
-}
-
-void DBusSystemTrayTask::syncIcons(const Plasma::DataEngine::Data &properties)
-{
- m_icon = properties["Icon"].value<QIcon>();
- m_iconName = properties["IconName"].toString();
-
- if (status() != Task::NeedsAttention) {
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- DBusSystemTrayWidget *iconWidget = qobject_cast<DBusSystemTrayWidget \
*>(widget);
- if (!iconWidget) {
- continue;
- }
-
- iconWidget->setIcon(m_iconName, m_icon);
-
- // we don't deal with xembed in mobile, and unlike the desktop version \
we want to be able
- // to resize stuff freely, so we ommit code to fix the icon size here.
-
- }
- }
-
- m_attentionIcon = properties["AttentionIcon"].value<QIcon>();
- m_attentionIconName = properties["AttentionIconName"].toString();
-
- QString m_movieName = properties["AttentionMovieName"].toString();
- syncMovie(m_movieName);
-
- //FIXME: this is used only on the monochrome ones, the third place where the \
overlay painting is implemented
- QIcon overlayIcon = properties["OverlayIcon"].value<QIcon>();
- if (overlayIcon.isNull() && \
!properties["OverlayIconName"].value<QString>().isEmpty()) {
- overlayIcon = KIcon(properties["OverlayIconName"].value<QString>());
- }
-
- if (!overlayIcon.isNull()) {
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- DBusSystemTrayWidget *iconWidget = qobject_cast<DBusSystemTrayWidget \
*>(widget);
- if (iconWidget) {
- iconWidget->setOverlayIcon(overlayIcon);
- }
- }
- }
-}
-
-void DBusSystemTrayTask::blinkAttention()
-{
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- DBusSystemTrayWidget *iconWidget = qobject_cast<DBusSystemTrayWidget \
*>(widget);
- if (iconWidget) {
- iconWidget->setIcon(m_blink?m_attentionIconName:m_iconName, \
m_blink?m_attentionIcon:m_icon);
- }
- }
- m_blink = !m_blink;
-}
-
-void DBusSystemTrayTask::syncMovie(const QString &m_movieName)
-{
- delete m_movie;
- if (m_movieName.isEmpty()) {
- m_movie = 0;
- return;
- }
- if (QDir::isAbsolutePath(m_movieName)) {
- m_movie = new QMovie(m_movieName);
- } else {
- m_movie = KIconLoader::global()->loadMovie(m_movieName, KIconLoader::Panel);
- }
- if (m_movie) {
- connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(updateMovieFrame()));
- }
-}
-
-
-
-void DBusSystemTrayTask::updateMovieFrame()
-{
- Q_ASSERT(m_movie);
- QPixmap pix = m_movie->currentPixmap();
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- Plasma::IconWidget *iconWidget = qobject_cast<Plasma::IconWidget *>(widget);
- if (iconWidget) {
- iconWidget->setIcon(pix);
- }
- }
-}
-
-
-//toolTip
-
-void DBusSystemTrayTask::syncToolTip(const QString &title, const QString &subTitle, \
const QIcon &toolTipIcon)
-{
- if (title.isEmpty()) {
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- Plasma::ToolTipManager::self()->clearContent(widget);
- }
- return;
- }
-
- Plasma::ToolTipContent toolTipData(title, subTitle, toolTipIcon);
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- Plasma::ToolTipManager::self()->setContent(widget, toolTipData);
- }
-}
-
-
-//Status
-
-void DBusSystemTrayTask::syncStatus(QString newStatus)
-{
- Task::Status status = \
(Task::Status)metaObject()->enumerator(metaObject()->indexOfEnumerator("Status")).keyToValue(newStatus.toLatin1());
-
- if (this->status() == status) {
- return;
- }
-
- if (status == Task::NeedsAttention) {
- if (m_movie) {
- m_movie->stop();
- m_movie->start();
- } else if (!m_attentionIcon.isNull()) {
- if (!m_blinkTimer) {
- m_blinkTimer = new QTimer(this);
- connect(m_blinkTimer, SIGNAL(timeout()), this, \
SLOT(blinkAttention()));
- m_blinkTimer->start(500);
- }
- }
- } else {
- if (m_movie) {
- m_movie->stop();
- }
-
- if (m_blinkTimer) {
- m_blinkTimer->stop();
- m_blinkTimer->deleteLater();
- m_blinkTimer = 0;
- }
-
- foreach (QGraphicsWidget *widget, widgetsByHost()) {
- DBusSystemTrayWidget *iconWidget = qobject_cast<DBusSystemTrayWidget \
*>(widget);
- if (iconWidget) {
- iconWidget->setIcon(m_iconName, m_icon);
- }
- }
- }
-
- setStatus(status);
-}
-
-}
-
-#include "dbussystemtraytask.moc"
diff --git a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.h \
b/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.h deleted file \
mode 100644 index 3f9ae30..0000000
--- a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraytask.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/***************************************************************************
- * *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef DBUSSYSTEMTRAYTASK_H
-#define DBUSSYSTEMTRAYTASK_H
-
-#include "../../core/task.h"
-
-#include <Plasma/DataEngine>
-
-namespace Plasma
-{
-
-class Service;
-
-}
-
-namespace SystemTray
-{
-
-class DBusSystemTrayTaskPrivate;
-
-class DBusSystemTrayTask : public Task
-{
- Q_OBJECT
-
- friend class DBusSystemTrayProtocol;
-
-public:
- DBusSystemTrayTask(const QString &serviceName, Plasma::Service *service, QObject \
*parent);
- ~DBusSystemTrayTask();
-
- QGraphicsWidget* createWidget(Plasma::Applet *host);
- bool isValid() const;
- bool isEmbeddable() const;
- virtual QString name() const;
- virtual QString typeId() const;
- virtual QIcon icon() const;
-
-private:
- void syncToolTip(const QString &title, const QString &subTitle, const QIcon \
&toolTipIcon);
- void syncMovie(const QString &);
- void syncIcons(const Plasma::DataEngine::Data &properties);
-
-private Q_SLOTS:
- void syncStatus(QString status);
- void updateMovieFrame();
- void blinkAttention();
- void dataUpdated(const QString &taskName, const Plasma::DataEngine::Data \
&taskData);
-
-private:
- QString m_typeId;
- QString m_name;
- QString m_title;
- QIcon m_icon;
- QString m_iconName;
- QIcon m_attentionIcon;
- QString m_attentionIconName;
- QMovie *m_movie;
- QTimer *m_blinkTimer;
- Plasma::Service *m_service;
- bool m_blink : 1;
- bool m_valid : 1;
- bool m_embeddable : 1;
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.cpp \
b/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.cpp deleted \
file mode 100644 index e9dcb71..0000000
--- a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/***************************************************************************
- * *
- * Copyright (C) 2009 Aaron Seigo <aseigo@kde.org> *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "dbussystemtraywidget.h"
-
-#include <QApplication>
-#include <QDBusAbstractInterface>
-#include <QDesktopWidget>
-#include <QGraphicsSceneWheelEvent>
-#include <QMenu>
-
-#include <KAction>
-
-#include <Plasma/Containment>
-#include <Plasma/Corona>
-#include <Plasma/ServiceJob>
-#include <Plasma/Theme>
-
-namespace SystemTray
-{
-
-DBusSystemTrayWidget::DBusSystemTrayWidget(Plasma::Applet *parent, Plasma::Service \
*service)
- : Plasma::IconWidget(parent),
- m_service(service),
- m_host(parent),
- m_waitingOnContextMenu(false)
-{
- KAction *action = new KAction(this);
- setAction(action);
- connect(action, SIGNAL(triggered()), this, SLOT(calculateShowPosition()));
-}
-
-void DBusSystemTrayWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Plasma::IconWidget::mousePressEvent(event);
-
- if (event->button() == Qt::MidButton) {
- event->accept();
- }
-}
-
-void DBusSystemTrayWidget::setItemIsMenu(bool itemIsMenu)
-{
- m_itemIsMenu = itemIsMenu;
-}
-
-bool DBusSystemTrayWidget::itemIsMenu() const
-{
- return m_itemIsMenu;
-}
-
-void DBusSystemTrayWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- if (event->button() == Qt::MidButton) {
- KConfigGroup params = m_service->operationDescription("SecondaryActivate");
- params.writeEntry("x", event->screenPos().x());
- params.writeEntry("y", event->screenPos().y());
- m_service->startOperationCall(params);
- } else if (m_itemIsMenu && !m_waitingOnContextMenu) {
- m_waitingOnContextMenu = true;
- KConfigGroup params = m_service->operationDescription("ContextMenu");
- params.writeEntry("x", event->screenPos().x());
- params.writeEntry("y", event->screenPos().y());
- KJob *job = m_service->startOperationCall(params);
- connect(job, SIGNAL(result(KJob*)), this, SLOT(showContextMenu(KJob*)));
- return;
- }
-
- Plasma::IconWidget::mouseReleaseEvent(event);
-}
-
-void DBusSystemTrayWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
-{
- KConfigGroup params = m_service->operationDescription("Scroll");
- params.writeEntry("delta", event->delta());
- params.writeEntry("direction", "Vertical");
- m_service->startOperationCall(params);
-}
-
-void DBusSystemTrayWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
-{
- if (m_waitingOnContextMenu) {
- return;
- }
-
- m_waitingOnContextMenu = true;
- KConfigGroup params = m_service->operationDescription("ContextMenu");
- params.writeEntry("x", event->screenPos().x());
- params.writeEntry("y", event->screenPos().y());
- KJob *job = m_service->startOperationCall(params);
- connect(job, SIGNAL(result(KJob*)), this, SLOT(showContextMenu(KJob*)));
-}
-
-void DBusSystemTrayWidget::showContextMenu(KJob *job)
-{
- m_waitingOnContextMenu = false;
- Plasma::ServiceJob *sjob = qobject_cast<Plasma::ServiceJob *>(job);
- if (!sjob) {
- return;
- }
-
- QMenu *menu = qobject_cast<QMenu *>(sjob->result().value<QObject *>());
- if (menu) {
- if (m_host->containment() && m_host->containment()->corona()) {
- menu->adjustSize();
- QPoint p = m_host->containment()->corona()->popupPosition(this, \
menu->size());
- //kDebug() << "execing at: " << p << menu->size();
- menu->exec(p);
- } else {
- // Compute a reasonable position for the menu if we don't have a corona.
- QPoint pos(sjob->parameters()["x"].toInt(), \
sjob->parameters()["y"].toInt());
- QRect availableRect = QApplication::desktop()->availableGeometry(pos);
- QRect menuRect = QRect(pos, menu->sizeHint());
- if (menuRect.left() < availableRect.left()) {
- menuRect.moveLeft(availableRect.left());
- } else if (menuRect.right() > availableRect.right()) {
- menuRect.moveRight(availableRect.right());
- }
- if (menuRect.top() < availableRect.top()) {
- menuRect.moveTop(availableRect.top());
- } else if (menuRect.bottom() > availableRect.bottom()) {
- menuRect.moveBottom(availableRect.bottom());
- }
- //kDebug() << "non-corona execing at: " << menuRect.topLeft();
- menu->exec(menuRect.topLeft());
- }
- }
-}
-
-void DBusSystemTrayWidget::calculateShowPosition()
-{
- Plasma::Corona *corona = m_host->containment()->corona();
- QSize s(1, 1);
- QPoint pos = corona->popupPosition(this, s);
- KConfigGroup params = m_service->operationDescription("Activate");
- params.writeEntry("x", pos.x());
- params.writeEntry("y", pos.y());
- m_service->startOperationCall(params);
-}
-
-void DBusSystemTrayWidget::setIcon(const QString &iconName, const QIcon &icon)
-{
- if (!iconName.isEmpty()) {
- QString name = QString("icons/") + iconName.split("-").first();
- if (Plasma::Theme::defaultTheme()->imagePath(name).isEmpty()) {
- Plasma::IconWidget::setIcon(icon);
- } else {
- setSvg(name, iconName);
- if (svg().isEmpty()) {
- Plasma::IconWidget::setIcon(icon);
- }
- }
- } else {
- Plasma::IconWidget::setIcon(icon);
- }
-}
-
-void DBusSystemTrayWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem \
*option, QWidget *widget)
-{
- Plasma::IconWidget::paint(painter, option, widget);
- if (!svg().isEmpty()) {
- int size = 0;
- if (iconSize().width() <= KIconLoader::SizeSmallMedium) {
- size = KIconLoader::SizeSmall/2;
- } else if (iconSize().width() <= KIconLoader::SizeMedium) {
- size = KIconLoader::SizeSmall/2;
- } else {
- size = KIconLoader::SizeSmall;
- }
- m_overlayIcon.paint(painter, QRect(option->rect.bottomRight() - QPoint(size, \
size), QSize(size, size)));
- }
-}
-
-void DBusSystemTrayWidget::setOverlayIcon(const QIcon &icon)
-{
- m_overlayIcon = icon;
-}
-
-QIcon DBusSystemTrayWidget::overlayIcon() const
-{
- return m_overlayIcon;
-}
-
-}
-
diff --git a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.h \
b/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.h deleted file \
mode 100644 index 0c6daf0..0000000
--- a/applets/mobilesystray/protocols/dbussystemtray/dbussystemtraywidget.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/***************************************************************************
- * *
- * Copyright (C) 2009 Aaron Seigo <aseigo@kde.org> *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef DBUSSYSTEMTRAYWIDGET_H
-#define DBUSSYSTEMTRAYWIDGET_H
-
-#include <Plasma/IconWidget>
-
-class KJob;
-
-namespace Plasma
-{
- class Applet;
-}
-
-namespace SystemTray
-{
-
-class DBusSystemTrayWidget : public Plasma::IconWidget
-{
- Q_OBJECT
-
-public:
- DBusSystemTrayWidget(Plasma::Applet *parent, Plasma::Service *service);
- void setIcon(const QString &iconName, const QIcon &icon);
-
- void setItemIsMenu(bool itemIsMenu);
- bool itemIsMenu() const;
-
- void setOverlayIcon(const QIcon &icon);
- QIcon overlayIcon() const;
-
-Q_SIGNALS:
- void clicked(const QPoint &pos);
-
-protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void wheelEvent(QGraphicsSceneWheelEvent *event);
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget \
*widget);
-
-private Q_SLOTS:
- void calculateShowPosition();
- void showContextMenu(KJob *job);
-
-private:
- Plasma::Service *m_service;
- Plasma::Applet *m_host;
- QIcon m_overlayIcon;
- bool m_itemIsMenu;
- bool m_waitingOnContextMenu;
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/protocols/plasmoid/plasmoidtask.cpp \
b/applets/mobilesystray/protocols/plasmoid/plasmoidtask.cpp deleted file mode 100644
index 0ac4a88..0000000
--- a/applets/mobilesystray/protocols/plasmoid/plasmoidtask.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/***************************************************************************
- * plasmoidtask.cpp *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "plasmoidtask.h"
-#include <fixx11h.h>
-
-#include <KIcon>
-#include <KIconLoader>
-
-#include <plasma/applet.h>
-#include <plasma/popupapplet.h>
-#include <plasma/plasma.h>
-
-
-namespace SystemTray
-{
-
-PlasmoidTask::PlasmoidTask(Plasma::Applet* applet, int id, QObject *parent, \
Plasma::Applet *host)
- : Task(parent),
- m_name(applet->pluginName()),
- m_typeId(applet->pluginName()),
- m_host(host),
- m_takenByParent(false)
-{
- setupApplet(applet, id);
-}
-
-PlasmoidTask::~PlasmoidTask()
-{
- emit taskDeleted(m_host, m_typeId);
-}
-
-
-bool PlasmoidTask::isEmbeddable() const
-{
- return m_applet && !m_takenByParent;
-}
-
-bool PlasmoidTask::isValid() const
-{
- return !m_name.isEmpty() && m_applet;
-}
-
-QString PlasmoidTask::name() const
-{
- if (m_applet) {
- return m_applet.data()->name();
- }
-
- return m_name;
-}
-
-
-QString PlasmoidTask::typeId() const
-{
- return m_typeId;
-}
-
-
-QIcon PlasmoidTask::icon() const
-{
- return m_icon;
-}
-
-Plasma::Applet *PlasmoidTask::host() const
-{
- return m_host;
-}
-
-QGraphicsWidget* PlasmoidTask::createWidget(Plasma::Applet *host)
-{
- if (host != m_host || !m_applet) {
- return 0;
- }
-
- Plasma::Applet *applet = m_applet.data();
- m_takenByParent = true;
- applet->setParent(host);
- applet->setParentItem(host);
-
-// The mobile systray is a regular containment, so applets added to it should \
already be init.
-// The following should not be needed.
-// applet->init();
-// applet->updateConstraints(Plasma::StartupCompletedConstraint);
-// applet->flushPendingConstraintsEvents();
-// applet->updateConstraints(Plasma::AllConstraints);
-// applet->flushPendingConstraintsEvents();
-
- // make sure to record it in the configuration so that if we reload from the \
config,
- // this applet is remembered
- KConfigGroup dummy;
- applet->save(dummy);
-
- connect(applet, SIGNAL(newStatus(Plasma::ItemStatus)), this, \
SLOT(newAppletStatus(Plasma::ItemStatus)));
-
- newAppletStatus(applet->status());
-
- connect(applet, SIGNAL(configNeedsSaving()), host, SIGNAL(configNeedsSaving()));
- connect(applet, SIGNAL(releaseVisualFocus()), host, \
SIGNAL(releaseVisualFocus()));
-
- return static_cast<QGraphicsWidget*>(applet);
-}
-
-void PlasmoidTask::forwardConstraintsEvent(Plasma::Constraints constraints)
-{
- Plasma::Applet *applet = m_applet.data();
- if (applet) {
- applet->updateConstraints(constraints);
- applet->flushPendingConstraintsEvents();
- }
-}
-
-void PlasmoidTask::setupApplet(Plasma::Applet *applet, int id)
-{
- m_applet = applet;
-
- //FIXME: System Information should be system services, but battery and \
devicenotifier are both there. we would need multiple categories
- if (applet->category() == "System Information" ||
- applet->category() == "Network") {
- setCategory(Hardware);
- } else if (applet->category() == "Online Services") {
- setCategory(Communications);
- }
-
- m_icon = KIcon(applet->icon());
-
- applet->setFlag(QGraphicsItem::ItemIsMovable, false);
-
- connect(applet, SIGNAL(destroyed(QObject*)), this, \
SLOT(appletDestroyed(QObject*)));
- applet->setBackgroundHints(Plasma::Applet::NoBackground);
-
- applet->setPreferredSize(KIconLoader::SizeSmallMedium+2, \
KIconLoader::SizeSmallMedium+2);
- kDebug() << applet->name() << " Applet loaded";
-}
-
-void PlasmoidTask::appletDestroyed(QObject *)
-{
- deleteLater();
-}
-
-void PlasmoidTask::newAppletStatus(Plasma::ItemStatus status)
-{
- Plasma::Applet *applet = m_applet.data();
- if (!applet) {
- return;
- }
-
- switch (status) {
- case Plasma::PassiveStatus:
- if (Plasma::PopupApplet *popupApplet = qobject_cast<Plasma::PopupApplet \
*>(applet)) {
- popupApplet->hidePopup();
- }
- setStatus(Task::Passive);
- break;
-
- case Plasma::ActiveStatus:
- setStatus(Task::Active);
- break;
-
- case Plasma::NeedsAttentionStatus:
- setStatus(Task::NeedsAttention);
- break;
-
- default:
- case Plasma::UnknownStatus:
- setStatus(Task::UnknownStatus);
- }
-
- emit changed(this);
-}
-
-}
-
-#include "plasmoidtask.moc"
diff --git a/applets/mobilesystray/protocols/plasmoid/plasmoidtask.h \
b/applets/mobilesystray/protocols/plasmoid/plasmoidtask.h deleted file mode 100644
index 6cba767..0000000
--- a/applets/mobilesystray/protocols/plasmoid/plasmoidtask.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/***************************************************************************
- * plasmoidtask.h *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef PLASMOIDTASK_H
-#define PLASMOIDTASK_H
-
-#include "../../core/task.h"
-
-#include <plasma/plasma.h>
-
-namespace SystemTray
-{
-
-
-class PlasmoidTask : public Task
-{
- Q_OBJECT
-
-public:
-// removed as we should not need to add applet by name anymore.
-// PlasmoidTask(const QString &appletName, int id, QObject *parent, \
Plasma::Applet *host);
- PlasmoidTask(Plasma::Applet* applet, int id, QObject *parent, Plasma::Applet \
*host);
- virtual ~PlasmoidTask();
-
- bool isValid() const;
- virtual bool isEmbeddable() const;
- virtual QString name() const;
- virtual QString typeId() const;
- virtual QIcon icon() const;
- void forwardConstraintsEvent(Plasma::Constraints constraints);
- Plasma::Applet *host() const;
-
-protected Q_SLOTS:
- void appletDestroyed(QObject *object);
- void newAppletStatus(Plasma::ItemStatus status);
-
-Q_SIGNALS:
- void taskDeleted(Plasma::Applet *host, const QString &typeId);
-
-protected:
- virtual QGraphicsWidget* createWidget(Plasma::Applet *applet);
-
-private:
- void setupApplet(Plasma::Applet *applet, int id);
-
- QString m_name;
- QString m_typeId;
- QIcon m_icon;
- QWeakPointer<Plasma::Applet> m_applet;
- Plasma::Applet *m_host;
- bool m_takenByParent;
-};
-
-}
-
-#endif
diff --git a/applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.cpp \
b/applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.cpp deleted file mode \
100644 index 8a7074c..0000000
--- a/applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/***************************************************************************
- * plasmoidprotocol.cpp *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "plasmoidtask.h"
-#include "plasmoidtaskprotocol.h"
-
-#include <KDebug>
-
-#include <Plasma/Applet>
-
-namespace SystemTray
-{
-
-PlasmoidProtocol::PlasmoidProtocol(QObject *parent)
- : Protocol(parent)
-{
-}
-
-
-PlasmoidProtocol::~PlasmoidProtocol()
-{
-}
-
-
-void PlasmoidProtocol::init()
-{
-}
-
-void PlasmoidProtocol::forwardConstraintsEvent(Plasma::Constraints constraints, \
Plasma::Applet *host)
-{
- if (m_tasks.contains(host)) {
- QHash<QString, PlasmoidTask*> tasksForHost = m_tasks.value(host);
- foreach (PlasmoidTask *task, tasksForHost) {
- task->forwardConstraintsEvent(constraints);
- }
- }
-}
-
-void PlasmoidProtocol::addApplet(Plasma::Applet* applet, const int id, \
Plasma::Applet *parent)
-{
- PlasmoidTask *task = new PlasmoidTask(applet, id, this, parent);
- setupTask(task, applet->pluginName(), parent);
-}
-
-void PlasmoidProtocol::setupTask(PlasmoidTask *task, const QString appletName, \
Plasma::Applet *parent) {
- if (!task->isValid()) {
- // we failed to load our applet *sob*
- delete task;
- return;
- }
-
-
- m_tasks[parent].insert(appletName, task);
-
- connect(task, SIGNAL(taskDeleted(Plasma::Applet *, const QString &)), this, \
SLOT(cleanupTask(Plasma::Applet *, const QString &)));
- emit taskCreated(task);
-}
-
-void PlasmoidProtocol::removeApplet(const QString appletName, Plasma::Applet \
*parent)
-{
- if (!m_tasks.contains(parent) || !m_tasks.value(parent).contains(appletName)) {
- return;
- }
-
- Plasma::Applet *applet = qobject_cast<Plasma::Applet \
*>(m_tasks.value(parent).value(appletName)->widget(parent, true));
-
- if (applet) {
- applet->destroy();
- }
-}
-
-void PlasmoidProtocol::cleanupTask(Plasma::Applet *host, const QString &typeId)
-{
- kDebug() << "task with typeId" << typeId << "removed";
- if (m_tasks.contains(host)) {
- m_tasks[host].remove(typeId);
- if (m_tasks.value(host).isEmpty()) {
- m_tasks.remove(host);
- }
- }
-}
-
-QStringList PlasmoidProtocol::applets(Plasma::Applet *host) const
-{
- QStringList list;
- if (!m_tasks.contains(host)) {
- return list;
- }
-
- QHashIterator<QString, PlasmoidTask *> i(m_tasks.value(host));
-
- while (i.hasNext()) {
- i.next();
- list << i.key();
- }
-
- return list;
-}
-
-}
-
-#include "plasmoidtaskprotocol.moc"
diff --git a/applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.h \
b/applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.h deleted file mode \
100644 index 37ccc65..0000000
--- a/applets/mobilesystray/protocols/plasmoid/plasmoidtaskprotocol.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/***************************************************************************
- * plasmoidprotocol.h *
- * *
- * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
- * Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
- * Copyright (C) 2009 Marco Martin <notmart@gmail.com> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef PLASMOIDTASKPROTOCOL_H
-#define PLASMOIDTASKPROTOCOL_H
-
-#include "../../core/protocol.h"
-
-#include <KConfigGroup>
-
-#include <QHash>
-#include <QStringList>
-
-namespace SystemTray
-{
-
-class PlasmoidTask;
-
-class PlasmoidProtocol : public Protocol
-{
- Q_OBJECT
-
-public:
- PlasmoidProtocol(QObject * parent);
- ~PlasmoidProtocol();
-
- void init();
-
- void forwardConstraintsEvent(Plasma::Constraints constraints, Plasma::Applet \
*host);
-// removed as loading applets from config is the containment's job now
-// void loadFromConfig(Plasma::Applet *parent);
-// removed as we should not need to add applet by name anymore.
-// void addApplet(const QString appletName, const int id, Plasma::Applet \
*parent);
- void addApplet(Plasma::Applet* applet, const int id, Plasma::Applet *parent);
- void removeApplet(const QString appletName, Plasma::Applet *parent);
- QStringList applets(Plasma::Applet *parent) const;
-
-private slots:
- void cleanupTask(Plasma::Applet *host, const QString &typeId);
-
-private:
- void setupTask(PlasmoidTask* task, const QString appletName, Plasma::Applet \
*parent);
- QHash<Plasma::Applet *, QHash<QString, PlasmoidTask*> > m_tasks;
-};
-
-}
-
-
-#endif
diff --git a/applets/mobilesystray/ui/applet.cpp \
b/applets/mobilesystray/ui/applet.cpp deleted file mode 100644
index 4da1df6..0000000
--- a/applets/mobilesystray/ui/applet.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/***************************************************************************
- * applet.cpp *
- * *
- * Copyright (C) 2010 Lim Yuen Hoe <yuenhoe@hotmail.com> *
- * Copyright (C) 2011 Marco Martin <mart@kde.org> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#include "applet.h"
-
-#include <QDeclarativeItem>
-#include <QGraphicsLinearLayout>
-#include <QGraphicsSceneResizeEvent>
-#include <QTimer>
-
-#include <KIcon>
-#include <KIconLoader>
-#include <KStandardDirs>
-#include <KWindowSystem>
-
-#include <Plasma/Containment>
-#include <Plasma/Corona>
-#include <Plasma/DeclarativeWidget>
-#include <Plasma/Dialog>
-#include <Plasma/FrameSvg>
-
-
-namespace SystemTray
-{
-
-MobileTray::MobileTray(QObject *parent, const QVariantList &args)
- : Plasma::Containment(parent, args),
- m_appSwitcherDialog(0),
- initDone(false)
-{
- m_background = new Plasma::FrameSvg(this);
- m_background->setImagePath("widgets/translucentbackground");
- m_background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
-
- // list of applets to "always show"
- m_fixedList << "notifications" << "org.kde.fakebattery" << "org.kde.fakesignal" \
<< "digital-clock";
-
- m_declarativeWidget = new Plasma::DeclarativeWidget(this);
- m_declarativeWidget->setQmlPath(KStandardDirs::locate("data", \
"plasma-mobile/containments/mobilesystray/main.qml"));
-
- connect(this, SIGNAL(appletAdded(Plasma::Applet*,const QPointF&)),
- this, SLOT(addTrayApplet(Plasma::Applet*)));
-
- // use a timer to avoid repeated resizing
- m_resizeTimer = new QTimer(this);
- m_resizeTimer->setSingleShot(true);
- connect(m_resizeTimer, SIGNAL(timeout()), this, SLOT(resizeContents()));
-}
-
-
-MobileTray::~MobileTray()
-{
- if (m_appSwitcherDialog && m_appSwitcherDialog->graphicsWidget()) {
- delete m_appSwitcherDialog->graphicsWidget();
- }
-}
-
-void MobileTray::init()
-{
- if (formFactor() != Plasma::Horizontal && formFactor() != Plasma::Vertical) {
- setFormFactor(Plasma::Horizontal);
- }
-
- QDeclarativeItem *mainItem = \
qobject_cast<QDeclarativeItem*>(m_declarativeWidget->rootObject());
-
- if (mainItem) {
- connect(mainItem, SIGNAL(shrinkRequested()), this, \
SIGNAL(shrinkRequested()));
- }
-
- initDone = true;
-}
-
-void MobileTray::constraintsEvent(Plasma::Constraints constraints)
-{
- if (constraints & Plasma::LocationConstraint) {
- Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders;
-
- switch (location()) {
- case Plasma::LeftEdge:
- borders ^= Plasma::FrameSvg::LeftBorder;
- break;
- case Plasma::RightEdge:
- borders ^= Plasma::FrameSvg::RightBorder;
- break;
- case Plasma::TopEdge:
- borders ^= Plasma::FrameSvg::TopBorder;
- break;
- case Plasma::BottomEdge:
- borders ^= Plasma::FrameSvg::BottomBorder;
- break;
- default:
- break;
- }
-
- m_background->setEnabledBorders(borders);
- qreal left, top, right, bottom;
- m_background->getMargins(left, top, right, bottom);
- setContentsMargins(left, top, right, bottom);
- m_declarativeWidget->setGeometry(contentsRect());
- }
-}
-
-void MobileTray::resizeContents()
-{
- m_declarativeWidget->setGeometry(contentsRect());
- m_declarativeWidget->show();
-}
-
-void MobileTray::resizeEvent(QGraphicsSceneResizeEvent* event)
-{
-#define IMMEDIATE_RESIZE 1
-#if IMMEDIATE_RESIZE
- m_declarativeWidget->setGeometry(contentsRect());
-#else
- // resizing the contents seems slow, asynchronous, and thus jerky and \
potentially problematic,
- // so we avoid resizing them continuously..
- m_resizeTimer->start(500);
- m_declarativeWidget->hide();
-#endif
-
- m_background->resizeFrame(event->newSize());
-}
-
-// create plasmoidtasks out of applets added to the containment
-void MobileTray::addTrayApplet(Plasma::Applet* applet)
-{
- //treat the appswitcher in a different way: it's wise?
- if (!m_appSwitcherDialog && applet->pluginName() == "org.kde.appswitcher") {
- applet->setParentItem(0);
- corona()->addOffscreenWidget(applet);
- m_appSwitcherDialog = new Plasma::Dialog();
- m_appSwitcherDialog->setGraphicsWidget(applet);
- KWindowSystem::setType(m_appSwitcherDialog->winId(), NET::Dock);
- m_appSwitcherDialog->show();
- applet->setMaximumSize(KIconLoader::SizeLarge, KIconLoader::SizeMedium);
- } else {
- QDeclarativeItem *mainItem = \
qobject_cast<QDeclarativeItem*>(m_declarativeWidget->rootObject());
-
- if (mainItem) {
- QDeclarativeItem *tasksList = \
mainItem->findChild<QDeclarativeItem*>("tasksList");
- if (tasksList) {
- QDeclarativeListReference childrenRef(tasksList, "children");
- childrenRef.append(applet);
- }
- }
- }
-}
-
-void MobileTray::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- m_background->paintFrame(painter);
-}
-
-// This is the command that links your applet to the .desktop file
-K_EXPORT_PLASMA_APPLET(mobilesystemtray, MobileTray)
-
-}
-
-#include "applet.moc"
\ No newline at end of file
diff --git a/applets/mobilesystray/ui/applet.h b/applets/mobilesystray/ui/applet.h
deleted file mode 100644
index bfa1d7a..0000000
--- a/applets/mobilesystray/ui/applet.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/***************************************************************************
- * applet.h *
- * *
- * Copyright (C) 2010 Lim Yuen Hoe <yuenhoe@hotmail.com> *
- * Copyright (C) 2011 Marco Martin <mart@kde.org> *
- * *
- * 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
-
-#ifndef APPLET_H
-#define APPLET_H
-
-#include <Plasma/Containment>
-
-namespace Plasma
-{
-class DeclarativeWidget;
-class FrameSvg;
-class Dialog;
-}
-
-class QTimer;
-
-namespace SystemTray
-{
-
-class Manager;
-class Task;
-
-
-/**
- * Main applet of the mobile version of the system tray.
- *
- * It has two modes - "active" and "passive", and switches between them depending on \
the
- * width of the applet. "Active" mode is meant to be interactive and all icons are \
visible
- * together with an additional cancel icon that hints to the parent to shrink it \
back to "passive"
- * mode using the "shrinkRequested()" signal. "Passive" mode is meant to be \
non-interactive and
- * some icons are hidden.
- *
- * The tray differentiates between two kinds of icons - fixed and cyclic. Fixed \
icons are always
- * shown irregardless of mode, while cyclic icons can be hidden in "passive" mode.
- */
-class MobileTray : public Plasma::Containment
-{
- Q_OBJECT
-public:
- // Basic Create/Destroy
- MobileTray(QObject *parent, const QVariantList &args);
- ~MobileTray();
-
- void init();
-
- void constraintsEvent(Plasma::Constraints constraints);
-
-signals:
- void shrinkRequested(); // signal to parent to shrink the tray to "passive" mode
-
-protected:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget = 0);
- void resizeEvent (QGraphicsSceneResizeEvent * event);
-
-protected slots:
- void resizeContents();
- void addTrayApplet(Plasma::Applet* ap);
-
-private:
- Plasma::FrameSvg *m_background;
- QList<QString> m_fixedList; // List of icon names that should be \
"fixed"
-
- Plasma::DeclarativeWidget *m_declarativeWidget;
- QTimer *m_resizeTimer;
- Plasma::Dialog *m_appSwitcherDialog;
- bool initDone;
-};
-
-}
-#endif
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic