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/LLockScreen.cpp102
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.h42
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.ui144
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp181
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h59
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp83
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h55
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp27
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h37
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h45
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri6
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri15
12 files changed, 796 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp
new file mode 100644
index 00000000..4cc6d68b
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp
@@ -0,0 +1,102 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "LLockScreen.h"
+#include "ui_LLockScreen.h"
+
+#include <unistd.h>
+
+#define NUMTRIES 3
+#define WAITMINS 1
+#define DEBUG 1
+
+LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScreen()){
+ ui->setupUi(this);
+ waittime = new QTimer(this);
+ waittime->setInterval(WAITMINS*60000); //(too many attempts in short time)
+ waittime->setSingleShot(true);
+ refreshtime = new QTimer(this); //timer to update the wait time display
+ refreshtime->setInterval(6000); //6 seconds (1/10 second)
+
+ connect(ui->tool_unlock, SIGNAL(clicked()), this, SLOT(TryUnlock()) );
+ connect(ui->line_password, SIGNAL(returnPressed()), this, SLOT(TryUnlock()) );
+ connect(ui->line_password, SIGNAL(textEdited(QString)), this, SIGNAL(InputDetected()) );
+ connect(ui->line_password, SIGNAL(cursorPositionChanged(int,int)), this, SIGNAL(InputDetected()) );
+ connect(waittime, SIGNAL(timeout()), this, SLOT(aboutToShow()) );
+ connect(refreshtime, SIGNAL(timeout()), this, SLOT(UpdateLockInfo()) );
+}
+
+LLockScreen::~LLockScreen(){
+
+}
+
+void LLockScreen::LoadSystemDetails(){
+ //Run every time the screen is initially locked
+ QString user = QString(getlogin());
+ ui->label_username->setText( QString(tr("Locked by: %1")).arg(user) );
+ ui->label_hostname->setText( QHostInfo::localHostName() );
+ ui->tool_unlock->setIcon( LXDG::findIcon("document-decrypt","") );
+ attempts = 0;
+}
+
+void LLockScreen::aboutToHide(){
+ //auto-hide timeout - clear display
+ ui->line_password->clear();
+ ui->line_password->clearFocus();
+ if(refreshtime->isActive()){ refreshtime->stop(); }
+}
+
+void LLockScreen::aboutToShow(){
+ if(!waittime->isActive()){
+ ui->label_info->clear();
+ this->setEnabled(true);
+ triesleft = NUMTRIES; //back to initial number of tries
+ if(refreshtime->isActive()){ refreshtime->stop(); }
+ }else{
+ if(!refreshtime->isActive()){ refreshtime->start(); }
+ }
+ UpdateLockInfo();
+ ui->line_password->clear();
+ ui->line_password->setFocus();
+}
+
+// =================
+// PRIVATE SLOTS
+// =================
+void LLockScreen::UpdateLockInfo(){
+ QString info;
+ /*if(triesleft>0 && triesleft<NUMTRIES ){
+ if(triesleft==1){info = tr("1 Attempt Left"); }
+ else{info = QString(tr("%1 Attempts Left")).arg(QString::number(triesleft)); }
+ }else*/
+ if(waittime->isActive()){
+ info = tr("Too Many Failures")+"\n"+ QString(tr("Wait %1 Minutes")).arg( QString::number(qRound(waittime->remainingTime()/6000.0)/10.0) );
+ }else if(attempts>0){ info.append("\n"+QString(tr("Failed Attempts: %1")).arg(QString::number(attempts)) ); }
+ ui->label_info->setText(info);
+}
+
+void LLockScreen::TryUnlock(){
+ attempts++;
+ this->setEnabled(false);
+ QString pass = ui->line_password->text();
+ ui->line_password->clear();
+ bool ok = (LUtils::runCmd("lumina-checkpass", QStringList() << pass) == 0);
+ if(ok){
+ emit ScreenUnlocked();
+ this->setEnabled(true);
+ }else{
+ triesleft--;
+ if(triesleft>0){
+ this->setEnabled(true);
+ }else{
+ waittime->start();
+ refreshtime->start();
+ }
+ ui->line_password->setFocus();
+ }
+ UpdateLockInfo();
+
+}
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.h
new file mode 100644
index 00000000..040499c1
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.h
@@ -0,0 +1,42 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_DESKTOP_LOCK_SCREEN_WIDGET_H
+#define _LUMINA_DESKTOP_LOCK_SCREEN_WIDGET_H
+
+#include "GlobalDefines.h"
+
+namespace Ui{
+ class LLockScreen;
+};
+
+class LLockScreen : public QWidget{
+ Q_OBJECT
+public:
+ LLockScreen(QWidget *parent = 0);
+ ~LLockScreen();
+
+ void LoadSystemDetails(); //Run right after the screen is initially locked
+
+public slots:
+ void aboutToHide(); //auto-hide timeout (can happen multiple times per lock)
+ void aboutToShow(); //about to be re-shown (can happen multiple times per lock)
+
+private:
+ Ui::LLockScreen *ui;
+ int triesleft, attempts;
+ QTimer *waittime;
+ QTimer *refreshtime;
+
+private slots:
+ void UpdateLockInfo();
+ void TryUnlock();
+
+signals:
+ void ScreenUnlocked();
+ void InputDetected();
+};
+#endif
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.ui b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.ui
new file mode 100644
index 00000000..7f0b45b8
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.ui
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LLockScreen</class>
+ <widget class="QWidget" name="LLockScreen">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>289</width>
+ <height>188</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="frame_unlock">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_hostname">
+ <property name="font">
+ <font>
+ <weight>50</weight>
+ <italic>true</italic>
+ <bold>false</bold>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true">hostname</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_username">
+ <property name="text">
+ <string notr="true">Locked by username</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_info">
+ <property name="font">
+ <font>
+ <italic>true</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLineEdit" name="line_password">
+ <property name="inputMask">
+ <string notr="true"/>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="placeholderText">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="tool_unlock">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Unlock Session</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
new file mode 100644
index 00000000..0c92784e
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
@@ -0,0 +1,181 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "LScreenSaver.h"
+#include <QScreen>
+#include <QApplication>
+
+#define DEBUG 1
+
+LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint){
+ starttimer = new QTimer(this);
+ starttimer->setSingleShot(true);
+ locktimer = new QTimer(this);
+ locktimer->setSingleShot(true);
+ hidetimer = new QTimer(this);
+ hidetimer->setSingleShot(true);
+
+ 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; }");
+ this->setMouseTracking(true);
+ connect(starttimer, SIGNAL(timeout()), this, SLOT(ShowScreenSaver()) );
+ connect(locktimer, SIGNAL(timeout()), this, SLOT(LockScreen()) );
+ connect(hidetimer, SIGNAL(timeout()), this, SLOT(HideLockScreen()) );
+ connect(LOCKER, SIGNAL(ScreenUnlocked()), this, SLOT(SSFinished()) );
+ connect(LOCKER, SIGNAL(InputDetected()), this, SLOT(newInputEvent()) );
+}
+
+LScreenSaver::~LScreenSaver(){
+
+}
+
+bool LScreenSaver::isLocked(){
+ return SSLocked;
+}
+
+void LScreenSaver::UpdateTimers(){
+ //This is generally used for programmatic changes
+ if(starttimer->isActive()){ starttimer->stop();}
+ if(locktimer->isActive()){ locktimer->stop(); }
+ if(hidetimer->isActive()){ hidetimer->stop(); }
+
+ if(!SSRunning && !SSLocked && (starttimer->interval() > 1000) ){ starttimer->start(); } //time to SS start
+ else if( SSRunning && !SSLocked && (locktimer->interval() > 1000 ) ){ locktimer->start(); } //time to lock
+ else if( !SSRunning && SSLocked ){ hidetimer->start(); } //time to hide lock screen
+}
+
+// ===========
+// PUBLIC SLOTS
+// ===========
+void LScreenSaver::start(){
+ reloadSettings(); //setup all the initial time frames
+ starttimer->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 );
+}
+
+void LScreenSaver::newInputEvent(){
+ if(updating){ return; } //in the middle of making changes which could cause an event
+ if(DEBUG){ qDebug() << "New Input Event"; }
+ if(SSRunning && SSLocked){
+ //Running and locked
+ // Hide the running setting, and display the lock screen
+ HideScreenSaver();
+ ShowLockScreen();
+ }else if(SSRunning){
+ //Only running, not locked
+ HideScreenSaver();
+ }
+ UpdateTimers();
+
+}
+
+void LScreenSaver::LockScreenNow(){
+ ShowScreenSaver();
+ LockScreen();
+}
+
+// ===========
+// PRIVATE SLOTS
+// ===========
+void LScreenSaver::ShowScreenSaver(){
+ if(DEBUG){ qDebug() << "Showing Screen Saver:" << QDateTime::currentDateTime().toString(); }
+ SSRunning = true;
+ updating = true;
+ //Now remove any current Base widgets (prevent any lingering painting between sessions)
+ for(int i=0; i<BASES.length(); i++){
+ if(DEBUG){ qDebug() << " - Removing SS Base"; }
+ delete BASES.takeAt(i); i--;
+ }
+ //Now go through and create/show all the various widgets
+ QList<QScreen*> SCREENS = QApplication::screens();
+ QRect bounds;
+ cBright = LOS::ScreenBrightness();
+ if(cBright>0){ LOS::setScreenBrightness(cBright/2); } //cut to half while the screensaver is active
+ 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);
+ 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() );
+ }
+ //Now set the overall parent widget geometry and show everything
+ this->setGeometry(bounds); //overall background widget
+ if(!this->isActiveWindow()){
+ this->raise();
+ this->show();
+ this->activateWindow();
+ }
+ for(int i=0; i<BASES.length(); i++){
+ BASES[i]->show();
+ BASES[i]->startPainting();
+ }
+ updating = false;
+ UpdateTimers();
+}
+
+void LScreenSaver::ShowLockScreen(){
+ if(DEBUG){ qDebug() << "Showing Lock Screen:" << QDateTime::currentDateTime().toString(); }
+ LOCKER->aboutToShow();
+ //Move the screen locker to the appropriate spot
+ QPoint ctr = QApplication::desktop()->screenGeometry(QCursor::pos()).center();
+ LOCKER->resize(LOCKER->sizeHint());
+ LOCKER->move(ctr - QPoint(LOCKER->width()/2, LOCKER->height()/2) );
+ LOCKER->show();
+ //Start the timer for hiding the lock screen due to inactivity
+ UpdateTimers();
+}
+
+void LScreenSaver::HideScreenSaver(){
+ if(DEBUG){ qDebug() << "Hiding Screen Saver:" << QDateTime::currentDateTime().toString(); }
+ SSRunning = false;
+ if(cBright>0){ LOS::setScreenBrightness(cBright); } //return to current brightness
+ if(!SSLocked){
+ this->hide();
+ emit ClosingScreenSaver();
+ }
+ for(int i=0; i<BASES.length(); i++){
+ BASES[i]->hide();
+ BASES[i]->stopPainting();
+ }
+ UpdateTimers();
+}
+
+void LScreenSaver::HideLockScreen(){
+ if(DEBUG){ qDebug() << "Hiding Lock Screen:" << QDateTime::currentDateTime().toString(); }
+ //Leave the Locked flag set (still locked, just not visible)
+ LOCKER->aboutToHide();
+ LOCKER->hide();
+ this->repaint();
+ if(SSLocked){ ShowScreenSaver(); }
+ UpdateTimers();
+}
+
+void LScreenSaver::LockScreen(){
+ if(SSLocked){ return; }
+ if(DEBUG){ qDebug() << "Locking Screen:" << QDateTime::currentDateTime().toString(); }
+ SSLocked = true;
+ LOCKER->LoadSystemDetails();
+ UpdateTimers();
+}
+
+void LScreenSaver::SSFinished(){
+ if(DEBUG){ qDebug() << "Screensaver Finished:" << QDateTime::currentDateTime().toString(); }
+ SSLocked = false;
+ HideLockScreen();
+ HideScreenSaver();
+}
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h
new file mode 100644
index 00000000..5119d8b1
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h
@@ -0,0 +1,59 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_H
+
+#include "GlobalDefines.h"
+
+#include "SSBaseWidget.h"
+#include "LLockScreen.h"
+
+class LScreenSaver : public QWidget{
+ Q_OBJECT
+public:
+ LScreenSaver();
+ ~LScreenSaver();
+
+ bool isLocked();
+
+private:
+ QTimer *starttimer, *locktimer, *hidetimer;
+ QSettings *settings;
+ QList<SSBaseWidget*> BASES;
+ LLockScreen *LOCKER;
+ int cBright;
+ bool SSRunning, SSLocked, updating;
+
+ void UpdateTimers();
+
+public slots:
+ void start();
+ void reloadSettings();
+ void newInputEvent();
+ void LockScreenNow();
+
+private slots:
+ void ShowScreenSaver();
+ void ShowLockScreen();
+ void HideScreenSaver();
+ void HideLockScreen();
+
+ void LockScreen();
+ void SSFinished();
+
+signals:
+ void StartingScreenSaver();
+ void ClosingScreenSaver();
+
+protected:
+ void mouseMoveEvent(QMouseEvent*){
+ QTimer::singleShot(0,this, SLOT(newInputEvent()));
+ }
+
+};
+
+#endif \ No newline at end of file
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
new file mode 100644
index 00000000..83b82ff8
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/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;
+ }
+}
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
new file mode 100644
index 00000000..a6574679
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
@@ -0,0 +1,55 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This class is the widget which provides the screensaver painting/plugin functionality
+//===========================================
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_BASE_WIDGET_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_BASE_WIDGET_H
+
+#include "GlobalDefines.h"
+#include "animations/BaseAnimGroup.h"
+
+class SSBaseWidget : public QWidget{
+ Q_OBJECT
+public:
+ SSBaseWidget(QWidget *parent, QSettings *set);
+ ~SSBaseWidget();
+
+ void setPlugin(QString);
+
+public slots:
+ void startPainting();
+ void stopPainting();
+
+private:
+ QString plugType, cplug; //type of custom painting to do
+ BaseAnimGroup *ANIM;
+ QSettings *settings;
+
+private slots:
+
+signals:
+ void InputDetected(); //just in case no event handling setup at the WM level
+
+protected:
+ void mouseMoveEvent(QMouseEvent *ev){
+ ev->accept();
+ emit InputDetected();
+ }
+ void keyPressEvent(QKeyEvent *ev){
+ ev->accept();
+ emit InputDetected();
+ }
+ void paintEvent(QPaintEvent*){
+ QStyleOption opt;
+ opt.init(this);
+ QPainter p(this);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+ }
+
+};
+
+#endif
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
new file mode 100644
index 00000000..1e55dc76
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp
@@ -0,0 +1,27 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "BaseAnimGroup.h"
+
+//Include all the known subclasses here, then add a unique ID for it to the functions at the bottom
+#include "SampleAnimation.h"
+
+//==============================
+// PLUGIN LOADING/LISTING
+//==============================
+BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSettings *set){
+ //This is where we place all the known plugin ID's, and load the associated subclass
+ if(type == "sample"){
+ return (new SampleAnimation(parent, set));
+ }else{
+ //Unknown screensaver, return a blank animation group
+ return (new BaseAnimGroup(parent, set));
+ }
+}
+
+QStringList BaseAnimGroup::KnownAnimations(){
+ return (QStringList() << "sample");
+} \ No newline at end of file
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
new file mode 100644
index 00000000..dd7269d4
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.h
@@ -0,0 +1,37 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This class is the container which provides the screensaver animations
+// and should be subclassed for each of the various animation types
+//===========================================
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_BASE_ANIMATION_GROUP_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_BASE_ANIMATION_GROUP_H
+
+#include "GlobalDefines.h"
+
+class BaseAnimGroup : public QParallelAnimationGroup{
+ Q_OBJECT
+public:
+ QWidget *canvas;
+ QSettings *settings;
+
+ virtual void LoadAnimations(){} //This is the main function which needs to be subclassed
+
+ BaseAnimGroup(QWidget *parent, QSettings *set){
+ canvas = parent;
+ settings = set;
+ }
+ ~BaseAnimGroup(){}
+
+ //==============================
+ // PLUGIN LOADING/LISTING (Change in the .cpp file)
+ //==============================
+ static BaseAnimGroup* NewAnimation(QString type, QWidget *parent, QSettings *set);
+ static QStringList KnownAnimations();
+
+};
+
+#endif \ No newline at end of file
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
new file mode 100644
index 00000000..e0f11ba5
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/SampleAnimation.h
@@ -0,0 +1,45 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This class is the sample plugin for a ScreenSaver animation
+//===========================================
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_SAMPLE_ANIMATION_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_SAMPLE_ANIMATION_H
+
+#include "GlobalDefines.h"
+#include "BaseAnimGroup.h"
+
+class SampleAnimation : public BaseAnimGroup{
+ Q_OBJECT
+private:
+ QWidget *ball;
+
+public:
+ SampleAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+ ~SampleAnimation(){ this->stop(); delete ball; }
+
+ void LoadAnimations(){
+ //qDebug() << "Loading Sample Animation";
+ ball = new QWidget(canvas);
+ //This creates a red "ball" on the widget which is going to expand/contract in the center of the screen
+ ball->setStyleSheet("background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.341, fy:0.796, stop:0.00531915 rgba(107, 10, 10, 255), stop:0.521277 rgba(170, 10, 10, 255), stop:0.957447 rgba(200, 0, 0, 255), stop:0.994681 rgba(0, 0, 0, 225), stop:1 rgba(255, 255, 255, 0));");
+ //Now setup the movements
+ QPropertyAnimation *move = new QPropertyAnimation(ball,"geometry");
+ QPoint ctr(canvas->width()/2, canvas->height()/2);
+ QRect initgeom(ctr-QPoint(12,12), QSize(24,24) );
+ move->setKeyValueAt(0, initgeom ); //starting point
+ move->setKeyValueAt(1, initgeom ); //ending point (same as start for continuity)
+ int size = canvas->width();
+ if(size > canvas->height()){ size = canvas->height(); }
+ move->setKeyValueAt(0.5, QRect(ctr-QPoint(size/2, size/2), QSize(size,size))); //touch the edge of the screen
+ move->setDuration(10000); //10 seconds
+ this->addAnimation(move);
+ this->setLoopCount(10); //repeat 10 times
+ ball->show();
+ }
+
+};
+#endif
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri
new file mode 100644
index 00000000..adb1ed6c
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/animations.pri
@@ -0,0 +1,6 @@
+SOURCES += $$PWD/BaseAnimGroup.cpp
+
+HEADERS += $$PWD/BaseAnimGroup.h \
+ $$PWD/SampleAnimation.h
+
+#FORMS +=
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri b/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri
new file mode 100644
index 00000000..f95891c1
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri
@@ -0,0 +1,15 @@
+SOURCES *= $${PWD}/LLockScreen.cpp \
+ $${PWD}/LScreenSaver.cpp \
+ $${PWD}/SSBaseWidget.cpp
+
+HEADERS *= $${PWD}/LLockScreen.h \
+ $${PWD}/LScreenSaver.h \
+ $${PWD}/SSBaseWidget.h
+
+FORMS *= $${PWD}/LLockScreen.ui
+
+#update the includepath so we can just (#include <LScreenSaver.h>) as needed without paths
+INCLUDEPATH *= ${PWD}
+
+#Now include all the screensaver animations/options
+include(animations/animations.pri)
bgstack15