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/SSBaseWidget.cpp63
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h12
2 files changed, 24 insertions, 51 deletions
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 a6d5be60..227e51ac 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
@@ -12,10 +12,11 @@
// ========
// PUBLIC
// ========
-SSBaseWidget::SSBaseWidget(QWidget *parent) : QWidget(parent){
+SSBaseWidget::SSBaseWidget(QWidget *parent) : QQuickView(parent->windowHandle()){
this->setObjectName("LuminaBaseSSWidget");
- ANIM = 0;
- this->setMouseTracking(true);
+ this->setResizeMode(QQuickView::SizeRootObjectToView);
+ this->setColor(QColor("black")); //default color for the view
+ //this->setMouseTracking(true);
plugType="none";
restartTimer = new QTimer(this);
restartTimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "globals/plugin_time_seconds", 60).toInt() * 1000);
@@ -24,7 +25,6 @@ SSBaseWidget::SSBaseWidget(QWidget *parent) : QWidget(parent){
}
SSBaseWidget::~SSBaseWidget(){
- if(ANIM!=0){ this->stopPainting(); }
}
void SSBaseWidget::setPlugin(QString plug){
@@ -35,54 +35,27 @@ void SSBaseWidget::setPlugin(QString plug){
// PUBLIC SLOTS
// =============
void SSBaseWidget::startPainting(){
- cplug = plugType;
//free up any old animation instance
- if(ANIM!=0){
- stopPainting();
- }
+ stopPainting();
//If a random plugin - grab one of the known plugins
- if(cplug=="random"){
- QStringList valid = BaseAnimGroup::KnownAnimations();
- valid.removeAll("none"); //they want a screensaver - remove the "none" option from the valid list
- if(valid.isEmpty()){ cplug = "none"; } //no known plugins
- else{ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin
- }
- if(DEBUG){ qDebug() << " - Screen Saver:" << plugType << cplug; }
- //Now list all the various plugins and start them appropriately
- QString style;
- if(cplug=="none"){
- style = "background: black;"; //show the underlying black parent widget
- }else{
- style = "background: black;";
+ if(plugType=="random"){
+ QList<SSPlugin> valid = SSPluginSystem::findAllPlugins();
+ if(!valid.isEmpty()){ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin
+ }else if(plugType!="none"){
+ cplug = SSPluginSystem::findPlugin(plugType);
}
- this->setStyleSheet("QWidget#LuminaBaseSSWidget{ "+style+"}");
- this->repaint();
- //If not a stylesheet-based plugin - set it here
- if(cplug!="none"){
- ANIM = BaseAnimGroup::NewAnimation(cplug, this);
- connect(ANIM, SIGNAL(finished()), this, SLOT(startPainting()) ); //repeat the plugin as needed
- ANIM->LoadAnimations();
+ if(DEBUG){ qDebug() << " - Screen Saver:" << plugType << cplug.scriptURL() << cplug.isValid(); }
+ if(cplug.isValid()){
+ this->setSource( cplug.scriptURL() );
+ restartTimer->start();
}
- //Now start the animation(s)
- if(ANIM!=0){
- if(ANIM->animationCount()>0){
- if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); }
- ANIM->start();
- }
- }
- restartTimer->start();
+
}
void SSBaseWidget::stopPainting(){
- if(ANIM!=0){
- if(DEBUG){ qDebug() << "Stopping Animation!!"; }
- ANIM->stop();
- //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(!this->source().isEmpty()){
+ this->setSource(QUrl());
+ cplug = SSPlugin(); //empty structure
}
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 af809127..fdb23e66 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
@@ -10,9 +10,9 @@
#define _LUMINA_DESKTOP_SCREEN_SAVER_BASE_WIDGET_H
#include "global-includes.h"
-#include "animations/BaseAnimGroup.h"
+#include <plugins-screensaver.h>
-class SSBaseWidget : public QWidget{
+class SSBaseWidget : public QQuickView{
Q_OBJECT
public:
SSBaseWidget(QWidget *parent);
@@ -25,8 +25,8 @@ public slots:
void stopPainting();
private:
- QString plugType, cplug; //type of custom painting to do
- BaseAnimGroup *ANIM;
+ QString plugType;
+ SSPlugin cplug;
QTimer *restartTimer;
private slots:
@@ -43,12 +43,12 @@ protected:
ev->accept();
emit InputDetected();
}
- void paintEvent(QPaintEvent*){
+ /*void paintEvent(QPaintEvent*){
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
- }
+ }*/
};
bgstack15