-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecboxitem.cpp
More file actions
61 lines (56 loc) · 1.85 KB
/
Copy pathrecboxitem.cpp
File metadata and controls
61 lines (56 loc) · 1.85 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "recboxitem.h"
#include "ui_recboxitem.h"
RecBoxItem::RecBoxItem(QWidget *parent)
: QWidget(parent)
, ui(new Ui::RecBoxItem)
{
ui->setupUi(this);
ui->MusicImage->installEventFilter(this);
}
RecBoxItem::~RecBoxItem()
{
delete ui;
}
bool RecBoxItem::eventFilter(QObject *watched, QEvent *event)
{
if(watched==ui->MusicImage)
{
int imagewidth=ui->MusicImage->width();
int imageheight=ui->MusicImage->height();
if(event->type()==QEvent::Enter)
{
QPropertyAnimation *animation=new QPropertyAnimation(ui->MusicImage,"geometry");
animation->setDuration(100);
animation->setKeyValueAt(0,QRect(9,9,imagewidth,imageheight));
animation->setKeyValueAt(1,QRect(9,0,imagewidth,imageheight));
animation->start();
connect(animation,&QPropertyAnimation::finished,this,[=](){
delete animation;
qDebug()<<"delete success";
});
return true;
}else if(event->type()==QEvent::Leave)
{
QPropertyAnimation *animation=new QPropertyAnimation(ui->MusicImage,"geometry");
animation->setDuration(100);
animation->setKeyValueAt(0,QRect(9,0,imagewidth,imageheight));
animation->setKeyValueAt(1,QRect(9,9,imagewidth,imageheight));
animation->start();
connect(animation,&QPropertyAnimation::finished,this,[=](){
delete animation;
qDebug()<<"delete success";
});
return true;
}
}
return QObject::eventFilter(watched,event);
}
void RecBoxItem::SetImage(const QString &path)
{
QString imagestyle="border-image:url("+path+");";
ui->RecImages->setStyleSheet(imagestyle);
}
void RecBoxItem::SetText(const QString &content)
{
ui->RecText->setText(content);
}