Skip to content

Commit c57fc75

Browse files
authored
Merge pull request #1 from secondYearProjects/dev
GUI changes
2 parents bfe26af + 211ef36 commit c57fc75

15 files changed

+271
-9
lines changed

SmartTimer/SmartTimer.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ HEADERS += \
4747
toggleswitch.h \
4848
alertwidget.h \
4949
addalarmdialog.h \
50-
changealarmdialog.h
50+
changealarmdialog.h \
51+
widgetsettings.h
5152

5253
FORMS += \
5354
mainwindow.ui \

SmartTimer/addalarmdialog.ui

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@
7878
<property name="alignment">
7979
<set>Qt::AlignCenter</set>
8080
</property>
81+
<property name="displayFormat">
82+
<string>HH:mm</string>
83+
</property>
84+
<property name="time">
85+
<time>
86+
<hour>0</hour>
87+
<minute>0</minute>
88+
<second>0</second>
89+
</time>
90+
</property>
8191
</widget>
8292
</item>
8393
</layout>
@@ -120,6 +130,18 @@
120130
<height>50</height>
121131
</size>
122132
</property>
133+
<property name="font">
134+
<font>
135+
<weight>75</weight>
136+
<bold>true</bold>
137+
</font>
138+
</property>
139+
<property name="text">
140+
<string>Alarm</string>
141+
</property>
142+
<property name="alignment">
143+
<set>Qt::AlignCenter</set>
144+
</property>
123145
</widget>
124146
</item>
125147
</layout>

SmartTimer/alertwidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ alertwidget::alertwidget(int msecs, const QString& name, bool turnedOn, QWidget
7777

7878
this->setContextMenuPolicy(Qt::CustomContextMenu);
7979

80-
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
80+
connect(this, SIGNAL(customContextMenuRequest(const QPoint &)),
8181
this, SLOT(ShowContextMenu(const QPoint &)));
8282

8383
}
@@ -126,6 +126,8 @@ void alertwidget::onTickCheck()
126126
player->play();
127127
ui->stopButton->show();
128128
ui->stopButton->setEnabled(true);
129+
130+
emit blinkInfo("Alarms",true);
129131
}
130132

131133
void alertwidget::blink()
@@ -174,6 +176,7 @@ void alertwidget::closeAlarm()
174176

175177

176178
emit del(this);
179+
emit blinkInfo("Alarms",false);
177180

178181
this->close();
179182
}

SmartTimer/alertwidget.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public slots:
4242
void alarmFinished();
4343
void del(const alertwidget*);
4444

45-
void customContextMenuRequested(const QPoint &);
45+
void customContextMenuRequest(const QPoint &);
46+
47+
void blinkInfo(QString tabName, bool enable);
4648

4749
private:
4850
Ui::alertwidget *ui;

SmartTimer/alertwidget.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ QPushButton {
4444
border-radius: 35px;
4545
}
4646

47-
QPushButton:hover:enabled {
47+
QPushButton#stopButton:hover:enabled {
4848
background-color: rgb(213, 126, 76);
4949
}</string>
5050
</property>
@@ -108,7 +108,7 @@ QPushButton:hover:enabled {
108108
</font>
109109
</property>
110110
<property name="text">
111-
<string>TextLabel</string>
111+
<string>Alarm</string>
112112
</property>
113113
</widget>
114114
</item>

SmartTimer/changealarmdialog.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
<bold>true</bold>
130130
</font>
131131
</property>
132+
<property name="text">
133+
<string>Alarm</string>
134+
</property>
132135
<property name="maxLength">
133136
<number>25</number>
134137
</property>

SmartTimer/mainwindow.cpp

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,21 @@ MainWindow::MainWindow(QWidget *parent) :
2727

2828

2929
logger = new smartTimerLog(this);
30+
alarmsBlinkTimer = new QTimer(this);
31+
timersBlinkTimer = new QTimer(this);
3032

3133
connect(ui->addTimerButton,SIGNAL(clicked()),this,SLOT(addTimer()));
3234
connect(ui->addAlarmButton,SIGNAL(clicked()),this,SLOT(addAlarm()));
33-
// TODO : here
35+
3436
connect(logger, SIGNAL(createTimer(int,QString)), this, SLOT(onTimeRecieved(int,QString)));
3537
connect(logger, SIGNAL(createAlarm(int,QString,bool)), this, SLOT(onAlarmTimeRecieved(int,QString,bool)));
3638

3739

40+
connect(alarmsBlinkTimer,SIGNAL(timeout()),this,SLOT(alarmsTabBlink()));
41+
connect(timersBlinkTimer,SIGNAL(timeout()),this,SLOT(timersTabBlink()));
42+
43+
44+
3845
timerScrollWidget = new QWidget;
3946
timerScrollWidget->setLayout(new QVBoxLayout);
4047
timerScrollWidget->setMaximumWidth(400);
@@ -63,6 +70,7 @@ void MainWindow::addTimer()
6370
auto *addDial = new addTimerDialog();
6471
connect(addDial,SIGNAL(sendTimerData(int,QString)),this, SLOT(onTimeRecieved(int,QString)));
6572

73+
6674
addDial->exec();
6775
}
6876

@@ -82,6 +90,8 @@ void MainWindow::onTimeRecieved(int msecs, const QString& _name)
8290

8391
connect(newTimer, SIGNAL(del(const TimerWidget*)), this, SLOT(remove(const TimerWidget*)));
8492
connect(newTimer, SIGNAL(timerFinished()), this, SLOT(onTimerFinished()));
93+
connect(newTimer, SIGNAL(blinkInfo(QString, bool)), this, SLOT(tabBlinking(QString,bool)));
94+
8595

