diff options
5 files changed, 98 insertions, 10 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp index 2abd1f90..1e86d489 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp @@ -9,6 +9,8 @@ //Include all the known subclasses here, then add a unique ID for it to the functions at the bottom //#include "SampleAnimation.h" #include "Fireflies.h" +#include "Grav.h" +#include "SampleAnimation.h" //============================== // PLUGIN LOADING/LISTING @@ -17,14 +19,16 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti //This is where we place all the known plugin ID's, and load the associated subclass if(type=="fireflies"){ return (new FirefliesAnimation(parent,set)); - /*}else if(type == "sample"){ - return (new SampleAnimation(parent, set));*/ - }else{ + }else if(type == "sample"){ + return (new SampleAnimation(parent, set)); + }else if(type == "grav") { + return (new GravAnimation(parent, set)); + }else { //Unknown screensaver, return a blank animation group return (new BaseAnimGroup(parent, set)); } } QStringList BaseAnimGroup::KnownAnimations(){ - return (QStringList() << "fireflies" << "none"); + return (QStringList() << "grav" /*<< "sample" << "fireflies"*/ << "none"); } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h index f1ef5fa3..a54b6cfd 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h @@ -79,8 +79,8 @@ private: public: FirefliesAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} - ~FirefliesAnimation(){ - this->stop(); + ~FirefliesAnimation(){ + this->stop(); //while(fireflies.length()>0){ fireflies.takeAt(0)->deleteLater(); } } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h new file mode 100644 index 00000000..9e5a580c --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h @@ -0,0 +1,84 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_GRAV_ANIMATION_H +#define _LUMINA_DESKTOP_SCREEN_SAVER_GRAV_ANIMATION_H + +#define PI 3.1416 + +#include "global-includes.h" +#include "BaseAnimGroup.h" +#include <QSequentialAnimationGroup> +#include <cmath> + +class Grav: public QSequentialAnimationGroup{ + Q_OBJECT +private: + QWidget *planet; + QPropertyAnimation *movement; + QSize range; +private slots: + void LoopChanged(){ + static double time = 0; + //Adjust the movement animation a bit + movement->setStartValue(movement->endValue()); //start at the previous end point + QPoint pt = movement->startValue().toPoint(); + QPoint diff((cos(pt.x()) - cos(pt.x()+time)), (sin(pt.y()) - sin(pt.y() +time)) ); + pt.setX( pt.x() + diff.x() ); + pt.setY( pt.y() + diff.y() ); + movement->setEndValue(pt); + movement->setDuration(2); + time+=0.01; + planet->show(); + } + void stopped(){planet->hide(); } + +public: + Grav(QWidget *parent) : QSequentialAnimationGroup(parent){ + planet = new QWidget(parent); + range = parent->size(); + planet->setStyleSheet("background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(215, 215, 143, 255), stop:0.83871 rgba(221, 235, 64, 140), stop:1 rgba(0, 0, 0, 255));"); + //setup the movement animation + movement = new QPropertyAnimation(planet); + movement->setTargetObject(planet); + movement->setPropertyName("pos"); + movement->setEndValue( QPoint( qrand() % range.width(), qrand()%range.height()) ); //on anim start, this will become the starting point + this->addAnimation(movement); + LoopChanged(); //load initial values + planet->setGeometry( QRect(movement->startValue().toPoint(), QSize(15, 15))); + connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) ); + connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + } + ~Grav(){} + +}; + +class GravAnimation : public BaseAnimGroup{ + Q_OBJECT +private: + QList<Grav*> planets; + +public: + GravAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + ~GravAnimation(){ + this->stop(); + } + + void LoadAnimations(){ + while(planets.length()>0){ planets.takeAt(0)->deleteLater(); } + canvas->setStyleSheet("background: black;"); + int number = settings->value("planets/number",10).toInt(); + for(int i=0; i<number; i++){ + if(planets.length()>number){ continue; } + Grav *tmp = new Grav(canvas); + this->addAnimation(tmp); + planets << tmp; + } + while(planets.length()>number){planets.takeAt(number)->deleteLater(); } + } + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h index 972a5109..c2bb0c96 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h @@ -20,7 +20,7 @@ private: public: SampleAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} ~SampleAnimation(){ this->stop(); delete ball; } - + void LoadAnimations(){ //qDebug() << "Loading Sample Animation"; ball = new QWidget(canvas); diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri index 919ec4e0..06f2b38f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri @@ -1,7 +1,7 @@ SOURCES += $$PWD/BaseAnimGroup.cpp HEADERS += $$PWD/BaseAnimGroup.h \ -# $$PWD/SampleAnimation.h \ - $${PWD}/Fireflies.h - + $$PWD/SampleAnimation.h \ + $${PWD}/Fireflies.h \ + $${PWD}/Grav.h #FORMS += |