Skip to content

Commit 9345ade

Browse files
committed
Add DD to GUI
1 parent d26cec1 commit 9345ade

11 files changed

+154
-30
lines changed

SmartTimer/addalarmdialog.ui

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -201,23 +201,8 @@
201201
<cursorShape>ArrowCursor</cursorShape>
202202
</property>
203203
<property name="currentText">
204-
<string>Standard alarm</string>
204+
<string/>
205205
</property>
206-
<item>
207-
<property name="text">
208-
<string>Standard alarm</string>
209-
</property>
210-
</item>
211-
<item>
212-
<property name="text">
213-
<string>Sound2</string>
214-
</property>
215-
</item>
216-
<item>
217-
<property name="text">
218-
<string>Sound3</string>
219-
</property>
220-
</item>
221206
</widget>
222207
</item>
223208
</layout>

SmartTimer/changealarmdialog.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</font>
5959
</property>
6060
<property name="text">
61-
<string>Alarm Time:</string>
61+
<string>Time:</string>
6262
</property>
6363
</widget>
6464
</item>
@@ -117,7 +117,7 @@
117117
</font>
118118
</property>
119119
<property name="text">
120-
<string>Alarm name:</string>
120+
<string>Name:</string>
121121
</property>
122122
</widget>
123123
</item>

SmartTimer/changetimerdialog.cpp

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

44
#include <QTime>
55
#include <QFile>
6+
#include <QLineEdit>
67

78
ChangeTimerDialog::ChangeTimerDialog(TimerWidget *parent) :
89
QDialog(parent),
@@ -36,6 +37,8 @@ ChangeTimerDialog::ChangeTimerDialog(TimerWidget *parent) :
3637
QValidator *validator = new QRegExpValidator(rx, this);
3738

3839
ui->timerName->setValidator(validator);
40+
41+
3942
}
4043

4144
ChangeTimerDialog::~ChangeTimerDialog()

SmartTimer/changetimerdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
</font>
121121
</property>
122122
<property name="text">
123-
<string>Timer name:</string>
123+
<string>Name:</string>
124124
</property>
125125
</widget>
126126
</item>

SmartTimer/globalsettingsdialog.cpp

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
#include <QSlider>
77
#include <QHBoxLayout>
88

9+
10+
int elpasedTime(QTime time)
11+
{
12+
return time.hour()*3600*1000+
13+
time.minute()*60*1000+
14+
time.second()*1000;
15+
}
16+
917
GlobalSettingsDialog::GlobalSettingsDialog(GlobalSettings old, QWidget *parent) :
1018
QDialog(parent),
1119
ui(new Ui::GlobalSettingsDialog)
@@ -26,10 +34,24 @@ GlobalSettingsDialog::GlobalSettingsDialog(GlobalSettings old, QWidget *parent)
2634
ui->alarmFormat->setText(old.alarmTimeFormat);
2735
ui->TimerFormat->setText(old.timerTimeFormat);
2836

29-
RangeWidget *DDrange = new RangeWidget(Qt::Horizontal);
30-
ui->RangeLayout->addWidget(DDrange);
37+
if (oldSettings.DDenabled)
38+
ui->DDenable->setChecked(true);
39+
40+
if (!oldSettings.DDenabled)
41+
{
42+
ui->DDmin->setEnabled(false);
43+
ui->DDmax->setEnabled(false);
44+
}
45+
46+
ui->DDmin->setTime(QTime::fromMSecsSinceStartOfDay(oldSettings.DDstart));
47+
ui->DDmax->setTime(QTime::fromMSecsSinceStartOfDay(oldSettings.DDend));
3148

32-
connect(DDrange,SIGNAL(rangeChanged(int , int )),this,SLOT(rangeChanged(int,int)));
49+
connect(ui->DDenable,SIGNAL(clicked(bool)),this, SLOT(DDenableState(bool)));
50+
51+
//RangeWidget *DDrange = new RangeWidget(Qt::Horizontal);
52+
//ui->RangeLayout->addWidget(DDrange);
53+
54+
//connect(DDrange,SIGNAL(rangeChanged(int , int )),this,SLOT(rangeChanged(int,int)));
3355