8696
timersList.append(newTimer);
8797
}
@@ -118,6 +128,99 @@ void MainWindow::onAlarmTimeRecieved(int msecs, const QString& _name, bool turne
118128
alarmScrollWidget->layout()->addWidget(newAlarm);
119129

120130
connect(newAlarm, SIGNAL(del(const alertwidget*)), this, SLOT(remove(const alertwidget*)));
131+
connect(newAlarm, SIGNAL(blinkInfo(QString, bool)), this, SLOT(tabBlinking(QString,bool)));
132+
121133

122134
alarmsList.append(newAlarm);
123135
}
136+
137+
void MainWindow::tabBlinking(QString tabName, bool enable)
138+
{
139+
if (enable)
140+
{
141+
if (tabName=="Timers")
142+
{
143+
blinkingTimers++;
144+
ui->SmartTimerTabs->setCurrentIndex(0);
145+
}
146+
if (tabName=="Alarms")
147+
{
148+
blinkingAlarms++;
149+
ui->SmartTimerTabs->setCurrentIndex(1);
150+
}
151+
}
152+
else
153+
{
154+
if (tabName=="Timers" && blinkingTimers)
155+
{
156+
blinkingTimers--;
157+
}
158+
if (tabName=="Alarms" && blinkingAlarms)
159+
{
160+
blinkingAlarms--;
161+
}
162+
}
163+
if (blinkingTimers && !timersBlinking)
164+
{
165+
timersBlinkTimer->start(400);
166+
timersBlinking = true;
167+
timersBlinkState = false;
168+
}
169+
if (blinkingAlarms && !alarmsBlinking)
170+
{
171+
alarmsBlinkTimer->start(400);
172+
alarmsBlinking = true;
173+
alarmsBlinkState = false;
174+
}
175+
176+
if (!blinkingTimers)
177+
{
178+
timersBlinkTimer->stop();
179+
180+
ui->Timers->setProperty("blink", false);
181+
this->style()->unpolish(ui->Timers);
182+
this->style()->polish(ui->Timers);
183+
184+
timersBlinkState = false;
185+
186+
timersBlinking = false;
187+
188+
}
189+
190+
if (!blinkingAlarms)
191+
{
192+
alarmsBlinkTimer->stop();
193+
194+
ui->Alarms->setProperty("blink", false);
195+
this->style()->unpolish(ui->Alarms);
196+
this->style()->polish(ui->Alarms);
197+
198+
alarmsBlinkState = false;
199+
200+
alarmsBlinking = false;
201+
}
202+
203+
}
204+
205+
void MainWindow::alarmsTabBlink()
206+
{
207+
ui->Alarms->setProperty("blink", !alarmsBlinkState);
208+
ui->Alarms->style()->unpolish(ui->Alarms);
209+
ui->Alarms->style()->polish(ui->Alarms);
210+
211+
212+
alarmsBlinkState = !alarmsBlinkState;
213+
}
214+
215+
void MainWindow::timersTabBlink()
216+
{
217+
218+
ui->Timers->setProperty("blink", !timersBlinkState);
219+
ui->Timers->style()->unpolish(ui->Timers);
220+
ui->Timers->style()->polish(ui->Timers);
221+
ui->Timers->update();
222+
223+
224+
225+
timersBlinkState = !timersBlinkState;
226+
}

SmartTimer/mainwindow.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public slots:
3030
void onTimerFinished();
3131
void onAlarmTimeRecieved(int msecs, const QString& _name, bool turnedOn);
3232

33+
void tabBlinking(QString tabName, bool enable);
34+
void alarmsTabBlink();
35+
void timersTabBlink();
36+
3337
signals:
3438
void del(QList<TimerWidget*> timers,QList<alertwidget*> alarms);
3539
private:
@@ -42,6 +46,19 @@ public slots:
4246

4347
QWidget *timerScrollWidget;
4448
QWidget *alarmScrollWidget;
49+
50+
int blinkingAlarms = 0;
51+
int blinkingTimers = 0;
52+
53+
bool alarmsBlinking = false;
54+
bool timersBlinking = false;
55+
56+
bool alarmsBlinkState = false;
57+
bool timersBlinkState = false;
58+
59+
QTimer *alarmsBlinkTimer;
60+
QTimer *timersBlinkTimer;
61+
4562
};
4663

4764
#endif // MAINWINDOW_H

SmartTimer/mainwindow.ui

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@
6363
<height>791</height>
6464
</rect>
6565
</property>
66+
<property name="styleSheet">
67+
<string notr="true">QWidget[blink=true] {
68+
background-color: black;
69+
}</string>
70+
</property>
6671
<property name="currentIndex">
67-
<number>1</number>
72+
<number>0</number>
6873
</property>
6974
<widget class="QWidget" name="Timers">
75+
<property name="styleSheet">
76+
<string notr="true"/>
77+
</property>
7078
<attribute name="title">
7179
<string>Timers</string>
7280
</attribute>

SmartTimer/smarttimerlog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "smarttimerlog.h"
22
#include "timerwidget.h"
3+
#include "widgetsettings.h"
34

45
#include <iostream>
56
#include <fstream>
@@ -8,6 +9,8 @@
89
#include <QUrl>
910
#include <QString>
1011

12+
#include <QJsonDocument>
13+
1114
smartTimerLog::smartTimerLog(QObject *parent) : QObject(parent)
1215
{
1316
this->par = parent;
@@ -66,6 +69,19 @@ void smartTimerLog::runLogger()
6669
}
6770

6871
logFile2.close();
72+
73+
74+
75+
QString alarms = "alarms.json";
76+
77+
78+
79+
80+
81+
82+
83+
84+
6985
}
7086

7187
void smartTimerLog::saveLog(QList<TimerWidget*> timers, QList<alertwidget*> alarms)

0 commit comments

Comments
 (0)