not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / quicklaunch / quicklaunchIcon.cpp
blobefcac6ba43f9726166d20f8acb19625a25c54466
1 /***************************************************************************
2 * Copyright (C) 2008 by Lukas Appelhans *
3 * l.appelhans@gmx.de *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20 #include "quicklaunchIcon.h"
22 #include <QGraphicsSceneContextMenuEvent>
23 #include <QGraphicsSceneDragDropEvent>
25 #include <KMenu>
26 #include <KRun>
28 #include "quicklaunchApplet.h"
30 QuicklaunchIcon::QuicklaunchIcon(const KUrl & appUrl, const KIcon & icon, QuicklaunchApplet *parent)
31 : Plasma::IconWidget(icon, QString(), parent),
32 m_launcher(parent),
33 m_appUrl(appUrl),
34 m_removeAction(0)
36 setAcceptDrops(true);
37 connect(this, SIGNAL(clicked()), SLOT(execute()));
40 QuicklaunchIcon::~QuicklaunchIcon()
44 KUrl QuicklaunchIcon::url() const
46 return m_appUrl;
49 void QuicklaunchIcon::execute()
51 new KRun(m_appUrl, 0);
54 void QuicklaunchIcon::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
56 KMenu m;
57 m.addAction(m_launcher->action("configure"));
58 m.addSeparator();
59 m.addActions(m_launcher->contextActions(this));
60 m.addSeparator();
61 m.addAction(m_launcher->action("remove"));
62 m.exec(event->screenPos());
65 /*bool QuicklaunchIcon::eventFilter(QObject * object, QEvent * event)
67 if (event->type() != QEvent::GraphicsSceneMouseMove) {
68 return Plasma::IconWidget::eventFilter(object, event);
71 QDrag * drag = new QDrag(static_cast<QGraphicsSceneMouseEvent*>(event)->widget());
72 QMimeData * data = new QMimeData;
73 KUrl::List urls;
74 urls << m_appUrl;
75 urls.populateMimeData(data);
76 drag->setMimeData(data);
77 drag->exec();
78 event->accept();
79 return true;
80 }*/