forked from CountMurphy/QTalarm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added solve math to stop alarm feature
- Loading branch information
1 parent
8a5535b
commit fab23d1
Showing
16 changed files
with
456 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "bastardsnooze.h" | ||
#include "ui_bastardsnooze.h" | ||
#include <QRandomGenerator> | ||
#include <QDateTime> | ||
#include <QMessageBox> | ||
#include <QCloseEvent> | ||
|
||
BastardSnooze::BastardSnooze(QWidget *parent, Alarm * curAlarm) : | ||
QMainWindow(parent), | ||
ui(new Ui::BastardSnooze) | ||
{ | ||
ui->setupUi(this); | ||
QRandomGenerator *generator=new QRandomGenerator(); | ||
generator->seed(QDateTime::currentSecsSinceEpoch()); | ||
val1 = generator->bounded(13); | ||
val2 = generator->bounded(13); | ||
randOp = generator->bounded(3); | ||
this->ui->num1->setProperty("value",val1); | ||
this->ui->num2->setProperty("value",val2); | ||
switch(randOp) | ||
{ | ||
case 0: | ||
this->ui->Operator->setText("+"); | ||
break; | ||
case 1: | ||
this->ui->Operator->setText("-"); | ||
break; | ||
case 2: | ||
this->ui->Operator->setText("X"); | ||
break; | ||
} | ||
|
||
this->_curAlarm=curAlarm; | ||
|
||
//connect btn | ||
connect(ui->okbtn,SIGNAL(clicked()),this,SLOT(checkMath())); | ||
connect(ui->Ans,SIGNAL(returnPressed()),this,SLOT(checkMath())); | ||
} | ||
|
||
void BastardSnooze::checkMath() | ||
{ | ||
bool retVal=false; | ||
switch (randOp) { | ||
case 0: | ||
retVal=val1+val2==ui->Ans->text().toInt(); | ||
break; | ||
case 1: | ||
retVal=val1-val2==ui->Ans->text().toInt(); | ||
break; | ||
case 2: | ||
retVal=val1*val2==ui->Ans->text().toInt(); | ||
break; | ||
} | ||
if(retVal) | ||
{ | ||
this->_curAlarm->Stop(); | ||
this->hide(); | ||
this->~BastardSnooze(); | ||
}else{ | ||
QMessageBox::critical(this,"WRONG","WRONG"); | ||
} | ||
} | ||
|
||
BastardSnooze::~BastardSnooze() | ||
{ | ||
delete ui; | ||
this->deleteLater(); | ||
} | ||
|
||
void BastardSnooze::closeEvent(QCloseEvent *event) | ||
{ | ||
event->ignore(); | ||
QMessageBox::warning(this,"Nope","you didn't think it was going to be that easy did you?"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef BASTARDSNOOZE_H | ||
#define BASTARDSNOOZE_H | ||
|
||
#include <QMainWindow> | ||
#include "alarm.h" | ||
|
||
namespace Ui { | ||
class BastardSnooze; | ||
} | ||
|
||
class BastardSnooze : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit BastardSnooze(QWidget *parent = nullptr, Alarm * curAlarm=0); | ||
~BastardSnooze(); | ||
|
||
private: | ||
Ui::BastardSnooze *ui; | ||
qint32 val1; | ||
qint32 val2; | ||
qint32 randOp; | ||
Alarm * _curAlarm; | ||
void closeEvent(QCloseEvent*); | ||
private slots: | ||
void checkMath(); | ||
}; | ||
|
||
#endif // BASTARDSNOOZE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>BastardSnooze</class> | ||
<widget class="QMainWindow" name="BastardSnooze"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>977</width> | ||
<height>332</height> | ||
</rect> | ||
</property> | ||
<property name="focusPolicy"> | ||
<enum>Qt::StrongFocus</enum> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Bastard Snooze</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<widget class="QLCDNumber" name="num1"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>210</x> | ||
<y>30</y> | ||
<width>171</width> | ||
<height>111</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QLCDNumber" name="num2"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>610</x> | ||
<y>30</y> | ||
<width>161</width> | ||
<height>111</height> | ||
</rect> | ||
</property> | ||
<property name="segmentStyle"> | ||
<enum>QLCDNumber::Filled</enum> | ||
</property> | ||
</widget> | ||
<widget class="QLabel" name="Operator"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>450</x> | ||
<y>50</y> | ||
<width>91</width> | ||
<height>81</height> | ||
</rect> | ||
</property> | ||
<property name="baseSize"> | ||
<size> | ||
<width>0</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="font"> | ||
<font> | ||
<pointsize>53</pointsize> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string>X</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignCenter</set> | ||
</property> | ||
</widget> | ||
<widget class="QPushButton" name="okbtn"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>520</x> | ||
<y>220</y> | ||
<width>161</width> | ||
<height>51</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>OK</string> | ||
</property> | ||
<property name="autoDefault"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="default"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
<widget class="QLineEdit" name="Ans"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>260</x> | ||
<y>220</y> | ||
<width>211</width> | ||
<height>51</height> | ||
</rect> | ||
</property> | ||
<property name="font"> | ||
<font> | ||
<pointsize>50</pointsize> | ||
</font> | ||
</property> | ||
</widget> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>977</width> | ||
<height>23</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.