Skip to content

Commit 490b379

Browse files
committed
Progress commit
1 parent c60eafe commit 490b379

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

SmartTimer/mainwindow.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ void MainWindow::onSettingsRecieved(GlobalSettings settings)
156156
Settings = settings;
157157

158158
this->setWindowOpacity(Settings.windowOpacity);
159+
160+
updateWidgets();
159161
}
160162

161163
// TODO: here
@@ -255,3 +257,11 @@ void MainWindow::timersTabBlink()
255257

256258
timersBlinkState = !timersBlinkState;
257259
}
260+
261+
void MainWindow::updateWidgets()
262+
{
263+
for (auto timer:timersList)
264+
{
265+
timer->updateWidget(Settings);
266+
}
267+
}

SmartTimer/mainwindow.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class MainWindow : public QMainWindow
3232
void setAlarmFormat(QString val) {Settings.alarmTimeFormat = val; this->update();}
3333
void setTimerFormat(QString val) {Settings.timerTimeFormat = val; this->update();}
3434

35+
GlobalSettings getSettings() const { return Settings; }
36+
3537
public slots:
3638
void addTimer();
3739
void addAlarm();
@@ -48,6 +50,9 @@ public slots:
4850
void alarmsTabBlink();
4951
void timersTabBlink();
5052

53+
54+
void updateWidgets();
55+
5156
signals:
5257
void del(QList<TimerWidget*> timers,QList<alertwidget*> alarms,GlobalSettings);
5358
private:

SmartTimer/mainwindow.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
<string notr="true"/>
239239
</property>
240240
<property name="currentIndex">
241-
<number>1</number>
241+
<number>0</number>
242242
</property>
243243
<widget class="QWidget" name="Timers">
244244
<property name="sizePolicy">

SmartTimer/timerwidget.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <string>
88

99
#include <QFile>
10+
#include <QTextFormat>
1011

1112
int TimerWidget::MAXID = 0;
1213

@@ -103,6 +104,14 @@ void TimerWidget::setTimerDuration(int _duration)
103104
ui->timeLeft->setText(QString::fromStdString(secondsToTimeString(Settings.msecs/1000)));
104105
}
105106

107+
void TimerWidget::updateWidget(GlobalSettings _globalSettings)
108+
{
109+
globalSettings = _globalSettings;
110+
ui->intervalTime->setText((QTime::fromMSecsSinceStartOfDay(Settings.msecs)).toString(globalSettings.timerTimeFormat));
111+
112+
//ui->timeLeft->setText((QTime::fromMSecsSinceStartOfDay(Settings.msecs)).toString(globalSettings.timerTimeFormat));
113+
}
114+
106115
void TimerWidget::resetTimer()
107116
{
108117
timer->stop();

SmartTimer/timerwidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "widgetsettings.h"
77

8+
89
#include <QWidget>
910
#include <QTimer>
1011
#include <QTime>
@@ -35,6 +36,8 @@ class TimerWidget : public QWidget
3536
void setTimerName(const QString &_name);
3637
void setTimerDuration(int _duration);
3738

39+
void updateWidget(GlobalSettings _globalSettings);
40+
3841
public slots:
3942
void startTimer();
4043
void resetTimer();
@@ -60,6 +63,7 @@ public slots:
6063
static int MAXID;
6164

6265
WidgetSettings Settings;
66+
GlobalSettings globalSettings;
6367

6468
int id;
6569
QTimer *timer;
@@ -76,6 +80,8 @@ public slots:
7680
Ui::TimerWidget *ui;
7781

7882
std::string secondsToTimeString(int val);
83+
84+
7985
};
8086

8187

0 commit comments

Comments
 (0)