-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpicshow.cpp
More file actions
124 lines (108 loc) · 3.62 KB
/
picshow.cpp
File metadata and controls
124 lines (108 loc) · 3.62 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "picshow.h"
#include "ui_picshow.h"
#include <QEvent>
picShow::picShow(QWidget *parent) :
QDialog(parent),
ui(new Ui::picShow)
{
ui->setupUi(this);
ui->previous->SetIcons(":/icon/previous.png"
,":/icon/previous_hover.png"
,":/icon/previous_press.png");
ui->next->SetIcons(":/icon/next.png"
,":/icon/next_hover.png"
,":/icon/next_press.png");
QGraphicsOpacityEffect *opacityPre = new QGraphicsOpacityEffect(this);
opacityPre->setOpacity(0);
ui->previous->setGraphicsEffect(opacityPre);
QGraphicsOpacityEffect *opacitynext = new QGraphicsOpacityEffect(this);
opacitynext->setOpacity(0);
ui->next->setGraphicsEffect(opacitynext);
m_animationShowPre = new QPropertyAnimation(opacityPre,"opacity",this);
m_animationShowPre->setEasingCurve(QEasingCurve::Linear);
m_animationShowPre->setDuration(500);
m_animationShownext = new QPropertyAnimation(opacitynext,"opacity",this);
m_animationShownext->setEasingCurve(QEasingCurve::Linear);
m_animationShownext->setDuration(500);
connect(ui->next,&QPushButton::clicked,this,&picShow::SigNextClicked);
connect(ui->previous,&QPushButton::clicked,this,&picShow::SigPreClicked);
}
picShow::~picShow()
{
delete ui;
}
void picShow::ReloadPic()
{
if(m_selectedPath != ""){
const int &width = ui->gridLayout->geometry().width();
const int &height = ui->gridLayout->geometry().height();
m_pixmap.load(m_selectedPath);
m_pixmap = m_pixmap.scaled(width,height,Qt::KeepAspectRatio);
ui->label->setPixmap(m_pixmap);
}
}
bool picShow::event(QEvent *e)
{
switch (e->type()) {
case QEvent::Enter:
showPreNextBtn(true);
break;
case QEvent::Leave:
showPreNextBtn(false);
break;
default:
break;
}
return QDialog::event(e);
}
void picShow::showPreNextBtn(bool bShow)
{
if(!bShow && m_bBtnVisible){
m_animationShowPre->stop();
m_animationShowPre->setStartValue(1);
m_animationShowPre->setEndValue(0);
m_animationShowPre->start();
m_animationShownext->stop();
m_animationShownext->setStartValue(1);
m_animationShownext->setEndValue(0);
m_animationShownext->start();
m_bBtnVisible = false;
return;
}
if(bShow && !m_bBtnVisible){
m_animationShowPre->stop();
m_animationShowPre->setStartValue(0);
m_animationShowPre->setEndValue(1);
m_animationShowPre->start();
m_animationShownext->stop();
m_animationShownext->setStartValue(0);
m_animationShownext->setEndValue(1);
m_animationShownext->start();
m_bBtnVisible = true;
return;
}
}
void picShow::SlotSelectItem(const QString &path)
{
m_selectedPath = path;
m_pixmap.load(path);
int width = this->width()-20;
int height = this->height()-20;
m_pixmap = m_pixmap.scaled(width,height,Qt::KeepAspectRatio);
ui->label->setPixmap(m_pixmap);
}
void picShow::SlotUpdatePic(const QString &path)
{
m_selectedPath = path;
if(m_selectedPath != ""){
const int &width = ui->gridLayout->geometry().width();
const int &height = ui->gridLayout->geometry().height();
m_pixmap.load(m_selectedPath);
m_pixmap = m_pixmap.scaled(width,height,Qt::KeepAspectRatio);
ui->label->setPixmap(m_pixmap);
}
}
void picShow::SlotClearItem()
{
m_selectedPath = "";
}