1
/***************************************************************************
2
* Copyright (C) 2010 by Anton Kreuzkamp <akreuzkamp@web.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
21
#include "applauncheritem.h"
22
#include "taskgroupitem.h"
24
#include <taskmanager/taskactions.h>
27
#include <QGraphicsSceneContextMenuEvent>
28
#include <QGraphicsView>
31
#include <KAuthorized>
32
#include <KIconEffect>
34
#include <Plasma/ToolTipManager>
35
#include <Plasma/Corona>
36
#include <Plasma/Containment>
37
#include <Plasma/PaintUtils>
39
AppLauncherItem::AppLauncherItem( QGraphicsWidget* parent, Tasks* applet, TaskManager::LauncherItem* launcher)
40
: AbstractTaskItem(parent, applet)
42
m_launcher = launcher;
43
m_abstractItem = launcher;
46
void AppLauncherItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
48
if (event->button() == Qt::LeftButton && boundingRect().contains(event->pos())) {
53
void AppLauncherItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e)
55
if (!KAuthorized::authorizeKAction("kwin_rmb") || !m_launcher) {
56
QGraphicsWidget::contextMenuEvent(e);
60
QList <QAction*> actionList;
62
QAction *configAction = m_applet->action("configure");
63
if (configAction && configAction->isEnabled()) {
64
actionList.append(configAction);
67
TaskManager::BasicMenu menu(0, m_launcher, &m_applet->groupManager(), actionList);
70
if (m_applet->formFactor() != Plasma::Vertical) {
71
menu.setMinimumWidth(size().width());
74
Q_ASSERT(m_applet->containment());
75
Q_ASSERT(m_applet->containment()->corona());
76
stopWindowHoverEffect();
77
menu.exec(m_applet->containment()->corona()->popupPosition(this, menu.size()));
81
void AppLauncherItem::updateToolTip()
83
Plasma::ToolTipContent data(m_launcher->name(),m_launcher->genericName(),m_launcher->icon());
84
data.setInstantPopup(true);
85
Plasma::ToolTipManager::self()->setContent(this, data);
88
void AppLauncherItem::keyPressEvent(QKeyEvent *event)
90
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
96
QGraphicsWidget::keyPressEvent(event);
100
void AppLauncherItem::setAdditionalMimeData(QMimeData* mimeData)
103
m_launcher->addMimeData(mimeData);
107
#include "applauncheritem.moc"