• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeplasma-addons API Reference
  • KDE Home
  • Contact Us
 

GroupingDesktop

  • sources
  • kde-4.14
  • kdeplasma-addons
  • containments
  • groupingdesktop
  • lib
freehandle.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2007 by Kevin Ottens <ervin@kde.org>
3  * Copyright 2009-2010 by Giulio Camuffo <giuliocamuffo@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Library General Public License as
7  * published by the Free Software Foundation; either version 2, 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 Library General Public
16  * License 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 
21 #include "freehandle.h"
22 
23 #include <QApplication>
24 #include <QtGui/QGraphicsSceneMouseEvent>
25 #include <QtGui/QLinearGradient>
26 #include <QtGui/QPainter>
27 #include <QtGui/QApplication>
28 #include <QtGui/QMenu>
29 #include <QTouchEvent>
30 #include <QMatrix>
31 #include <QTransform>
32 #include <QPropertyAnimation>
33 
34 #include <kcolorscheme.h>
35 #include <kglobalsettings.h>
36 #include <kicon.h>
37 #include <kiconloader.h>
38 #include <kwindowsystem.h>
39 
40 #include <cmath>
41 #include <math.h>
42 
43 #include <Plasma/Corona>
44 #include <Plasma/PaintUtils>
45 #include <Plasma/Theme>
46 #include <Plasma/View>
47 #include <Plasma/FrameSvg>
48 
49 #include "abstractgroup.h"
50 #include "groupingcontainment.h"
51 
52 using namespace Plasma;
53 qreal _k_distanceForPoint(const QPointF& point);
54 qreal _k_pointAngle(const QPointF& point);
55 QPointF _k_rotatePoint(const QPointF& point, qreal angle);
56 QPointF _k_projectPoint(QPointF point, QPointF v);
57 
58 FreeHandle::FreeHandle(GroupingContainment *parent, Plasma::Applet *applet)
59  : Handle(parent, applet),
60  m_pressedButton(NoButton),
61  m_iconSize(KIconLoader::SizeSmall),
62  m_opacity(0.0),
63  m_animType(FadeIn),
64  m_backgroundBuffer(0),
65  m_buttonsOnRight(false),
66  m_pendingFade(false)
67 {
68  init();
69 }
70 
71 FreeHandle::FreeHandle(GroupingContainment *parent, AbstractGroup *group)
72  : Handle(parent, group),
73  m_pressedButton(NoButton),
74  m_iconSize(KIconLoader::SizeSmall),
75  m_opacity(0.0),
76  m_animType(FadeIn),
77  m_backgroundBuffer(0),
78  m_buttonsOnRight(false),
79  m_pendingFade(false)
80 {
81  init();
82 }
83 
84 FreeHandle::~FreeHandle()
85 {
86  detachWidget();
87  delete m_backgroundBuffer;
88 }
89 
90 void FreeHandle::init()
91 {
92  setFlags(flags() | QGraphicsItem::ItemStacksBehindParent);
93  KColorScheme colorScheme(QPalette::Active, KColorScheme::View,
94  Theme::defaultTheme()->colorScheme());
95  setAcceptTouchEvents(true);
96  m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
97  m_originalGeom = mapToScene(QRectF(QPoint(0,0), widget()->size())).boundingRect();
98  m_originalTransform = widget()->transform();
99 
100  QPointF center = QRectF(QPointF(), widget()->size()).center();
101  m_angle = _k_pointAngle(m_originalTransform.map(center + QPointF(1.0, 0.0)) - center);
102 
103  m_hoverTimer = new QTimer(this);
104  m_hoverTimer->setSingleShot(true);
105  m_hoverTimer->setInterval(333);
106 
107  m_leaveTimer = new QTimer(this);
108  m_leaveTimer->setSingleShot(true);
109  m_leaveTimer->setInterval(500);
110 
111  connect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(hoverTimeout()));
112  connect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
113  connect(widget(), SIGNAL(destroyed(QObject*)), this, SLOT(widgetDestroyed()));
114 
115  setAcceptsHoverEvents(true);
116  m_hoverTimer->start();
117 
118  //icons
119  m_configureIcons = new Svg(this);
120  m_configureIcons->setImagePath("widgets/configuration-icons");
121  m_configureIcons->setContainsMultipleImages(true);
122 
123  m_background = new FrameSvg(this);
124  m_background->setImagePath("widgets/background");
125  widget()->installSceneEventFilter(this);
126 
127  calculateSize();
128 }
129 
130 // void FreeHandle::detachWidget()
131 // {
132 // if (!widget()) {
133 // return;
134 // }
135 //
136 // disconnect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(hoverTimeout()));
137 // disconnect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
138 // widget()->disconnect(this);
139 //
140 // if (applet() && (applet()->geometry() != m_originalGeom || applet()->transform() != m_originalTransform)) {
141 // // emit applet()->appletTransformedByUser(); //FIXME: protected!
142 // } else if (group() && (group()->geometry() != m_originalGeom || group()->transform() != m_originalTransform)) {
143 // emit group()->groupTransformedByUser();
144 // }
145 //
146 // applet() = 0;
147 // group() = 0;
148 // widget() = 0;
149 // }
150 
151 QRectF FreeHandle::boundingRect() const
152 {
153  return m_totalRect;
154 }
155 
156 QPainterPath FreeHandle::shape() const
157 {
158  //when the containment changes the widget is reset to 0
159  if (widget()) {
160  QPainterPath path = PaintUtils::roundedRectangle(m_decorationRect, 10);
161  return path.united(widget()->shape());
162  } else {
163  return QGraphicsItem::shape();
164  }
165 }
166 
167 QPainterPath FreeHandleRect(const QRectF &rect, int radius, bool onRight)
168 {
169  QPainterPath path;
170  if (onRight) {
171  // make the left side straight
172  path.moveTo(rect.left(), rect.top()); // Top left
173  path.lineTo(rect.right() - radius, rect.top()); // Top side
174  path.quadTo(rect.right(), rect.top(),
175  rect.right(), rect.top() + radius); // Top right corner
176  path.lineTo(rect.right(), rect.bottom() - radius); // Right side
177  path.quadTo(rect.right(), rect.bottom(),
178  rect.right() - radius, rect.bottom()); // Bottom right corner
179  path.lineTo(rect.left(), rect.bottom()); // Bottom side
180  } else {
181  // make the right side straight
182  path.moveTo(QPointF(rect.left(), rect.top() + radius));
183  path.quadTo(rect.left(), rect.top(),
184  rect.left() + radius, rect.top()); // Top left corner
185  path.lineTo(rect.right(), rect.top()); // Top side
186  path.lineTo(rect.right(), rect.bottom()); // Right side
187  path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
188  path.quadTo(rect.left(), rect.bottom(),
189  rect.left(), rect.bottom() - radius); // Bottom left corner
190  }
191 
192  path.closeSubpath();
193  return path;
194 }
195 
196 void FreeHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
197 {
198  Q_UNUSED(option);
199  Q_UNUSED(widget);
200 
201  //kDebug() << m_opacity << m_anim << FadeOut;
202  if (qFuzzyCompare(m_opacity + 1.0, 1.0)) {
203  if (m_animType == FadeOut) {
204  //kDebug() << "WOOOOOOOOO";
205  QTimer::singleShot(0, this, SLOT(emitDisappear()));
206  }
207  return;
208  }
209 
210  qreal translation;
211 
212  if (m_buttonsOnRight) {
213  //kDebug() << "translating by" << m_opacity
214  // << (-(1 - m_opacity) * m_rect.width()) << m_rect.width();
215  translation = -(1 - m_opacity) * m_rect.width();
216  } else {
217  translation = (1 - m_opacity) * m_rect.width();
218  }
219 
220  painter->translate(translation, 0);
221 
222  painter->setPen(Qt::NoPen);
223  painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
224 
225  int iconMargin = m_iconSize / 2;
226 
227  const QSize pixmapSize(int(m_decorationRect.width()),
228  int(m_decorationRect.height()) + m_iconSize * 5 + 1);
229  const QSize iconSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
230 
231  bool isRunning = false;
232  if (m_anim.data()) {
233  isRunning = m_anim.data()->state() == QAbstractAnimation::Running ? \
234  true : false;
235  }
236 
237  //regenerate our buffer?
238  if (isRunning || !m_backgroundBuffer || m_backgroundBuffer->size() != pixmapSize) {
239  QColor transparencyColor = Qt::black;
240  transparencyColor.setAlphaF(qMin(m_opacity, qreal(0.99)));
241 
242  QLinearGradient g(QPoint(0, 0), QPoint(m_decorationRect.width(), 0));
243  //fading out panel
244  if (m_rect.height() > qreal(minimumHeight()) * 1.25) {
245  if (m_buttonsOnRight) {
246  qreal opaquePoint =
247  (m_background->marginSize(LeftMargin) - translation) / m_decorationRect.width();
248  //kDebug() << "opaquePoint" << opaquePoint
249  // << m_background->marginSize(LeftMargin) << m_decorationRect.width();
250  g.setColorAt(0.0, Qt::transparent);
251  g.setColorAt(qMax(qreal(0.0), opaquePoint - qreal(0.05)), Qt::transparent);
252  g.setColorAt(opaquePoint, transparencyColor);
253  g.setColorAt(1.0, transparencyColor);
254  } else {
255  qreal opaquePoint =
256  1 - ((m_background->marginSize(RightMargin) + translation) / m_decorationRect.width());
257  g.setColorAt(1.0, Qt::transparent);
258  g.setColorAt(opaquePoint + 0.05, Qt::transparent);
259  g.setColorAt(qMax(qreal(0), opaquePoint), transparencyColor);
260  g.setColorAt(0.0, transparencyColor);
261  }
262  //complete panel
263  } else {
264  g.setColorAt(0.0, transparencyColor);
265  }
266 
267  m_background->resizeFrame(m_decorationRect.size());
268 
269  if (!m_backgroundBuffer || m_backgroundBuffer->size() != pixmapSize) {
270  delete m_backgroundBuffer;
271  m_backgroundBuffer = new QPixmap(pixmapSize);
272  }
273  m_backgroundBuffer->fill(Qt::transparent);
274  QPainter buffPainter(m_backgroundBuffer);
275 
276  m_background->paintFrame(&buffPainter);
277 
278  //+1 because otherwise due to rounding errors when rotated could appear one pixel
279  //of the icon at the border of the widget
280  //QRectF iconRect(QPointF(pixmapSize.width() - m_iconSize + 1, m_iconSize), iconSize);
281  QRectF iconRect(QPointF(0, m_decorationRect.height() + 1), iconSize);
282  if (m_buttonsOnRight) {
283  iconRect.moveLeft(
284  pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
285  } else {
286  iconRect.moveLeft(m_background->marginSize(RightMargin));
287  }
288  AbstractGroup *parentGroup = this->widget()->property("group").value<AbstractGroup *>();
289  if (!(parentGroup && parentGroup->groupType() == AbstractGroup::ConstrainedGroup)) {
290  if (m_buttonsOnRight) {
291  m_configureIcons->paint(&buffPainter, iconRect, "size-diagonal-tr2bl");
292  } else {
293  m_configureIcons->paint(&buffPainter, iconRect, "size-diagonal-tl2br");
294  }
295  iconRect.translate(0, m_iconSize);
296 
297  m_configureIcons->paint(&buffPainter, iconRect, "rotate");
298  iconRect.translate(0, m_iconSize);
299  }
300 
301  if ((applet() && applet()->hasConfigurationInterface()) || (group() && group()->hasConfigurationInterface())) {
302  m_configureIcons->paint(&buffPainter, iconRect, "configure");
303  iconRect.translate(0, m_iconSize);
304  }
305 
306  if (applet() && applet()->hasValidAssociatedApplication()) {
307  m_configureIcons->paint(&buffPainter, iconRect, "maximize");
308  iconRect.translate(0, m_iconSize);
309  }
310 
311  m_configureIcons->paint(&buffPainter, iconRect, "close");
312 
313  buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
314  //blend the background
315  buffPainter.fillRect(m_backgroundBuffer->rect(), g);
316  //blend the icons
317  //buffPainter.fillRect(QRect(QPoint((int)m_decorationRect.width(), 0), QSize(m_iconSize + 1,
318  // (int)m_decorationRect.height())), transparencyColor);
319  }
320 
321  painter->drawPixmap(m_decorationRect.toRect(), *m_backgroundBuffer,
322  QRect(QPoint(0, 0), m_decorationRect.size().toSize()));
323 
324  //XXX this code is duplicated in the next function
325  QPointF basePoint = m_rect.topLeft() + QPointF(HANDLE_MARGIN, iconMargin);
326  QPointF step = QPointF(0, m_iconSize + iconMargin);
327  QPointF separator = step + QPointF(0, iconMargin);
328  //end duplicate code
329 
330  QPointF shiftC;
331  QPointF shiftD;
332  QPointF shiftR;
333  QPointF shiftM;
334  QPointF shiftMx;
335 
336  switch(m_pressedButton)
337  {
338  case ConfigureButton:
339  shiftC = QPointF(2, 2);
340  break;
341  case RemoveButton:
342  shiftD = QPointF(2, 2);
343  break;
344  case RotateButton:
345  shiftR = QPointF(2, 2);
346  break;
347  case ResizeButton:
348  shiftM = QPointF(2, 2);
349  break;
350  case MaximizeButton:
351  shiftMx = QPointF(2, 2);
352  break;
353  default:
354  break;
355  }
356 
357  QRectF sourceIconRect(QPointF(0, m_decorationRect.height() + 1), iconSize);
358  if (m_buttonsOnRight) {
359  sourceIconRect.moveLeft(
360  pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
361  } else {
362  sourceIconRect.moveLeft(m_background->marginSize(RightMargin));
363  }
364 
365  AbstractGroup *parentGroup = this->widget()->property("group").value<AbstractGroup *>();
366  if (!(parentGroup && parentGroup->groupType() == AbstractGroup::ConstrainedGroup)) {
367  if (group() || (applet() && applet()->aspectRatioMode() != FixedSize)) {
368  //resize
369  painter->drawPixmap(
370  QRectF(basePoint + shiftM, iconSize), *m_backgroundBuffer, sourceIconRect);
371  basePoint += step;
372  }
373  sourceIconRect.translate(0, m_iconSize);
374 
375  //rotate
376  painter->drawPixmap(QRectF(basePoint + shiftR, iconSize), *m_backgroundBuffer, sourceIconRect);
377  sourceIconRect.translate(0, m_iconSize);
378  basePoint += step;
379  }
380  //configure
381  if ((applet() && applet()->hasConfigurationInterface()) || (group() && group()->hasConfigurationInterface())) {
382  painter->drawPixmap(
383  QRectF(basePoint + shiftC, iconSize), *m_backgroundBuffer, sourceIconRect);
384  sourceIconRect.translate(0, m_iconSize);
385  basePoint += step;
386  }
387 
388  //maximize
389  if (applet() && applet()->hasValidAssociatedApplication()) {
390  painter->drawPixmap(
391  QRectF(basePoint + shiftMx, iconSize), *m_backgroundBuffer, sourceIconRect);
392  sourceIconRect.translate(0, m_iconSize);
393  basePoint += step;
394  }
395 
396  //close
397  basePoint = m_rect.bottomLeft() + QPointF(HANDLE_MARGIN, 0) - step;
398  painter->drawPixmap(QRectF(basePoint + shiftD, iconSize), *m_backgroundBuffer, sourceIconRect);
399 }
400 
401 void FreeHandle::emitDisappear()
402 {
403  emit disappearDone(this);
404 }
405 
406 Handle::ButtonType FreeHandle::mapToButton(const QPointF &point) const
407 {
408  int iconMargin = m_iconSize / 2;
409  //XXX this code is duplicated in the prev. function
410  QPointF basePoint = m_rect.topLeft() + QPointF(HANDLE_MARGIN, iconMargin);
411  QPointF step = QPointF(0, m_iconSize + iconMargin);
412  QPointF separator = step + QPointF(0, iconMargin);
413  //end duplicate code
414 
415  QRectF activeArea = QRectF(basePoint, QSizeF(m_iconSize, m_iconSize));
416 
417  AbstractGroup *parentGroup = widget()->property("group").value<AbstractGroup *>();
418  if (!(parentGroup && parentGroup->groupType() == AbstractGroup::ConstrainedGroup)) {
419  if (group() || (applet() && applet()->aspectRatioMode() != FixedSize)) {
420  if (activeArea.contains(point)) {
421  return ResizeButton;
422  }
423  activeArea.translate(step);
424  }
425 
426  if (activeArea.contains(point)) {
427  return RotateButton;
428  }
429  activeArea.translate(step);
430  }
431 
432  if ((applet() && applet()->hasConfigurationInterface()) || (group() && group()->hasConfigurationInterface())) {
433  if (activeArea.contains(point)) {
434  return ConfigureButton;
435  }
436  activeArea.translate(step);
437  }
438 
439  if (applet() && applet()->hasValidAssociatedApplication()) {
440  if (activeArea.contains(point)) {
441  return MaximizeButton;
442  }
443  }
444 
445  activeArea.moveTop(m_rect.bottom() - activeArea.height() - iconMargin);
446  if (activeArea.contains(point)) {
447  return RemoveButton;
448  }
449 
450  return MoveButton;
451  //return applet()->mapToParent(applet()->shape()).contains(point) ? NoButton : MoveButton;
452 }
453 
454 void FreeHandle::mousePressEvent(QGraphicsSceneMouseEvent *event)
455 {
456  //containment recently switched?
457  if (!widget()) {
458  QGraphicsItem::mousePressEvent(event);
459  return;
460  }
461 
462  if (m_pendingFade) {
463  //m_pendingFade = false;
464  return;
465  }
466 
467  if (event->button() == Qt::LeftButton) {
468  m_originalGeom = mapToScene(QRectF(QPoint(0,0), widget()->size())).boundingRect();
469  QPointF center = widget()->boundingRect().center();
470  m_originalTransform = widget()->transform();
471  m_angle = _k_pointAngle(m_originalTransform.map(center + QPointF(1.0, 0.0)) - center);
472 
473  m_pressedButton = mapToButton(event->pos());
474  //kDebug() << "button pressed:" << m_pressedButton;
475  if (m_pressedButton != NoButton) {
476  containment()->raise(widget());
477  m_zValue = widget()->zValue();
478  setZValue(m_zValue);
479  }
480 
481  if (m_pressedButton == MoveButton) {
482  containment()->setMovingWidget(widget());
483  }
484 
485  if (m_pressedButton == ResizeButton || m_pressedButton == RotateButton) {
486  m_originalGeom = mapToScene(QRectF(QPoint(0,0), widget()->size())).boundingRect();
487  m_origWidgetCenter = m_originalGeom.center();
488  m_origWidgetSize = QPointF(widget()->size().width(), widget()->size().height());
489 
490  // resize
491  if (m_buttonsOnRight) {
492  m_resizeStaticPoint = widget()->mapToScene(QPointF(0, widget()->size().height()));
493  } else {
494  m_resizeStaticPoint = widget()->mapToScene(m_origWidgetSize);
495  }
496  m_resizeGrabPoint = event->scenePos();
497 
498  // rotate
499  m_rotateAngleOffset = m_angle - _k_pointAngle(event->scenePos() - m_origWidgetCenter);
500  }
501 
502  event->accept();
503 
504  //set mousePos to the position in the widget, in screencoords, so it becomes easy
505  //to reposition the toplevel view to the correct position.
506  if (currentView() && widget()) {
507  QPoint localpos = currentView()->mapFromScene(widget()->scenePos());
508  m_mousePos = event->screenPos() - currentView()->mapToGlobal(localpos);
509  }
510  return;
511  }
512 
513  QGraphicsItem::mousePressEvent(event);
514 }
515 
516 void FreeHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
517 {
518  //kDebug() << "button pressed:" << m_pressedButton << ", fade pending?" << m_pendingFade;
519 
520  if (m_pendingFade) {
521  startFading(FadeOut, m_entryPos);
522  m_pendingFade = false;
523  }
524 
525  ButtonType releasedAtButton = mapToButton(event->pos());
526 
527  if (widget() && event->button() == Qt::LeftButton) {
528  switch (m_pressedButton) {
529  case ConfigureButton:
530  //FIXME: Remove this call once the configuration management change was done
531  if (applet() && m_pressedButton == releasedAtButton) {
532  applet()->showConfigurationInterface();
533  } else if (group() && group()->hasConfigurationInterface()) {
534  group()->showConfigurationInterface();
535  }
536  break;
537  case RemoveButton:
538  if (m_pressedButton == releasedAtButton) {
539  forceDisappear();
540  if (applet()) {
541  applet()->destroy();
542  } else {
543  group()->destroy();
544  }
545  return;
546  }
547  break;
548  case MoveButton:
549  {
550  // test for containment change
551  //kDebug() << "testing for containment change, sceneBoundingRect = "
552  // << containment()->sceneBoundingRect();
553  if (!containment()->sceneBoundingRect().contains(widget()->scenePos())) {
554  // see which containment it belongs to
555  Corona * corona = qobject_cast<Corona*>(scene());
556  if (corona) {
557  foreach (Containment *containment, corona->containments()) {
558  QPointF pos;
559  QGraphicsView *v = containment->view();
560  if (v) {
561  pos = v->mapToScene(v->mapFromGlobal(event->screenPos() - m_mousePos));
562 
563  if (containment->sceneBoundingRect().contains(pos)) {
564  //kDebug() << "new containment = " << containments[i];
565  //kDebug() << "rect = " << containments[i]->sceneBoundingRect();
566  // add the widget to the new containment and take it from the old one
567  //kDebug() << "moving to other containment with position" << pos;;
568  switchContainment(static_cast<GroupingContainment *>(containment), pos);
569  break;
570  }
571  }
572  }
573  }
574  }
575 
576  emit widgetMoved(widget());
577 
578  break;
579  }
580  case MaximizeButton:
581  if (applet()) {
582  applet()->runAssociatedApplication();
583  }
584  break;
585  default:
586  break;
587  }
588  }
589 
590  m_pressedButton = NoButton;
591  update();
592 }
593 
594 qreal _k_distanceForPoint(const QPointF& point)
595 {
596  return std::sqrt(point.x() * point.x() + point.y() * point.y());
597 }
598 
599 qreal _k_pointAngle(const QPointF& point)
600 {
601  qreal r = sqrt(point.x() * point.x() + point.y() * point.y());
602  qreal cosine = point.x() / r;
603 
604  if (point.y() >= 0) {
605  return acos(cosine);
606  } else {
607  return -acos(cosine);
608  }
609 }
610 
611 QPointF _k_rotatePoint(const QPointF& point, qreal angle)
612 {
613  return QTransform().rotateRadians(angle).map(point);
614 }
615 
616 QPointF _k_projectPoint(QPointF point, QPointF v)
617 {
618  v /= sqrt(v.x() * v.x() + v.y() * v.y());
619  qreal a = v.x() * v.x();
620  qreal b = v.x() * v.y();
621  qreal d = v.y() * v.y();
622  return QMatrix(a, b, b, d, 0., 0.).map(point);
623 }
624 
625 void FreeHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
626 {
627  static const qreal snapAngle = M_PI_2 /* $i 3.14159 / 2.0 */;
628 
629  if (!widget()) {
630  QGraphicsItem::mouseMoveEvent(event);
631  return;
632  }
633 
634  //Track how much the mouse has moved.
635  QPointF deltaScene = event->scenePos() - event->lastScenePos();
636 
637  if (m_pressedButton == MoveButton) {
638  if (leaveCurrentView(event->screenPos())) {
639  Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
640  if (v && v != currentView()) {
641  Containment *c = v->containment();
642  if (c) {
643  QPoint pos = v->mapFromGlobal(event->screenPos());
644  //we actually have been dropped on another containment, so
645  //move there: we have a screenpos, we need a scenepos
646  //FIXME how reliable is this transform?
647  switchContainment(static_cast<GroupingContainment *>(c), v->mapToScene(pos));
648  }
649  }
650  }
651 
652  QPointF curPos = event->pos();
653  QPointF lastPos = event->lastPos();
654 
655  QTransform transform = widget()->transform();
656  //we need to discard translation from the transform
657  QTransform t(transform.m11(), transform.m12(), transform.m21(), transform.m22(), 0, 0);
658  QPointF delta = t.map(curPos - lastPos);
659  widget()->moveBy(delta.x(), delta.y());
660  } else if (m_pressedButton == ResizeButton || m_pressedButton == RotateButton) {
661  QPointF cursorPoint = event->scenePos();
662 
663  // the code below will adjust these based on the type of operation
664  QPointF newSize;
665  QPointF newCenter;
666  qreal newAngle;
667 
668  // get size limits
669  QSizeF min = widget()->minimumSize();
670  QSizeF max = widget()->maximumSize();
671 
672  if (min.width() < KIconLoader::SizeSmall || min.height() < KIconLoader::SizeSmall) {
673  min = widget()->effectiveSizeHint(Qt::MinimumSize);
674  }
675 
676  if (max.isEmpty()) {
677  max = widget()->effectiveSizeHint(Qt::MaximumSize);
678  }
679 
680  // If the widget doesn't have a minimum size, calculate based on a
681  // minimum content area size of 16x16 (KIconLoader::SizeSmall)
682  if (min.width() < KIconLoader::SizeSmall || min.height() < KIconLoader::SizeSmall) {
683  min = widget()->boundingRect().size() - widget()->contentsRect().size();
684  min = QSizeF(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
685  }
686 
687  if (m_pressedButton == RotateButton) {
688  newSize = m_origWidgetSize;
689  newCenter = m_origWidgetCenter;
690 
691  QPointF centerRelativePoint = cursorPoint - m_origWidgetCenter;
692  if (_k_distanceForPoint(centerRelativePoint) < 10) {
693  newAngle = m_angle;
694  } else {
695  qreal cursorAngle = _k_pointAngle(centerRelativePoint);
696  newAngle = m_rotateAngleOffset + cursorAngle;
697  if (fabs(remainder(newAngle, snapAngle)) < 0.15) {
698  newAngle = newAngle - remainder(newAngle, snapAngle);
699  }
700  }
701  } else {
702  // un-rotate screen points so we can read differences of coordinates
703 
704  QTransform t(widget()->sceneTransform());
705  //take the angle relative to the scene
706  qreal angle = (t.m12() > 0 ? acos(t.m11()) : -acos(t.m11()));
707 
708  QPointF rStaticPoint = _k_rotatePoint(m_resizeStaticPoint, -angle);
709  QPointF rCursorPoint = _k_rotatePoint(cursorPoint, -angle);
710  QPointF rGrabPoint = _k_rotatePoint(m_resizeGrabPoint, -angle);
711 
712  if (m_buttonsOnRight) {
713  newSize = m_origWidgetSize + QPointF(rCursorPoint.x() - rGrabPoint.x(), rGrabPoint.y() - rCursorPoint.y());
714  } else {
715  newSize = m_origWidgetSize + QPointF(rGrabPoint.x() - rCursorPoint.x(), rGrabPoint.y() - rCursorPoint.y());
716  }
717 
718  // preserving aspect ratio?
719  if (applet() && ((applet()->aspectRatioMode() != Plasma::IgnoreAspectRatio &&
720  !(event->modifiers() & Qt::ControlModifier)) ||
721  (applet()->aspectRatioMode() == Plasma::IgnoreAspectRatio &&
722  (event->modifiers() & Qt::ControlModifier)))) {
723  // project size to keep ratio
724  newSize = _k_projectPoint(newSize, m_origWidgetSize);
725  // limit size, presering ratio
726  qreal ratio = m_origWidgetSize.y() / m_origWidgetSize.x();
727  newSize.rx() = qMin(max.width(), qMax(min.width(), newSize.x()));
728  newSize.ry() = newSize.x() * ratio;
729  newSize.ry() = qMin(max.height(), qMax(min.height(), newSize.y()));
730  newSize.rx() = newSize.y() / ratio;
731  } else {
732  // limit size
733  newSize.rx() = qMin(max.width(), qMax(min.width(), newSize.x()));
734  newSize.ry() = qMin(max.height(), qMax(min.height(), newSize.y()));
735  }
736 
737  // move center such that the static corner remains in the same place
738  if (m_buttonsOnRight) {
739  newCenter = _k_rotatePoint(QPointF(rStaticPoint.x() + newSize.x()/2,
740  rStaticPoint.y() - newSize.y()/2), angle);
741  } else {
742  newCenter = _k_rotatePoint(QPointF(rStaticPoint.x() - newSize.x()/2,
743  rStaticPoint.y() - newSize.y()/2), angle);
744  }
745 
746  newAngle = m_angle;
747  }
748 
749  // apply size
750  widget()->resize(newSize.x(), newSize.y());
751 
752  // apply position, no need if we're rotating
753  if (m_pressedButton != RotateButton) {
754  widget()->setPos(widget()->parentItem()->mapFromScene(newCenter - newSize/2));
755  }
756 
757  // apply angle
758  QTransform at;
759  at.translate(newSize.x()/2, newSize.y()/2);
760  at.rotateRadians(newAngle);
761  at.translate(-newSize.x()/2, -newSize.y()/2);
762  widget()->setTransform(at);
763  m_angle = newAngle;
764  } else {
765  QGraphicsItem::mouseMoveEvent(event);
766  }
767 }
768 
769 bool FreeHandle::sceneEvent(QEvent *event)
770 {
771  switch (event->type()) {
772  case QEvent::TouchEnd: {
773  QTransform t = widget()->transform();
774  QRectF geom = widget()->geometry();
775  QPointF translation(t.m31(), t.m32());
776  QPointF center = geom.center();
777  geom.setWidth(geom.width()*qAbs(t.m11()));
778  geom.setHeight(geom.height()*qAbs(t.m22()));
779  geom.moveCenter(center);
780 
781  widget()->setGeometry(geom);
782  t.reset();
783  t.translate(widget()->size().width()/2, widget()->size().height()/2);
784  t.rotateRadians(m_angle);
785  t.translate(-widget()->size().width()/2, -widget()->size().height()/2);
786 
787 
788  widget()->setTransform(t);
789  return true;
790  }
791  case QEvent::TouchBegin:
792  case QEvent::TouchUpdate:
793  {
794  QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
795  if (touchPoints.count() == 2) {
796  const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
797  const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
798 
799  //rotation
800  QLineF line0(touchPoint0.lastScenePos(), touchPoint1.lastScenePos());
801  QLineF line1(touchPoint0.scenePos(), touchPoint1.scenePos());
802  m_angle = m_angle+(line1.angleTo(line0)*M_PI_2/90);
803  QTransform t = widget()->transform();
804  t.translate(widget()->size().width()/2, widget()->size().height()/2);
805  t.rotate(line1.angleTo(line0));
806 
807  //scaling
808  qreal scaleFactor = 1;
809  if (line0.length() > 0) {
810  scaleFactor = line1.length() / line0.length();
811  }
812 
813  t.scale(scaleFactor, scaleFactor);
814  t.translate(-widget()->size().width()/2, -widget()->size().height()/2);
815  widget()->setTransform(t);
816 
817  }
818  return true;
819  }
820  default:
821  break;
822  }
823  return QGraphicsItem::sceneEvent(event);
824 }
825 
826 void FreeHandle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
827 {
828  Q_UNUSED(event);
829 // kDebug() << "hover enter";
830 
831  //if a disappear was scheduled stop the timer
832  if (m_leaveTimer->isActive()) {
833  m_leaveTimer->stop();
834  }
835  // if we're already fading out, fade back in
836  else if (!m_anim.data() && m_animType == FadeOut) {
837  startFading(FadeIn, m_entryPos, true);
838  }
839 }
840 
841 void FreeHandle::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
842 {
843  hoverEnterEvent(event);
844 }
845 
846 void FreeHandle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
847 {
848  Q_UNUSED(event);
849 
850  foreach (QWidget *widget, QApplication::topLevelWidgets()) {
851  QMenu *menu = qobject_cast<QMenu*>(widget);
852  if (menu && menu->isVisible()) {
853  connect(menu, SIGNAL(aboutToHide()), this, SLOT(leaveTimeout()));
854  return;
855  }
856  }
857 
858 
859  // if we haven't even showed up yet, remove the handle
860  if (m_hoverTimer->isActive()) {
861  m_hoverTimer->stop();
862  QTimer::singleShot(0, this, SLOT(emitDisappear()));
863  } else if (m_pressedButton != NoButton) {
864  m_pendingFade = true;
865  } else {
866  //wait a moment to hide the handle in order to recheck the mouse position
867  m_leaveTimer->start();
868  }
869 }
870 
871 bool FreeHandle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
872 {
873  if (watched == widget() && event->type() == QEvent::GraphicsSceneHoverLeave) {
874  hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent*>(event));
875  }
876 
877  return false;
878 }
879 
880 void FreeHandle::setFadeAnimation(qreal progress)
881 {
882  m_opacity = progress;
883  //kDebug() << "progress" << progress << "m_opacity" << m_opacity << m_anim << "(" << FadeIn << ")";
884  if (qFuzzyCompare(progress, qreal(1.0))) {
885  delete m_backgroundBuffer;
886  m_backgroundBuffer = 0;
887  }
888 
889  update();
890 }
891 
892 qreal FreeHandle::fadeAnimation() const
893 {
894  return m_opacity;
895 }
896 
897 void FreeHandle::hoverTimeout()
898 {
899  startFading(FadeIn, m_entryPos);
900 }
901 
902 void FreeHandle::leaveTimeout()
903 {
904  if (!isUnderMouse()) {
905  startFading(FadeOut, m_entryPos);
906  }
907 }
908 
909 void FreeHandle::widgetResized()
910 {
911  prepareGeometryChange();
912  calculateSize();
913  update();
914 }
915 
916 void FreeHandle::setHoverPos(const QPointF &hoverPos)
917 {
918  m_entryPos = hoverPos;
919 
920  if (!boundingRect().contains(hoverPos)) {
921  m_leaveTimer->start();
922  }
923 }
924 
925 void FreeHandle::startFading(FadeType anim, const QPointF &hoverPos, bool preserveSide)
926 {
927  QPropertyAnimation *propAnim = m_anim.data();
928 
929  if (anim == FadeIn) {
930  if (propAnim) {
931  propAnim->stop();
932  } else {
933  propAnim = new QPropertyAnimation(this, "fadeAnimation", this);
934  m_anim = propAnim;
935  }
936  }
937 
938  m_entryPos = hoverPos;
939  qreal time = 100;
940 
941  if (!widget()) {
942  m_animType = FadeOut;
943  setFadeAnimation(1.0);
944  return;
945  }
946 
947  if (anim == FadeIn) {
948  //kDebug() << m_entryPos.x() << widget()->pos().x();
949  prepareGeometryChange();
950  bool wasOnRight = m_buttonsOnRight;
951  if (!preserveSide) {
952  m_buttonsOnRight = m_entryPos.x() > (widget()->size().width() / 2);
953  }
954  calculateSize();
955  QPolygonF region = widget()->mapToParent(m_rect).intersected(widget()->parentWidget()->boundingRect());
956  //kDebug() << region << m_rect << mapToParent(m_rect) << containmnet->boundingRect();
957  if (region != widget()->mapToParent(m_rect)) {
958  // switch sides
959  //kDebug() << "switch sides";
960  m_buttonsOnRight = !m_buttonsOnRight;
961  calculateSize();
962  QPolygonF region2 = widget()->mapToParent(m_rect).intersected(widget()->parentWidget()->boundingRect());
963  if (region2 != mapToParent(m_rect)) {
964  // ok, both sides failed to be perfect... which one is more perfect?
965  QRectF f1 = region.boundingRect();
966  QRectF f2 = region2.boundingRect();
967  //kDebug() << "still not a perfect world"
968  // << f2.width() << f2.height() << f1.width() << f1.height();
969  if ((f2.width() * f2.height()) < (f1.width() * f1.height())) {
970  //kDebug() << "we did better the first time";
971  m_buttonsOnRight = !m_buttonsOnRight;
972  calculateSize();
973  }
974  }
975  }
976 
977  if (wasOnRight != m_buttonsOnRight &&
978  m_animType == FadeIn &&
979  anim == FadeIn &&
980  m_opacity <= 1) {
981  m_opacity = 0.0;
982  }
983 
984  time *= 1.0 - m_opacity;
985  } else {
986  time *= m_opacity;
987  }
988 
989  if (propAnim) {
990  propAnim->setStartValue(0);
991  propAnim->setEndValue(1);
992  propAnim->setDuration(time);
993  }
994 
995  m_animType = anim;
996  //kDebug() << "animating for " << time << "ms";
997  if (m_animType == FadeIn) {
998  propAnim->setDirection(QAbstractAnimation::Forward);
999  propAnim->start();
1000  } else if (propAnim) {
1001  propAnim->setDirection(QAbstractAnimation::Backward);
1002  propAnim->start(QAbstractAnimation::DeleteWhenStopped);
1003  }
1004 }
1005 
1006 void FreeHandle::forceDisappear()
1007 {
1008  setAcceptsHoverEvents(false);
1009  startFading(FadeOut, m_entryPos);
1010 }
1011 
1012 int FreeHandle::minimumHeight()
1013 {
1014  int iconMargin = m_iconSize / 2;
1015  int requiredHeight = iconMargin + //first margin
1016  (m_iconSize + iconMargin) * 4 + //XXX remember to update this if the number of buttons changes
1017  iconMargin ; //blank space before the close button
1018 
1019  if (applet() && applet()->hasConfigurationInterface()) {
1020  requiredHeight += (m_iconSize + iconMargin);
1021  }
1022 
1023  return requiredHeight;
1024 }
1025 
1026 void FreeHandle::calculateSize()
1027 {
1028  KIconLoader *iconLoader = KIconLoader::global();
1029  //m_iconSize = iconLoader->currentSize(KIconLoader::Small); //does not work with double sized icon
1030  m_iconSize = iconLoader->loadIcon("transform-scale", KIconLoader::Small).width(); //workaround
1031 
1032  int handleHeight = qMax(minimumHeight(), int(widget()->contentsRect().height() * 0.8));
1033  int handleWidth = m_iconSize + 2 * HANDLE_MARGIN;
1034  int top =
1035  widget()->contentsRect().top() + (widget()->contentsRect().height() - handleHeight) / 2.0;
1036 
1037  qreal marginLeft, marginTop, marginRight, marginBottom;
1038  m_background->getMargins(marginLeft, marginTop, marginRight, marginBottom);
1039 
1040  if (m_buttonsOnRight) {
1041  //put the rect on the right of the widget
1042  m_rect = QRectF(widget()->size().width(), top, handleWidth, handleHeight);
1043  } else {
1044  //put the rect on the left of the widget
1045  m_rect = QRectF(-handleWidth, top, handleWidth, handleHeight);
1046  }
1047 
1048  if (widget()->contentsRect().height() > qreal(minimumHeight()) * 1.25) {
1049  int addedMargin = marginLeft / 2;
1050 
1051  // now we check to see if the shape is smaller than the contents,
1052  // and that the shape is not just the bounding rect; in those cases
1053  // we have a shaped guy and we draw a full panel;
1054  // TODO: allow widgets to mark when they have translucent areas and
1055  // should therefore skip this test?
1056  if (!widget()->shape().contains(widget()->contentsRect())) {
1057  QPainterPath p;
1058  p.addRect(widget()->boundingRect());
1059  if (widget()->shape() != p) {
1060  addedMargin = widget()->contentsRect().width() / 2;
1061  }
1062  }
1063 
1064  if (m_buttonsOnRight) {
1065  marginLeft += addedMargin;
1066  } else {
1067  marginRight += addedMargin;
1068  }
1069  }
1070 
1071  //m_rect = widget()->mapToParent(m_rect).boundingRect();
1072  m_decorationRect = m_rect.adjusted(-marginLeft, -marginTop, marginRight, marginBottom);
1073  m_totalRect = m_decorationRect.united(widget()->boundingRect());
1074 }
1075 
1076 #include "freehandle.moc"
1077 
QGraphicsItem::mapToParent
QPointF mapToParent(const QPointF &point) const
QTimer::setInterval
void setInterval(int msec)
FreeHandle::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: freehandle.cpp:196
QTransform
_k_distanceForPoint
qreal _k_distanceForPoint(const QPointF &point)
Definition: freehandle.cpp:594
QGraphicsItem::parentWidget
QGraphicsWidget * parentWidget() const
QEvent
QPixmap::size
QSize size() const
QWidget
FreeHandle::hoverEnterEvent
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Definition: freehandle.cpp:826
Handle::disappearDone
void disappearDone(Handle *self)
QEvent::type
Type type() const
groupingcontainment.h
FreeHandle::hoverLeaveEvent
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition: freehandle.cpp:846
QSize::width
int width() const
QRectF::toRect
QRect toRect() const
FreeHandle::FreeHandle
FreeHandle(GroupingContainment *parent, Plasma::Applet *applet)
Definition: freehandle.cpp:58
QPainter::fillRect
void fillRect(const QRectF &rectangle, const QBrush &brush)
QPainter::setCompositionMode
void setCompositionMode(CompositionMode mode)
FreeHandle::startFading
void startFading(FadeType anim, const QPointF &hoverPos, bool preserveSide=false)
Definition: freehandle.cpp:925
QTouchEvent::TouchPoint::lastScenePos
QPointF lastScenePos() const
QTransform::reset
void reset()
GroupingContainment::raise
void raise(QGraphicsWidget *widget)
Raises a widget above all the other Applets or Groups.
Definition: groupingcontainment.cpp:996
QPixmap::fill
void fill(const QColor &color)
AbstractGroup::showConfigurationInterface
virtual void showConfigurationInterface()
Lets the user interact with the Group options.
Definition: abstractgroup.cpp:775
FreeHandle::hoverMoveEvent
void hoverMoveEvent(QGraphicsSceneHoverEvent *event)
Definition: freehandle.cpp:841
QGraphicsItem::moveBy
void moveBy(qreal dx, qreal dy)
QPainterPath::closeSubpath
void closeSubpath()
_k_rotatePoint
QPointF _k_rotatePoint(const QPointF &point, qreal angle)
Definition: freehandle.cpp:611
QGradient::setColorAt
void setColorAt(qreal position, const QColor &color)
QTransform::map
QPoint map(const QPoint &point) const
QGraphicsItem::sceneTransform
QTransform sceneTransform() const
QGraphicsItem::setAcceptTouchEvents
void setAcceptTouchEvents(bool enabled)
QGraphicsView::mapToScene
QPointF mapToScene(const QPoint &point) const
QRectF::size
QSizeF size() const
_k_projectPoint
QPointF _k_projectPoint(QPointF point, QPointF v)
Definition: freehandle.cpp:616
Handle::detachWidget
virtual void detachWidget()
Definition: handle.cpp:105
Handle::ButtonType
ButtonType
Definition: handle.h:46
QWidget::isVisible
bool isVisible() const
QGraphicsItem::sceneBoundingRect
QRectF sceneBoundingRect() const
QWidget::mapToGlobal
QPoint mapToGlobal(const QPoint &pos) const
QGraphicsSceneMouseEvent::screenPos
QPoint screenPos() const
QVariant::value
T value() const
QPainterPath::moveTo
void moveTo(const QPointF &point)
QRectF::top
qreal top() const
QWeakPointer::data
T * data() const
QGraphicsItem
Handle
Definition: handle.h:41
QGraphicsSceneMouseEvent::scenePos
QPointF scenePos() const
QPoint
FreeHandle::mouseMoveEvent
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: freehandle.cpp:625
QLinearGradient
QGraphicsItem::scene
QGraphicsScene * scene() const
Handle::RemoveButton
Definition: handle.h:51
abstractgroup.h
GroupingContainment::setMovingWidget
void setMovingWidget(QGraphicsWidget *widget)
Call this function when an Applet or a Group is being moved by the user.
Definition: groupingcontainment.cpp:969
QRectF::left
qreal left() const
QVariantAnimation::setStartValue
void setStartValue(const QVariant &value)
QGraphicsItem::update
void update(const QRectF &rect)
FreeHandleRect
QPainterPath FreeHandleRect(const QRectF &rect, int radius, bool onRight)
Definition: freehandle.cpp:167
QTouchEvent::TouchPoint
Handle::containment
GroupingContainment * containment() const
Definition: handle.cpp:95
QRectF::setHeight
void setHeight(qreal height)
QPointF
QObject::event
virtual bool event(QEvent *e)
Handle::applet
Plasma::Applet * applet() const
Definition: handle.cpp:85
QGraphicsWidget::resize
void resize(const QSizeF &size)
Handle::currentView
QGraphicsView * currentView() const
Definition: handle.cpp:100
QRectF::bottom
qreal bottom() const
Handle::MaximizeButton
Definition: handle.h:53
FreeHandle::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: freehandle.cpp:454
QRect
QGraphicsItem::zValue
qreal zValue() const
QGraphicsItem::pos
QPointF pos() const
FreeHandle::FadeIn
Definition: freehandle.h:50
QTransform::translate
QTransform & translate(qreal dx, qreal dy)
QList::count
int count(const T &value) const
QPointF::x
qreal x() const
QPointF::y
qreal y() const
QSizeF::isEmpty
bool isEmpty() const
QRectF::translate
void translate(qreal dx, qreal dy)
QAbstractAnimation::stop
void stop()
QGraphicsItem::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QObject::property
QVariant property(const char *name) const
QTransform::scale
QTransform & scale(qreal sx, qreal sy)
QPainterPath::united
QPainterPath united(const QPainterPath &p) const
QTimer
QPropertyAnimation
Handle::group
AbstractGroup * group() const
Definition: handle.cpp:90
QObject
QPainter::setPen
void setPen(const QColor &color)
QPainterPath::lineTo
void lineTo(const QPointF &endPoint)
Handle::ResizeButton
Definition: handle.h:52
QGraphicsSceneMouseEvent
QSizeF::toSize
QSize toSize() const
QGraphicsItem::setPos
void setPos(const QPointF &pos)
QTransform::m31
qreal m31() const
QTransform::m32
qreal m32() const
QTransform::m11
qreal m11() const
QTransform::m12
qreal m12() const
QTransform::m21
qreal m21() const
QTransform::m22
qreal m22() const
QPainter::drawPixmap
void drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)
FreeHandle::fadeAnimation
qreal fadeAnimation
Definition: freehandle.h:47
QPainter
QRectF::topLeft
QPointF topLeft() const
QPainterPath::addRect
void addRect(const QRectF &rectangle)
QGraphicsItem::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Handle::switchContainment
void switchContainment(GroupingContainment *containment, const QPointF &pos)
move our widget to another containment
Definition: handle.cpp:140
QGraphicsItem::mapFromScene
QPointF mapFromScene(const QPointF &point) const
QGraphicsLayoutItem::effectiveSizeHint
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint) const
freehandle.h
QRectF::moveLeft
void moveLeft(qreal x)
QTransform::rotateRadians
QTransform & rotateRadians(qreal angle, Qt::Axis axis)
FreeHandle::sceneEvent
bool sceneEvent(QEvent *)
Definition: freehandle.cpp:769
QGraphicsView::mapFromScene
QPoint mapFromScene(const QPointF &point) const
QRectF::center
QPointF center() const
QGraphicsSceneMouseEvent::button
Qt::MouseButton button() const
QList::first
T & first()
QRectF::united
QRectF united(const QRectF &rectangle) const
QList
FreeHandle::setHoverPos
void setHoverPos(const QPointF &hoverPos)
Definition: freehandle.cpp:916
QGraphicsItem::flags
GraphicsItemFlags flags() const
QColor
QGraphicsWidget::maximumSize
maximumSize
QLineF
QGraphicsSceneHoverEvent
Handle::widget
QGraphicsWidget * widget() const
Definition: handle.cpp:80
QGraphicsItem::prepareGeometryChange
void prepareGeometryChange()
QTouchEvent::TouchPoint::scenePos
QPointF scenePos() const
QRectF::moveCenter
void moveCenter(const QPointF &position)
QPixmap
FreeHandle::sceneEventFilter
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Definition: freehandle.cpp:871
QMenu
QGraphicsItem::sceneEvent
virtual bool sceneEvent(QEvent *event)
QRectF::right
qreal right() const
QSize
FreeHandle::FadeType
FadeType
Definition: freehandle.h:49
Handle::ConfigureButton
Definition: handle.h:50
QTimer::stop
void stop()
QPainter::setRenderHints
void setRenderHints(QFlags< QPainter::RenderHint > hints, bool on)
QTransform::rotate
QTransform & rotate(qreal angle, Qt::Axis axis)
AbstractGroup::ConstrainedGroup
The transformations of the applet are constrained by, e.g.
Definition: abstractgroup.h:56
Handle::RotateButton
Definition: handle.h:49
QPainterPath
QPolygonF::boundingRect
QRectF boundingRect() const
QGraphicsItem::mapToScene
QPointF mapToScene(const QPointF &point) const
QRectF::width
qreal width() const
QGraphicsItem::setAcceptsHoverEvents
void setAcceptsHoverEvents(bool enabled)
QSizeF
Handle::leaveCurrentView
bool leaveCurrentView(const QPoint &pos) const
Definition: handle.cpp:124
GroupingContainment
The base Containment class.
Definition: groupingcontainment.h:38
QRectF
QRectF::setWidth
void setWidth(qreal width)
QGraphicsItem::transform
QTransform transform() const
QWidget::mapFromGlobal
QPoint mapFromGlobal(const QPoint &pos) const
QMatrix
QGraphicsItem::setFlags
void setFlags(QFlags< QGraphicsItem::GraphicsItemFlag > flags)
QList::last
T & last()
QGraphicsItem::setTransform
void setTransform(const QTransform &matrix, bool combine)
QGraphicsItem::shape
virtual QPainterPath shape() const
QRectF::bottomLeft
QPointF bottomLeft() const
QPointF::rx
qreal & rx()
QPointF::ry
qreal & ry()
QVariantAnimation::setEndValue
void setEndValue(const QVariant &value)
QPainter::translate
void translate(const QPointF &offset)
QVariantAnimation::setDuration
void setDuration(int msecs)
QGraphicsItem::installSceneEventFilter
void installSceneEventFilter(QGraphicsItem *filterItem)
QTimer::start
void start(int msec)
QColor::setAlphaF
void setAlphaF(qreal alpha)
QStyleOptionGraphicsItem
QRectF::adjusted
QRectF adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const
QRectF::height
qreal height() const
QGraphicsItem::parentItem
QGraphicsItem * parentItem() const
FreeHandle::boundingRect
QRectF boundingRect() const
Definition: freehandle.cpp:151
QRectF::contains
bool contains(const QPointF &point) const
Handle::NoButton
Definition: handle.h:47
QGraphicsLayoutItem::contentsRect
QRectF contentsRect() const
AbstractGroup::destroy
void destroy()
Destroy this Groups and its children, deleting the configurations too.
Definition: abstractgroup.cpp:476
QAbstractAnimation::start
void start(QAbstractAnimation::DeletionPolicy policy)
QGraphicsWidget::minimumSize
minimumSize
QGraphicsItem::isUnderMouse
bool isUnderMouse() const
QGraphicsSceneMouseEvent::pos
QPointF pos() const
FreeHandle::~FreeHandle
virtual ~FreeHandle()
Definition: freehandle.cpp:84
QSizeF::height
qreal height() const
QPainterPath::quadTo
void quadTo(const QPointF &c, const QPointF &endPoint)
QRectF::moveTop
void moveTop(qreal y)
QTimer::isActive
bool isActive() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QMatrix::map
void map(int x, int y, int *tx, int *ty) const
AbstractGroup
The base Group class.
Definition: abstractgroup.h:43
_k_pointAngle
qreal _k_pointAngle(const QPointF &point)
Definition: freehandle.cpp:599
QGraphicsItem::contains
virtual bool contains(const QPointF &point) const
QPixmap::rect
QRect rect() const
QAbstractAnimation::setDirection
void setDirection(Direction direction)
AbstractGroup::groupType
GroupType groupType
Definition: abstractgroup.h:48
QGraphicsItem::setZValue
void setZValue(qreal z)
QTouchEvent
QGraphicsWidget::geometry
geometry
QGraphicsView
Handle::widgetMoved
void widgetMoved(QGraphicsWidget *widget)
QGraphicsWidget::boundingRect
virtual QRectF boundingRect() const
QGraphicsItem::scenePos
QPointF scenePos() const
QObject::destroyed
void destroyed(QObject *obj)
QSizeF::width
qreal width() const
QApplication::topLevelWidgets
QWidgetList topLevelWidgets()
FreeHandle::FadeOut
Definition: freehandle.h:51
Handle::MoveButton
Definition: handle.h:48
FreeHandle::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition: freehandle.cpp:516
QTimer::setSingleShot
void setSingleShot(bool singleShot)
QPolygonF
FreeHandle::shape
QPainterPath shape() const
Definition: freehandle.cpp:156
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:39:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

GroupingDesktop

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

kdeplasma-addons API Reference

Skip menu "kdeplasma-addons API Reference"
  •     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