diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver/animations')
4 files changed, 41 insertions, 29 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 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); |