Skip to content

Commit 8054504

Browse files
committed
Style context menu
1 parent f38bec9 commit 8054504

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

SmartTimer/alertwidget.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "ui_alertwidget.h"
33
#include "changealarmdialog.h"
44

5-
65
#include <iostream>
76

87
int getMsecs(const QTime& t)
@@ -126,6 +125,7 @@ void alertwidget::onTickCheck()
126125
blinking = true;
127126
player->play();
128127
ui->stopButton->show();
128+
ui->stopButton->setEnabled(true);
129129
}
130130

131131
void alertwidget::blink()
@@ -137,11 +137,15 @@ void alertwidget::blink()
137137
" background-color: qlineargradient(spread:pad, x1:0.622, y1:0.0113636,"
138138
" x2:1, y2:0, stop:0 rgb(183, 106, 56), stop:0.626368 rgba(0, 0, 0, 0));"
139139
" border-radius: 30px;"
140+
" border: 0px;"
140141
" }");
141142
}
142143
else
143144
{
144-
ui->widget->setStyleSheet("QWidget { background-color: rgb(113,113,113); }");
145+
ui->widget->setStyleSheet("QWidget {"
146+
" background-color: rgb(113,113,113);"
147+
" border: 0px; "
148+
"}");
145149
}
146150
blinky = !blinky;
147151
}
@@ -187,14 +191,16 @@ void alertwidget::ShowContextMenu(const QPoint &pos)
187191
{
188192
QMenu contextMenu(tr("Context menu"), this);
189193

190-
QAction action1("Delete alarm", this);
191-
QAction action2("Change alarm", this);
192-
connect(&action1, SIGNAL(triggered()), this, SLOT(closeAlarm()));
193-
connect(&action2, SIGNAL(triggered()), this, SLOT(changeAlarm()));
194-
contextMenu.addAction(&action1);
195-
contextMenu.addAction(&action2);
194+
QAction actionDelete("Delete alarm", this);
195+
QAction actionChange("Change alarm", this);
196+
197+
connect(&actionDelete, SIGNAL(triggered()), this, SLOT(closeAlarm()));
198+
connect(&actionChange, SIGNAL(triggered()), this, SLOT(changeAlarm()));
199+
contextMenu.addAction(&actionDelete);
200+
contextMenu.addAction(&actionChange);
196201

197202
contextMenu.exec(mapToGlobal(pos));
203+
198204
}
199205

200206
void alertwidget::setAlarm(int msecs, const QString & _name)
@@ -209,15 +215,12 @@ void alertwidget::setAlarm(int msecs, const QString & _name)
209215

210216
}
211217

212-
213218
void alertwidget::mousePressEvent(QMouseEvent *e)
214219
{
215220
if (e->button() == Qt::RightButton)
216221
{
217222
player->stop();
218-
219223
ShowContextMenu(e->pos());
220-
//emit closeAlarm();
221224
}
222225
}
223226

SmartTimer/changealarmdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ChangeAlarmDialog::ChangeAlarmDialog(alertwidget *parent) :
2020
ui->time->setTime(QTime::fromMSecsSinceStartOfDay(parent->getAlertTime()));
2121

2222
connect(ui->changeButton,SIGNAL(clicked()), this, SLOT(changeAlarm()));
23+
connect(ui->cancelButton,SIGNAL(clicked()), this, SLOT(close()));
2324
}
2425

2526
ChangeAlarmDialog::~ChangeAlarmDialog()

SmartTimer/stylesheet.qss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ QPushButton#changeButton:hover {
139139
}
140140

141141

142+
QMenu {
143+
color: rgb(218,218,218);
144+
font: 15pt;
145+
}
146+
147+
QMenu::item:selected {
148+
background-color: rgb(220,150,90);
149+
}
142150

143151

144152

0 commit comments

Comments
 (0)