aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-01-04 21:47:56 +0000
committerWeblate <noreply@weblate.org>2017-01-04 21:47:56 +0000
commit5840eb59b26d1dab6f43b2e2f9e4ca6ce8b70e0f (patch)
tree931c2fe0927dcf25cac4031374db4b0c6dcdc727 /src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp
parentTranslated using Weblate (lumina_SEARCH@fr (generated)) (diff)
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-5840eb59b26d1dab6f43b2e2f9e4ca6ce8b70e0f.tar.gz
lumina-5840eb59b26d1dab6f43b2e2f9e4ca6ce8b70e0f.tar.bz2
lumina-5840eb59b26d1dab6f43b2e2f9e4ca6ce8b70e0f.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp b/src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp
new file mode 100644
index 00000000..83b82ff8
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-WM/SSBaseWidget.cpp
@@ -0,0 +1,83 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+
+#include "SSBaseWidget.h"
+
+#define DEBUG 1
+
+static QStringList validPlugs;
+// ========
+// PUBLIC
+// ========
+SSBaseWidget::SSBaseWidget(QWidget *parent, QSettings *set) : 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);
+}
+
+SSBaseWidget::~SSBaseWidget(){
+ if(ANIM!=0){ this->stopPainting(); }
+}
+
+void SSBaseWidget::setPlugin(QString plug){
+ plug = plug.toLower();
+ if(validPlugs.contains(plug) || plug=="random"){ plugType = plug; }
+ else{ plugType = "none"; }
+}
+
+// =============
+// PUBLIC SLOTS
+// =============
+void SSBaseWidget::startPainting(){
+ cplug = plugType;
+ //free up any old animation instance
+ if(ANIM!=0){
+ ANIM->stop(); ANIM->clear();
+ delete ANIM; ANIM = 0;
+ }
+ //If a random plugin - grab one of the known plugins
+ if(cplug=="random"){
+ QStringList valid = BaseAnimGroup::KnownAnimations();
+ if(valid.isEmpty()){ cplug = "none"; } //no known plugins
+ else{ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin
+ }
+ if(DEBUG){ qDebug() << " - Screen Saver:" << cplug; }
+ //Now list all the various plugins and start them appropriately
+ QString style;
+ if(cplug=="none"){
+ style = "background: transparent;"; //show the underlying black parent widget
+ }else{
+ style = "background: black;";
+ }
+ this->setStyleSheet("QWidget#LuminaBaseSSWidget{ "+style+"}");
+ this->repaint();
+ //If not a stylesheet-based plugin - set it here
+ if(cplug!="none"){
+ ANIM = BaseAnimGroup::NewAnimation(cplug, this, settings);
+ connect(ANIM, SIGNAL(finished()), this, SLOT(startPainting()) ); //repeat the plugin as needed
+ ANIM->LoadAnimations();
+ }
+ //Now start the animation(s)
+ if(ANIM!=0){
+ //if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); }
+ if(ANIM->animationCount()>0){
+ if(DEBUG){ qDebug() << " - Starting SS Plugin:" << cplug << ANIM->animationCount() << ANIM->duration() << ANIM->loopCount(); }
+ ANIM->start();
+ }
+ }
+}
+
+void SSBaseWidget::stopPainting(){
+ if(ANIM!=0){
+ ANIM->stop();
+ ANIM->clear();
+ delete ANIM;
+ ANIM = 0;
+ }
+}
bgstack15