aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
-rw-r--r--src-qt5/core/lumina-desktop-unified/global-includes.h3
-rw-r--r--src-qt5/core/lumina-desktop-unified/lumina-desktop.pro2
-rw-r--r--src-qt5/core/lumina-desktop-unified/main.cpp2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp14
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp8
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h8
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp8
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h98
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h155
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h9
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h104
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri2
12 files changed, 347 insertions, 66 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h
index 92f895c2..8b8cd16c 100644
--- a/src-qt5/core/lumina-desktop-unified/global-includes.h
+++ b/src-qt5/core/lumina-desktop-unified/global-includes.h
@@ -34,6 +34,7 @@
#include <QAnimationGroup>
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
+#include <QGraphicsOpacityEffect>
#include <QWindow>
#include <QWidget>
#include <QWidgetAction>
@@ -47,6 +48,8 @@
#include <QThread>
#include <QMediaObject>
#include <QMediaPlayer>
+#include <QVideoWidget>
+#include <QMediaPlaylist>
// libLumina includes
#include <LuminaX11.h>
diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
index 79f2ba6f..04d5b602 100644
--- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
+++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
@@ -1,7 +1,7 @@
include($${PWD}/../../OS-detect.pri)
QT += core gui network
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia concurrent svg
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia multimediawidgets concurrent svg
diff --git a/src-qt5/core/lumina-desktop-unified/main.cpp b/src-qt5/core/lumina-desktop-unified/main.cpp
index 8e40f7eb..ef15cfcd 100644
--- a/src-qt5/core/lumina-desktop-unified/main.cpp
+++ b/src-qt5/core/lumina-desktop-unified/main.cpp
@@ -29,7 +29,7 @@ int main(int argc, char ** argv)
setenv("DESKTOP_SESSION","Lumina",1);
setenv("XDG_CURRENT_DESKTOP","Lumina",1);
setenv("QT_NO_GLIB", "1", 1); //Disable the glib event loop within Qt at runtime (performance hit + bugs)
- unsetenv("QT_QPA_PLATFORMTHEME"); //causes issues with Lumina themes - not many people have this by default...
+ //unsetenv("QT_QPA_PLATFORMTHEME"); //causes issues with Lumina themes - not many people have this by default...
unsetenv("QT_AUTO_SCREEN_SCALE_FACTOR"); //need exact-pixel measurements (no fake scaling)
//Startup the session
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 bfcfa54d..39a7b596 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 0
+#define DEBUG 1
LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint){
starttimer = new QTimer(this);
@@ -102,13 +102,14 @@ void LScreenSaver::ShowScreenSaver(){
//Now go through and create/show all the various widgets
QList<QScreen*> SCREENS = QApplication::screens();
QRect bounds;
- cBright = LOS::ScreenBrightness();
- if(cBright>0){ LOS::setScreenBrightness(cBright/2); } //cut to half while the screensaver is active
+ //cBright = LOS::ScreenBrightness();
+ //if(cBright>0){ LOS::setScreenBrightness(cBright/2); } //cut to half while the screensaver is active
for(int i=0; i<SCREENS.length(); i++){
bounds = bounds.united(SCREENS[i]->geometry());
if(DEBUG){ qDebug() << " - New SS Base:" << i; }
BASES << new SSBaseWidget(this, settings);
connect(BASES[i], SIGNAL(InputDetected()), this, SLOT(newInputEvent()) );
+
//Setup the geometry of the base to match the screen
BASES[i]->setGeometry(SCREENS[i]->geometry()); //match this screen geometry
BASES[i]->setPlugin(settings->value("screenplugin"+QString::number(i+1), settings->value("defaultscreenplugin","random").toString() ).toString() );
@@ -144,15 +145,18 @@ 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
+ //if(cBright>0){ LOS::setScreenBrightness(cBright); } //return to current brightness
if(!SSLocked){
this->hide();
emit ClosingScreenSaver();
emit LockStatusChanged(false);
}
+ qDebug() << "Stop ScreenSavers";
for(int i=0; i<BASES.length(); i++){
- BASES[i]->hide();
BASES[i]->stopPainting();
+ BASES[i]->hide();
+ BASES.takeAt(i)->deleteLater();
+ i--;
}
UpdateTimers();
}
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 b31ef793..7854b597 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
@@ -39,8 +39,7 @@ void SSBaseWidget::startPainting(){
cplug = plugType;
//free up any old animation instance
if(ANIM!=0){
- ANIM->stop(); ANIM->clear();
- delete ANIM; ANIM = 0;
+ stopPainting();
}
//If a random plugin - grab one of the known plugins
if(cplug=="random"){
@@ -76,9 +75,10 @@ void SSBaseWidget::startPainting(){
void SSBaseWidget::stopPainting(){
if(ANIM!=0){
+ qDebug() << "Stopping Animation!!";
ANIM->stop();
- ANIM->clear();
- delete ANIM;
+ //ANIM->clear();
+ ANIM->deleteLater();
ANIM = 0;
}
}
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
index bdcefa24..9d987178 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
@@ -14,10 +14,10 @@
class SSBaseWidget : public QWidget{
Q_OBJECT
-public:
+public:
SSBaseWidget(QWidget *parent, QSettings *set);
~SSBaseWidget();
-
+
void setPlugin(QString);
public slots:
@@ -30,7 +30,7 @@ private:
QSettings *settings;
private slots:
-
+
signals:
void InputDetected(); //just in case no event handling setup at the WM level
@@ -49,7 +49,7 @@ protected:
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
-
+
};
#endif
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 017eaf9f..c8a248c0 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
@@ -12,6 +12,8 @@
#include "Grav.h"
#include "SampleAnimation.h"
#include "Text.h"
+#include "ImageSlideshow.h"
+#include "VideoSlideshow.h"
//==============================
// PLUGIN LOADING/LISTING
@@ -24,6 +26,10 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti
return (new GravAnimation(parent, set));
}else if(type == "text") {
return (new TextAnimation(parent, set));
+ }else if(type == "imageSlideshow") {
+ return (new ImageAnimation(parent, set));
+ }else if(type == "videoSlideshow") {
+ return (new VideoAnimation(parent, set));
}else {
//Unknown screensaver, return a blank animation group
return (new BaseAnimGroup(parent, set));
@@ -31,5 +37,5 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti
}
QStringList BaseAnimGroup::KnownAnimations(){
- return (QStringList() << "fireflies" << "grav" << "text");
+ return (QStringList() << "imageSlideshow" /*<< "grav" << "text" << "imageSlideshow" << "fireflies"*/);
}
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
index ad1b1122..50d733e9 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h
@@ -9,11 +9,10 @@
//PI is equal to 2*pi
#define PI 6.2832
-
#include "global-includes.h"
#include "BaseAnimGroup.h"
-#include <QParallelAnimationGroup>
#include <QtMath>
+#include <QMatrix>
class Grav: public QParallelAnimationGroup{
Q_OBJECT
@@ -21,55 +20,63 @@ private:
QWidget *planet;
QPropertyAnimation *orbit;
QSize range;
- QList<QPoint> path;
+ //QList<QPoint> path;
double radius;
void setupLoop(QPoint start, QPoint *ref){
- orbit->setStartValue(start);
+ //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;
+ double step = 300.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);
+ double xrand = 0.4; //(qrand()%10+4)/10.0;
+ double yrand = 0.4; //(qrand()%10+4)/10.0;
+
+ double theta = 1.5707963;
+ //double theta = aTan((start.x() - ref->x())/(start.y() - ref->y()));
+ QMatrix rotation = QMatrix(qCos(theta), qSin(theta), -qSin(theta), qCos(theta), -ref->x(), -ref->y());
+ qDebug() << rotation;
+ //qDebug() << "Starting Point" << start;
+ //qDebug() << "Angle" << theta;
+ //qDebug() << "Distance" << radius;
+ //qDebug() << "Center" << *ref;
+
+ 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 rotFP = rotation.map(firstP);
+ qDebug() << "First Point" << firstP;
+ qDebug() << "Rotation by Matrix" << rotFP;
+ 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) )));
+ 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));
//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);
- }
-
+ 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);
+ //path.push_back(lastP);
}
private slots:
- void LoopChanged(int loop){
+ /*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:
@@ -79,7 +86,7 @@ public:
QPoint center = parent->geometry().center();
//Creates a random planet size. Between 12 and 45 pixels
- double planet_radius = 1.75* ((qrand()%20)+7);
+ int planet_radius = qRound(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);
@@ -93,24 +100,28 @@ public:
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;
+ QRect invalid = QRect(center+QPoint(-50,-50), center+QPoint(50,50));
+ QPoint tmp = center;
+ while(invalid.contains(tmp)){
+ int randwidth = qrand()%(range.width() - 2*planet_radius) + planet_radius;
+ int randheight = qrand()%(range.height()- 2*planet_radius) + planet_radius;
+ tmp = QPoint(randwidth, randheight);
+ }
//Creates all frames for the animation
- setupLoop(QPoint(randwidth, randheight), &center);
+ setupLoop(tmp, &center);
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
+ this->setLoopCount(1); //number of orbits
+ orbit->setDuration( qrand() %1000 + 19000); //20 second 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(currentLoopChanged(int)), this, SLOT(LoopChanged(int)) );
connect(this, SIGNAL(finished()), this, SLOT(stopped()) );
}
~Grav(){}
@@ -130,13 +141,14 @@ private slots:
for(int i=0; i<this->animationCount(); i++){
if(this->animationAt(i)->state()==QAbstractAnimation::Running){ running++; }
}
- if(running<=1){ wobble->stop(); emit wobble->finished();}
+ if(running<=1){ wobble->stop(); emit wobble->finished();}
}
public:
GravAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
~GravAnimation(){
- //this->stop();
+ sun->deleteLater();
+ while(planets.length()>0){ planets.takeAt(0)->deleteLater(); }
}
void LoadAnimations(){
@@ -144,8 +156,8 @@ public:
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));");
+ 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
@@ -162,7 +174,6 @@ public:
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;");
@@ -171,14 +182,13 @@ public:
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
+ qDebug() << "Starting planets";
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()));
+ connect(tmp, SIGNAL(finished()), this, SLOT(checkFinished()));
planets << tmp;
}
- while(planets.length()>number){planets.takeAt(number)->deleteLater(); }
}
};
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h
new file mode 100644
index 00000000..a64144ac
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h
@@ -0,0 +1,155 @@
+//===========================================
+// 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_IMAGESLIDESHOW_ANIMATION_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_IMAGESLIDESHOW_ANIMATION_H
+
+#include "global-includes.h"
+#include "BaseAnimGroup.h"
+
+class ImageSlideshow: public QParallelAnimationGroup{
+ Q_OBJECT
+private:
+ QLabel *image;
+ QPropertyAnimation *bounce, *fading;
+ QPixmap pixmap;
+ QStringList imageFiles;
+ QString imagePath, scriptPath;
+ QSize screenSize;
+ bool animate, scriptLoad;
+
+private:
+ void setupAnimation() {
+ //Choose between starting from top or bottom at random
+ if(qrand() % 2) {
+ bounce->setKeyValueAt(0, QPoint(0,screenSize.height()-image->height()));
+ bounce->setKeyValueAt(0.25, QPoint((screenSize.width()-image->width())/2,0));
+ bounce->setKeyValueAt(0.5, QPoint(screenSize.width()-image->width(),screenSize.height()-image->height()));
+ bounce->setKeyValueAt(0.75, QPoint((screenSize.width()-image->width())/2,0));
+ bounce->setKeyValueAt(1, QPoint(0,screenSize.height()-image->height()));
+ }else{
+ bounce->setKeyValueAt(0, QPoint(0,0));
+ bounce->setKeyValueAt(0.25, QPoint((screenSize.width()-image->width())/2,screenSize.height()-image->height()));
+ bounce->setKeyValueAt(0.5, QPoint(screenSize.width()-image->width(),0));
+ bounce->setKeyValueAt(0.75, QPoint((screenSize.width()-image->width())/2,screenSize.height()-image->height()));
+ bounce->setKeyValueAt(1, QPoint(0,0));
+ }
+ }
+
+ void chooseImage() {
+ QString randomFile = imagePath+imageFiles[qrand() % imageFiles.size()];
+
+ //Choose a new file if the chosen one is not an image
+ while(QImageReader::imageFormat(randomFile).isEmpty())
+ randomFile = imagePath+imageFiles[qrand() % imageFiles.size()];
+ if(scriptLoad){
+ QProcess process;
+ process.start("/home/zwelch/test.sh");
+ process.waitForFinished(1000);
+ QByteArray output = process.readAllStandardOutput();
+ qDebug() << output;
+ pixmap.load(imagePath+imageFiles[qrand() % imageFiles.size()]);
+ }else{
+ pixmap.load(imagePath+imageFiles[qrand() % imageFiles.size()]);
+ }
+
+ //If the image is larger than the screen, then shrink the image down to 3/4 it's size (so there's still some bounce)
+ //Scale the pixmap to keep the aspect ratio instead of resizing the label itself
+ if(pixmap.width() > screenSize.width() or pixmap.height() > screenSize.height())
+ pixmap = pixmap.scaled(screenSize*(3.0/4.0), Qt::KeepAspectRatio);
+
+ //Set pixmap to the image label
+ image->setPixmap(pixmap);
+ image->resize(pixmap.size());
+ }
+
+private slots:
+ void LoopChanged(){
+ //Load a new random image. Resize the label based on the image's size
+ chooseImage();
+ setupAnimation();
+ }
+ void stopped(){ qDebug() << "Image Stopped"; image->hide();}
+
+public:
+ ImageSlideshow(QWidget *parent, QString path, bool animate, bool scriptLoad, QString scriptPath) : QParallelAnimationGroup(parent){
+ imagePath = path;
+ image = new QLabel(parent);
+ screenSize = parent->size();
+ this->animate = animate;
+ this->scriptLoad = scriptLoad;
+ this->scriptPath = scriptPath;
+
+ //Generate the list of files in the directory
+ imageFiles = QDir(imagePath).entryList(QDir::Files);
+ if(imageFiles.empty())
+ qDebug() << "Current image file path has no files.";
+
+ //Change some default settings for the image. If scaledContents is false, the image will be cut off if resized
+ image->setScaledContents(true);
+ image->setAlignment(Qt::AlignHCenter);
+
+ //Load a random initial image
+ chooseImage();
+
+ //Create the animation that moves the image across the screen
+ bounce = new QPropertyAnimation(image, "pos", parent);
+
+ //Add the animation that fades the image in and out
+ QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(parent);
+ image->setGraphicsEffect(eff);
+ fading = new QPropertyAnimation(eff,"opacity");
+ fading->setKeyValueAt(0, 0);
+ fading->setKeyValueAt(0.20, 1);
+ fading->setKeyValueAt(0.80, 1);
+ fading->setKeyValueAt(1, 0);
+ this->addAnimation(fading);
+
+ setupAnimation();
+ image->show();
+ //Only add the animation if set in the configuration file
+ if(animate)
+ this->addAnimation(bounce);
+ else
+ //If no animation, center the image in the middle of the screen
+ image->move(QPoint((parent->width()-image->width())/2,(parent->height()-image->height())/2));
+
+ //Loop through 30 times for a total for 4 minutes
+ this->setLoopCount(30);
+ bounce->setDuration(8000);
+ fading->setDuration(8000);
+
+ connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) );
+ connect(this, SIGNAL(finished()), this, SLOT(stopped()) );
+ }
+ ~ImageSlideshow(){}
+
+};
+
+class ImageAnimation: public BaseAnimGroup{
+ Q_OBJECT
+public:
+ ImageAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ ~ImageAnimation(){
+ this->stop();
+ }
+
+ void LoadAnimations(){
+ canvas->setStyleSheet("background: black;");
+ //Load the path of the images from the configuration file (default /usr/local/backgrounds/)
+ QString imagePath = settings->value("imageSlideshow/path","/usr/local/backgrounds/").toString();
+ //Load whether to animate the image (default true)
+ bool animate = settings->value("imageSlideshow/animate", true).toBool();
+ bool scriptLoad = settings->value("imageSlideshow/scriptLoad", true).toBool();
+ QString scriptPath;
+ if(scriptLoad)
+ scriptPath = settings->value("imageSlideshow/scriptPath", "/usr/local/backgrounds/script.sh").toString();
+ ImageSlideshow *tmp = new ImageSlideshow(canvas, imagePath, animate, scriptLoad, scriptPath);
+ this->addAnimation(tmp);
+ }
+
+};
+#endif
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
index a4c49692..3ec0af82 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h
@@ -4,11 +4,8 @@
// 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
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_TEXT_ANIMATION_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_TEXT_ANIMATION_H
#include "global-includes.h"
#include "BaseAnimGroup.h"
@@ -38,7 +35,7 @@ private slots:
currLoc.setY(currLoc.y() + v.y());
movement->setEndValue(currLoc);
}
- void stopped(){ qDebug() << "text stopped"; text->hide();}
+ void stopped(){ qDebug() << "Text Stopped"; text->hide();}
public:
Text(QWidget *parent) : QParallelAnimationGroup(parent){
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
new file mode 100644
index 00000000..cc3c1b83
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
@@ -0,0 +1,104 @@
+//===========================================
+// 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_VIDEOSLIDESHOW_ANIMATION_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H
+
+#include "global-includes.h"
+#include "BaseAnimGroup.h"
+
+class VideoSlideshow: public QPropertyAnimation{
+ Q_OBJECT
+public:
+ VideoSlideshow(QWidget *parent, QVideoWidget *videoWidget) : QPropertyAnimation(videoWidget, "pos", parent){
+ this->setKeyValueAt(0,QPoint(0,0));
+ this->setKeyValueAt(1,QPoint(0,0));
+ this->setDuration(1000000);
+ this->setLoopCount(-1);
+ }
+ ~VideoSlideshow(){}
+
+};
+
+class VideoAnimation: public BaseAnimGroup{
+ Q_OBJECT
+private:
+ QString videoPath;
+ VideoSlideshow *tmp;
+ QVideoWidget *videoWidget;
+ QMediaPlayer *video;
+ QStringList videoFiles;
+ bool multimonitor;
+
+private slots:
+ void startVideo(QAbstractAnimation::State state) {
+ qDebug() << "Status: " << video->mediaStatus() << "New Animation State:" << state;
+ if(state==QAbstractAnimation::Running){
+ video->setVolume(100);
+ video->play();
+ }
+ if(state==QAbstractAnimation::Stopped && video->state()!=QMediaPlayer::StoppedState){
+ video->stop();
+ }
+ }
+
+ void stopVideo() {
+ if(video->state() == QMediaPlayer::StoppedState) {
+ qDebug() << "Stopping Animation";
+ //this->deleteLater();
+ videoWidget->hide();
+ tmp->stop();
+ //tmp->deleteLater();
+ videoWidget->deleteLater();
+ video->deleteLater();
+ }
+ }
+
+public:
+ VideoAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+
+ ~VideoAnimation(){
+ this->stop();
+ }
+
+ void LoadAnimations(){
+ canvas->setStyleSheet("background: black;");
+
+ //Load the path of the videos from the configuration file (default /usr/local/videos/)
+ videoPath = settings->value("videoSlideshow/path","/usr/local/videos").toString();
+ if(!videoPath.endsWith("/")){ videoPath.append("/"); }
+
+ //Set whether to copy videos on two monitors or play different videos
+ multimonitor = settings->value("videoSlideshow/multimonitor",true).toBool();
+
+ video = new QMediaPlayer(canvas, QMediaPlayer::VideoSurface);
+ videoWidget = new QVideoWidget(canvas);
+ videoWidget->setGeometry(QRect(QPoint(0,0), canvas->size()));
+
+ tmp = new VideoSlideshow(canvas, videoWidget);
+ this->addAnimation(tmp);
+
+ //Generate the list of files in the directory
+ videoFiles = QDir(videoPath).entryList(QDir::Files);
+ if(videoFiles.empty())
+ qDebug() << "Current video file path has no files.";
+
+ this->setLoopCount(1);
+
+ QUrl url = QUrl::fromLocalFile(videoPath+videoFiles[qrand() % videoFiles.size()]);
+ video->setMedia(url);
+ qDebug() << url;
+ video->setVideoOutput(videoWidget);
+ videoWidget->show();
+
+ qDebug() << "VideoWidget Displayed";
+ connect(tmp, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), this, SLOT(startVideo(QAbstractAnimation::State)) );
+ //connect(video, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(startVideo()) );
+ connect(video, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stopVideo()) );
+ }
+
+};
+#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 35141a0e..fdc75717 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
@@ -4,5 +4,7 @@ HEADERS += $$PWD/BaseAnimGroup.h \
$$PWD/SampleAnimation.h \
$${PWD}/Fireflies.h \
$${PWD}/Grav.h \
+ $${PWD}/ImageSlideshow.h \
+ $${PWD}/VideoSlideshow.h \
$${PWD}/Text.h
#FORMS +=
bgstack15