-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclosebutton.cpp
More file actions
47 lines (41 loc) · 1.05 KB
/
closebutton.cpp
File metadata and controls
47 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "closebutton.h"
#include <QStyle>
#include <QPainter>
#include <QPaintEvent>
#include <definitions/resources.h>
#include <definitions/stylesheets.h>
#include "iconstorage.h"
#include "stylestorage.h"
CloseButton::CloseButton(QWidget *AParent) : QAbstractButton(AParent)
{
setMouseTracking(true);
setFocusPolicy(Qt::NoFocus);
setProperty("isHover",false);
StyleStorage::staticStorage(RSR_STORAGE_STYLESHEETS)->insertAutoStyle(this,STS_UTILS_CLOSEBUTTON);
}
QSize CloseButton::sizeHint() const
{
ensurePolished();
return icon().availableSizes().value(0);
}
void CloseButton::enterEvent(QEvent *AEvent)
{
QAbstractButton::enterEvent(AEvent);
setProperty("isHover",true);
StyleStorage::updateStyle(this);
}
void CloseButton::leaveEvent(QEvent *AEvent)
{
QAbstractButton::leaveEvent(AEvent);
setProperty("isHover",false);
StyleStorage::updateStyle(this);
}
void CloseButton::paintEvent(QPaintEvent *AEvent)
{
Q_UNUSED(AEvent)
if (!icon().isNull())
{
QPainter p(this);
icon().paint(&p,rect());
}
}