diff options
author | Ken Moore <moorekou@gmail.com> | 2015-11-02 10:31:39 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-11-02 10:31:39 -0500 |
commit | b2c02af28049c4feed7a845505ef9a931237056a (patch) | |
tree | 535afc3e4aba5191a0604e70a78f7ca4a72f0762 /lumina-wm-INCOMPLETE | |
parent | Cleanup how auto-start apps are launched a bit (start them via a single lumin... (diff) | |
download | lumina-b2c02af28049c4feed7a845505ef9a931237056a.tar.gz lumina-b2c02af28049c4feed7a845505ef9a931237056a.tar.bz2 lumina-b2c02af28049c4feed7a845505ef9a931237056a.zip |
Add all the animations framework for the screensaver side of lumina-wm (with a quick "sample" plugin).
Diffstat (limited to 'lumina-wm-INCOMPLETE')
-rw-r--r-- | lumina-wm-INCOMPLETE/GlobalDefines.h | 6 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/LScreenSaver.cpp | 50 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/LScreenSaver.h | 10 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/SSBaseWidget.cpp | 65 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/SSBaseWidget.h | 38 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/animations/BaseAnimGroup.cpp | 27 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/animations/BaseAnimGroup.h | 39 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/animations/SampleAnimation.h | 43 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/animations/animations.pri | 6 | ||||
-rw-r--r-- | lumina-wm-INCOMPLETE/lumina-wm.pro | 5 |
10 files changed, 280 insertions, 9 deletions
diff --git a/lumina-wm-INCOMPLETE/GlobalDefines.h b/lumina-wm-INCOMPLETE/GlobalDefines.h index f78f9cbd..4376a891 100644 --- a/lumina-wm-INCOMPLETE/GlobalDefines.h +++ b/lumina-wm-INCOMPLETE/GlobalDefines.h @@ -31,8 +31,14 @@ #include <QX11Info> #include <QCoreApplication> #include <QPropertyAnimation> +#include <QAnimationGroup> +#include <QParallelAnimationGroup> #include <QWindow> +#include <QWidget> #include <QBackingStore> +#include <QPaintEvent> +#include <QPainter> +#include <QSettings> // libLumina includes #include <LuminaX11.h> diff --git a/lumina-wm-INCOMPLETE/LScreenSaver.cpp b/lumina-wm-INCOMPLETE/LScreenSaver.cpp index a903701c..3b1d5e6a 100644 --- a/lumina-wm-INCOMPLETE/LScreenSaver.cpp +++ b/lumina-wm-INCOMPLETE/LScreenSaver.cpp @@ -5,8 +5,10 @@ // See the LICENSE file for full details //=========================================== #include "LScreenSaver.h" +#include <QScreen> +#include <QApplication> -LScreenSaver::LScreenSaver(){ +LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint){ starttimer = new QTimer(this); starttimer->setSingleShot(true); locktimer = new QTimer(this); @@ -16,7 +18,8 @@ LScreenSaver::LScreenSaver(){ settings = new QSettings("LuminaDE","lumina-screensaver",this); SSRunning = SSLocked = false; - + this->setObjectName("LSCREENSAVERBASE"); + this->setStyleSheet("LScreenSaver#LSCREENSAVERBASE{ background: black; }"); connect(starttimer, SIGNAL(timeout()), this, SLOT(ShowScreenSaver()) ); } @@ -24,6 +27,10 @@ LScreenSaver::~LScreenSaver(){ } +bool LScreenSaver::isLocked(){ + return SSLocked; +} + // =========== // PUBLIC SLOTS // =========== @@ -48,7 +55,8 @@ void LScreenSaver::newInputEvent(){ if(SSRunning && SSLocked){ //Running and locked // Hide the running setting, and display the lock screen - + HideScreenSaver(); + ShowLockScreen(); //Start the timer for restarting the SS and hiding the lockscreen hidetimer->start(); @@ -73,25 +81,53 @@ void LScreenSaver::newInputEvent(){ // PRIVATE SLOTS // =========== void LScreenSaver::ShowScreenSaver(){ - SSRunning = true; //Start the lock timer if necessary if(!SSLocked && (settings->value("lockdelaymin",10).toInt()>0) ){ locktimer->start(); } + //Now go through and create/show all the various widgets + QList<QScreen*> SCREENS = QApplication::screens(); + QRect bounds; + for(int i=0; i<SCREENS.length(); i++){ + bounds = bounds.united(SCREENS[i]->geometry()); + if( (BASES.length()-1) < i){ + //Nothing for this screen yet - go ahead and create one + BASES << new SSBaseWidget(this, settings); + } + //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 remove any extra Base widgets (in case a screen was removed) + for(int i=SCREENS.length(); i<BASES.length(); i++){ + delete BASES.takeAt(i); i--; + } + //Now set the overall parent widget geometry and show everything + this->setGeometry(bounds); //overall background widget + this->raise(); + this->show(); + this->activateWindow(); + for(int i=0; i<BASES.length(); i++){ + BASES[i]->show(); + QTimer::singleShot(100, BASES[i], SLOT(startPainting()) ); //start in 1/2 second + } } void LScreenSaver::ShowLockScreen(){ - SSLocked = true; //Start the timer for hiding the lock screen due to inactivity if(settings->value("hidesecs",15).toInt() > 0 ){ hidetimer->start(); } } void LScreenSaver::HideScreenSaver(){ - SSRunning = false; + if(!SSLocked){ + this->hide(); + emit ClosingScreenSaver(); + } + for(int i=0; i<BASES.length(); i++){ QTimer::singleShot(0,BASES[i], SLOT(stopPainting())); } } void LScreenSaver::HideLockScreen(){ - //Leave the Locked flag set (still locked, just not visible) } diff --git a/lumina-wm-INCOMPLETE/LScreenSaver.h b/lumina-wm-INCOMPLETE/LScreenSaver.h index c2965ae6..a0595a7c 100644 --- a/lumina-wm-INCOMPLETE/LScreenSaver.h +++ b/lumina-wm-INCOMPLETE/LScreenSaver.h @@ -7,20 +7,26 @@ #ifndef _LUMINA_DESKTOP_SCREEN_SAVER_H #define _LUMINA_DESKTOP_SCREEN_SAVER_H -#include <QObject> +#include <QWidget> #include <QStringList> #include <QTimer> #include <QSettings> -class LScreenSaver : public QObject{ +#include "SSBaseWidget.h" + +class LScreenSaver : public QWidget{ Q_OBJECT public: LScreenSaver(); ~LScreenSaver(); + bool isLocked(); + private: QTimer *starttimer, *locktimer, *hidetimer; QSettings *settings; + QList<SSBaseWidget*> BASES; + bool SSRunning, SSLocked; public slots: diff --git a/lumina-wm-INCOMPLETE/SSBaseWidget.cpp b/lumina-wm-INCOMPLETE/SSBaseWidget.cpp new file mode 100644 index 00000000..3371c5e2 --- /dev/null +++ b/lumina-wm-INCOMPLETE/SSBaseWidget.cpp @@ -0,0 +1,65 @@ +//=========================================== +// 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" + +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 + ANIM = 0; +} + +SSBaseWidget::~SSBaseWidget(){ + +} + +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; + if(ANIM!=0){ ANIM->clear(); } + //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 + } + //Now list all the various plugins and start them appropriately + QString style; + if(cplug=="none"){ + style = "background: transparent"; //show the underlying black parent widget + } + this->setStyleSheet(style); + //If not a stylesheet-based plugin - set it here + if(ANIM!=0){ free(ANIM); ANIM = 0; } //free up the old instance + if(cplug!="none"){ + ANIM = BaseAnimGroup::NewAnimation(cplug, this, settings); + connect(ANIM, SIGNAL(finished()), this, SLOT(startPainting()) ); //repeat the plugin as needed + } + //Now start the animation(s) + if(ANIM!=0){ + if(ANIM->animationCount()>0){ ANIM->start(); } + } +} + +void SSBaseWidget::stopPainting(){ + if(ANIM!=0){ + ANIM->stop(); + ANIM->clear(); + } +} diff --git a/lumina-wm-INCOMPLETE/SSBaseWidget.h b/lumina-wm-INCOMPLETE/SSBaseWidget.h new file mode 100644 index 00000000..9858b52f --- /dev/null +++ b/lumina-wm-INCOMPLETE/SSBaseWidget.h @@ -0,0 +1,38 @@ +//=========================================== +// 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: + +}; + +#endif diff --git a/lumina-wm-INCOMPLETE/animations/BaseAnimGroup.cpp b/lumina-wm-INCOMPLETE/animations/BaseAnimGroup.cpp new file mode 100644 index 00000000..1e55dc76 --- /dev/null +++ b/lumina-wm-INCOMPLETE/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/lumina-wm-INCOMPLETE/animations/BaseAnimGroup.h b/lumina-wm-INCOMPLETE/animations/BaseAnimGroup.h new file mode 100644 index 00000000..05c36ea2 --- /dev/null +++ b/lumina-wm-INCOMPLETE/animations/BaseAnimGroup.h @@ -0,0 +1,39 @@ +//=========================================== +// 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; + //Now load the animations for this particular plugin + LoadAnimations(); + } + ~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/lumina-wm-INCOMPLETE/animations/SampleAnimation.h b/lumina-wm-INCOMPLETE/animations/SampleAnimation.h new file mode 100644 index 00000000..8e513426 --- /dev/null +++ b/lumina-wm-INCOMPLETE/animations/SampleAnimation.h @@ -0,0 +1,43 @@ +//=========================================== +// 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 +public: + SampleAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} + + ~SampleAnimation(){} + +private: + QWidget *ball; + virtual void LoadAnimations(){ + 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));"); + //ball->setSize(QSize(64,64)); + ball->move(canvas->geometry().center()-QPoint(32,32)); + //Now setup the movements + QPropertyAnimation *move = new QPropertyAnimation(ball,"size"); + move->setKeyValueAt(0, QSize(64, 64) ); + int size = canvas->width(); + if(size > canvas->height()){ size = canvas->height(); } + move->setKeyValueAt(0.5, QSize(size,size)); //touch the edge of the screen + move->setKeyValueAt(1, QSize(64, 64) ); //back to original size + move->setDuration(10000); //10 seconds + this->addAnimation(move); + this->setLoopCount(10); //repeat 10 times + } + +}; +#endif diff --git a/lumina-wm-INCOMPLETE/animations/animations.pri b/lumina-wm-INCOMPLETE/animations/animations.pri new file mode 100644 index 00000000..5473d4e1 --- /dev/null +++ b/lumina-wm-INCOMPLETE/animations/animations.pri @@ -0,0 +1,6 @@ +SOURCES += $$PWD/BaseAnimGroup.cpp + +HEADERS += $$PWD/BaseAnimGroup.h \ + $$PWD/SampleAnimation.h + +FORMS +=
\ No newline at end of file diff --git a/lumina-wm-INCOMPLETE/lumina-wm.pro b/lumina-wm-INCOMPLETE/lumina-wm.pro index bba49cdc..3fd5026e 100644 --- a/lumina-wm-INCOMPLETE/lumina-wm.pro +++ b/lumina-wm-INCOMPLETE/lumina-wm.pro @@ -28,6 +28,7 @@ LRELEASE = $$QT5LIBDIR/bin/lrelease SOURCES += main.cpp \ WMSession.cpp \ LScreenSaver.cpp \ + SSBaseWidget.cpp \ LXcbEventFilter.cpp \ LWindow.cpp @@ -35,11 +36,15 @@ SOURCES += main.cpp \ HEADERS += GlobalDefines.h \ WMSession.h \ LScreenSaver.h \ + SSBaseWidget.h \ LXcbEventFilter.h \ LWindow.h FORMS += +#Now add in all the screensaver animation plugins +include(animations/animations.pri) + INCLUDEPATH += ../libLumina $$PREFIX/include TRANSLATIONS = i18n/lumina-wm_af.ts \ |