Revert "kdeplasma-addons: adjust to plasma animations support removal"

This reverts commit 3851bc2700.
This commit is contained in:
Ivailo Monev 2015-10-28 09:36:32 +02:00
parent dacf91e59a
commit 4cbba576f7
23 changed files with 191 additions and 14 deletions

View file

@ -34,12 +34,14 @@
#include <KLineEdit>
#include <KTextBrowser>
#include <Plasma/Animator>
#include <Plasma/IconWidget>
#include <Plasma/LineEdit>
#include <Plasma/TextBrowser>
#include <Plasma/Theme>
#include <Plasma/ToolTipContent>
#include <Plasma/ToolTipManager>
#include <plasma/animations/animation.h>
#define AUTO_DEFINE_TIMEOUT 500
@ -164,6 +166,13 @@ QGraphicsWidget *DictApplet::graphicsWidget()
m_graphicsWidget->setLayout(m_layout);
m_graphicsWidget->setPreferredSize(500, 200);
Animation *zoomAnim =
Plasma::Animator::create(Plasma::Animator::ZoomAnimation);
zoomAnim->setTargetWidget(m_wordEdit);
zoomAnim->setProperty("zoom", 1.0);
zoomAnim->setProperty("duration", 350);
zoomAnim->start(QAbstractAnimation::DeleteWhenStopped);
return m_graphicsWidget;
}

View file

@ -28,6 +28,9 @@
#include <KDebug>
#include <KGlobalSettings>
#include <Plasma/Animation>
#include <Plasma/Animator>
Fifteen::Fifteen(QGraphicsItem* parent, int size)
: QGraphicsWidget(parent),
m_size(0), // this will immediately get overwritten by setSize(size) below, but needs an initial value
@ -365,12 +368,36 @@ void Fifteen::movePiece(Piece *piece, int newX, int newY)
int width = contentsRect().width() / m_size;
int height = contentsRect().height() / m_size;
QPointF pos = QPointF(newX * width, newY * height);
// stop and delete any existing animation
Plasma::Animation *animation = m_animations.value(piece).data();
if (animation) {
if (animation->state() == QAbstractAnimation::Running) {
animation->stop();
}
delete animation;
animation = NULL;
}
animation = Plasma::Animator::create(Plasma::Animator::SlideAnimation, this);
animation->setTargetWidget(piece);
animation->setProperty("easingCurve", QEasingCurve::InOutQuad);
animation->setProperty("movementDirection", Plasma::Animation::MoveAny);
animation->setProperty("distancePointF", pos - piece->pos());
m_animations[piece] = animation;
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
void Fifteen::toggleBlank(bool show)
{
if (show && !m_blank->isVisible()) {
m_blank->show();
if (show) {
if (!m_blank->isVisible()) {
Plasma::Animation *animation = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
animation->setProperty("startOpacity", 0.0);
animation->setProperty("targetOpacity", 1.0);
animation->setTargetWidget(m_blank);
animation->start(QAbstractAnimation::DeleteWhenStopped);
m_blank->show();
}
} else {
m_blank->hide();
}

View file

@ -31,6 +31,7 @@
#include <QTimer>
#include <plasma/applet.h>
#include <plasma/animator.h>
class ConfigDialog;
class QGraphicsSceneDragDropEvent;

View file

@ -42,6 +42,9 @@ class QTextLayout;
class QString;
class QAction;
// Plasma
#include <Plasma/Animator>
class Tasks;
class TaskGroupItem;
class LayoutWidget;

View file

@ -28,6 +28,8 @@
// Plasma
#include <Plasma/Theme>
#include <Plasma/Animator>
#include <Plasma/Animation>
#include <Plasma/PaintUtils>
KimpanelLabelGraphics::KimpanelLabelGraphics(RenderType type, QGraphicsItem *parent)

View file

@ -42,6 +42,8 @@
#include <KStandardAction>
#include <KAction>
#include <Plasma/Animator>
#include <Plasma/Animation>
#include <Plasma/PushButton>
#include <Plasma/Theme>
@ -668,6 +670,18 @@ void Notes::createTextFormatingWidgets()
m_buttonAnimGroup = new QParallelAnimationGroup(this);
for (int i = 0; i < 6; i++){
m_buttonAnim[i] = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
m_buttonAnimGroup->addAnimation(m_buttonAnim[i]);
}
m_buttonAnim[0]->setTargetWidget(m_buttonBold);
m_buttonAnim[1]->setTargetWidget(m_buttonItalic);
m_buttonAnim[2]->setTargetWidget(m_buttonUnderline);
m_buttonAnim[3]->setTargetWidget(m_buttonStrikeThrough);
m_buttonAnim[4]->setTargetWidget(m_buttonCenter);
m_buttonAnim[5]->setTargetWidget(m_buttonFill);
showOptions(false);
connect(m_buttonOption->nativeWidget(), SIGNAL(toggled(bool)), this, SLOT(showOptions(bool)));
@ -678,6 +692,14 @@ void Notes::showOptions(bool show)
{
m_buttonOption->nativeWidget()->setDown(show);
qreal targetOpacity = show ? 1 : 0;
qreal startOpacity = 1 - targetOpacity;
for (int i = 0; i < 6; i++){
m_buttonAnim[i]->setProperty("startOpacity", startOpacity);
m_buttonAnim[i]->setProperty("targetOpacity", targetOpacity);
}
m_buttonAnimGroup->start();
}

View file

@ -109,6 +109,7 @@ class Notes : public Plasma::PopupApplet
TopWidget *m_topWidget;
QParallelAnimationGroup *m_buttonAnimGroup;
Plasma::Animation *m_buttonAnim[6];
};
#endif

View file

@ -34,6 +34,7 @@
#include <KIcon>
// Plasma
#include <Plasma/Animator>
#include <Plasma/FrameSvg>
#include <Plasma/ScrollBar>
#include <Plasma/Svg>

View file

@ -33,6 +33,7 @@
// Plasma Includes
#include <Plasma/Theme>
#include <Plasma/Service>
#include <Plasma/Animator>
#include <Plasma/TreeView>
#include <Plasma/TabBar>
#include <Plasma/Label>

View file

@ -31,6 +31,8 @@
#include <QStringList>
#include <Plasma/Theme>
#include <Plasma/Animator>
#include <Plasma/Animation>
#include <Plasma/IconWidget>
#include <Plasma/Service>
@ -212,7 +214,28 @@ void TaskEditor::startAnimation(QSizeF endSize, bool show) {
fullSize = endSize;
resize(fullSize);
animationFinished();
Plasma::Animation *animation = m_fadeAnimation.data();
if (!animation) {
animation = Plasma::Animator::create(Plasma::Animator::FadeAnimation);
animation->setTargetWidget(this);
animation->setProperty("startValue", 0.0);
animation->setProperty("endValue", 1.0);
animation->setProperty("duration", 100);
m_fadeAnimation = animation;
connect(animation, SIGNAL(finished()), this, SLOT(animationFinished()));
} else if (animation->state() == QAbstractAnimation::Running) {
animation->pause();
}
if (show) {
animation->setProperty("easingCurve", QEasingCurve::InQuad);
animation->setProperty("direction", QAbstractAnimation::Forward);
animation->start(QAbstractAnimation::KeepWhenStopped);
} else {
animation->setProperty("easingCurve", QEasingCurve::OutQuad);
animation->setProperty("direction", QAbstractAnimation::Backward);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
}
void TaskEditor::animationFinished() {

View file

@ -26,6 +26,7 @@
#include <QWeakPointer>
#include <QAbstractAnimation>
#include <plasma/plasma_export.h>
#include <plasma/animator.h>
#include <plasma/dataengine.h>

View file

@ -32,6 +32,8 @@
#include <Plasma/Containment>
#include <Plasma/FrameSvg>
#include <Plasma/Animator>
#include <Plasma/Animation>
#include "groupingcontainment.h"
#include "freehandle.h"
@ -84,6 +86,14 @@ void AbstractGroupPrivate::destroyGroup()
delete q;
}
void AbstractGroupPrivate::startDestroyAnimation()
{
Plasma::Animation *zoomAnim = Plasma::Animator::create(Plasma::Animator::ZoomAnimation);
q->connect(zoomAnim, SIGNAL(finished()), q, SLOT(destroyGroup()));
zoomAnim->setTargetWidget(q);
zoomAnim->start();
}
void AbstractGroupPrivate::appletDestroyed(Plasma::Applet *applet)
{
if (applets.contains(applet)) {
@ -97,7 +107,7 @@ void AbstractGroupPrivate::appletDestroyed(Plasma::Applet *applet)
emit q->configNeedsSaving();
if (destroying && (q->children().count() == 0)) {
destroyGroup();
startDestroyAnimation();
destroying = false;
}
}
@ -119,7 +129,7 @@ void AbstractGroupPrivate::subGroupDestroyed(AbstractGroup *subGroup)
emit q->configNeedsSaving();
if (destroying && (q->children().count() == 0)) {
destroyGroup();
startDestroyAnimation();
destroying = false;
}
}
@ -470,7 +480,7 @@ void AbstractGroup::destroy()
d->destroying = true;
if (children().count() == 0) {
d->destroyGroup();
d->startDestroyAnimation();
return;
}

View file

@ -26,6 +26,7 @@
#include <QWeakPointer>
#include <QPropertyAnimation>
#include <Plasma/Animator>
#include <Plasma/Svg>
#include "handle.h"

View file

@ -35,6 +35,8 @@
#include <KIcon>
#include <KPushButton>
#include <Plasma/Animation>
#include <Plasma/Animator>
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/ItemBackground>
@ -63,6 +65,10 @@ GroupIconList::GroupIconList(Plasma::Location loc, QGraphicsItem *parent)
m_arrowsSvg->setContainsMultipleImages(true);
m_arrowsSvg->resize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
m_slide = Plasma::Animator::create(Plasma::Animator::SlideAnimation);
m_slide->setEasingCurve(QEasingCurve::Linear);
connect(m_slide, SIGNAL(finished()), this, SLOT(scrollStepFinished()));
//init arrows
m_upLeftArrow = new Plasma::ToolButton(this);
m_upLeftArrow->setPreferredSize(IconSize(KIconLoader::Panel), IconSize(KIconLoader::Panel));
@ -81,6 +87,8 @@ GroupIconList::GroupIconList(Plasma::Location loc, QGraphicsItem *parent)
m_listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_listLayout = new QGraphicsLinearLayout(m_listWidget);
m_slide->setTargetWidget(m_listWidget);
m_listWidget->installEventFilter(this);
m_scrollWidget->installEventFilter(this);
@ -108,6 +116,7 @@ GroupIconList::GroupIconList(Plasma::Location loc, QGraphicsItem *parent)
GroupIconList::~GroupIconList()
{
delete m_slide;
}
bool GroupIconList::eventFilter(QObject *obj, QEvent *event)
@ -303,7 +312,16 @@ void GroupIconList::scrollTo(int index)
m_firstItemIndex = index;
scrollStepFinished();
m_slide->stop();
if (m_orientation == Qt::Horizontal) {
m_slide->setProperty("movementDirection", Plasma::Animation::MoveLeft);
} else {
m_slide->setProperty("movementDirection", Plasma::Animation::MoveUp);
}
m_slide->setProperty("distance", move);
m_slide->start();
manageArrows();
}
@ -325,8 +343,11 @@ void GroupIconList::scrollStepFinished()
m_scrollingDueToWheel = false;
//keep scrolling if the button is held down
if (m_upLeftArrow->isEnabled() && m_upLeftArrow->isDown()) {
scrollUpLeft();
bool movingLeftUp = m_slide->property("distance").value<qreal>() < 0;
if (movingLeftUp) {
if (m_upLeftArrow->isEnabled() && m_upLeftArrow->isDown()) {
scrollUpLeft();
}
} else if (m_downRightArrow->isEnabled() && m_downRightArrow->isDown()) {
scrollDownRight();
}

View file

@ -35,6 +35,8 @@
#include <netwm.h>
#include <Plasma/Corona>
#include <Plasma/Animator>
#include <Plasma/Animation>
#include <Plasma/WindowEffects>
#include "abstractgroup.h"
@ -408,7 +410,14 @@ void GroupingContainmentPrivate::onWidgetMoved(QGraphicsWidget *widget)
QRectF newGeom(widget->geometry());
if (geom != newGeom) {
widgetMovedAnimationComplete();
Plasma::Animation *anim = Plasma::Animator::create(Plasma::Animator::GeometryAnimation);
if (anim) {
q->connect(anim, SIGNAL(finished()), q, SLOT(widgetMovedAnimationComplete()));
anim->setTargetWidget(widget);
anim->setProperty("startGeometry", geom);
anim->setProperty("targetGeometry", newGeom);
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
} else {
blockSceneEventFilter = false;
}
@ -614,6 +623,12 @@ void GroupingContainment::addGroup(AbstractGroup *group, const QPointF &pos)
if (!d->loading && !pos.isNull()) {
d->manageGroup(group, pos);
Plasma::Animation *anim = Plasma::Animator::create(Plasma::Animator::AppearAnimation);
if (anim) {
anim->setTargetWidget(group);
anim->setDirection(QAbstractAnimation::Backward);
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
}
group->installEventFilter(this);

View file

@ -33,6 +33,8 @@
#include <Plasma/Theme>
#include <Plasma/PaintUtils>
#include <Plasma/ToolButton>
#include <Plasma/Animator>
#include <Plasma/Animation>
#include "spacer.h"
#include "gridmanager.h"
@ -592,7 +594,15 @@ bool GridGroup::eventFilter(QObject *obj, QEvent *event)
QPointF p(child->mapFromScene(static_cast<QGraphicsSceneMouseEvent *>(event)->scenePos()));
checkCorner(p, child);
child->installEventFilter(this);
Plasma::Animation *anim = Plasma::Animator::create(Plasma::Animator::GeometryAnimation);
if (anim) {
child->removeEventFilter(this);
anim->setTargetWidget(child);
anim->setProperty("startGeometry", geom);
anim->setProperty("targetGeometry", child->geometry());
anim->start(QAbstractAnimation::DeleteWhenStopped);
connect(anim, SIGNAL(finished()), this, SLOT(resizeDone()));
}
m_showGrid = false;
update();
@ -608,6 +618,12 @@ bool GridGroup::eventFilter(QObject *obj, QEvent *event)
return AbstractGroup::eventFilter(obj, event);
}
void GridGroup::resizeDone()
{
Plasma::Animation *anim = static_cast<Plasma::Animation *>(sender());
anim->targetWidget()->installEventFilter(this);
}
void GridGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
AbstractGroup::paint(painter, option, widget);

View file

@ -55,6 +55,7 @@ class GridGroup : public AbstractGroup
void removeRowOrColumn();
void appletRemoved(Plasma::Applet *applet);
void subGroupRemoved(AbstractGroup *group);
void resizeDone();
private:
void updateChild(QGraphicsWidget *child);

View file

@ -27,7 +27,9 @@
#include <Plasma/Theme>
#include <Plasma/PaintUtils>
#include <Plasma/Animator>
#include <Plasma/ToolButton>
#include <Plasma/Animation>
static const int SIZE = 30;
@ -65,6 +67,12 @@ GridManager::GridManager(QGraphicsItem *parent)
//FIXME: QGraphicsLayout is bugged and it won't lay out the items until a resize is called.
resize(50, 50);
m_fadeAnim = Plasma::Animator::create(Plasma::Animator::FadeAnimation);
m_fadeAnim->setTargetWidget(this);
m_fadeAnim->setProperty("startOpacity", 0);
m_fadeAnim->setProperty("targetOpacity", 1);
connect(m_fadeAnim, SIGNAL(finished()), this, SLOT(animationFinished()));
connect(m_newRowCol, SIGNAL(clicked()), this, SIGNAL(newClicked()));
connect(m_delRowCol, SIGNAL(clicked()), this, SIGNAL(deleteClicked()));
connect(m_newRowCol2, SIGNAL(clicked()), this, SIGNAL(newClicked()));
@ -112,7 +120,8 @@ void GridManager::setLocation(Plasma::Location location)
if (isVisible()) {
m_replace = true;
animationFinished();
m_fadeAnim->setDirection(QAbstractAnimation::Backward);
m_fadeAnim->start();
} else {
place();
}
@ -169,21 +178,28 @@ void GridManager::place()
void GridManager::showAnimated()
{
show();
animationFinished();
m_fadeAnim->setDirection(QAbstractAnimation::Forward);
m_fadeAnim->start();
}
void GridManager::hideAnimated()
{
m_location = Plasma::Floating;
m_replace = false;
animationFinished();
m_fadeAnim->setDirection(QAbstractAnimation::Backward);
m_fadeAnim->start();
}
void GridManager::animationFinished()
{
if (m_fadeAnim->direction() == QAbstractAnimation::Backward) {
hide();
if (m_replace) {
place();
}
}
}
void GridManager::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)

View file

@ -28,6 +28,7 @@ class QGraphicsLinearLayout;
namespace Plasma {
class ToolButton;
class Animation;
}
class GridManager : public QGraphicsWidget
@ -62,6 +63,7 @@ class GridManager : public QGraphicsWidget
Plasma::ToolButton *m_newRowCol2;
Plasma::ToolButton *m_delRowCol;
Plasma::ToolButton *m_delRowCol2;
Plasma::Animation *m_fadeAnim;
bool m_replace;
};

View file

@ -24,6 +24,7 @@
#include <QtCore/QObject>
#include <QtGui/QGraphicsObject>
#include <Plasma/Animator>
#include <Plasma/Svg>
class QGraphicsView;

View file

@ -21,6 +21,7 @@
#include "ScrollBar.h"
#include "Widget.h"
#include <Plasma/Animator>
#include <QGraphicsSceneWheelEvent>
#include <lancelot/layouts/FullBorderLayout.h>

View file

@ -21,6 +21,7 @@
#include <KStandardDirs>
#include <Plasma/Theme>
#include <Plasma/Animator>
#include "backgroundlistmodel.h"
#include "backgrounddelegate.h"
//#include "ksmserver_interface.h"

View file

@ -31,6 +31,7 @@
#include <KLocalizedString>
#include <KPushButton>
#include <KStandardDirs>
#include <Plasma/Animator>
#include <Plasma/Theme>
// Libplasmaweather includes