-
Notifications
You must be signed in to change notification settings - Fork 88
/
chooseemojidlg.cpp
57 lines (47 loc) · 1.23 KB
/
chooseemojidlg.cpp
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
#include "chooseemojidlg.h"
#include "ui_chooseemojidlg.h"
#include <QMouseEvent>
#include <QMovie>
#include "emoji.h"
ChooseEmojiDlg::ChooseEmojiDlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChooseEmojiDlg)
{
ui->setupUi(this);
setWindowFlags(Qt::Tool);
setFixedSize(size());
mMovie = new QMovie(this);
ui->gifLabel->setMovie(mMovie);
connect(ui->chooseWidget, SIGNAL(choose(int)), this, SLOT(choose(int)));
connect(ui->chooseWidget, SIGNAL(choose(int)), this, SLOT(hide()));
connect(ui->chooseWidget, SIGNAL(hesitate(int)), this, SLOT(hesitate(int)));
}
ChooseEmojiDlg::~ChooseEmojiDlg()
{
delete ui;
}
void ChooseEmojiDlg::hideEvent(QHideEvent *event)
{
mMovie->stop();
}
void ChooseEmojiDlg::hesitate(int index)
{
if (index == -1)
{
ui->hintLabel->setText("");
mMovie->stop();
ui->gifLabel->setText("");
}
else
{
ui->hintLabel->setText(QString(g_emojiText[index])+" "+QString(g_emojis[index]));
auto gif = ":/default/res/face/"+QString::number(index+1)+".gif";
mMovie->stop();
mMovie->setFileName(gif);
mMovie->start();
}
}
void ChooseEmojiDlg::choose(int index)
{
emit choose(g_emojis[index]);
}