From da3fcc1b6749c0acc070ff009cf35d88070a4a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Sun, 21 Feb 2010 17:06:10 +0000 Subject: [PATCH 01/22] Mime ddata support in runners svn path=/trunk/KDE/kdelibs/; revision=1093881 --- abstractrunner.cpp | 6 ++++++ abstractrunner.h | 7 +++++++ runnermanager.cpp | 22 ++++++++++++++++++++++ runnermanager.h | 12 ++++++++++++ 4 files changed, 47 insertions(+) diff --git a/abstractrunner.cpp b/abstractrunner.cpp index 573477e39..029951fb4 100644 --- a/abstractrunner.cpp +++ b/abstractrunner.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -184,6 +185,11 @@ void AbstractRunner::clearActions() d->actions.clear(); } +QMimeData * AbstractRunner::setupMimeDataForMatch(const QueryMatch *match) +{ + return 0; +} + bool AbstractRunner::hasRunOptions() { return d->hasRunOptions; diff --git a/abstractrunner.h b/abstractrunner.h index b7b6526dc..8301eb12b 100644 --- a/abstractrunner.h +++ b/abstractrunner.h @@ -34,6 +34,7 @@ #include class QAction; +class QMimeData; class KCompletion; @@ -443,6 +444,12 @@ class PLASMA_EXPORT AbstractRunner : public QObject protected Q_SLOTS: void init(); + /** + * Reimplement this slot if you want your runner + * to support serialization and drag and drop + */ + QMimeData * setupMimeDataForMatch(const Plasma::QueryMatch *match); + private: friend class RunnerScript; diff --git a/runnermanager.cpp b/runnermanager.cpp index f4ff57fda..cca68b6e3 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -542,6 +542,28 @@ QList RunnerManager::actionsForMatch(const QueryMatch &match) return QList(); } +QMimeData * RunnerManager::mimeDataForMatch(const QString &id) const +{ + return mimeDataForMatch(d->context.match(id)); +} + + +QMimeData * RunnerManager::mimeDataForMatch(const QueryMatch &match) const +{ + AbstractRunner *runner = match.runner(); + QMimeData * mimeData; + if (runner && QMetaObject::invokeMethod( + runner, + "setupMimeDataForMatch", Qt::DirectConnection, + Q_RETURN_ARG(QMimeData*, mimeData), + Q_ARG(const Plasma::QueryMatch *, & match) + )) { + return mimeData; + } + + return 0; +} + void RunnerManager::setupMatchSession() { d->teardownRequested = false; diff --git a/runnermanager.h b/runnermanager.h index 9bc2d8d05..976ae5a7c 100644 --- a/runnermanager.h +++ b/runnermanager.h @@ -168,6 +168,18 @@ class PLASMA_EXPORT RunnerManager : public QObject */ QStringList allowedRunners() const; + /** + * @return mime data of the specified match + * @since 4.5 + */ + QMimeData * mimeDataForMatch(const QueryMatch &match) const; + + /** + * @return mime data of the specified match + * @since 4.5 + */ + QMimeData * mimeDataForMatch(const QString &id) const; + public Q_SLOTS: /** * Call this method when the runners should be prepared for a query session. From 2e5064ca2f4904d1203f7f1c97da3cd57aefdc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Sun, 21 Feb 2010 19:30:11 +0000 Subject: [PATCH 02/22] Changed method name svn path=/trunk/KDE/kdelibs/; revision=1093946 --- abstractrunner.cpp | 2 +- abstractrunner.h | 3 ++- runnermanager.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/abstractrunner.cpp b/abstractrunner.cpp index 029951fb4..34b6e7b73 100644 --- a/abstractrunner.cpp +++ b/abstractrunner.cpp @@ -185,7 +185,7 @@ void AbstractRunner::clearActions() d->actions.clear(); } -QMimeData * AbstractRunner::setupMimeDataForMatch(const QueryMatch *match) +QMimeData * AbstractRunner::mimeDataForMatch(const QueryMatch *match) { return 0; } diff --git a/abstractrunner.h b/abstractrunner.h index 8301eb12b..95a085a7f 100644 --- a/abstractrunner.h +++ b/abstractrunner.h @@ -447,8 +447,9 @@ class PLASMA_EXPORT AbstractRunner : public QObject /** * Reimplement this slot if you want your runner * to support serialization and drag and drop + * @since 4.5 */ - QMimeData * setupMimeDataForMatch(const Plasma::QueryMatch *match); + QMimeData * mimeDataForMatch(const Plasma::QueryMatch *match); private: friend class RunnerScript; diff --git a/runnermanager.cpp b/runnermanager.cpp index cca68b6e3..0be9d5f43 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -554,7 +554,7 @@ QMimeData * RunnerManager::mimeDataForMatch(const QueryMatch &match) const QMimeData * mimeData; if (runner && QMetaObject::invokeMethod( runner, - "setupMimeDataForMatch", Qt::DirectConnection, + "mimeDataForMatch", Qt::DirectConnection, Q_RETURN_ARG(QMimeData*, mimeData), Q_ARG(const Plasma::QueryMatch *, & match) )) { From 2b9a4f4e631a0ed43dfffdf5d4e02d9c08ccecad Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 22 Feb 2010 09:36:20 +0000 Subject: [PATCH 03/22] when a moveevent occurs, is not by the animation, that sets the geometry instead, so we can safely use it to notice when somebody else has moved the contents by had. is really important in this case to immediately stop the animation svn path=/trunk/KDE/kdelibs/; revision=1094135 --- private/kineticscroll.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/private/kineticscroll.cpp b/private/kineticscroll.cpp index 6aee0c0b8..39b4d50fd 100644 --- a/private/kineticscroll.cpp +++ b/private/kineticscroll.cpp @@ -378,6 +378,11 @@ bool KineticScrolling::eventFilter(QObject *watched, QEvent *event) return false; } + if (event->type() == QEvent::GraphicsSceneMove) { + d->scrollAnimation->stop(); + return false; + } + bool notBlocked = true; if (d->multitouchGesture == KineticScrollingPrivate::GestureNone && d->parent && d->parent->scene()) { From ce3762373fa66521574f9463911d4f3d4c4ae17a Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 22 Feb 2010 11:21:30 +0000 Subject: [PATCH 04/22] add an explicit way to stop svn path=/trunk/KDE/kdelibs/; revision=1094245 --- animator.h | 8 ++++++++ deprecated/animator.cpp | 7 +++++++ private/kineticscroll.cpp | 11 ++++++----- private/kineticscroll_p.h | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/animator.h b/animator.h index d61f20120..c82db346d 100644 --- a/animator.h +++ b/animator.h @@ -198,6 +198,14 @@ public: */ void unregisterScrollingManager(QGraphicsWidget *widget); + /** + * Stop any scrolling that could be happening on widget + * + * @param the widget that must stop animating + * @since 4.5 + */ + void stopScrollingWidget(QGraphicsWidget *widget); + Q_SIGNALS: void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim); void movementFinished(QGraphicsItem *item); diff --git a/deprecated/animator.cpp b/deprecated/animator.cpp index 27ddf63bc..bdf98dd3f 100644 --- a/deprecated/animator.cpp +++ b/deprecated/animator.cpp @@ -782,5 +782,12 @@ void Animator::unregisterScrollingManager(QGraphicsWidget *widget) } } +void Animator::stopScrollingWidget(QGraphicsWidget *widget) +{ + if (d->scrollingManagers.contains(widget)) { + d->scrollingManagers.value(widget)->stop(); + } +} + } // namespace Plasma diff --git a/private/kineticscroll.cpp b/private/kineticscroll.cpp index 39b4d50fd..6e323f9e2 100644 --- a/private/kineticscroll.cpp +++ b/private/kineticscroll.cpp @@ -369,6 +369,12 @@ void KineticScrolling::setWidget(QGraphicsWidget *parent) /* TODO: add a new property in plasma::ScrollWidget 'hasOvershoot' */ } +void KineticScrolling::stop() +{ + d->scrollAnimation->stop(); +} + + bool KineticScrolling::eventFilter(QObject *watched, QEvent *event) { Q_UNUSED(watched); @@ -378,11 +384,6 @@ bool KineticScrolling::eventFilter(QObject *watched, QEvent *event) return false; } - if (event->type() == QEvent::GraphicsSceneMove) { - d->scrollAnimation->stop(); - return false; - } - bool notBlocked = true; if (d->multitouchGesture == KineticScrollingPrivate::GestureNone && d->parent && d->parent->scene()) { diff --git a/private/kineticscroll_p.h b/private/kineticscroll_p.h index 5f2571367..cb413a494 100644 --- a/private/kineticscroll_p.h +++ b/private/kineticscroll_p.h @@ -40,6 +40,7 @@ public: KineticScrolling(QGraphicsWidget *parent); ~KineticScrolling(); void setWidget(QGraphicsWidget *parent); + void stop(); Q_SIGNALS: void stateChanged(QAbstractAnimation::State newState, From acc4b9ce1faed6cf7f063715d1c43e11b3853b91 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 22 Feb 2010 16:32:05 +0000 Subject: [PATCH 05/22] it's ok if the X-KDE-ParentApp line exists but is empty svn path=/trunk/KDE/kdelibs/; revision=1094363 --- containment.cpp | 2 +- dataenginemanager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/containment.cpp b/containment.cpp index e4e1f7c00..9bbb4673d 100644 --- a/containment.cpp +++ b/containment.cpp @@ -1081,7 +1081,7 @@ KPluginInfo::List Containment::listContainmentsOfType(const QString &type, QString constraint; if (parentApp.isEmpty()) { - constraint.append("not exist [X-KDE-ParentApp]"); + constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')"); } else { constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); } diff --git a/dataenginemanager.cpp b/dataenginemanager.cpp index 126285e3e..810e3ea54 100644 --- a/dataenginemanager.cpp +++ b/dataenginemanager.cpp @@ -174,7 +174,7 @@ QStringList DataEngineManager::listAllEngines(const QString &parentApp) QString constraint; if (parentApp.isEmpty()) { - constraint.append("not exist [X-KDE-ParentApp]"); + constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')"); } else { constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); } From ae50fe2e25937822ed121dd3a78b39442c42c576 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Mon, 22 Feb 2010 18:14:59 +0000 Subject: [PATCH 06/22] Added support to pinch multitouch gesture. svn path=/trunk/KDE/kdelibs/; revision=1094411 --- private/animablegraphicswebview.cpp | 20 ++++++++++++++++++++ private/animablegraphicswebview_p.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index 5f1aafbda..a1cded468 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -21,6 +21,8 @@ #include "animablegraphicswebview_p.h" #include +#include +#include #include #include @@ -152,5 +154,23 @@ void AnimableGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event) event->setAccepted(!m_dragToScroll); } +bool AnimableGraphicsWebView::event(QEvent * event) +{ + if (event->type() == QEvent::Gesture) { + gestureEvent(static_cast(event)); + return true; + } + + return KGraphicsWebView::event(event); +} + +bool AnimableGraphicsWebView::gestureEvent(QGestureEvent *event) +{ + if (QGesture *pinch = event->gesture(Qt::PinchGesture)){ + QPinchGesture *pinchGesture = static_cast(pinch); + setZoomFactor(zoomFactor() * pinchGesture->scaleFactor()); + } +} + #include "animablegraphicswebview_p.moc" diff --git a/private/animablegraphicswebview_p.h b/private/animablegraphicswebview_p.h index f585b64c8..2e323ac85 100644 --- a/private/animablegraphicswebview_p.h +++ b/private/animablegraphicswebview_p.h @@ -29,6 +29,8 @@ #include +class QGestureEvent; + namespace Plasma { @@ -51,12 +53,14 @@ public: bool dragToScroll() const; protected: + bool event(QEvent * event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void wheelEvent(QGraphicsSceneWheelEvent *event); private: + bool gestureEvent(QGestureEvent *event); bool m_dragToScroll; QPointF m_lastScrollPosition; }; From c64e8beb8328a1c6fab4067c416527267712a4cb Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 21:20:53 +0000 Subject: [PATCH 07/22] Adding missing documentation. svn path=/trunk/KDE/kdelibs/; revision=1094497 --- animations/pulser_p.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/animations/pulser_p.h b/animations/pulser_p.h index af30be7d9..50e3c2845 100644 --- a/animations/pulser_p.h +++ b/animations/pulser_p.h @@ -50,7 +50,20 @@ public: /** Destructor */ ~PulseAnimation(); + /** Pulse scale factor. + * + * How much the pulsed shadow will expand (the default is 1.5x the + * size of pulsed widget). + * + * @param scale Pulse scale value (should be bigger than 1.0). + */ void setTargetScale(qreal scale); + + /** Returns pulsed scale factor. + * + * The amount of pulsed shadow factor used (default is 1.5x the size + * of widget). + */ qreal targetScale() const; public Q_SLOTS: From ed33fab95ecbec8d83a45cd0e2fbf358afb282ad Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 21:21:27 +0000 Subject: [PATCH 08/22] Same case. svn path=/trunk/KDE/kdelibs/; revision=1094498 --- animations/pixmaptransition_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/animations/pixmaptransition_p.h b/animations/pixmaptransition_p.h index 055d7c681..2eeab5739 100644 --- a/animations/pixmaptransition_p.h +++ b/animations/pixmaptransition_p.h @@ -68,7 +68,10 @@ public: * Set the pixmap the animation will evolve to */ void setTargetPixmap(const QPixmap &); - + + /** + * Returns the current pixmap + */ QPixmap currentPixmap() const; protected: From ee1b3166f7027c4e61b25d4e500bdde6b8c98149 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 21:22:08 +0000 Subject: [PATCH 09/22] Adding a todo. svn path=/trunk/KDE/kdelibs/; revision=1094499 --- animations/stackedlayout.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/animations/stackedlayout.h b/animations/stackedlayout.h index 77de9ccbc..465ef229a 100644 --- a/animations/stackedlayout.h +++ b/animations/stackedlayout.h @@ -18,6 +18,8 @@ #ifndef STACKEDLAYOUT_H #define STACKEDLAYOUT_H +/* TODO: document the methods */ + #include #include #include From 24ea07b548a5c4cc35c3a0bcac818989df6f851b Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 21:38:22 +0000 Subject: [PATCH 10/22] Fixing behavior showed in IconWidget (thanks aseigo for helping, I owne you ein WEISSBIER!). svn path=/trunk/KDE/kdelibs/; revision=1094514 --- animations/pulsershadow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/animations/pulsershadow.cpp b/animations/pulsershadow.cpp index 93622b2b5..237974d82 100644 --- a/animations/pulsershadow.cpp +++ b/animations/pulsershadow.cpp @@ -79,9 +79,11 @@ void ShadowFake::setTarget(QGraphicsWidget *target) QPainter painter(&m_photo); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.fillRect(target->rect(), Qt::transparent); + QStyleOptionGraphicsItem style; - //FIXME: some widgets follow exposedRect viewport (e.g. QGraphicsWebView) style.exposedRect = target->boundingRect(); + style.rect = target->rect().toRect(); + target->paint(&painter, &style, 0); paintSubChildren(&painter, &style, target); painter.end(); From 04e16a4261b84e4d043e69b0c57979b15ed301ca Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 21:58:21 +0000 Subject: [PATCH 11/22] Implementing support for larger pre-scaled widget raster representation. svn path=/trunk/KDE/kdelibs/; revision=1094534 --- animations/pulsershadow.cpp | 47 +++++++++++++++++++++++++++---------- animations/pulsershadow_p.h | 3 +++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/animations/pulsershadow.cpp b/animations/pulsershadow.cpp index 237974d82..c14caa38c 100644 --- a/animations/pulsershadow.cpp +++ b/animations/pulsershadow.cpp @@ -27,6 +27,7 @@ namespace Plasma ShadowFake::ShadowFake(QGraphicsItem *parent) : QGraphicsWidget(parent), + m_iconBig(false), stack(0), m_target(0) { @@ -69,24 +70,37 @@ void ShadowFake::setTarget(QGraphicsWidget *target) stack = 0; m_target = target; setParentItem(target); - resize(target->size()); - setTransformOriginPoint(geometry().center()); QSize size(target->size().toSize()); + m_iconBig = false; - m_photo = QPixmap(size); - m_photo.fill(Qt::transparent); + if (m_target->property("iconRepresentation").isValid()) { + m_iconBig = true; + m_photo = QPixmap::fromImage( + m_target->property("iconRepresentation").value()); + resize(m_photo.size()); - QPainter painter(&m_photo); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.fillRect(target->rect(), Qt::transparent); + } else { - QStyleOptionGraphicsItem style; - style.exposedRect = target->boundingRect(); - style.rect = target->rect().toRect(); + resize(target->size()); - target->paint(&painter, &style, 0); - paintSubChildren(&painter, &style, target); - painter.end(); + m_photo = QPixmap(size); + m_photo.fill(Qt::transparent); + + QPainter painter(&m_photo); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + painter.fillRect(target->rect(), Qt::transparent); + + QStyleOptionGraphicsItem style; + style.exposedRect = target->boundingRect(); + style.rect = target->rect().toRect(); + + target->paint(&painter, &style, 0); + paintSubChildren(&painter, &style, target); + painter.end(); + + } + + setTransformOriginPoint(geometry().center()); } QGraphicsWidget *ShadowFake::target() const @@ -94,5 +108,12 @@ QGraphicsWidget *ShadowFake::target() const return m_target; } + +bool ShadowFake::isIconBigger() +{ + return m_iconBig; +} + + } diff --git a/animations/pulsershadow_p.h b/animations/pulsershadow_p.h index 81d032734..2b54cc688 100644 --- a/animations/pulsershadow_p.h +++ b/animations/pulsershadow_p.h @@ -38,10 +38,13 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + bool isIconBigger(); + private: void paintSubChildren(QPainter *painter, const QStyleOptionGraphicsItem *option, QGraphicsItem *target); + bool m_iconBig; int stack; QPixmap m_photo; QGraphicsWidget *m_target; From 3b589bbd680a8c0efe5064a54b8962adaff64da3 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 22:06:05 +0000 Subject: [PATCH 12/22] Implementing now the support for 'bigger icons' in the animation itself (it is missing the setting of the scale factor), but at least there is not any regression in the code. svn path=/trunk/KDE/kdelibs/; revision=1094544 --- animations/pulser.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/animations/pulser.cpp b/animations/pulser.cpp index c9100e18e..15b3e76d9 100644 --- a/animations/pulser.cpp +++ b/animations/pulser.cpp @@ -97,6 +97,15 @@ void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn setCopy(); } + if (m_under.data()->isIconBigger()) { + m_under.data()->setScale(0); + m_endScale = 1.0; + + } else { + m_scale = 0; + m_endScale = 1.5; + } + if (m_under.data()->isVisible() == false) { m_under.data()->setVisible(true); } @@ -112,8 +121,15 @@ void PulseAnimation::updateCurrentTime(int currentTime) { if (m_under.data()) { qreal delta = Animation::easingCurve().valueForProgress( currentTime / qreal(duration())); - delta = (1 - m_endScale) * delta; - m_under.data()->setScale(1 - delta); + + if (m_under.data()->isIconBigger()) { + /* TODO: calculate the scale for bigger icon */ + + } else { + m_under.data()->setScale(delta); + delta = (1 - m_endScale) * delta; + m_under.data()->setScale(1 - delta); + } delta = currentTime / qreal(duration()); if (direction() == Forward) { From 02d3966f3c553aae3ebf92831981085798087025 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 22:17:17 +0000 Subject: [PATCH 13/22] Setting the scale (it works now, there is a problem with centering). svn path=/trunk/KDE/kdelibs/; revision=1094558 --- animations/pulser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/animations/pulser.cpp b/animations/pulser.cpp index 15b3e76d9..f9425f635 100644 --- a/animations/pulser.cpp +++ b/animations/pulser.cpp @@ -123,7 +123,7 @@ void PulseAnimation::updateCurrentTime(int currentTime) qreal delta = Animation::easingCurve().valueForProgress( currentTime / qreal(duration())); if (m_under.data()->isIconBigger()) { - /* TODO: calculate the scale for bigger icon */ + m_under.data()->setScale(delta); } else { m_under.data()->setScale(delta); From 5506f87e55dc3c6a5380160da8274a915d44ac78 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 22:31:14 +0000 Subject: [PATCH 14/22] Trying to get the center right. svn path=/trunk/KDE/kdelibs/; revision=1094577 --- animations/pulsershadow.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/animations/pulsershadow.cpp b/animations/pulsershadow.cpp index c14caa38c..b250cd94d 100644 --- a/animations/pulsershadow.cpp +++ b/animations/pulsershadow.cpp @@ -78,7 +78,7 @@ void ShadowFake::setTarget(QGraphicsWidget *target) m_photo = QPixmap::fromImage( m_target->property("iconRepresentation").value()); resize(m_photo.size()); - + setTransformOriginPoint(target->geometry().center()); } else { resize(target->size()); @@ -97,10 +97,8 @@ void ShadowFake::setTarget(QGraphicsWidget *target) target->paint(&painter, &style, 0); paintSubChildren(&painter, &style, target); painter.end(); - + setTransformOriginPoint(geometry().center()); } - - setTransformOriginPoint(geometry().center()); } QGraphicsWidget *ShadowFake::target() const From 46eb95e99519753a14201aa2c17dbff88313a4e4 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Mon, 22 Feb 2010 23:04:46 +0000 Subject: [PATCH 15/22] Little fix for VC++ svn path=/trunk/KDE/kdelibs/; revision=1094583 --- private/animablegraphicswebview.cpp | 4 ++-- private/animablegraphicswebview_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index a1cded468..702a55233 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -164,9 +164,9 @@ bool AnimableGraphicsWebView::event(QEvent * event) return KGraphicsWebView::event(event); } -bool AnimableGraphicsWebView::gestureEvent(QGestureEvent *event) +void AnimableGraphicsWebView::gestureEvent(QGestureEvent *event) { - if (QGesture *pinch = event->gesture(Qt::PinchGesture)){ + if (QGesture *pinch == event->gesture(Qt::PinchGesture)){ QPinchGesture *pinchGesture = static_cast(pinch); setZoomFactor(zoomFactor() * pinchGesture->scaleFactor()); } diff --git a/private/animablegraphicswebview_p.h b/private/animablegraphicswebview_p.h index 2e323ac85..4fef52492 100644 --- a/private/animablegraphicswebview_p.h +++ b/private/animablegraphicswebview_p.h @@ -60,7 +60,7 @@ protected: void wheelEvent(QGraphicsSceneWheelEvent *event); private: - bool gestureEvent(QGestureEvent *event); + void gestureEvent(QGestureEvent *event); bool m_dragToScroll; QPointF m_lastScrollPosition; }; From abe1ca242accd230f64d29e9206e3c3684f5f764 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Mon, 22 Feb 2010 23:15:09 +0000 Subject: [PATCH 16/22] Fixed broken if. svn path=/trunk/KDE/kdelibs/; revision=1094587 --- private/animablegraphicswebview.cpp | 2 +- private/applethandle.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index 702a55233..01e02e069 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -166,7 +166,7 @@ bool AnimableGraphicsWebView::event(QEvent * event) void AnimableGraphicsWebView::gestureEvent(QGestureEvent *event) { - if (QGesture *pinch == event->gesture(Qt::PinchGesture)){ + if (QGesture *pinch = event->gesture(Qt::PinchGesture)){ QPinchGesture *pinchGesture = static_cast(pinch); setZoomFactor(zoomFactor() * pinchGesture->scaleFactor()); } diff --git a/private/applethandle.cpp b/private/applethandle.cpp index 6fce492da..038d3399a 100644 --- a/private/applethandle.cpp +++ b/private/applethandle.cpp @@ -731,6 +731,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event) bool AppletHandle::sceneEvent(QEvent *event) { switch (event->type()) { +#if 0 case QEvent::TouchEnd: { QTransform t = m_applet->transform(); QRectF geom = m_applet->geometry(); @@ -778,6 +779,11 @@ bool AppletHandle::sceneEvent(QEvent *event) } return true; +#endif + case QEvent::Gesture + { + QGesture *gesture = static_cast(event); + return true; } default: break; From 4dec145f854f51360c01ffde0d466edb06e061fe Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 22 Feb 2010 23:18:30 +0000 Subject: [PATCH 17/22] Safeguards in case of invalid image. svn path=/trunk/KDE/kdelibs/; revision=1094589 --- animations/pulsershadow.cpp | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/animations/pulsershadow.cpp b/animations/pulsershadow.cpp index b250cd94d..f95ded6ee 100644 --- a/animations/pulsershadow.cpp +++ b/animations/pulsershadow.cpp @@ -77,28 +77,30 @@ void ShadowFake::setTarget(QGraphicsWidget *target) m_iconBig = true; m_photo = QPixmap::fromImage( m_target->property("iconRepresentation").value()); - resize(m_photo.size()); - setTransformOriginPoint(target->geometry().center()); - } else { - - resize(target->size()); - - m_photo = QPixmap(size); - m_photo.fill(Qt::transparent); - - QPainter painter(&m_photo); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.fillRect(target->rect(), Qt::transparent); - - QStyleOptionGraphicsItem style; - style.exposedRect = target->boundingRect(); - style.rect = target->rect().toRect(); - - target->paint(&painter, &style, 0); - paintSubChildren(&painter, &style, target); - painter.end(); - setTransformOriginPoint(geometry().center()); + if ((m_photo.height() > 0) && (m_photo.width() > 0)) { + resize(m_photo.size()); + setTransformOriginPoint(target->geometry().center()); + return; + } } + + resize(target->size()); + + m_photo = QPixmap(size); + m_photo.fill(Qt::transparent); + + QPainter painter(&m_photo); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + painter.fillRect(target->rect(), Qt::transparent); + + QStyleOptionGraphicsItem style; + style.exposedRect = target->boundingRect(); + style.rect = target->rect().toRect(); + + target->paint(&painter, &style, 0); + paintSubChildren(&painter, &style, target); + painter.end(); + setTransformOriginPoint(geometry().center()); } QGraphicsWidget *ShadowFake::target() const From c8cd5ca2587b01396a4093a3d76735dec149ad33 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Mon, 22 Feb 2010 23:24:05 +0000 Subject: [PATCH 18/22] Sorry, I commited the wrong file. svn path=/trunk/KDE/kdelibs/; revision=1094591 --- private/applethandle.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/private/applethandle.cpp b/private/applethandle.cpp index 038d3399a..6fce492da 100644 --- a/private/applethandle.cpp +++ b/private/applethandle.cpp @@ -731,7 +731,6 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event) bool AppletHandle::sceneEvent(QEvent *event) { switch (event->type()) { -#if 0 case QEvent::TouchEnd: { QTransform t = m_applet->transform(); QRectF geom = m_applet->geometry(); @@ -779,11 +778,6 @@ bool AppletHandle::sceneEvent(QEvent *event) } return true; -#endif - case QEvent::Gesture - { - QGesture *gesture = static_cast(event); - return true; } default: break; From dc3e921b365ebceb711b99272946e04d0e4fa72e Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Tue, 23 Feb 2010 08:08:16 +0000 Subject: [PATCH 19/22] Added grabGesture() svn path=/trunk/KDE/kdelibs/; revision=1094755 --- private/animablegraphicswebview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index 01e02e069..17ad04798 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -32,6 +32,7 @@ using namespace Plasma; AnimableGraphicsWebView::AnimableGraphicsWebView(QGraphicsItem * parent) : KGraphicsWebView(parent) { + grabGesture(Qt::PinchGesture); m_dragToScroll = false; } From bb79950031549a5463dc7d7b73c4a8719f5dc06b Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Tue, 23 Feb 2010 08:35:02 +0000 Subject: [PATCH 20/22] Kinetic scroll zoom. svn path=/trunk/KDE/kdelibs/; revision=1094768 --- private/animablegraphicswebview.cpp | 29 ++++++++++------------------- private/animablegraphicswebview_p.h | 7 +++---- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index 17ad04798..81bc5fc1b 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -32,7 +32,6 @@ using namespace Plasma; AnimableGraphicsWebView::AnimableGraphicsWebView(QGraphicsItem * parent) : KGraphicsWebView(parent) { - grabGesture(Qt::PinchGesture); m_dragToScroll = false; } @@ -73,6 +72,16 @@ QPointF AnimableGraphicsWebView::scrollPosition() const } } +qreal AnimableGraphicsWebView::zoom() const +{ + return KGraphicsWebView::zoomFactor(); +} + +void AnimableGraphicsWebView::setZoom(const qreal zoom) +{ + KGraphicsWebView::setZoomFactor(zoom); +} + QRectF AnimableGraphicsWebView::viewportGeometry() const { QRectF result; @@ -155,23 +164,5 @@ void AnimableGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event) event->setAccepted(!m_dragToScroll); } -bool AnimableGraphicsWebView::event(QEvent * event) -{ - if (event->type() == QEvent::Gesture) { - gestureEvent(static_cast(event)); - return true; - } - - return KGraphicsWebView::event(event); -} - -void AnimableGraphicsWebView::gestureEvent(QGestureEvent *event) -{ - if (QGesture *pinch = event->gesture(Qt::PinchGesture)){ - QPinchGesture *pinchGesture = static_cast(pinch); - setZoomFactor(zoomFactor() * pinchGesture->scaleFactor()); - } -} - #include "animablegraphicswebview_p.moc" diff --git a/private/animablegraphicswebview_p.h b/private/animablegraphicswebview_p.h index 4fef52492..eb51e9e4e 100644 --- a/private/animablegraphicswebview_p.h +++ b/private/animablegraphicswebview_p.h @@ -29,8 +29,6 @@ #include -class QGestureEvent; - namespace Plasma { @@ -38,6 +36,7 @@ class AnimableGraphicsWebView : public KGraphicsWebView { Q_OBJECT + Q_PROPERTY(qreal zoomFactor READ zoom WRITE setZoom) Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition) Q_PROPERTY(QSizeF contentsSize READ contentsSize) Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry) @@ -51,16 +50,16 @@ public: QRectF viewportGeometry() const; void setDragToScroll(bool enable); bool dragToScroll() const; + qreal zoom() const; + void setZoom(const qreal zoom); protected: - bool event(QEvent * event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void wheelEvent(QGraphicsSceneWheelEvent *event); private: - void gestureEvent(QGestureEvent *event); bool m_dragToScroll; QPointF m_lastScrollPosition; }; From bbcac3459255284c5fd23f7b38e1bc1e1c7e237f Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Tue, 23 Feb 2010 10:26:42 +0000 Subject: [PATCH 21/22] Accept touch events. svn path=/trunk/KDE/kdelibs/; revision=1094827 --- private/animablegraphicswebview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index 81bc5fc1b..8ec9c7c45 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -32,6 +32,7 @@ using namespace Plasma; AnimableGraphicsWebView::AnimableGraphicsWebView(QGraphicsItem * parent) : KGraphicsWebView(parent) { + setAcceptTouchEvents(true); m_dragToScroll = false; } From ab5ddca4a86ac8e04724848d029650093954f234 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 23 Feb 2010 22:40:25 +0000 Subject: [PATCH 22/22] missing property svn path=/trunk/KDE/kdelibs/; revision=1095278 --- widgets/label.h | 1 + 1 file changed, 1 insertion(+) diff --git a/widgets/label.h b/widgets/label.h index 2ea1939d4..d672ae0b0 100644 --- a/widgets/label.h +++ b/widgets/label.h @@ -46,6 +46,7 @@ class PLASMA_EXPORT Label : public QGraphicsProxyWidget Q_PROPERTY(QString image READ image WRITE setImage) Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) Q_PROPERTY(bool hasScaledContents READ hasScaledContents WRITE setScaledContents) + Q_PROPERTY(bool textSelectable READ textSelectable WRITE setTextSelectable) Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) Q_PROPERTY(QLabel *nativeWidget READ nativeWidget)