diff options
6 files changed, 117 insertions, 9 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp index 0c92784e..3dcbf85e 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp @@ -92,6 +92,7 @@ void LScreenSaver::LockScreenNow(){ // =========== void LScreenSaver::ShowScreenSaver(){ if(DEBUG){ qDebug() << "Showing Screen Saver:" << QDateTime::currentDateTime().toString(); } + //QApplication::setOverrideCursor(QCursor::BlankCursor); SSRunning = true; updating = true; //Now remove any current Base widgets (prevent any lingering painting between sessions) @@ -141,6 +142,7 @@ void LScreenSaver::ShowLockScreen(){ } void LScreenSaver::HideScreenSaver(){ + //QApplication::restoreOverrideCursor(); if(DEBUG){ qDebug() << "Hiding Screen Saver:" << QDateTime::currentDateTime().toString(); } SSRunning = false; if(cBright>0){ LOS::setScreenBrightness(cBright); } //return to current brightness diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp index 9ad31f5c..943fe0a1 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp @@ -45,6 +45,7 @@ void SSBaseWidget::startPainting(){ //If a random plugin - grab one of the known plugins if(cplug=="random"){ QStringList valid = BaseAnimGroup::KnownAnimations(); + valid.removeAll("none"); //they want a screensaver - remove the "none" option from the valid list if(valid.isEmpty()){ cplug = "none"; } //no known plugins else{ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin } @@ -66,7 +67,6 @@ void SSBaseWidget::startPainting(){ } //Now start the animation(s) if(ANIM!=0){ - //if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); } if(ANIM->animationCount()>0){ if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); } ANIM->start(); 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 1e55dc76..2abd1f90 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 @@ -1,21 +1,24 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2015, Ken Moore +// Copyright (c) 2015-2017, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "BaseAnimGroup.h" //Include all the known subclasses here, then add a unique ID for it to the functions at the bottom -#include "SampleAnimation.h" +//#include "SampleAnimation.h" +#include "Fireflies.h" //============================== // PLUGIN LOADING/LISTING //============================== BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSettings *set){ //This is where we place all the known plugin ID's, and load the associated subclass - if(type == "sample"){ - return (new SampleAnimation(parent, set)); + if(type=="fireflies"){ + return (new FirefliesAnimation(parent,set)); + /*}else if(type == "sample"){ + return (new SampleAnimation(parent, set));*/ }else{ //Unknown screensaver, return a blank animation group return (new BaseAnimGroup(parent, set)); @@ -23,5 +26,5 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti } QStringList BaseAnimGroup::KnownAnimations(){ - return (QStringList() << "sample"); -}
\ No newline at end of file + return (QStringList() << "fireflies" << "none"); +} diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h index 3b442281..8798577f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2015, Ken Moore +// Copyright (c) 2015-2017, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -23,6 +23,7 @@ public: BaseAnimGroup(QWidget *parent, QSettings *set){ canvas = parent; settings = set; + canvas->setCursor( QCursor(Qt::BlankCursor) ); } ~BaseAnimGroup(){} 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 new file mode 100644 index 00000000..4e5acc3c --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h @@ -0,0 +1,101 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This class is the sample plugin for a ScreenSaver animation +//=========================================== +#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_FIREFLIES_ANIMATION_H +#define _LUMINA_DESKTOP_SCREEN_SAVER_FIREFLIES_ANIMATION_H + +#include "global-includes.h" +#include "BaseAnimGroup.h" +#include <QSequentialAnimationGroup> + +class Firefly : public QSequentialAnimationGroup{ + Q_OBJECT +private: + QWidget *fly; + QPropertyAnimation *movement, *flash; + int maxX, maxY; //maximum jitter in X/Y directions + QSize range; +private slots: + void LoopChanged(){ + //Adjust the movement animation a bit + movement->setStartValue(movement->endValue()); //start at the previous end point + QPoint pt = movement->startValue().toPoint(); + QPoint diff( (qrand()% maxX) - (maxX/2), (qrand()% maxY) - (maxY/2) ); + //Need to ensure it stays in the current box + if( (pt.x()+diff.x()) < 0 || (pt.x()+diff.x())>range.width()){ pt.setX(pt.x() - diff.x()); } //reverse the direction - otherwise will go out of bounds + else{ pt.setX( pt.x() + diff.x() ); } + if( (pt.y()+diff.y()) < 0 || (pt.y()+diff.y())>range.height()){ pt.setY(pt.y() - diff.y()); } //reverse the direction - otherwise will go out of bounds + else{ pt.setY( pt.y() + diff.y() ); } + movement->setEndValue(pt); + movement->setDuration( qrand() %500 + 1000); //between 1000->1500 ms animations for movements + //Adjust the flash duration/size a bit + flash->setDuration(qrand() %300 + 700); //700-1000 ms + int sz = qrand()%4 + 6; //6-10 pixel square + flash->setKeyValueAt(0.5, QSize(sz,sz)); //half-way point for the flash + fly->show(); + } + void stopped(){ fly->hide(); } + +public: + Firefly(QWidget *parent) : QSequentialAnimationGroup(parent){ + fly = new QWidget(parent); + range = parent->size(); + maxX = range.width()/4; maxY = range.height()/4; + fly->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(fly); + movement->setTargetObject(fly); + movement->setPropertyName("pos"); + movement->setEndValue( QPoint( qrand() % range.width(), qrand()%range.height()) ); //on anim start, this will become the starting point + //setup the flashing animation + flash = new QPropertyAnimation(fly); + flash->setTargetObject(fly); + flash->setPropertyName("size"); + flash->setStartValue(QSize(2,2)); + flash->setEndValue(flash->startValue()); + //now setup the order of the animations + this->setLoopCount(100); //do this 100 times + this->addAnimation(movement); + this->addAnimation(flash); + //Start up this firefly + LoopChanged(); //load initial values + fly->setGeometry( QRect(movement->startValue().toPoint(), flash->startValue().toSize()) ); + connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) ); + connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + } + ~Firefly(){} + +}; + +class FirefliesAnimation : public BaseAnimGroup{ + Q_OBJECT +private: + QList<Firefly*> fireflies; + +public: + FirefliesAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + ~FirefliesAnimation(){ + this->stop(); + //while(fireflies.length()>0){ fireflies.takeAt(0)->deleteLater(); } + } + + void LoadAnimations(){ + while(fireflies.length()>0){ fireflies.takeAt(0)->deleteLater(); } + canvas->setStyleSheet("background: black;"); + int number = settings->value("fireflies/number",100).toInt(); + for(int i=0; i<number; i++){ + if(fireflies.length()>number){ continue; } + Firefly *tmp = new Firefly(canvas); + this->addAnimation(tmp); + fireflies << tmp; + } + while( fireflies.length()>number){ fireflies.takeAt(number)->deleteLater(); } + } + +}; +#endif 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 adb1ed6c..919ec4e0 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,6 +1,7 @@ SOURCES += $$PWD/BaseAnimGroup.cpp HEADERS += $$PWD/BaseAnimGroup.h \ - $$PWD/SampleAnimation.h +# $$PWD/SampleAnimation.h \ + $${PWD}/Fireflies.h #FORMS += |