diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver')
11 files changed, 326 insertions, 45 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp index cdcf2434..0ff70142 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp @@ -10,17 +10,15 @@ #include <unistd.h> #define NUMTRIES 3 -//#define WAITMINS 1 #define DEBUG 1 LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScreen()){ ui->setupUi(this); waittime = new QTimer(this); - //waittime->setInterval(WAITMINS*60000); //(too many attempts in short time) waittime->setSingleShot(true); refreshtime = new QTimer(this); //timer to update the wait time display refreshtime->setInterval(6000); //6 seconds (1/10 second) - + connect(ui->tool_unlock, SIGNAL(clicked()), this, SLOT(TryUnlock()) ); connect(ui->line_password, SIGNAL(returnPressed()), this, SLOT(TryUnlock()) ); connect(ui->line_password, SIGNAL(textEdited(QString)), this, SIGNAL(InputDetected()) ); @@ -30,7 +28,7 @@ LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScr } LLockScreen::~LLockScreen(){ - + } void LLockScreen::LoadSystemDetails(){ @@ -47,7 +45,7 @@ void LLockScreen::aboutToHide(){ ui->line_password->clear(); ui->line_password->clearFocus(); if(refreshtime->isActive()){ refreshtime->stop(); } -} +} void LLockScreen::aboutToShow(){ if(!waittime->isActive()){ @@ -61,21 +59,17 @@ void LLockScreen::aboutToShow(){ UpdateLockInfo(); ui->line_password->clear(); ui->line_password->setFocus(); -} +} // ================= // PRIVATE SLOTS // ================= void LLockScreen::UpdateLockInfo(){ QString info; - /*if(triesleft>0 && triesleft<NUMTRIES ){ - if(triesleft==1){info = tr("1 Attempt Left"); } - else{info = QString(tr("%1 Attempts Left")).arg(QString::number(triesleft)); } - }else*/ - if(waittime->isActive()){ + if(waittime->isActive()){ info = tr("Too Many Failures")+"\n"+ QString(tr("Wait %1 Minutes")).arg( QString::number(qRound(waittime->remainingTime()/6000.0)/10.0) ); }else if(attempts>0){ info.append("\n"+QString(tr("Failed Attempts: %1")).arg(QString::number(attempts)) ); } - ui->label_info->setText(info); + ui->label_info->setText(info); } void LLockScreen::TryUnlock(){ @@ -89,11 +83,11 @@ void LLockScreen::TryUnlock(){ this->setEnabled(true); }else{ triesleft--; - if(triesleft>0){ + if(triesleft>0){ this->setEnabled(true); - }else{ + }else{ waittime->setInterval( (attempts/NUMTRIES)*60000); - waittime->start(); + waittime->start(); refreshtime->start(); } ui->line_password->setFocus(); 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 3dcbf85e..bfcfa54d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp @@ -8,7 +8,7 @@ #include <QScreen> #include <QApplication> -#define DEBUG 1 +#define DEBUG 0 LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint){ starttimer = new QTimer(this); @@ -17,7 +17,7 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo locktimer->setSingleShot(true); hidetimer = new QTimer(this); hidetimer->setSingleShot(true); - + LOCKER = new LLockScreen(this); LOCKER->hide(); settings = new QSettings("lumina-desktop","lumina-screensaver",this); @@ -33,7 +33,7 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo } LScreenSaver::~LScreenSaver(){ - + } bool LScreenSaver::isLocked(){ @@ -66,7 +66,7 @@ void LScreenSaver::reloadSettings(){ hidetimer->setInterval( settings->value("hidesecs",15).toInt() * 1000 ); } -void LScreenSaver::newInputEvent(){ +void LScreenSaver::newInputEvent(){ if(updating){ return; } //in the middle of making changes which could cause an event if(DEBUG){ qDebug() << "New Input Event"; } if(SSRunning && SSLocked){ @@ -79,7 +79,6 @@ void LScreenSaver::newInputEvent(){ HideScreenSaver(); } UpdateTimers(); - } void LScreenSaver::LockScreenNow(){ @@ -119,7 +118,7 @@ void LScreenSaver::ShowScreenSaver(){ if(!this->isActiveWindow()){ this->raise(); this->show(); - this->activateWindow(); + this->activateWindow(); } for(int i=0; i<BASES.length(); i++){ BASES[i]->show(); @@ -149,10 +148,11 @@ void LScreenSaver::HideScreenSaver(){ if(!SSLocked){ this->hide(); emit ClosingScreenSaver(); + emit LockStatusChanged(false); } - for(int i=0; i<BASES.length(); i++){ + for(int i=0; i<BASES.length(); i++){ BASES[i]->hide(); - BASES[i]->stopPainting(); + BASES[i]->stopPainting(); } UpdateTimers(); } @@ -171,6 +171,7 @@ void LScreenSaver::LockScreen(){ if(SSLocked){ return; } if(DEBUG){ qDebug() << "Locking Screen:" << QDateTime::currentDateTime().toString(); } SSLocked = true; + emit LockStatusChanged(true); LOCKER->LoadSystemDetails(); UpdateTimers(); } @@ -178,6 +179,7 @@ void LScreenSaver::LockScreen(){ void LScreenSaver::SSFinished(){ if(DEBUG){ qDebug() << "Screensaver Finished:" << QDateTime::currentDateTime().toString(); } SSLocked = false; + emit LockStatusChanged(false); HideLockScreen(); HideScreenSaver(); } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h index d27db37e..18f12fab 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h @@ -19,7 +19,7 @@ public: ~LScreenSaver(); bool isLocked(); - + private: QTimer *starttimer, *locktimer, *hidetimer; QSettings *settings; @@ -48,6 +48,7 @@ private slots: signals: void StartingScreenSaver(); void ClosingScreenSaver(); + void LockStatusChanged(bool locked); protected: void mouseMoveEvent(QMouseEvent*){ 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 943fe0a1..b31ef793 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp @@ -25,7 +25,7 @@ SSBaseWidget::SSBaseWidget(QWidget *parent, QSettings *set) : QWidget(parent){ SSBaseWidget::~SSBaseWidget(){ if(ANIM!=0){ this->stopPainting(); } } - + void SSBaseWidget::setPlugin(QString plug){ plug = plug.toLower(); if(validPlugs.contains(plug) || plug=="random"){ plugType = plug; } @@ -38,12 +38,12 @@ void SSBaseWidget::setPlugin(QString plug){ void SSBaseWidget::startPainting(){ cplug = plugType; //free up any old animation instance - if(ANIM!=0){ + if(ANIM!=0){ ANIM->stop(); ANIM->clear(); - delete ANIM; ANIM = 0; - } + delete ANIM; ANIM = 0; + } //If a random plugin - grab one of the known plugins - if(cplug=="random"){ + 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 @@ -67,9 +67,9 @@ void SSBaseWidget::startPainting(){ } //Now start the animation(s) if(ANIM!=0){ - if(ANIM->animationCount()>0){ + if(ANIM->animationCount()>0){ if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); } - ANIM->start(); + 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 2abd1f90..017eaf9f 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,9 @@ //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" +#include "Text.h" //============================== // PLUGIN LOADING/LISTING @@ -17,14 +20,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 == "grav") { + return (new GravAnimation(parent, set)); + }else if(type == "text") { + return (new TextAnimation(parent, set)); + }else { //Unknown screensaver, return a blank animation group return (new BaseAnimGroup(parent, set)); } } - + QStringList BaseAnimGroup::KnownAnimations(){ - return (QStringList() << "fireflies" << "none"); + return (QStringList() << "fireflies" << "grav" << "text"); } 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 8798577f..b1324e78 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 @@ -26,13 +26,13 @@ public: canvas->setCursor( QCursor(Qt::BlankCursor) ); } ~BaseAnimGroup(){} - + //============================== // PLUGIN LOADING/LISTING (Change in the .cpp file) //============================== static BaseAnimGroup* NewAnimation(QString type, QWidget *parent, QSettings *set); static QStringList KnownAnimations(); - + }; #endif 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..75dfb1ae 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 @@ -46,7 +46,7 @@ public: 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));"); + 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:0.99 rgba(0, 0, 0, 255), stop:1 transparent);"); //setup the movement animation movement = new QPropertyAnimation(fly); movement->setTargetObject(fly); @@ -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..ad1b1122 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h @@ -0,0 +1,185 @@ +//=========================================== +// 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 + +//PI is equal to 2*pi +#define PI 6.2832 + +#include "global-includes.h" +#include "BaseAnimGroup.h" +#include <QParallelAnimationGroup> +#include <QtMath> + +class Grav: public QParallelAnimationGroup{ + Q_OBJECT +private: + QWidget *planet; + QPropertyAnimation *orbit; + QSize range; + QList<QPoint> path; + double radius; + + void setupLoop(QPoint start, QPoint *ref){ + orbit->setStartValue(start); + + //Used to find overall speed. Distance from the planet to the sun + radius = qSqrt( (qPow(start.x()-ref->x(),2) + qPow(start.y()-ref->y(),2) )); + + //Number of frames in animation. Increase for smother motion + double step = 1000.0; + + //Random values that give the eliptical pattern to the orbit. Between 0.4 and 2.3 + double xrand = (qrand()%20+4)/10.0; + double yrand = (qrand()%20+4)/10.0; + + QPoint firstP = QPoint(ref->x() + xrand*start.x()*(qCos(0/step) -qSin(0/step)), ref->y() + yrand*start.y()*(qCos(0/step) -qSin(0/step))); + QPoint lastP = QPoint(ref->x() + xrand*start.x()*(qCos(PI/step) -qSin(PI/step)), ref->y() + yrand*start.y()*(qCos(PI/step) -qSin(PI/step))); + //orbit->setKeyValueAt(0, firstP); + //orbit->setKeyValueAt(1, lastP); + path.push_back(firstP); + + //Loops through all steps and creates all the points of the orbit + for(int i=1; i<step; i++) { + //Calculates the new point, including gravitational pull and eccentricity. Goes from 0 to 2PI in steps. + double newX = ref->x() + xrand*start.x()*(qCos((PI*i)/step) -qSin((PI*i)/step)); + double newY = ref->y() + yrand*start.y()*(qSin((PI*i)/step) + qCos((PI*i)/step)); + + //Calculates the radius from the sun as the distance between the points + radius = (qSqrt( (qPow(newX-ref->x(),2) + qPow(newY-ref->y(),2) ))); + + //Creates a new point and creates a key as part of the animation + QPoint newLoc = QPoint(newX, newY); + //orbit->setKeyValueAt(i/step, newLoc); + path.push_back(newLoc); + } + + //Sets the time for a full orbit. Increasing makes the orbit slower. + path.push_back(lastP); + } +private slots: + void LoopChanged(int loop){ + //Adjust the orbit animation a bit + if(loop >= 0) { + orbit->setStartValue(orbit->endValue()); //start at the previous end point + orbit->setEndValue(path.at(loop%1000)); + orbit->setDuration(10); + } + } + void stopped(){ qDebug() << "Planet stopped"; planet->hide();} + +public: + Grav(QWidget *parent) : QParallelAnimationGroup(parent){ + planet = new QWidget(parent); + range = parent->size(); + QPoint center = parent->geometry().center(); + + //Creates a random planet size. Between 12 and 45 pixels + double planet_radius = 1.75* ((qrand()%20)+7); + + //Creates a random color in RGB, then creates a circular gradient + QString color = "rgba(" + QString::number(qrand() % 256) + ", " + QString::number(qrand() % 256) + ", " + QString::number(qrand() % 256); + QString style = "background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 " + color+ + ", 255)" + " , stop:0.83871 " + color + ", 140)" + " , stop:0.99 rgba(0, 0, 0, 255), stop:1 transparent);"; + planet->setStyleSheet(style); + + //setup the orbit animation + orbit = new QPropertyAnimation(planet); + orbit->setPropertyName("pos"); + orbit->setTargetObject(planet); + + //Creates the random position of the planet, making sure it isn't too close to the sun + int randwidth = qrand()%(range.width()/2); + if(randwidth < range.width() + 100 and randwidth > range.width() - 100) randwidth = 100; + int randheight= qrand()%(range.height()/2); + if(randheight < range.height() + 100 and randheight > range.height() - 100) randheight = 100; + + //Creates all frames for the animation + setupLoop(QPoint(randwidth, randheight), ¢er); + this->addAnimation(orbit); + planet->show(); + + //Ensures the screensaver will not stop until the user wishes to login or it times out + this->setLoopCount(2000); //number of orbits + orbit->setEndValue(path.at(0)); + LoopChanged(0); //load initial values + + //Sets the initial size and location of the planet + planet->setGeometry(QRect(orbit->startValue().toPoint(), QSize(planet_radius, planet_radius))); + connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged(int)) ); + connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + } + ~Grav(){} + +}; + +class GravAnimation : public BaseAnimGroup{ + Q_OBJECT +private: + QList<Grav*> planets; + QWidget *sun; + QPropertyAnimation *wobble; + +private slots: + void checkFinished(){ + int running = 0; + for(int i=0; i<this->animationCount(); i++){ + if(this->animationAt(i)->state()==QAbstractAnimation::Running){ running++; } + } + if(running<=1){ wobble->stop(); emit wobble->finished();} + } + +public: + GravAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + ~GravAnimation(){ + //this->stop(); + } + + void LoadAnimations(){ + //Creates the sun, which is a thin shell with a gradient from green to yellow + sun = new QWidget(canvas); + QPoint center = canvas->geometry().center(); + QString sunstyle = QStringLiteral("background-color:qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, ") + + QStringLiteral("stop:0 rgba(0, 0, 0, 0), stop:0.38 rgba(0, 0, 0, 0), stop:0.4 rgba(82, 121, 76, 33), stop:0.5 rgba(159, 235, 148, 64), ") + + QStringLiteral("stop:0.6 rgba(255, 238, 150, 129), stop:0.7 rgba(0, 0, 0, 0));"); + sun->setStyleSheet(sunstyle); + + //Creates the sun's pulsing animation + wobble = new QPropertyAnimation(sun); + wobble->setPropertyName("geometry"); + wobble->setTargetObject(sun); + QRect initgeom = QRect(center-QPoint(12,12), QSize(60, 60)); + wobble->setStartValue(initgeom); + wobble->setKeyValueAt(0, initgeom ); //starting point + wobble->setKeyValueAt(1, initgeom ); //starting point + wobble->setKeyValueAt(0.5, QRect(center-QPoint(18,18), QSize(90, 90))); //starting point + wobble->setDuration(2000); + wobble->setLoopCount(-1); + this->addAnimation(wobble); + sun->show(); + sun->setGeometry(initgeom); + while(planets.length()>0){ planets.takeAt(0)->deleteLater(); } + + //Gives the screensaver a black background + canvas->setStyleSheet("background: black;"); + + //Pulls number of planets from settings, with 10 as default + int number = settings->value("planets/number",10).toInt(); + + //Loops through all planets and sets up the animations, then adds them to the base group and vector, which + for(int i=0; i<number; i++){ + if(planets.length()>number){ continue; } + Grav *tmp = new Grav(canvas); + this->addAnimation(tmp); + connect(tmp, SIGNAL(finished()), this, SLOT(checkFinished())); + 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/Text.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h new file mode 100644 index 00000000..a4c49692 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h @@ -0,0 +1,93 @@ +//=========================================== +// 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_Text_ANIMATION_H +#define _LUMINA_DESKTOP_SCREEN_SAVER_Text_ANIMATION_H + +//PI is equal to 2*pi +#define PI 6.2832 + +#include "global-includes.h" +#include "BaseAnimGroup.h" +#include <QParallelAnimationGroup> +#include <QtMath> + +class Text: public QParallelAnimationGroup{ + Q_OBJECT +private: + QLabel *text; + QPropertyAnimation *movement; + QSize range; + QPoint v; + bool bounce; + +private slots: + void LoopChanged(){ + movement->setStartValue(movement->endValue()); + QPoint currLoc = movement->startValue().toPoint(); + bounce = !(currLoc.y() < 100 or currLoc.y() > range.height()-100 or currLoc.x() > range.width()-100 or currLoc.x() < 100); + if((currLoc.y() < 10 or currLoc.y() > range.height()-40) and !bounce) { + v.setY((v.y() * -1) + (qrand() % 20 - 10)); + }else if((currLoc.x() > range.width()-10 or currLoc.x() < 10) and !bounce) { + v.setX((v.x() * -1) + (qrand() % 20 - 10)); + } + currLoc.setX(currLoc.x() + v.x()); + currLoc.setY(currLoc.y() + v.y()); + movement->setEndValue(currLoc); + } + void stopped(){ qDebug() << "text stopped"; text->hide();} + +public: + Text(QWidget *parent) : QParallelAnimationGroup(parent){ + text = new QLabel(parent); + range = parent->size(); + QPoint center = parent->geometry().center(); + + QString color = "rgba(" + QString::number(qrand() % 206 + 50) + ", " + QString::number(qrand() % 206 + 50) + ", " + QString::number(qrand() % 206 + 50); + text->setStyleSheet("QLabel {background-color: rgba(255, 255, 255, 10); color: " + color + "); }"); + text->setFont(QFont("Courier", 24, QFont::Bold)); + text->setText("test"); + QFontMetrics metrics(text->font()); + text->setMinimumSize(QSize( metrics.width(text->text())+10, metrics.height()*text->text().count("\n") +10)); + + movement = new QPropertyAnimation(text); + movement->setPropertyName("pos"); + movement->setTargetObject(text); + + this->addAnimation(movement); + text->show(); + v.setX((qrand() % 100 + 50) * qPow(-1, qrand() % 2)); + v.setY((qrand() % 100 + 50) * qPow(-1, qrand() % 2)); + movement->setStartValue(center); + //Ensures the screensaver will not stop until the user wishes to login or it times out + this->setLoopCount(2000); //number of movements + movement->setDuration(200); + movement->setEndValue(QPoint(qrand() % (int)range.height(), qrand() % range.width())); + LoopChanged(); //load initial values + + connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) ); + connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + } + ~Text(){} + +}; + +class TextAnimation : public BaseAnimGroup{ + Q_OBJECT +public: + TextAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + ~TextAnimation(){ + this->stop(); + } + + void LoadAnimations(){ + canvas->setStyleSheet("background: black;"); + Text *tmp = new Text(canvas); + this->addAnimation(tmp); + } + +}; +#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 919ec4e0..35141a0e 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,8 @@ SOURCES += $$PWD/BaseAnimGroup.cpp HEADERS += $$PWD/BaseAnimGroup.h \ -# $$PWD/SampleAnimation.h \ - $${PWD}/Fireflies.h - + $$PWD/SampleAnimation.h \ + $${PWD}/Fireflies.h \ + $${PWD}/Grav.h \ + $${PWD}/Text.h #FORMS += |