-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
65 lines (58 loc) · 2.38 KB
/
main.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
59
60
61
62
63
64
65
/*
************************************************************************************************************
-------------------------------------------------- cppLawyer -----------------------------------------------
+ Low stack memory usage
+ Almost No function overhead
+ Regulate Stack Memory
+ Agressive but peacefull
+ Low Ram Usage
+ Low Power Usage
+ Beautiful Adhan
+ Shows Accurate Prayer Times based on IP/Location
+ Shows How Many Minutes for the next prayer
+ Almost no CPU Usage
-- Version 3.0 --
- Bug fixes
- Performance improvements
- Server Changed
------------------------------------------------------------------------------------------------------------
************************************************************************************************************
*/
/////////DEPEND//////////
#include "main.h"
#include <QApplication>
#include <QTime>
#include "ui_gui.h"
#include <QMediaPlayer>
#include <thread>
//////////////////////
void rootTask(gui& w) noexcept{
w.adhanPlayer.setSource(std::move(QUrl(std::move("qrc:adhan/Adhan.mp3"))));
do{
w.set_data();
while((w.prayerTime == QTime(00,00,00))){
w.ui->CurrentPrayer->setText(std::move("Reconnect"));
w.ui->nextPrayer->setText(std::move("To Server"));
w.ui->timeTogo->setText(std::move("--:--:--"));
std::this_thread::sleep_for(std::chrono::seconds(5));
w.set_data();
}//try to fix issue by retrying to connect autoSolve//
do{
/* to prevent function overhead*/
w.ui->timeTogo->setText(std::move((QTime((w.prayerTime.hour() - QTime().currentTime().hour()),
(w.prayerTime.minute() - QTime().currentTime().minute()),
(60 - QTime().currentTime().second()))).toString("hh:mm:ss")));
///////////////////////////////////////////////////////////////////
std::this_thread::sleep_for(std::chrono::seconds(1));
}while(QTime::currentTime() < w.prayerTime);//waiting until it is time to pray//
w.adhanPlayer.play(); /*waits until adhan is done and so prayerTime has time to update*/
}while(w.program);
}//MAIN THREAD FOR THE APPLICATION
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
gui w;
w.operationThread = std::thread(rootTask, std::ref(w));
w.show();
return a.exec();
}