• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • workspace API Reference
  • KDE Home
  • Contact Us
 

liblancelot

  • sources
  • kde-4.14
  • workspace
  • kdeplasma-addons
  • libs
  • lancelot
  • widgets
HoverIcon.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007, 2008, 2009, 2010 Ivan Cukic <ivan.cukic(at)kde.org>
3  *
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
7  * Software Foundation
8  *
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
13  *
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.
18  */
19 
20 #include "HoverIcon.h"
21 
22 #include <QBasicTimer>
23 
24 #define ACTIVATION_TIME 300
25 
26 namespace Lancelot
27 {
28 
29 class HoverIcon::Private {
30 public:
31  Private(HoverIcon * parent)
32  : q(parent),
33  activationMethod(ClickActivate)
34  {
35  }
36 
37  void startTimer()
38  {
39  timer.start(ACTIVATION_TIME, q);
40  }
41 
42  void stopTimer()
43  {
44  timer.stop();
45  }
46 
47 
48  HoverIcon * q;
49  int activationMethod;
50  static QBasicTimer timer;
51 };
52 
53 QBasicTimer HoverIcon::Private::timer = QBasicTimer();
54 
55 HoverIcon::HoverIcon(QGraphicsItem * parent)
56  : Plasma::IconWidget(parent),
57  d(new Private(this))
58 {
59 
60 }
61 
62 HoverIcon::HoverIcon(const QString & text, QGraphicsItem * parent)
63  : Plasma::IconWidget(text, parent),
64  d(new Private(this))
65 {
66 
67 }
68 
69 HoverIcon::HoverIcon(const QIcon & icon, const QString & text, QGraphicsItem * parent)
70  : Plasma::IconWidget(icon, text, parent),
71  d(new Private(this))
72 {
73 
74 }
75 
76 HoverIcon::~HoverIcon()
77 {
78  delete d;
79 }
80 
81 void HoverIcon::timerEvent(QTimerEvent * event)
82 {
83  if (event->timerId() == d->timer.timerId()) {
84  d->stopTimer();
85  if (d->activationMethod == HoverActivate) {
86  emit activated();
87  }
88  }
89  Plasma::IconWidget::timerEvent(event);
90 }
91 
92 void HoverIcon::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
93 {
94  if (d->activationMethod == HoverActivate) {
95  d->startTimer();
96  }
97  Plasma::IconWidget::hoverEnterEvent(event);
98 }
99 
100 void HoverIcon::hoverLeaveEvent(QGraphicsSceneHoverEvent * event)
101 {
102  d->stopTimer();
103  Plasma::IconWidget::hoverLeaveEvent(event);
104 }
105 
106 void HoverIcon::setActivationMethod(int method)
107 {
108  if (method == ExtenderActivate) {
109  method = ClickActivate;
110  }
111  if (d->activationMethod == method)
112  return;
113  d->activationMethod = method;
114 }
115 
116 int HoverIcon::activationMethod() const
117 {
118  return d->activationMethod;
119 }
120 
121 } // namespace Lancelot
122 
123 #include "HoverIcon.moc"
124 
Lancelot::ExtenderActivate
Definition: lancelot.h:42
QBasicTimer
Lancelot::HoverIcon::HoverIcon
HoverIcon(QGraphicsItem *parent=0)
Creates a new Lancelot::HoverIcon.
Definition: HoverIcon.cpp:55
QGraphicsItem
Lancelot::HoverIcon::hoverLeaveEvent
L_Override void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition: HoverIcon.cpp:100
HoverIcon.h
QTimerEvent
Lancelot::HoverIcon::hoverEnterEvent
L_Override void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Definition: HoverIcon.cpp:92
Lancelot::HoverIcon::activationMethod
int activationMethod() const
Lancelot::HoverIcon::timerEvent
L_Override void timerEvent(QTimerEvent *event)
Definition: HoverIcon.cpp:81
Lancelot::HoverIcon::~HoverIcon
~HoverIcon()
Destroys this Lancelot::HoverIcon.
Definition: HoverIcon.cpp:76
ACTIVATION_TIME
#define ACTIVATION_TIME
Definition: HoverIcon.cpp:24
QString
QGraphicsSceneHoverEvent
Lancelot::HoverIcon::setActivationMethod
void setActivationMethod(int method)
Sets the activation method of the ExtenderButton.
Definition: HoverIcon.cpp:106
QTimerEvent::timerId
int timerId() const
Lancelot::HoverActivate
Definition: lancelot.h:40
QIcon
Lancelot::ClickActivate
Definition: lancelot.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:43:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

liblancelot

Skip menu "liblancelot"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

workspace API Reference

Skip menu "workspace API Reference"
  • kdeplasma-addons
  •       GroupingDesktop
  •     liblancelot

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal