2
* Copyright (C) 2007 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser/Library General Public License version 2,
6
* or (at your option) any later version, as published by the Free
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 Lesser/Library General Public License for more details
14
* You should have received a copy of the GNU Lesser/Library General Public
15
* License 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.
20
#include "HoverIcon.h"
22
#include <QBasicTimer>
24
#define ACTIVATION_TIME 300
29
class HoverIcon::Private {
31
Private(HoverIcon * parent)
33
activationMethod(ClickActivate)
39
timer.start(ACTIVATION_TIME, q);
50
static QBasicTimer timer;
53
QBasicTimer HoverIcon::Private::timer = QBasicTimer();
55
HoverIcon::HoverIcon(QGraphicsItem * parent)
56
: Plasma::IconWidget(parent),
62
HoverIcon::HoverIcon(const QString & text, QGraphicsItem * parent)
63
: Plasma::IconWidget(text, parent),
69
HoverIcon::HoverIcon(const QIcon & icon, const QString & text, QGraphicsItem * parent)
70
: Plasma::IconWidget(icon, text, parent),
76
HoverIcon::~HoverIcon()
81
void HoverIcon::timerEvent(QTimerEvent * event)
83
if (event->timerId() == d->timer.timerId()) {
85
if (d->activationMethod == HoverActivate) {
89
Plasma::IconWidget::timerEvent(event);
92
void HoverIcon::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
94
if (d->activationMethod == HoverActivate) {
97
Plasma::IconWidget::hoverEnterEvent(event);
100
void HoverIcon::hoverLeaveEvent(QGraphicsSceneHoverEvent * event)
103
Plasma::IconWidget::hoverLeaveEvent(event);
106
void HoverIcon::setActivationMethod(int method)
108
if (method == ExtenderActivate) {
109
method = ClickActivate;
111
if (d->activationMethod == method)
113
d->activationMethod = method;
116
int HoverIcon::activationMethod() const
118
return d->activationMethod;
121
} // namespace Lancelot
123
#include "HoverIcon.moc"