Skip to content

Commit f38bec9

Browse files
committed
Move stylesheets to the one file
1 parent a24674a commit f38bec9

18 files changed

+230
-401
lines changed

SmartTimer/SmartTimer.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,6 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
6565

6666
RESOURCES += \
6767
resources.qrc
68+
69+
DISTFILES += \
70+
stylesheet.qss

SmartTimer/addalarmdialog.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "addalarmdialog.h"
22
#include "ui_addalarmdialog.h"
33

4+
#include <QFile>
5+
46

57
static int getMsecs(const QTime& t)
68
{
@@ -13,6 +15,13 @@ addAlarmDialog::addAlarmDialog(QWidget *parent) :
1315
{
1416
ui->setupUi(this);
1517

18+
QFile file(":/stylesheet.qss");
19+
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
20+
{
21+
this->setStyleSheet(file.readAll());
22+
file.close();
23+
}
24+
1625
connect(ui->createButton,SIGNAL(clicked()),this,SLOT(sendData()));
1726
connect(ui->cancelButton,SIGNAL(clicked()),this,SLOT(close()));
1827
}

SmartTimer/addalarmdialog.ui

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -32,81 +32,7 @@
3232
</rect>
3333
</property>
3434
<property name="styleSheet">
35-
<string notr="true">QWidget {
36-
37-
background-color: rgb(113, 113, 113);
38-
39-
}
40-
41-
QLabel {
42-
color: rgb(238, 238, 236);
43-
font: bold;
44-
margin-left: 3px;
45-
}
46-
47-
QPushButton {
48-
background-color: rgb(113, 113, 113);
49-
border: 2px solid rgb(200,200,200);
50-
border-radius: 8px;
51-
52-
font: 14pt bold;
53-
color: rgb(230,230,230);
54-
}
55-
56-
QPushButton#createButton {
57-
58-
background-color: rgb(213, 126, 76);
59-
}
60-
61-
QPushButton#createButton:hover {
62-
background-color: rgb(220, 136, 86);
63-
}
64-
65-
QPushButton#cancelButton:hover {
66-
background-color: rgb(123, 123, 123);
67-
}
68-
69-
QLineEdit {
70-
border-radius: 10px;
71-
color: rgb(238, 238, 236);
72-
background-color: rgb(255, 204, 157,10);
73-
}
74-
75-
QTimeEdit {
76-
border-radius: 10px;
77-
color: rgb(238, 238, 236);
78-
font: 19pt bold;
79-
background-color: rgb(255, 204, 157,10);
80-
}
81-
82-
QTimeEdit::up-button {
83-
subcontrol-origin: border;
84-
subcontrol-position: top right;
85-
86-
background-color: rgb(213, 126, 76);
87-
width: 25px;
88-
height: 25px;
89-
border-width: 3px;
90-
border-color: rgb(85, 87, 83);
91-
border-radius: 4px;
92-
93-
margin-bottom: 2px;
94-
}
95-
96-
QTimeEdit::down-button {
97-
subcontrol-origin: border;
98-
subcontrol-position: bottom right;
99-
100-
background-color: rgb(213, 126, 76);
101-
width: 25px;
102-
height: 25px;
103-
border-width: 3px;
104-
border-color: rgb(85, 87, 83);
105-
border-radius: 4px;
106-
margin-top: 2px;
107-
}
108-
109-
</string>
35+
<string notr="true"/>
11036
</property>
11137
<layout class="QVBoxLayout" name="verticalLayout_2">
11238
<item>
@@ -149,6 +75,9 @@ QTimeEdit::down-button {
14975
<height>50</height>
15076
</size>
15177
</property>
78+
<property name="alignment">
79+
<set>Qt::AlignCenter</set>
80+
</property>
15281
</widget>
15382
</item>
15483
</layout>

SmartTimer/addtimerdialog.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
#include "addtimerdialog.h"
22
#include "ui_addtimerdialog.h"
33

4+
#include <QFile>
5+
46
addTimerDialog::addTimerDialog(QWidget *parent) :
57
QDialog(parent),
68
ui(new Ui::addTimerDialog)
79
{
810
ui->setupUi(this);
911

12+
QFile file(":/stylesheet.qss");
13+
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
14+
{
15+
this->setStyleSheet(file.readAll());
16+
file.close();
17+
}
18+
19+
20+
1021
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
1122
connect(ui->createButton, SIGNAL(clicked()), this, SLOT(returnAndClose()));
1223

SmartTimer/addtimerdialog.ui

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -39,79 +39,7 @@
3939
</rect>
4040
</property>
4141
<property name="styleSheet">
42-
<string notr="true">QWidget#DialogGrid {
43-
44-
background-color: rgb(113, 113, 113);
45-
46-
}
47-
48-
QLabel {
49-
color: rgb(238, 238, 236);
50-
font: bold;
51-
margin-left: 3px;
52-
}
53-
54-
QPushButton {
55-
background-color: rgb(113, 113, 113);
56-
border: 2px solid rgb(200,200,200);
57-
border-radius: 8px;
58-
59-
font: 14pt bold;
60-
color: rgb(230,230,230);
61-
}
62-
63-
QPushButton#createButton {
64-
65-
background-color: rgb(213, 126, 76);
66-
}
67-
68-
QPushButton#createButton:hover {
69-
background-color: rgb(220, 136, 86);
70-
}
71-
72-
QPushButton#cancelButton:hover {
73-
background-color: rgb(123, 123, 123);
74-
}
75-
76-
QLineEdit {
77-
border-radius: 10px;
78-
color: rgb(238, 238, 236);
79-
background-color: rgb(255, 204, 157,10);
80-
}
81-
82-
QTimeEdit {
83-
border-radius: 10px;
84-
color: rgb(238, 238, 236);
85-
font: 19pt bold;
86-
background-color: rgb(255, 204, 157,10);
87-
}
88-
89-
QTimeEdit::up-button {
90-
subcontrol-origin: border;
91-
subcontrol-position: top right;
92-
93-
background-color: rgb(213, 126, 76);
94-
width: 25px;
95-
height: 25px;
96-
border-width: 3px;
97-
border-color: rgb(85, 87, 83);
98-
border-radius: 4px;
99-
100-
margin-bottom: 2px;
101-
}
102-
103-
QTimeEdit::down-button {
104-
subcontrol-origin: border;
105-
subcontrol-position: bottom right;
106-
107-
background-color: rgb(213, 126, 76);
108-
width: 25px;
109-
height: 25px;
110-
border-width: 3px;
111-
border-color: rgb(85, 87, 83);
112-
border-radius: 4px;
113-
margin-top: 2px;
114-
}
42+
<string notr="true">
11543

