aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-08-02 21:00:16 +0000
committerWeblate <noreply@weblate.org>2017-08-02 21:00:16 +0000
commit3d511a0f8285088eba24cb22b15cda039d27f6a0 (patch)
tree2eccf8b44a5e9862e6733880c37d57a9af74b41a /src-qt5/core/lumina-desktop-unified
parentTranslated using Weblate (Spanish) (diff)
parentFix up the screensaver animation crashes *again*. (diff)
downloadlumina-3d511a0f8285088eba24cb22b15cda039d27f6a0.tar.gz
lumina-3d511a0f8285088eba24cb22b15cda039d27f6a0.tar.bz2
lumina-3d511a0f8285088eba24cb22b15cda039d27f6a0.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp11
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp5
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h8
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h57
5 files changed, 46 insertions, 37 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
index bfcfa54d..0ac8aaeb 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp
@@ -8,7 +8,7 @@
#include <QScreen>
#include <QApplication>
-#define DEBUG 0
+#define DEBUG 1
LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint){
starttimer = new QTimer(this);
@@ -102,8 +102,8 @@ void LScreenSaver::ShowScreenSaver(){
//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
+ //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; }
@@ -144,15 +144,16 @@ void LScreenSaver::HideScreenSaver(){
//QApplication::restoreOverrideCursor();
if(DEBUG){ qDebug() << "Hiding Screen Saver:" << QDateTime::currentDateTime().toString(); }
SSRunning = false;
- if(cBright>0){ LOS::setScreenBrightness(cBright); } //return to current brightness
+ //if(cBright>0){ LOS::setScreenBrightness(cBright); } //return to current brightness
if(!SSLocked){
this->hide();
emit ClosingScreenSaver();
emit LockStatusChanged(false);
}
for(int i=0; i<BASES.length(); i++){
- BASES[i]->hide();
+ qDebug() << "Stop ScreenSaver:" << i;
BASES[i]->stopPainting();
+ BASES[i]->hide();
}
UpdateTimers();
}
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 b31ef793..9ef0c491 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp
@@ -76,9 +76,10 @@ void SSBaseWidget::startPainting(){
void SSBaseWidget::stopPainting(){
if(ANIM!=0){
+ qDebug() << "Stopping Animation!!";
ANIM->stop();
- ANIM->clear();
- delete ANIM;
+ //ANIM->clear();
+ ANIM->deleteLater();
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
index bdcefa24..9d987178 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h
@@ -14,10 +14,10 @@
class SSBaseWidget : public QWidget{
Q_OBJECT
-public:
+public:
SSBaseWidget(QWidget *parent, QSettings *set);
~SSBaseWidget();
-
+
void setPlugin(QString);
public slots:
@@ -30,7 +30,7 @@ private:
QSettings *settings;
private slots:
-
+
signals:
void InputDetected(); //just in case no event handling setup at the WM level
@@ -49,7 +49,7 @@ protected:
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
index 017eaf9f..aaae8b41 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/BaseAnimGroup.cpp
@@ -31,5 +31,5 @@ BaseAnimGroup* BaseAnimGroup::NewAnimation(QString type, QWidget *parent, QSetti
}
QStringList BaseAnimGroup::KnownAnimations(){
- return (QStringList() << "fireflies" << "grav" << "text");
+ return (QStringList() << "grav");
}
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h
index ad1b1122..ec1de914 100644
--- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Grav.h
@@ -14,6 +14,7 @@
#include "BaseAnimGroup.h"
#include <QParallelAnimationGroup>
#include <QtMath>
+#include <QMatrix>
class Grav: public QParallelAnimationGroup{
Q_OBJECT
@@ -21,11 +22,11 @@ private:
QWidget *planet;
QPropertyAnimation *orbit;
QSize range;
- QList<QPoint> path;
+ //QList<QPoint> path;
double radius;
void setupLoop(QPoint start, QPoint *ref){
- orbit->setStartValue(start);
+ //orbit->setStartValue(start);
//Used to find overall speed. Distance from the planet to the sun
radius = qSqrt( (qPow(start.x()-ref->x(),2) + qPow(start.y()-ref->y(),2) ));
@@ -39,9 +40,9 @@ private:
QPoint firstP = QPoint(ref->x() + xrand*start.x()*(qCos(0/step) -qSin(0/step)), ref->y() + yrand*start.y()*(qCos(0/step) -qSin(0/step)));
QPoint lastP = QPoint(ref->x() + xrand*start.x()*(qCos(PI/step) -qSin(PI/step)), ref->y() + yrand*start.y()*(qCos(PI/step) -qSin(PI/step)));
- //orbit->setKeyValueAt(0, firstP);
- //orbit->setKeyValueAt(1, lastP);
- path.push_back(firstP);
+ orbit->setKeyValueAt(0, firstP);
+ orbit->setKeyValueAt(1, lastP);
+ //path.push_back(firstP);
//Loops through all steps and creates all the points of the orbit
for(int i=1; i<step; i++) {
@@ -54,21 +55,20 @@ private:
//Creates a new point and creates a key as part of the animation
QPoint newLoc = QPoint(newX, newY);
- //orbit->setKeyValueAt(i/step, newLoc);
- path.push_back(newLoc);
- }
-
+ orbit->setKeyValueAt(i/step, newLoc);
+ //path.push_back(newLoc);
+ }
//Sets the time for a full orbit. Increasing makes the orbit slower.
- path.push_back(lastP);
+ //path.push_back(lastP);
}
private slots:
void LoopChanged(int loop){
//Adjust the orbit animation a bit
- if(loop >= 0) {
+ /*if(loop >= 0) {
orbit->setStartValue(orbit->endValue()); //start at the previous end point
orbit->setEndValue(path.at(loop%1000));
orbit->setDuration(10);
- }
+ }*/
}
void stopped(){ qDebug() << "Planet stopped"; planet->hide();}
@@ -79,7 +79,7 @@ public:
QPoint center = parent->geometry().center();
//Creates a random planet size. Between 12 and 45 pixels
- double planet_radius = 1.75* ((qrand()%20)+7);
+ int planet_radius = qRound(1.75* ((qrand()%20)+7) );
//Creates a random color in RGB, then creates a circular gradient
QString color = "rgba(" + QString::number(qrand() % 256) + ", " + QString::number(qrand() % 256) + ", " + QString::number(qrand() % 256);
@@ -93,24 +93,32 @@ public:
orbit->setTargetObject(planet);
//Creates the random position of the planet, making sure it isn't too close to the sun
- int randwidth = qrand()%(range.width()/2);
- if(randwidth < range.width() + 100 and randwidth > range.width() - 100) randwidth = 100;
- int randheight= qrand()%(range.height()/2);
- if(randheight < range.height() + 100 and randheight > range.height() - 100) randheight = 100;
+ QRect invalid = QRect(center+QPoint(-50,-50), center+QPoint(50,50));
+ QPoint tmp = center;
+ while(invalid.contains(tmp)){
+ int randwidth = qrand()%(range.width() - 2*planet_radius) + planet_radius;
+ int randheight= qrand()%(range.height()- 2*planet_radius) + planet_radius;
+ tmp = QPoint(randwidth, randheight);
+ }
+
+ /*double tmpDistance = qSqrt((qPow((tmp.x()-center.x()), 2) + qPow((tmp.y()-center.y()), 2)));
+ double theta = qAsin(qAbs(tmp.y()-center.y())/tmpDistance);
+ QMatrix rotation = QMatrix(qCos(theta), qSin(theta), -qSin(theta), qCos(theta), -center.x(), -center.y());*/
//Creates all frames for the animation
- setupLoop(QPoint(randwidth, randheight), &center);
+ setupLoop(tmp, &center);
this->addAnimation(orbit);
planet->show();
//Ensures the screensaver will not stop until the user wishes to login or it times out
- this->setLoopCount(2000); //number of orbits
- orbit->setEndValue(path.at(0));
- LoopChanged(0); //load initial values
+ this->setLoopCount(5); //number of orbits
+ orbit->setDuration( qrand() %1000 + 19000); //20 second orbits
+ //orbit->setEndValue(path.at(0));
+ //LoopChanged(0); //load initial values
//Sets the initial size and location of the planet
planet->setGeometry(QRect(orbit->startValue().toPoint(), QSize(planet_radius, planet_radius)));
- connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged(int)) );
+ //connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged(int)) );
connect(this, SIGNAL(finished()), this, SLOT(stopped()) );
}
~Grav(){}
@@ -171,14 +179,13 @@ public:
int number = settings->value("planets/number",10).toInt();
//Loops through all planets and sets up the animations, then adds them to the base group and vector, which
+ qDebug() << "Starting planets";
for(int i=0; i<number; i++){
- if(planets.length()>number){ continue; }
Grav *tmp = new Grav(canvas);
this->addAnimation(tmp);
- connect(tmp, SIGNAL(finished()), this, SLOT(checkFinished()));
+ connect(tmp, SIGNAL(finished()), this, SLOT(checkFinished()));
planets << tmp;
}
- while(planets.length()>number){planets.takeAt(number)->deleteLater(); }
}
};
bgstack15