3456

3557
connect(ui->cancelButton,SIGNAL(clicked()),this,SLOT(canceled()));
@@ -45,7 +67,14 @@ GlobalSettingsDialog::~GlobalSettingsDialog()
4567

4668
void GlobalSettingsDialog::confirmed()
4769
{
48-
GlobalSettings newSettings(ui->opacitySlider->value()/100.0,ui->alarmFormat->text(), ui->TimerFormat->text());
70+
int elpasedTimeMin = elpasedTime(ui->DDmin->time());
71+
int elpasedTimeMax = elpasedTime(ui->DDmax->time());
72+
GlobalSettings newSettings(ui->opacitySlider->value()/100.0,
73+
ui->alarmFormat->text(),
74+
ui->TimerFormat->text(),
75+
static_cast<bool>(ui->DDenable->isChecked()),
76+
elpasedTimeMin,
77+
elpasedTimeMax);
4978
emit changeSettings(newSettings);
5079
this->close();
5180
}
@@ -58,7 +87,9 @@ void GlobalSettingsDialog::canceled()
5887

5988
void GlobalSettingsDialog::opacityChanged()
6089
{
61-
GlobalSettings newSettings(ui->opacitySlider->value()/100.0,ui->alarmFormat->text(), ui->TimerFormat->text());
90+
int elpasedTimeMin = elpasedTime(ui->DDmin->time());
91+
int elpasedTimeMax = elpasedTime(ui->DDmax->time());
92+
GlobalSettings newSettings(ui->opacitySlider->value()/100.0,ui->alarmFormat->text(), ui->TimerFormat->text(),static_cast<bool>(ui->DDenable->isChecked()),elpasedTimeMin, elpasedTimeMax);
6293

6394
ui->SliderValue->setText(QString::number(static_cast<int>(newSettings.windowOpacity*100))+"%");
6495

@@ -69,3 +100,12 @@ void GlobalSettingsDialog::rangeChanged(int min, int max)
69100
{
70101
ui->RangeValue->setText(QString::number(min)+" : "+QString::number(max));
71102
}
103+
104+
void GlobalSettingsDialog::DDenableState(bool state)
105+
{
106+
ui->DDmin->setEnabled(state);
107+
ui->DDmax->setEnabled(state);
108+
109+
}
110+
111+

SmartTimer/globalsettingsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public slots:
2121
void canceled();
2222
void opacityChanged();
2323
void rangeChanged(int min,int max);
24+
void DDenableState(bool state);
2425
signals:
2526
void changeSettings(GlobalSettings settings);
2627

SmartTimer/globalsettingsdialog.ui

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,71 @@
109109
</property>
110110
<property name="maximumSize">
111111
<size>
112-
<width>100</width>
112+
<width>16777215</width>
113113
<height>16777215</height>
114114
</size>
115115
</property>
116116
<property name="text">
117-
<string/>
117+
<string>Don't disturb mode:</string>
118118
</property>
119119
</widget>
120120
</item>
121+
<item>
122+
<spacer name="horizontalSpacer_4">
123+
<property name="orientation">
124+
<enum>Qt::Horizontal</enum>
125+
</property>
126+
<property name="sizeHint" stdset="0">
127+
<size>
128+
<width>40</width>
129+
<height>20</height>
130+
</size>
131+
</property>
132+
</spacer>
133+
</item>
134+
<item>
135+
<widget class="QRadioButton" name="DDenable">
136+
<property name="text">
137+
<string>enable</string>
138+
</property>
139+
</widget>
140+
</item>
141+
<item>
142+
<layout class="QVBoxLayout" name="verticalLayout_2">
143+
<item>
144+
<widget class="QTimeEdit" name="DDmin">
145+
<property name="minimumSize">
146+
<size>
147+
<width>200</width>
148+
<height>0</height>
149+
</size>
150+
</property>
151+
<property name="alignment">
152+
<set>Qt::AlignCenter</set>
153+
</property>
154+
<property name="displayFormat">
155+
<string>HH:mm</string>
156+
</property>
157+
</widget>
158+
</item>
159+
<item>
160+
<widget class="QTimeEdit" name="DDmax">
161+
<property name="minimumSize">
162+
<size>
163+
<width>200</width>
164+
<height>0</height>
165+
</size>
166+
</property>
167+
<property name="alignment">
168+
<set>Qt::AlignCenter</set>
169+
</property>
170+
<property name="displayFormat">
171+
<string>HH:mm</string>
172+
</property>
173+
</widget>
174+
</item>
175+
</layout>
176+
</item>
121177
</layout>
122178
</item>
123179
<item>
@@ -144,6 +200,12 @@
144200
</item>
145201
<item>
146202
<widget class="QLineEdit" name="alarmFormat">
203+
<property name="minimumSize">
204+
<size>
205+
<width>200</width>
206+
<height>0</height>
207+
</size>
208+
</property>
147209
<property name="alignment">
148210
<set>Qt::AlignCenter</set>
149211
</property>
@@ -175,6 +237,12 @@
175237
</item>
176238
<item>
177239
<widget class="QLineEdit" name="TimerFormat">
240+
<property name="minimumSize">
241+
<size>
242+
<width>200</width>
243+
<height>0</height>
244+
</size>
245+
</property>
178246
<property name="alignment">
179247
<set>Qt::AlignCenter</set>
180248
</property>

SmartTimer/smarttimerlog.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ void smartTimerLog::runLogger()
9393
double opacity;
9494
QString alarmFormat;
9595
QString timerFormat;
96-
stream3 >> opacity >> alarmFormat >> timerFormat;
97-
emit createSettings(GlobalSettings(opacity,toLoadFormat(alarmFormat), toLoadFormat(timerFormat)));
96+
int DDenable;
97+
int DDmin;
98+
int DDmax;
99+
stream3 >> opacity >> alarmFormat >> timerFormat >> DDenable >> DDmin >> DDmax;
100+
emit createSettings(GlobalSettings(opacity,toLoadFormat(alarmFormat), toLoadFormat(timerFormat),static_cast<bool>(DDenable),DDmin,DDmax));
98101

99102

100103
logFile3.close();
@@ -163,6 +166,7 @@ void smartTimerLog::saveLog(QList<TimerWidget*> timers, QList<alertwidget*> alar
163166
stream3 << settings.windowOpacity << " \n";
164167
stream3 << toSaveFormat(settings.alarmTimeFormat) << " \n";
165168
stream3 << toSaveFormat(settings.timerTimeFormat) << " \n";
169+
stream3 << settings.DDenabled << " " << settings.DDstart << " " << settings.DDend << " \n";
166170

167171
logFile3.close();
168172
}

SmartTimer/stylesheet.qss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,18 @@ QLineEdit {
154154

155155
QTimeEdit {
156156
border-radius: 10px;
157+
height: 55px;
157158
color: rgb(238, 238, 236);
158159
font: 19pt bold;
159160
background-color: rgb(255, 204, 157,10);
160161
}
162+
QTimeEdit:!enabled {
163+
border-radius: 10px;
164+
height: 55px;
165+
color: rgb(198, 198, 198);
166+
font: 19pt bold;
167+
background-color: rgb(205, 154, 107,10);
168+
}
161169

162170
QTimeEdit::up-button {
163171
subcontrol-origin: border;
@@ -247,6 +255,7 @@ QSlider::handle:horizontal {
247255
}
248256

249257
QComboBox {
258+
padding: 0 0 0 50;
250259
text-align: center;
251260
color: white;
252261
font: 15pt;
@@ -279,3 +288,12 @@ QComboBox QAbstractItemView {
279288
selection-background-color: rgb(255, 204, 157,10);
280289
}
281290

291+
292+
QRadioButton {
293+
font: 15pt white;
294+
}
295+
296+
QRadioButton::indicator {
297+
width: 15px;
298+
height: 15px;
299+
}

SmartTimer/widgetsettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "widgetsettings.h"
2+
#include <QLineEdit>
23

34
void addSounds(QComboBox *soundsCombo)
45
{

0 commit comments

Comments
 (0)