Skip to content

Commit 314a927

Browse files
committed
Add DD functional to timer and alarm
1 parent 9345ade commit 314a927

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

SmartTimer/alertwidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ int calculateDuration(const QTime &t)
2727
return 0;
2828
}
2929

30+
3031
alertwidget::alertwidget(WidgetSettings settings, QWidget *parent) :
3132
QWidget(parent),
3233
ui(new Ui::alertwidget)
@@ -123,11 +124,13 @@ void alertwidget::statusChanged(bool stat)
123124

124125
void alertwidget::onTickCheck()
125126
{
127+
if (DDCheck(globalSettings))
128+
player->play();
126129
std::cout << "!alert!" << std::endl;
127130
alertTick.stop();
128131
blinkTimer.start(300);
129132
blinking = true;
130-
player->play();
133+
131134
ui->stopButton->show();
132135
ui->stopButton->setEnabled(true);
133136

SmartTimer/globalsettingsdialog.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
#include "globalsettingsdialog.h"
22
#include "ui_globalsettingsdialog.h"
33
#include "rangewidget.h"
4+
#include "widgetsettings.h"
45

56
#include <QFile>
67
#include <QSlider>
78
#include <QHBoxLayout>
89

910

10-
int elpasedTime(QTime time)
11-
{
12-
return time.hour()*3600*1000+
13-
time.minute()*60*1000+
14-
time.second()*1000;
15-
}
1611

1712
GlobalSettingsDialog::GlobalSettingsDialog(GlobalSettings old, QWidget *parent) :
1813
QDialog(parent),

SmartTimer/timerwidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ void TimerWidget::resetTimer()
135135

136136
void TimerWidget::timerExecuted()
137137
{
138-
player->play();
138+
if (DDCheck(globalSettings))
139+
player->play();
139140
blinkTimer->start(350);
140141

141142
timer->stop();

SmartTimer/widgetsettings.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
#include "widgetsettings.h"
22
#include <QLineEdit>
3+
#include <QTime>
34

45
void addSounds(QComboBox *soundsCombo)
56
{
67
soundsCombo->addItem("Standard signal", "qrc:/sounds/sound1.wav");
78
soundsCombo->addItem("Bird", "qrc:/sounds/Bird.mp3");
89
soundsCombo->addItem("Light", "qrc:/sounds/Light.mp3");
910
}
11+
12+
int elpasedTime(QTime time)
13+
{
14+
return time.hour()*3600*1000+
15+
time.minute()*60*1000+
16+
time.second()*1000;
17+
}
18+
19+
bool DDCheck(GlobalSettings globalSettings)
20+
{
21+
int currTime = elpasedTime(QTime::currentTime());
22+
if (currTime>=globalSettings.DDstart && currTime <= globalSettings.DDend )
23+
return false;
24+
else
25+
return true;
26+
}

SmartTimer/widgetsettings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ struct GlobalSettings
4141

4242
};
4343

44+
bool DDCheck(GlobalSettings globalSettings);
45+
int elpasedTime(QTime time);
46+
4447
#endif // WIDGETSETTINGS_H

0 commit comments

Comments
 (0)