From dfac324cb6b02d19857f0e5dcced099d31ce957d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 11 Oct 2017 10:34:53 -0400 Subject: Get the Lumina2 screensaver system converted over to the new QML-backed plugin system. Still need to clean up some old files within the source tree, but it all works right now. --- .../src-screensaver/SSBaseWidget.cpp | 63 +++++++--------------- .../src-screensaver/SSBaseWidget.h | 12 ++--- 2 files changed, 24 insertions(+), 51 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver') 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 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 widgets = this->findChildren("",Qt::FindDirectChildrenOnly); - for(int i=0; ideleteLater(); } + 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 -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); - } + }*/ }; -- cgit From a2bb82ae14f9f52c15e08880a559781d6f9e9ecb Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 11 Oct 2017 12:14:26 -0400 Subject: A bit more cleanup for the screensaver system. Now the old animations are completely ignored in the build, and the mouse cursor is hidden while the screensaver is active. --- .../core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp | 6 +++--- src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h | 6 ------ src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri | 4 ++-- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver') 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 227e51ac..122307b3 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp @@ -16,10 +16,10 @@ SSBaseWidget::SSBaseWidget(QWidget *parent) : QQuickView(parent->windowHandle()) this->setObjectName("LuminaBaseSSWidget"); this->setResizeMode(QQuickView::SizeRootObjectToView); this->setColor(QColor("black")); //default color for the view - //this->setMouseTracking(true); + this->setCursor(Qt::BlankCursor); plugType="none"; restartTimer = new QTimer(this); - restartTimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "globals/plugin_time_seconds", 60).toInt() * 1000); + restartTimer->setInterval( DesktopSettings::instance()->value(DesktopSettings::ScreenSaver, "globals/plugin_time_seconds", 120).toInt() * 1000); restartTimer->setSingleShot(true); connect(restartTimer, SIGNAL(timeout()), this, SLOT(startPainting()) ); } @@ -47,7 +47,7 @@ void SSBaseWidget::startPainting(){ if(DEBUG){ qDebug() << " - Screen Saver:" << plugType << cplug.scriptURL() << cplug.isValid(); } if(cplug.isValid()){ this->setSource( cplug.scriptURL() ); - restartTimer->start(); + if(plugType=="random"){ restartTimer->start(); } } } 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 fdb23e66..72e02702 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h @@ -43,12 +43,6 @@ protected: ev->accept(); emit InputDetected(); } - /*void paintEvent(QPaintEvent*){ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - }*/ }; diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri b/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri index f95891c1..92cc7bd2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/screensaver.pri @@ -9,7 +9,7 @@ HEADERS *= $${PWD}/LLockScreen.h \ FORMS *= $${PWD}/LLockScreen.ui #update the includepath so we can just (#include ) as needed without paths -INCLUDEPATH *= ${PWD} +INCLUDEPATH *= $${PWD} #Now include all the screensaver animations/options -include(animations/animations.pri) +#include(animations/animations.pri) -- cgit From 2cedaf2c2ac9e4b4e3078c5a6f04ba5fc3f4f5b3 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 11 Oct 2017 14:46:54 -0400 Subject: Update lumina-checkpass with 2 additional options: 1. "-fd " pass in a file descriptor (such as 0 for standard input) to read password 2. "-f " pass in a file path to read the password Then update lumina-desktop-unified to use the "-f" version with a QTemporaryFile. I was trying to get it to use the "-fd" version, but the file descriptor I am getting from the QTemporaryFile does not seem to work properly - still need to track this down a bit more later but the -f option works fine for now. --- .../lumina-desktop-unified/src-screensaver/LLockScreen.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver') diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp index 0ff70142..b791ffd2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp @@ -77,7 +77,18 @@ void LLockScreen::TryUnlock(){ this->setEnabled(false); QString pass = ui->line_password->text(); ui->line_password->clear(); - bool ok = (LUtils::runCmd("lumina-checkpass", QStringList() << pass) == 0); + //Create a temporary file for the password, then pass that file descriptor to lumina-checkpass + QTemporaryFile *TF = new QTemporaryFile(".XXXXXXXXXX"); + TF->setAutoRemove(true); + bool ok = false; + if( TF->open() ){ + QTextStream in(TF); + in << pass; + in.flush(); //make sure we push it to the file **right now** since we need to keep the file open + ok = (LUtils::runCmd("lumina-checkpass", QStringList() << "-f" << TF->fileName() ) == 0); + TF->close(); + } + delete TF; if(ok){ emit ScreenUnlocked(); this->setEnabled(true); -- cgit