1 Star 0 Fork 9

fuyb/linux_feiq

forked from uenigma/linux_feiq 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
chooseemojiwidget.cpp 1008 Bytes
一键复制 编辑 原始数据 按行查看 历史
lpx 提交于 2021-12-16 21:35 +08:00 . 格式化代码
#include "chooseemojiwidget.h"
#include "emoji.h"
#include <QMouseEvent>
ChooseEmojiWidget::ChooseEmojiWidget(QWidget *parent)
: QLabel(parent), mIndex(-1)
{
setMouseTracking(true);
}
void ChooseEmojiWidget::mousePressEvent(QMouseEvent *event)
{
mIndex = getIndex(event->x(), event->y());
}
void ChooseEmojiWidget::mouseMoveEvent(QMouseEvent *event)
{
auto index = getIndex(event->x(), event->y());
if (index >= 0 && index < EMOJI_LEN)
{
emit hesitate(index);
}
else
{
emit hesitate(-1);
}
}
void ChooseEmojiWidget::mouseReleaseEvent(QMouseEvent *event)
{
auto index = getIndex(event->x(), event->y());
if (mIndex == index && mIndex >= 0 && mIndex < EMOJI_LEN)
{
emit choose(mIndex);
}
mIndex = -1;
}
int ChooseEmojiWidget::getIndex(int x, int y)
{
int col = x / 25;
int row = y / 25;
auto index = row * EMOJI_BMP_COL + col;
if (index >= 0 && index < EMOJI_LEN)
return index;
return -1;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HALOBING/linux_feiq.git
git@gitee.com:HALOBING/linux_feiq.git
HALOBING
linux_feiq
linux_feiq
master

搜索帮助