Skip to content

Commit 64d8157

Browse files
committed
Fix tab blinking
1 parent a81cd41 commit 64d8157

File tree

11 files changed

+126
-42
lines changed

11 files changed

+126
-42
lines changed

SmartTimer/addalarmdialog.ui

Lines changed: 13 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,9 @@
120130
<height>50</height>
121131
</size>
122132
</property>
133+
<property name="text">
134+
<string>Alarm</string>
135+
</property>
123136
</widget>
124137
</item>
125138
</layout>

SmartTimer/alertwidget.cpp

Lines changed: 1 addition & 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
}

SmartTimer/alertwidget.h

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

45-
void customContextMenuRequested(const QPoint &);
45+
void customContextMenuRequest(const QPoint &);
4646

47-
void blinkInfo(const QString &tabName, bool enable);
47+
void blinkInfo(QString tabName, bool enable);
4848

4949
private:
5050
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: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void MainWindow::onTimeRecieved(int msecs, const QString& _name)
9090

9191
connect(newTimer, SIGNAL(del(const TimerWidget*)), this, SLOT(remove(const TimerWidget*)));
9292
connect(newTimer, SIGNAL(timerFinished()), this, SLOT(onTimerFinished()));
93-
connect(newTimer, SIGNAL(blikInfo(const QString&, bool)), this, SLOT(tabBlinking(const QString&,bool)));
93+
connect(newTimer, SIGNAL(blinkInfo(QString, bool)), this, SLOT(tabBlinking(QString,bool)));
9494

9595

9696
timersList.append(newTimer);
@@ -128,81 +128,99 @@ void MainWindow::onAlarmTimeRecieved(int msecs, const QString& _name, bool turne
128128
alarmScrollWidget->layout()->addWidget(newAlarm);
129129

130130
connect(newAlarm, SIGNAL(del(const alertwidget*)), this, SLOT(remove(const alertwidget*)));
131-
connect(newAlarm, SIGNAL(blikInfo(QString, bool)), this, SLOT(tabBlinking(QString,bool)));
131+
connect(newAlarm, SIGNAL(blinkInfo(QString, bool)), this, SLOT(tabBlinking(QString,bool)));
132132

133133

134134
alarmsList.append(newAlarm);
135135
}
136136

137-
void MainWindow::tabBlinking(const QString &tabName, bool enable)
137+
void MainWindow::tabBlinking(QString tabName, bool enable)
138138
{
139139
if (enable)
140140
{
141141
if (tabName=="Timers")
142142
{
143-
timersBlink++;
143+
blinkingTimers++;
144+
ui->SmartTimerTabs->setCurrentIndex(0);
144145
}
145146
if (tabName=="Alarms")
146147
{
147-
alarmsBlink++;
148+
blinkingAlarms++;
149+
ui->SmartTimerTabs->setCurrentIndex(1);
148150
}
149151
}
150152
else
151153
{
152-
if (tabName=="Timers")
154+
if (tabName=="Timers" && blinkingTimers)
153155
{
154-
timersBlink--;
156+
blinkingTimers--;
155157
}
156-
if (tabName=="Alarms")
158+
if (tabName=="Alarms" && blinkingAlarms)
157159
{
158-
alarmsBlink--;
160+
blinkingAlarms--;
159161
}
160162
}
161-
if (timersBlink && !timersBlinking)
163+
if (blinkingTimers && !timersBlinking)
162164
{
163165
timersBlinkTimer->start(400);
166+
timersBlinking = true;
167+
timersBlinkState = false;
164168
}
165-
if (alarmsBlink && !alarmsBlinking)
169+
if (blinkingAlarms && !alarmsBlinking)
166170
{
167171
alarmsBlinkTimer->start(400);
172+
alarmsBlinking = true;
173+
alarmsBlinkState = false;
168174
}
169175

170-
if (!timersBlink)
176+
if (!blinkingTimers)
171177
{
172178
timersBlinkTimer->stop();
173179

174-
ui->Timers->setProperty("blinky", false);
180+
ui->Timers->setProperty("blink", false);
175181
this->style()->unpolish(ui->Timers);
176182
this->style()->polish(ui->Timers);
183+
184+
timersBlinkState = false;
185+
186+
timersBlinking = false;
187+
177188
}
178189

179-
if (!alarmsBlink)
190+
if (!blinkingAlarms)
180191
{
181192
alarmsBlinkTimer->stop();
182193

183-
ui->Alarms->setProperty("blinky", !alarmsBlinky);
194+
ui->Alarms->setProperty("blink", false);
184195
this->style()->unpolish(ui->Alarms);
185196
this->style()->polish(ui->Alarms);
186197

187-
alarmsBlinky = !alarmsBlinky;
198+
alarmsBlinkState = false;
199+
200+
alarmsBlinking = false;
188201
}
189202

190203
}
191204

