diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2017-08-15 09:30:58 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2017-08-15 09:35:45 -0400 |
commit | 0079e45a9bd78c2ebbef5abe641e268571ade45b (patch) | |
tree | da4676da3a921194673fe3a21c458ab69398ea77 /src-qt5 | |
parent | A bit more random work: (diff) | |
download | lumina-0079e45a9bd78c2ebbef5abe641e268571ade45b.tar.gz lumina-0079e45a9bd78c2ebbef5abe641e268571ade45b.tar.bz2 lumina-0079e45a9bd78c2ebbef5abe641e268571ade45b.zip |
Added fixes for the experimental video screensaver
Diffstat (limited to 'src-qt5')
5 files changed, 59 insertions, 43 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 2c36af80..39a7b596 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp @@ -151,10 +151,12 @@ void LScreenSaver::HideScreenSaver(){ emit ClosingScreenSaver(); emit LockStatusChanged(false); } + qDebug() << "Stop ScreenSavers"; for(int i=0; i<BASES.length(); i++){ - qDebug() << "Stop ScreenSaver:" << i; BASES[i]->stopPainting(); BASES[i]->hide(); + BASES.takeAt(i)->deleteLater(); + i--; } UpdateTimers(); } 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 7fc4eb50..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 @@ -37,5 +37,5 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti } QStringList BaseAnimGroup::KnownAnimations(){ - return (QStringList() << "videoSlideshow" /*<< "grav" << "text" << "imageSlideshow" << "fireflies"*/); + return (QStringList() << "imageSlideshow" /*<< "grav" << "text" << "imageSlideshow" << "fireflies"*/); } 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 4abc3ae7..a64144ac 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,9 +17,9 @@ private: QPropertyAnimation *bounce, *fading; QPixmap pixmap; QStringList imageFiles; - QString imagePath; + QString imagePath, scriptPath; QSize screenSize; - bool animate; + bool animate, scriptLoad; private: void setupAnimation() { @@ -45,7 +45,16 @@ private: //Choose a new file if the chosen one is not an image while(QImageReader::imageFormat(randomFile).isEmpty()) randomFile = imagePath+imageFiles[qrand() % imageFiles.size()]; - pixmap.load(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 @@ -66,11 +75,13 @@ private slots: void stopped(){ qDebug() << "Image Stopped"; image->hide();} public: - ImageSlideshow(QWidget *parent, QString path, bool animate) : QParallelAnimationGroup(parent){ + 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); @@ -132,7 +143,11 @@ public: 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(); - ImageSlideshow *tmp = new ImageSlideshow(canvas, imagePath, animate); + 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); } 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 fdddaf93..cc3c1b83 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 @@ -16,6 +16,8 @@ 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(){} @@ -29,29 +31,32 @@ private: QVideoWidget *videoWidget; QMediaPlayer *video; QStringList videoFiles; - QMediaPlaylist *playlist; - bool multimonitor, random; + bool multimonitor; private slots: - void startVideo() { - this->addAnimation(tmp); - tmp->setDuration(video->duration()); - qDebug() << "Status: " << video->mediaStatus(); - video->setPlaylist(playlist); - video->setVolume(100); - video->play(); + 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 LoopChanged(){ - qDebug() << "New Video"; - if(random) - playlist->setCurrentIndex(qrand() % videoFiles.size()); - else - playlist->setCurrentIndex(playlist->currentIndex()+1); + void stopVideo() { + if(video->state() == QMediaPlayer::StoppedState) { + qDebug() << "Stopping Animation"; + //this->deleteLater(); + videoWidget->hide(); + tmp->stop(); + //tmp->deleteLater(); + videoWidget->deleteLater(); + video->deleteLater(); + } } - void stopped(){qDebug() << "Video Stopped"; videoWidget->hide();} - public: VideoAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} @@ -63,39 +68,36 @@ 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 = 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(); - //Set whether to play random videos or in order - random = settings->value("videoSlideshow/random",false).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(videoFiles.size()); - - //Load a random initial video - playlist = new QMediaPlaylist(); - for(int i = 0; i < videoFiles.size(); i++) - playlist->addMedia(QUrl::fromLocalFile(videoFiles[i])); - if(random) - playlist->setCurrentIndex(qrand() % videoFiles.size()); + 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(video, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(startVideo())); - connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) ); - connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); + 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()) ); } }; diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui index 4b81dd6c..57567e52 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui @@ -695,9 +695,6 @@ </widget> <widget class="QStatusBar" name="statusbar"/> <widget class="QToolBar" name="toolBar"> - <property name="windowTitle"> - <string>toolBar</string> - </property> <property name="movable"> <bool>false</bool> </property> |