11644
</string>
11745
</property>

SmartTimer/alertwidget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ alertwidget::alertwidget(int msecs, const QString& name, bool turnedOn, QWidget
4848

4949
ui->setupUi(this);
5050

51+
QFile file(":/stylesheet.qss");
52+
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
53+
{
54+
this->setStyleSheet(file.readAll());
55+
file.close();
56+
}
57+
5158
ui->timeLabel->setText(alertTime.toString("hh:mm"));
5259
ui->alarmNameLabel->setText(alertName);
5360

SmartTimer/alertwidget.ui

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,11 @@
3535
<string>Form</string>
3636
</property>
3737
<property name="styleSheet">
38-
<string notr="true">QWidget {
39-
background-color: rgb(113,113,113);
40-
color: rgb(210,210,210);
41-
}
42-
43-
QWidget#alertSwitch {
38+
<string notr="true">QWidget#alertSwitch {
4439
margin-right: 5px;
4540
}
4641

4742
QPushButton {
48-
background-color: rgb(113,113,113);
49-
color: white;
5043
border: 0px;
5144
border-radius: 35px;
5245
}

SmartTimer/changealarmdialog.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
#include "ui_changealarmdialog.h"
33
#include "alertwidget.h"
44

5+
#include <QFile>
6+
57
ChangeAlarmDialog::ChangeAlarmDialog(alertwidget *parent) :
68
QDialog(parent),
79
ui(new Ui::ChangeAlarmDialog)
810
{
911
ui->setupUi(this);
1012

11-
ui->alarmName->setText(parent->getName());
12-
ui->time->setTime(QTime::fromMSecsSinceStartOfDay(parent->getAlertTime()));
13+
QFile file(":/stylesheet.qss");
14+
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
15+
{
16+
this->setStyleSheet(file.readAll());
17+
file.close();
18+
}
19+
ui->alarmName->setText(parent->getName());
20+
ui->time->setTime(QTime::fromMSecsSinceStartOfDay(parent->getAlertTime()));
1321

14-
connect(ui->changeButton,SIGNAL(clicked()), this, SLOT(changeAlarm()));
22+
connect(ui->changeButton,SIGNAL(clicked()), this, SLOT(changeAlarm()));
1523
}
1624