192205
void MainWindow::alarmsTabBlink()
193206
{
194-
ui->Alarms->setProperty("blinky", !alarmsBlinky);
195-
this->style()->unpolish(ui->Alarms);
196-
this->style()->polish(ui->Alarms);
207+
ui->Alarms->setProperty("blink", !alarmsBlinkState);
208+
ui->Alarms->style()->unpolish(ui->Alarms);
209+
ui->Alarms->style()->polish(ui->Alarms);
210+
197211

198-
alarmsBlinky = !alarmsBlinky;
212+
alarmsBlinkState = !alarmsBlinkState;
199213
}
200214

201215
void MainWindow::timersTabBlink()
202216
{
203-
ui->Timers->setProperty("blinky", !timersBlinky);
204-
this->style()->unpolish(ui->Timers);
205-
this->style()->polish(ui->Timers);
206217

207-
timersBlinky = !timersBlinky;
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;
208226
}

SmartTimer/mainwindow.h

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

33-
void tabBlinking(const QString &tabName, bool enable);
33+
void tabBlinking(QString tabName, bool enable);
3434
void alarmsTabBlink();
3535
void timersTabBlink();
3636

@@ -47,14 +47,14 @@ public slots:
4747
QWidget *timerScrollWidget;
4848
QWidget *alarmScrollWidget;
4949

50-
int alarmsBlink = 0;
51-
int timersBlink = 0;
50+
int blinkingAlarms = 0;
51+
int blinkingTimers = 0;
5252

5353
bool alarmsBlinking = false;
5454
bool timersBlinking = false;
5555

56-
bool alarmsBlinky = false;
57-
bool timersBlinky = false;
56+
bool alarmsBlinkState = false;
57+
bool timersBlinkState = false;
5858

5959
QTimer *alarmsBlinkTimer;
6060
QTimer *timersBlinkTimer;

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/stylesheet.qss

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ QWidget {
33
color: rgb(230,230,230);
44
}
55

6+
7+
68
QPushButton#addTimerButton, QPushButton#addAlarmButton {
79
background-color: rgb(113, 113, 113);
810
border: 2px solid rgb(200,200,200);
@@ -26,6 +28,8 @@ QTabWidget {
2628
border: 0px;
2729
}
2830

31+
32+
2933
QTabBar::tab {
3034
color: white;
3135
font: 14pt ;
@@ -53,12 +57,44 @@ QTabBar::tab:!selected {
5357
margin-top: 5px; /* make non-selected tabs look smaller */
5458
}
5559

56-
QTabBar::tab[blink=true]
57-
{
58-
background: rgb(0,0,0);
60+
QWidget[blink=true] {
61+
color: white;
62+
font: 14pt ;
63+
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0.333333 rgba(149, 149, 149, 197), stop:1 rgba(255, 255, 255, 0));
64+
border-bottom: 0px;
65+
border-top-left-radius: 20px;
66+
border-top-right-radius: 20px;
67+
border-bottom-left-radius: 10px;
68+
border-bottom-right-radius: 10px;
69+
min-width: 202px;
70+
min-height: 30px;
71+
padding: 2px;
72+
}
73+
74+
75+
QScrollBar:vertical {
76+
border: 0px;
77+
78+
background: solid rgb(116,116,116);
79+
width: 10px;
80+
margin: 22px 0 22px 0;
5981
}
6082

6183

84+
QScrollBar::handle:vertical {
85+
background: rgba(223, 136, 86);
86+
border-radius: 5px;
87+
min-height: 20px;
88+
}
89+
90+
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
91+
border: 0px;
92+
width: 0px;
93+
height: 0px;
94+
}
95+
96+
97+
6298

6399

64100
QWidget#DialogGrid {
@@ -156,5 +192,3 @@ QMenu::item:selected {
156192

157193

158194

159-
160-

SmartTimer/timerwidget.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ void TimerWidget::resetTimer()
121121
ui->editButton->setEnabled(true);
122122

123123
ui->restartButton->setStyleSheet("");
124+
125+
emit blinkInfo("Timers",false);
124126
}
125127

126128
void TimerWidget::timerExecuted()
@@ -174,13 +176,19 @@ void TimerWidget::blink()
174176

175177
void TimerWidget::closeTimer()
176178
{
179+
if (blinkTimer->isActive())
180+
emit blinkInfo("Timers",false);
181+
177182
player->stop();
178183
timer->stop();
179184
tickTimer->stop();
180185
blinkTimer->stop();
181186

187+
188+
182189
emit del(this);
183-
emit blinkInfo("Timers",false);
190+
191+
184192

185193
this->close();
186194
}

0 commit comments

Comments
 (0)