aboutsummaryrefslogtreecommitdiff
path: root/lumina-wm-INCOMPLETE/LScreenSaver.cpp
blob: 7af3758f9516fa9de335d2b1090b9f3b1f286885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//===========================================
//  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"

LScreenSaver::LScreenSaver(){
  starttimer = new QTimer(this);
    starttimer->setSingleShot(true);
  locktimer = new QTimer(this);
    locktimer->setSingleShot(true);
  hidetimer = new QTimer(this);
    hidetimer->setSingleShot(true);
	
  settings = new QSettings("LuminaDE","lumina-screensaver",this);
  SSRunning = SSLocked = false;
	
  connect(starttimer, SIGNAL(timeout()), this, SLOT(ShowScreenSaver()) );
}

LScreenSaver::~LScreenSaver(){
	
}

// ===========
//  PUBLIC SLOTS
// ===========
void LScreenSaver::start(){
  reloadSettings(); //setup all the initial time frames
  
}

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(){
  //First stop any timers that are running
  if(starttimer->isActive()){ starttimer->stop();}
  if(locktimer->isActive()){ locktimer->stop(); }
  if(hidetimer->isActive()){ hidetimer->stop(); }
    
  if(SSRunning && SSLocked){
    //Running and locked
    // Hide the running setting, and display the lock screen
	
    //Start the timer for restarting the SS and hiding the lockscreen
    hidetimer->start();
	  
  }else if(SSRunning){
    //Only running, not locked
    //De-activate the screensaver and start the main timer
    HideScreenSaver();
    starttimer->start();
	  
  }else if(SSLocked){
    //Only locked, not running
    hidetimer->start(); //restart the time to hide the lock screen
    
  }else{
    //Neither running nor locked
    if( settings.value("timedelaymin",10).toInt() > 0 ){ starttimer->start(); }
  }
  
}

// ===========
//  PRIVATE SLOTS
// ===========
void LScreenSaver::ShowScreenSaver(){
	
  SSRunning = true;
  //Start the lock timer if necessary
  if(!SSLocked && (settings.value("lockdelaymin",10).toInt()>0) ){ locktimer->start(); }
}

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;
}

void LScreenSaver::HideLockScreen(){

  //Leave the Locked flag set (still locked, just not visible)
}
bgstack15