-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgetsettings.cpp
More file actions
66 lines (57 loc) · 1.53 KB
/
widgetsettings.cpp
File metadata and controls
66 lines (57 loc) · 1.53 KB
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
#include "widgetsettings.h"
#include <QLineEdit>
#include <QTime>
void addSounds(QComboBox *soundsCombo)
{
soundsCombo->addItem("Standard signal", "qrc:/sounds/sound1.wav");
soundsCombo->addItem("Bird song", "qrc:/sounds/Bird.mp3");
soundsCombo->addItem("Light music", "qrc:/sounds/Light.mp3");
}
int elpasedTime(QTime time)
{
return time.hour()*3600*1000+
time.minute()*60*1000+
time.second()*1000;
}
bool DDCheck(GlobalSettings globalSettings)
{
int currTime = elpasedTime(QTime::currentTime());
if (globalSettings.DDenabled)
{
if (globalSettings.DDstart==globalSettings.DDend)
return true;
if(globalSettings.DDstart<globalSettings.DDend)
{
if (currTime>=globalSettings.DDstart && currTime <= globalSettings.DDend )
return false;
return true;
}
else
{
if (currTime>=globalSettings.DDstart || currTime <= globalSettings.DDend)
return false;
return true;
}
}
else
return true;
}
int calculateDuration(const QTime &t)
{
int alertMsecs = getMsecs(t);
int currMsecs = getMsecs(QTime::currentTime());
if (currMsecs > alertMsecs)
{
int wholeDay = 3600*24*1000;
return (wholeDay+alertMsecs-currMsecs);
}
if (currMsecs < alertMsecs)
{
return (alertMsecs-currMsecs);
}
return 0;
}
int getMsecs(const QTime &t)
{
return (t.hour()*3600+t.minute()*60+t.second())*1000+t.msec();
}