1725
ChangeAlarmDialog::~ChangeAlarmDialog()

SmartTimer/changealarmdialog.ui

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -23,81 +23,7 @@
2323
</rect>
2424
</property>
2525
<property name="styleSheet">
26-
<string notr="true">QWidget#DialogGrid {
27-
28-
background-color: rgb(113, 113, 113);
29-
30-
}
31-
32-
QLabel {
33-
color: rgb(238, 238, 236);
34-
font: bold;
35-
margin-left: 3px;
36-
}
37-
38-
QPushButton {
39-
background-color: rgb(113, 113, 113);
40-
border: 2px solid rgb(200,200,200);
41-
border-radius: 8px;
42-
43-
font: 14pt bold;
44-
color: rgb(230,230,230);
45-
}
46-
47-
QPushButton#changeButton {
48-
49-
background-color: rgb(213, 126, 76);
50-
}
51-
52-
QPushButton#changeButton:hover {
53-
background-color: rgb(220, 136, 86);
54-
}
55-
56-
QPushButton#cancelButton:hover {
57-
background-color: rgb(123, 123, 123);
58-
}
59-
60-
QLineEdit {
61-
border-radius: 10px;
62-
color: rgb(238, 238, 236);
63-
background-color: rgb(255, 204, 157,10);
64-
}
65-
66-
QTimeEdit {
67-
border-radius: 10px;
68-
color: rgb(238, 238, 236);
69-
font: 19pt bold;
70-
background-color: rgb(255, 204, 157,10);
71-
}
72-
73-
QTimeEdit::up-button {
74-
subcontrol-origin: border;
75-
subcontrol-position: top right;
76-
77-
background-color: rgb(213, 126, 76);
78-
width: 25px;
79-
height: 25px;
80-
border-width: 3px;
81-
border-color: rgb(85, 87, 83);
82-
border-radius: 4px;
83-
84-
margin-bottom: 2px;
85-
}
86-
87-
QTimeEdit::down-button {
88-
subcontrol-origin: border;
89-
subcontrol-position: bottom right;
90-
91-
background-color: rgb(213, 126, 76);
92-
width: 25px;
93-
height: 25px;
94-
border-width: 3px;
95-
border-color: rgb(85, 87, 83);
96-
border-radius: 4px;
97-
margin-top: 2px;
98-
}
99-
100-
</string>
26+
<string notr="true"/>
10127
</property>
10228
<layout class="QGridLayout" name="gridLayout">
10329
<property name="leftMargin">

SmartTimer/changetimerdialog.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22
#include "ui_changetimerdialog.h"
33

44
#include <QTime>
5+
#include <QFile>
56

67
ChangeTimerDialog::ChangeTimerDialog(TimerWidget *parent) :
78
QDialog(parent),
89
ui(new Ui::ChangeTimerDialog)
910
{
1011
ui->setupUi(this);
1112

13+
QFile file(":/stylesheet.qss");
14+
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
15+
{
16+
this->setStyleSheet(file.readAll());
17+
file.close();
18+
}
19+
20+
1221
par = parent;
1322

1423
ui->timerName->setText(parent->getTimerName());

0 commit comments

Comments
 (0)