aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-08-30 05:22:30 -0400
committerKen Moore <ken@ixsystems.com>2017-08-30 05:22:30 -0400
commit50384966b759498167365867d49a5df120b1fe26 (patch)
tree145a68394d8070f7bb0a0938c46cf898987c99d1
parentMake sure the context menu label is center-aligned (diff)
downloadlumina-50384966b759498167365867d49a5df120b1fe26.tar.gz
lumina-50384966b759498167365867d49a5df120b1fe26.tar.bz2
lumina-50384966b759498167365867d49a5df120b1fe26.zip
Clean up the use of the settings files within the entire screensaver system.
Also fix some minor whitespace/alignment in code, and add fallback routines to a couple screensavers which need external files (so they don't crash if nothing was setup or a directory is empty)
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp18
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h1
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp9
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h3
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp26
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h10
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h6
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h10
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/ImageSlideshow.h81
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h12
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h44
12 files changed, 119 insertions, 103 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 39a7b596..ff63e3a3 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);
@@ -20,7 +20,6 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo
LOCKER = new LLockScreen(this);
LOCKER->hide();
- settings = new QSettings("lumina-desktop","lumina-screensaver",this);
SSRunning = SSLocked = updating = false;
this->setObjectName("LSCREENSAVERBASE");
this->setStyleSheet("LScreenSaver#LSCREENSAVERBASE{ background: grey; }");
@@ -60,10 +59,9 @@ void LScreenSaver::start(){
}
void LScreenSaver::reloadSettings(){
- settings->sync();
- starttimer->setInterval( settings->value("timedelaymin",10).toInt() * 60000 );
- locktimer->setInterval( settings->value("lockdelaymin",1).toInt() * 60000 );
- hidetimer->setInterval( settings->value("hidesecs",15).toInt() * 1000 );
+ starttimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "timedelaymin",10).toInt() * 60000 );
+ locktimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "lockdelaymin",1).toInt() * 60000 );
+ hidetimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "hidesecs",15).toInt() * 1000 );
}
void LScreenSaver::newInputEvent(){
@@ -107,12 +105,12 @@ void LScreenSaver::ShowScreenSaver(){
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);
+ BASES << new SSBaseWidget(this);
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() );
+ BASES[i]->setPlugin(DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "screenplugin_"+SCREENS[i]->name(), DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "defaultscreenplugin","random").toString() ).toString() );
}
//Now set the overall parent widget geometry and show everything
this->setGeometry(bounds); //overall background widget
@@ -151,7 +149,7 @@ void LScreenSaver::HideScreenSaver(){
emit ClosingScreenSaver();
emit LockStatusChanged(false);
}
- qDebug() << "Stop ScreenSavers";
+ if(DEBUG){ qDebug() << "Stop ScreenSavers"; }
for(int i=0; i<BASES.length(); i++){
BASES[i]->stopPainting();
BASES[i]->hide();
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 18f12fab..2276fb6d 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h
@@ -22,7 +22,6 @@ public:
private:
QTimer *starttimer, *locktimer, *hidetimer;
- QSettings *settings;
QList<SSBaseWidget*> BASES;
LLockScreen *LOCKER;
int cBright;
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 7854b597..8e7eb7f6 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
@@ -7,15 +7,14 @@
#include "SSBaseWidget.h"
-#define DEBUG 1
+#define DEBUG 0
static QStringList validPlugs;
// ========
// PUBLIC
// ========
-SSBaseWidget::SSBaseWidget(QWidget *parent, QSettings *set) : QWidget(parent){
+SSBaseWidget::SSBaseWidget(QWidget *parent) : QWidget(parent){
if(validPlugs.isEmpty()){ validPlugs << "none"; } //add more later
- settings = set; //needed to pass along for plugins to read any special options/settings
this->setObjectName("LuminaBaseSSWidget");
ANIM = 0;
this->setMouseTracking(true);
@@ -60,7 +59,7 @@ void SSBaseWidget::startPainting(){
this->repaint();
//If not a stylesheet-based plugin - set it here
if(cplug!="none"){
- ANIM = BaseAnimGroup::NewAnimation(cplug, this, settings);
+ ANIM = BaseAnimGroup::NewAnimation(cplug, this);
connect(ANIM, SIGNAL(finished()), this, SLOT(startPainting()) ); //repeat the plugin as needed
ANIM->LoadAnimations();
}
@@ -75,7 +74,7 @@ void SSBaseWidget::startPainting(){
void SSBaseWidget::stopPainting(){
if(ANIM!=0){
- qDebug() << "Stopping Animation!!";
+ if(DEBUG){ qDebug() << "Stopping Animation!!"; }
ANIM->stop();
//ANIM->clear();
ANIM->deleteLater();
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 9d987178..c4c7388a 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
@@ -15,7 +15,7 @@
class SSBaseWidget : public QWidget{
Q_OBJECT
public:
- SSBaseWidget(QWidget *parent, QSettings *set);
+ SSBaseWidget(QWidget *parent);
~SSBaseWidget();
void setPlugin(QString);
@@ -27,7 +27,6 @@ public slots:
private:
QString plugType, cplug; //type of custom painting to do
BaseAnimGroup *ANIM;
- QSettings *settings;
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 c8a248c0..477724e3 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
@@ -15,27 +15,37 @@
#include "ImageSlideshow.h"
#include "VideoSlideshow.h"
+
+QVariant BaseAnimGroup::readSetting(QString variable, QVariant defaultvalue){
+ return DesktopSettings::instance()->value(DesktopSettings::ScreenSaver,
+ "Animations/"+animPlugin+"/"+variable, defaultvalue);
+}
+
//==============================
// PLUGIN LOADING/LISTING
//==============================
-BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSettings *set){
+BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent){
//This is where we place all the known plugin ID's, and load the associated subclass
+ BaseAnimGroup *anim = 0;
if(type=="fireflies"){
- return (new FirefliesAnimation(parent,set));
+ anim = new FirefliesAnimation(parent);
}else if(type == "grav") {
- return (new GravAnimation(parent, set));
+ anim = new GravAnimation(parent);
}else if(type == "text") {
- return (new TextAnimation(parent, set));
+ anim = new TextAnimation(parent);
}else if(type == "imageSlideshow") {
- return (new ImageAnimation(parent, set));
+ anim = new ImageAnimation(parent);
}else if(type == "videoSlideshow") {
- return (new VideoAnimation(parent, set));
+ anim = new VideoAnimation(parent);
}else {
//Unknown screensaver, return a blank animation group
- return (new BaseAnimGroup(parent, set));
+ anim = new BaseAnimGroup(parent);
}
+ //tag the animation with the type it is and return it
+ if(anim!=0){ anim->animPlugin = type; }
+ return anim;
}
QStringList BaseAnimGroup::KnownAnimations(){
- return (QStringList() << "imageSlideshow" /*<< "grav" << "text" << "imageSlideshow" << "fireflies"*/);
+ return (QStringList() << "grav" << "text" << "imageSlideshow" << "videoSlideshow" << "fireflies");
}
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 b1324e78..92e038ed 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
@@ -16,21 +16,23 @@ class BaseAnimGroup : public QParallelAnimationGroup{
Q_OBJECT
public:
QWidget *canvas;
- QSettings *settings;
+ QString animPlugin;
virtual void LoadAnimations(){} //This is the main function which needs to be subclassed
- BaseAnimGroup(QWidget *parent, QSettings *set){
+ BaseAnimGroup(QWidget *parent){
canvas = parent;
- settings = set;
canvas->setCursor( QCursor(Qt::BlankCursor) );
}
~BaseAnimGroup(){}
+ QVariant readSetting(QString variable, QVariant defaultvalue = QVariant());
+
+
//==============================
// PLUGIN LOADING/LISTING (Change in the .cpp file)
//==============================
- static BaseAnimGroup* NewAnimation(QString type, QWidget *parent, QSettings *set);
+ static BaseAnimGroup* NewAnimation(QString type, QWidget *parent);
static QStringList KnownAnimations();
};
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 75dfb1ae..d0e7a653 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
@@ -78,7 +78,7 @@ private:
QList<Firefly*> fireflies;
public:
- FirefliesAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ FirefliesAnimation(QWidget *parent) : BaseAnimGroup(parent){}
~FirefliesAnimation(){
this->stop();
//while(fireflies.length()>0){ fireflies.takeAt(0)->deleteLater(); }
@@ -87,14 +87,14 @@ public:
void LoadAnimations(){
while(fireflies.length()>0){ fireflies.takeAt(0)->deleteLater(); }
canvas->setStyleSheet("background: black;");
- int number = settings->value("fireflies/number",100).toInt();
+ int number = readSetting("number",qrand()%30 + 50).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(); }
+
}
};
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 50d733e9..099e6645 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
@@ -36,7 +36,7 @@ private:
double xrand = 0.4; //(qrand()%10+4)/10.0;
double yrand = 0.4; //(qrand()%10+4)/10.0;
- double theta = 1.5707963;
+ 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;
@@ -46,9 +46,9 @@ private:
//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);
+ QPoint rotFP = rotation.map(firstP);
qDebug() << "First Point" << firstP;
- qDebug() << "Rotation by Matrix" << rotFP;
+ 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);
@@ -145,7 +145,7 @@ private slots:
}
public:
- GravAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ GravAnimation(QWidget *parent) : BaseAnimGroup(parent){}
~GravAnimation(){
sun->deleteLater();
while(planets.length()>0){ planets.takeAt(0)->deleteLater(); }
@@ -179,7 +179,7 @@ public:
canvas->setStyleSheet("background: black;");
//Pulls number of planets from settings, with 10 as default
- int number = settings->value("planets/number",10).toInt();
+ 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";
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 a64144ac..c040c7ac 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
@@ -40,30 +40,27 @@ private:
}
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()]);
- }
+ QString 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(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)
//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() 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());
+ //Set pixmap to the image label
+ image->setPixmap(pixmap);
+ image->resize(pixmap.size());
}
private slots:
@@ -80,20 +77,25 @@ public:
image = new QLabel(parent);
screenSize = parent->size();
this->animate = animate;
- this->scriptLoad = scriptLoad;
- this->scriptPath = scriptPath;
-
+ 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();
+ //Ensure all the files are actually images
+ for(int i=0; i<imageFiles.length(); i++){
+ if(QImageReader::imageFormat(imagePath+"/"+imageFiles[i]).isEmpty()){ imageFiles.removeAt(i); i--; }
+ }
+ if(imageFiles.empty()){
+ qDebug() << "Current image file path has no files.";
+ image->setText("No image files found:\n"+imagePath);
+ }else{
+ //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);
@@ -132,7 +134,7 @@ public:
class ImageAnimation: public BaseAnimGroup{
Q_OBJECT
public:
- ImageAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ ImageAnimation(QWidget *parent) : BaseAnimGroup(parent){}
~ImageAnimation(){
this->stop();
}
@@ -140,13 +142,14 @@ public:
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();
+ QString imagePath = readSetting("path", LOS::LuminaShare()+"../wallpapers/").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();
+ bool animate = readSetting("animate", true).toBool();
+ bool scriptLoad = readSetting("scriptLoad", true).toBool();
+ QString scriptPath;
+ if(scriptLoad){
+ scriptPath = readSetting("scriptPath", "/usr/local/backgrounds/script.sh").toString();
+ }
ImageSlideshow *tmp = new ImageSlideshow(canvas, imagePath, animate, scriptLoad, scriptPath);
this->addAnimation(tmp);
}
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 c2bb0c96..c7a8b237 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
@@ -18,7 +18,7 @@ private:
QWidget *ball;
public:
- SampleAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ SampleAnimation(QWidget *parent) : BaseAnimGroup(parent){}
~SampleAnimation(){ this->stop(); delete ball; }
void LoadAnimations(){
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 3ec0af82..88c0873b 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
@@ -38,7 +38,7 @@ private slots:
void stopped(){ qDebug() << "Text Stopped"; text->hide();}
public:
- Text(QWidget *parent) : QParallelAnimationGroup(parent){
+ Text(QWidget *parent, QString display) : QParallelAnimationGroup(parent){
text = new QLabel(parent);
range = parent->size();
QPoint center = parent->geometry().center();
@@ -46,7 +46,7 @@ public:
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");
+ text->setText(display);
QFontMetrics metrics(text->font());
text->setMinimumSize(QSize( metrics.width(text->text())+10, metrics.height()*text->text().count("\n") +10));
@@ -75,14 +75,18 @@ public:
class TextAnimation : public BaseAnimGroup{
Q_OBJECT
public:
- TextAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ TextAnimation(QWidget *parent) : BaseAnimGroup(parent){}
~TextAnimation(){
this->stop();
}
void LoadAnimations(){
canvas->setStyleSheet("background: black;");
- Text *tmp = new Text(canvas);
+ //Read off the text that needs to be displayed
+ QString textToShow = readSetting("text", "").toString();
+ if(textToShow.isEmpty()){ textToShow = "You forgot the text!!"; }
+ // Now create the animation
+ Text *tmp = new Text(canvas, textToShow);
this->addAnimation(tmp);
}
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
index 9c52c447..1f9c4cbc 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
@@ -4,7 +4,7 @@
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
-#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H
#define _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H
#include "global-includes.h"
@@ -22,7 +22,7 @@ private:
private slots:
public:
- VideoAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ VideoAnimation(QWidget *parent) : BaseAnimGroup(parent){}
~VideoAnimation(){
this->stop();
@@ -32,7 +32,7 @@ public:
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();
+ videoPath = readSetting("path","/usr/local/videos").toString();
if(!videoPath.endsWith("/")){ videoPath.append("/"); }
//Set whether to copy videos on two monitors or play different videos
@@ -43,28 +43,30 @@ public:
videoWidget = new QVideoWidget(canvas);
video->setVideoOutput(videoWidget);
videoWidget->setGeometry(QRect(QPoint(0,0), canvas->size()));
-
+
//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.";
+ if(videoFiles.empty()){
+ qDebug() << "Current video file path has no files:" << videoPath;
+ return;
+ }
- //Loading a random file from a directory
- QDesktopWidget *dw = new QDesktopWidget();
- QMediaPlaylist *playlist = new QMediaPlaylist();
- for(int i = 0; i < videoFiles.size(); i++)
- playlist->addMedia(QUrl::fromLocalFile(videoPath+videoFiles[i]));
- qsrand(QTime::currentTime().msec());
- playlist->setCurrentIndex(qrand() % videoFiles.size());
- playlist->setPlaybackMode(QMediaPlaylist::Random);
+ //Loading a random file from a directory
+ QDesktopWidget *dw = new QDesktopWidget();
+ QMediaPlaylist *playlist = new QMediaPlaylist();
+ for(int i = 0; i < videoFiles.size(); i++){
+ playlist->addMedia(QUrl::fromLocalFile(videoPath+videoFiles[i]));
+ }
+ playlist->setCurrentIndex(qrand() % videoFiles.size());
+ playlist->setPlaybackMode(QMediaPlaylist::Random);
videoWidget->show();
- video->setPlaylist(playlist);
- //Only play sound for one monitor to prevent messed up audio
- if(dw->screenNumber(canvas) == 0)
- video->setVolume(100);
- else
- video->setVolume(0);
- video->play();
+ video->setPlaylist(playlist);
+ //Only play sound for one monitor to prevent messed up audio
+ if(dw->screenNumber(canvas) == 0)
+ video->setVolume(100);
+ else
+ video->setVolume(0);
+ video->play();
}
};
bgstack15