#include "SlideAnimationWidget.h"
#include "ui_SlideAnimationWidget.h"
#include <QAbstractItemView>
#include <QListView>
#include <QMouseEvent>
SlideAnimationWidget::SlideAnimationWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::SlideAnimationWidget)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow | Qt::WindowStaysOnTopHint);
m_slideOutAnimation = new QPropertyAnimation(this,"geometry");
connect(m_slideOutAnimation,&QPropertyAnimation::finished,this,&SlideAnimationWidget::slotSlideOutFinished);
m_slideOutAnimation->setEasingCurve(QEasingCurve::OutSine);
m_slideOutAnimation->setDuration(1300);
m_slideInAnimation = new QPropertyAnimation(this,"geometry");
connect(m_slideInAnimation,&QPropertyAnimation::finished,this,&SlideAnimationWidget::slotSlideInFinished);
m_slideInAnimation->setEasingCurve(QEasingCurve::InSine);
m_slideInAnimation->setDuration(1300);
ui->stackedWidget->setCurrentIndex(0);
ui->label->installEventFilter(this);
ui->controlWidget->installEventFilter(this);
ui->cbxFocusMode->view()->installEventFilter(this);
ui->cbxField->view()->installEventFilter(this);
ui->cbxFocusStep->view()->installEventFilter(this);
this->setMaximumWidth(SLIDE_MIN_WIDTH);
}
SlideAnimationWidget::~SlideAnimationWidget()
{
delete ui;
}
void SlideAnimationWidget::setPos(int x, int y)
{
m_posX = x;
m_posY = y;
move(x,y);
}
bool SlideAnimationWidget::eventFilter(QObject *obj, QEvent *event)
{
if(obj == ui->cbxFocusMode->view() ||
obj == ui->cbxField->view() ||
obj == ui->cbxFocusStep->view())
{
if (event->type() == QEvent::FocusIn)
{
m_bInComboBox = true;
}
else if (event->type() == QEvent::FocusOut)
{
m_bInComboBox = false;
}
}
else if(obj == ui->label)
{
//鼠标进入的时候
if (event->type() == QEvent::Enter &&
ui->stackedWidget->currentIndex() == 0 &&
!m_bShowSideflag)
{
if(m_slideOutAnimation->state() == QAbstractAnimation::Running)
return true;
//qDebug()<<"Enter";
this->setMaximumWidth(SLIDE_MAX_WIDTH);
m_slideOutAnimation->setStartValue(QRect(m_posX,m_posY,SLIDE_MIN_WIDTH,this->height()));
m_slideOutAnimation->setEndValue(QRect(m_posX,m_posY,SLIDE_MAX_WIDTH,this->height()));
m_slideOutAnimation->start();
ui->stackedWidget->setCurrentIndex(1);
m_bShowSideflag = true;
return true;
}
return false;//别的事件会传给label对象
}
else if(obj == ui->controlWidget)
{
//鼠标离开的时候
if (event->type() == QEvent::Leave &&
ui->stackedWidget->currentIndex() == 1 &&
m_bShowSideflag && !m_bInComboBox && !m_bContainMouse)
{
if(m_slideInAnimation->state() == QAbstractAnimation::Running)
return true;
//qDebug()<<"Leave";
m_slideInAnimation->setStartValue(QRect(m_posX,m_posY,SLIDE_MAX_WIDTH,this->height()));
m_slideInAnimation->setEndValue(QRect(m_posX,m_posY,SLIDE_MIN_WIDTH,this->height()));
m_slideInAnimation->start();
m_bShowSideflag = false;
return true;
}
return false;//别的事件会传给label对象
}
// if(event->type() == QEvent::MouseMove)
// {
// QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
// qDebug()<<"x = "<<mouseEvent->pos().x()<<" "<<mouseEvent->pos().y();
// if(mouseEvent->x() < SLIDE_MAX_WIDTH && mouseEvent->y() < this->height())
// {
// m_bContainMouse = true;
// }
// else
// m_bContainMouse = false;
// return true;
// }
// standard event processing
return QWidget::eventFilter(obj, event);
}
void SlideAnimationWidget::slotSlideOutFinished()
{
}
void SlideAnimationWidget::slotSlideInFinished()
{
this->setMaximumWidth(SLIDE_MIN_WIDTH);
ui->stackedWidget->setCurrentIndex(0);
}

灬Sunnnnn
- 粉丝: 3w+
最新资源
- 自动化项目的管理流程与要点.docx
- 互联网+背景下大学英语课程思政建设探究.docx
- yolo目标检测算法相关实现
- 单片机函数信号发生器设计打印.doc
- C单片机智能电称研发设计方案.doc
- VB-SQL工资管理系统设计研究报告.doc
- 中国大数据大事记(-).docx
- 企业财务管理受会计信息化的影响和对策.docx
- 三菱PLC控制四层电梯大学设计设计[]9.doc
- 铁路运输的标准化与信息化研究.docx
- matlab处理音频信号.doc
- 物联网策划方案.docx
- XX中学网络建设实施方案书.doc
- javaee课程研究设计信息管理系统需求分析.doc
- 计算机多媒体网络教学发展趋势和方向.docx
- 基于价值链的移动电子商务商业模式的研究.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


