aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-screensaver
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp4
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp19
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h1
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h16
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h38
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h14
7 files changed, 57 insertions, 37 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 ff63e3a3..a0edde9f 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
@@ -110,7 +110,9 @@ void LScreenSaver::ShowScreenSaver(){
//Setup the geometry of the base to match the screen
BASES[i]->setGeometry(SCREENS[i]->geometry()); //match this screen geometry
- BASES[i]->setPlugin(DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "screenplugin_"+SCREENS[i]->name(), DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "defaultscreenplugin","random").toString() ).toString() );
+ QString plug = DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "plugin_"+SCREENS[i]->name(), "").toString();
+ if(plug.isEmpty()){ plug = DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "default_plugin","random").toString(); }
+ BASES[i]->setPlugin(plug);
}
//Now set the overall parent widget geometry and show everything
this->setGeometry(bounds); //overall background widget
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 8e7eb7f6..a6d5be60 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
@@ -7,18 +7,20 @@
#include "SSBaseWidget.h"
-#define DEBUG 0
+#define DEBUG 1
-static QStringList validPlugs;
// ========
// PUBLIC
// ========
SSBaseWidget::SSBaseWidget(QWidget *parent) : QWidget(parent){
- if(validPlugs.isEmpty()){ validPlugs << "none"; } //add more later
this->setObjectName("LuminaBaseSSWidget");
ANIM = 0;
this->setMouseTracking(true);
plugType="none";
+ restartTimer = new QTimer(this);
+ restartTimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "globals/plugin_time_seconds", 60).toInt() * 1000);
+ restartTimer->setSingleShot(true);
+ connect(restartTimer, SIGNAL(timeout()), this, SLOT(startPainting()) );
}
SSBaseWidget::~SSBaseWidget(){
@@ -26,9 +28,7 @@ SSBaseWidget::~SSBaseWidget(){
}
void SSBaseWidget::setPlugin(QString plug){
- plug = plug.toLower();
- if(validPlugs.contains(plug) || plug=="random"){ plugType = plug; }
- else{ plugType = "none"; }
+ plugType = plug.toLower();
}
// =============
@@ -47,7 +47,7 @@ void SSBaseWidget::startPainting(){
if(valid.isEmpty()){ cplug = "none"; } //no known plugins
else{ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin
}
- if(DEBUG){ qDebug() << " - Screen Saver:" << cplug; }
+ if(DEBUG){ qDebug() << " - Screen Saver:" << plugType << cplug; }
//Now list all the various plugins and start them appropriately
QString style;
if(cplug=="none"){
@@ -70,6 +70,7 @@ void SSBaseWidget::startPainting(){
ANIM->start();
}
}
+ restartTimer->start();
}
void SSBaseWidget::stopPainting(){
@@ -79,5 +80,9 @@ void SSBaseWidget::stopPainting(){
//ANIM->clear();
ANIM->deleteLater();
ANIM = 0;
+ //Delete any child widgets of the canvas
+ QList<QWidget*> widgets = this->findChildren<QWidget*>("",Qt::FindDirectChildrenOnly);
+ for(int i=0; i<widgets.length(); i++){ widgets[i]->deleteLater(); }
}
+ if(restartTimer->isActive()){ restartTimer->stop(); }
}
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 c4c7388a..af809127 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
@@ -27,6 +27,7 @@ public slots:
private:
QString plugType, cplug; //type of custom painting to do
BaseAnimGroup *ANIM;
+ QTimer *restartTimer;
private slots:
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 477724e3..9b095fe4 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
@@ -47,5 +47,5 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent){
}
QStringList BaseAnimGroup::KnownAnimations(){
- return (QStringList() << "grav" << "text" << "imageSlideshow" << "videoSlideshow" << "fireflies");
+ return (QStringList() << "none" << "grav" << "text" << "imageSlideshow" << "videoSlideshow" << "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 099e6645..df75ad67 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
@@ -77,13 +77,13 @@ private slots:
orbit->setDuration(10);
}
}*/
- void stopped(){ qDebug() << "Planet stopped"; planet->hide();}
+ void stopped(){ planet->hide();}
public:
Grav(QWidget *parent) : QParallelAnimationGroup(parent){
planet = new QWidget(parent);
range = parent->size();
- QPoint center = parent->geometry().center();
+ QPoint center = QRect(QPoint(0,0), parent->size()).center();;
//Creates a random planet size. Between 12 and 45 pixels
int planet_radius = qRound(1.75* ((qrand()%20)+7) );
@@ -114,7 +114,7 @@ public:
planet->show();
//Ensures the screensaver will not stop until the user wishes to login or it times out
- this->setLoopCount(1); //number of orbits
+ this->setLoopCount(3); //number of orbits
orbit->setDuration( qrand() %1000 + 19000); //20 second orbits
//orbit->setEndValue(path.at(0));
//LoopChanged(0); //load initial values
@@ -154,7 +154,7 @@ public:
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();
+ QPoint center = QRect(QPoint(0,0), canvas->size()).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));");
@@ -164,11 +164,11 @@ public:
wobble = new QPropertyAnimation(sun);
wobble->setPropertyName("geometry");
wobble->setTargetObject(sun);
- QRect initgeom = QRect(center-QPoint(12,12), QSize(60, 60));
+ QRect initgeom = QRect(center-QPoint(30,30), 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->setKeyValueAt(0.5, QRect(center-QPoint(45,45), QSize(90, 90))); //starting point
wobble->setDuration(2000);
wobble->setLoopCount(-1);
this->addAnimation(wobble);
@@ -176,13 +176,13 @@ public:
sun->setGeometry(initgeom);
//Gives the screensaver a black background
- canvas->setStyleSheet("background: black;");
+ //canvas->setStyleSheet("background: black;");
//Pulls number of planets from settings, with 10 as default
int number = readSetting("planets/number",qrand()%5+3).toInt();
//Loops through all planets and sets up the animations, then adds them to the base group and vector, which
- qDebug() << "Starting planets";
+ //qDebug() << "Starting planets";
for(int i=0; i<number; i++){
Grav *tmp = new Grav(canvas);
this->addAnimation(tmp);
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
index c040c7ac..fd98acb6 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h
@@ -17,7 +17,7 @@ private:
QPropertyAnimation *bounce, *fading;
QPixmap pixmap;
QStringList imageFiles;
- QString imagePath, scriptPath;
+ QString imagePath, scriptPath, curpixmap;
QSize screenSize;
bool animate, scriptLoad;
@@ -40,27 +40,33 @@ private:
}
void chooseImage() {
- QString randomFile = imagePath+imageFiles[qrand() % imageFiles.size()];
- if(scriptLoad){
+ /*if(scriptLoad){
QProcess process;
process.start("/home/zwelch/test.sh");
process.waitForFinished(1000);
QByteArray output = process.readAllStandardOutput();
//qDebug() << output;
- pixmap.load(randomFile);
- }else{
- pixmap.load(randomFile);
- }
-
- //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)
+ //pixmap.load(randomFile);
+ }else{*/
+ //File Load
+ QString randomFile = curpixmap;
+ if(imageFiles.size()>1 || curpixmap.isEmpty()){
+ while(curpixmap==randomFile){ randomFile = imagePath+imageFiles[qrand() % imageFiles.size()]; }
+ }
+ if(curpixmap!=randomFile){
+ //no need to load the new file or change the label
+ pixmap.load(randomFile);
+ //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);
- }
+ if(pixmap.width() >= (screenSize.width()-10) || pixmap.height() >= (screenSize.height()-10) ){
+ pixmap = pixmap.scaled(screenSize*(3.0/4.0), Qt::KeepAspectRatio);
+ }
+ //Set pixmap to the image label
+ image->setPixmap(pixmap);
+ image->resize(pixmap.size());
+ }
+ //}
- //Set pixmap to the image label
- image->setPixmap(pixmap);
- image->resize(pixmap.size());
}
private slots:
@@ -69,7 +75,7 @@ private slots:
chooseImage();
setupAnimation();
}
- void stopped(){ qDebug() << "Image Stopped"; image->hide();}
+ void stopped(){ image->hide();}
public:
ImageSlideshow(QWidget *parent, QString path, bool animate, bool scriptLoad, QString scriptPath) : QParallelAnimationGroup(parent){
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 88c0873b..6ba18b22 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
@@ -12,6 +12,8 @@
#include <QParallelAnimationGroup>
#include <QtMath>
+#include <unistd.h>
+
class Text: public QParallelAnimationGroup{
Q_OBJECT
private:
@@ -41,10 +43,10 @@ public:
Text(QWidget *parent, QString display) : QParallelAnimationGroup(parent){
text = new QLabel(parent);
range = parent->size();
- QPoint center = parent->geometry().center();
+ QPoint center = QRect( QPoint(0,0), parent->size()).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->setStyleSheet("QLabel {background-color: transparent; color: " + color + "); }");
text->setFont(QFont("Courier", 24, QFont::Bold));
text->setText(display);
QFontMetrics metrics(text->font());
@@ -60,7 +62,7 @@ public:
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
+ this->setLoopCount(200); //number of wall bounces
movement->setDuration(200);
movement->setEndValue(QPoint(qrand() % (int)range.height(), qrand() % range.width()));
LoopChanged(); //load initial values
@@ -84,7 +86,11 @@ public:
canvas->setStyleSheet("background: black;");
//Read off the text that needs to be displayed
QString textToShow = readSetting("text", "").toString();
- if(textToShow.isEmpty()){ textToShow = "You forgot the text!!"; }
+ if(textToShow.isEmpty()){
+ char hname[300];
+ gethostname(hname, 300);
+ textToShow = QString::fromLocal8Bit(hname);
+ }
// Now create the animation
Text *tmp = new Text(canvas, textToShow);
this->addAnimation(tmp);
bgstack15