-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventinformer.cpp
58 lines (53 loc) · 1.5 KB
/
eventinformer.cpp
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
#include "eventinformer.h"
#include <QDebug>
eventInformer::eventInformer(QObject *parent) :
QObject(parent)
{
m_form.setWindowFlags(Qt::ToolTip); //Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint
m_form.move((QApplication::desktop()->width() - m_form.width()) / 2,
(QApplication::desktop()->height() - m_form.height()) / 2);
connect(&m_form, SIGNAL(acceptSignal()), this, SLOT(closeEvent()));
m_sound = new QSound(m_SoundPath);
}
eventInformer::~eventInformer()
{
delete m_sound;
}
void eventInformer::setSettings(structSettings *s)
{
m_showDialog = s->showDialog;
m_playSound = s->playSound;
m_msgPattern = s->msgPattern;
if(m_SoundPath != s->SoundPath)
{
m_SoundPath = s->SoundPath;
delete m_sound;
m_sound = new QSound(m_SoundPath);
}
}
void eventInformer::showEvent(QList<events> *List)
{
if(m_showDialog)
{
QString msgString;
for(int i = 0; i < List->size(); i++)
{
msgString = m_msgPattern
.arg(List->value(i).date.toString("dd.MM.yyyy"))
.arg(List->value(i).time.toString("hh:mm:ss"))
.arg(List->value(i).cabinet)
.arg(List->value(i).inf);
m_form.append(msgString);
emit eventOccured(List->value(i).id);
}
m_form.show();
}
if(m_playSound)
m_sound->play();
delete List;
}
void eventInformer::closeEvent()
{
m_sound->stop();
m_form.clear();
}