Applets
fdotask.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 * fdotask.cpp * 00003 * * 00004 * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> * 00005 * * 00006 * This program is free software; you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation; either version 2 of the License, or * 00009 * (at your option) any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 00020 ***************************************************************************/ 00021 00022 #include "fdographicswidget.h" 00023 #include "fdotask.h" 00024 00025 #include <KWindowSystem> 00026 #include <Plasma/Applet> 00027 00028 namespace SystemTray 00029 { 00030 00031 class FdoTask::Private 00032 { 00033 public: 00034 Private(WId winId) 00035 : winId(winId) 00036 { 00037 KWindowInfo info = KWindowSystem::windowInfo(winId, NET::WMName, NET::WM2WindowClass); 00038 00039 // FIXME: This isn't unique 00040 typeId = info.windowClassName(); 00041 00042 name = info.name(); 00043 if (name.isEmpty()) { 00044 name = typeId; 00045 } 00046 00047 icon = KWindowSystem::icon(winId); 00048 } 00049 00050 WId winId; 00051 QString name; 00052 QString typeId; 00053 QIcon icon; 00054 }; 00055 00056 00057 FdoTask::FdoTask(WId winId) 00058 : d(new Private(winId)) 00059 { 00060 } 00061 00062 00063 FdoTask::~FdoTask() 00064 { 00065 emit taskDeleted(d->winId); 00066 delete d; 00067 } 00068 00069 00070 bool FdoTask::isEmbeddable() const 00071 { 00072 return associatedWidgets().count() == 0; 00073 } 00074 00075 00076 QString FdoTask::name() const 00077 { 00078 return d->name; 00079 } 00080 00081 00082 QString FdoTask::typeId() const 00083 { 00084 return d->typeId; 00085 } 00086 00087 00088 QIcon FdoTask::icon() const 00089 { 00090 return d->icon; 00091 } 00092 00093 00094 QGraphicsWidget* FdoTask::createWidget(Plasma::Applet *applet) 00095 { 00096 QGraphicsWidget *widget = new FdoGraphicsWidget(d->winId, applet); 00097 connect(widget, SIGNAL(clientClosed()), this, SLOT(deleteLater())); 00098 return widget; 00099 } 00100 00101 00102 } 00103 00104 #include "fdotask.moc"