1 Star 0 Fork 0

tongy boys/material-pri

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
qtmaterialautocomplete_internal.cpp 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
#include "qtmaterialautocomplete_internal.h"
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
#include <QSignalTransition>
/*!
* \class QtMaterialAutoCompleteStateMachine
* \internal
*/
/*!
* \internal
*/
QtMaterialAutoCompleteStateMachine::QtMaterialAutoCompleteStateMachine(QWidget *menu)
: QStateMachine(menu),
m_menu(menu),
m_closedState(new QState),
m_openState(new QState),
m_closingState(new QState)
{
Q_ASSERT(menu);
addState(m_closedState);
addState(m_openState);
addState(m_closingState);
setInitialState(m_closedState);
QSignalTransition *transition;
transition = new QSignalTransition(this, &QtMaterialAutoCompleteStateMachine::shouldOpen);
transition->setTargetState(m_openState);
m_closedState->addTransition(transition);
transition = new QSignalTransition(this, &QtMaterialAutoCompleteStateMachine::shouldClose);
transition->setTargetState(m_closedState);
m_openState->addTransition(transition);
transition = new QSignalTransition(this, &QtMaterialAutoCompleteStateMachine::shouldFade);
transition->setTargetState(m_closingState);
m_openState->addTransition(transition);
m_closedState->assignProperty(menu, "visible", false);
m_openState->assignProperty(menu, "visible", true);
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
menu->setGraphicsEffect(effect);
m_openState->assignProperty(effect, "opacity", 1);
m_closingState->assignProperty(effect, "opacity", 0);
m_closedState->assignProperty(effect, "opacity", 0);
QPropertyAnimation *animation;
animation = new QPropertyAnimation(effect, "opacity", this);
animation->setDuration(240);
addDefaultAnimation(animation);
transition = new QSignalTransition(animation, &QPropertyAnimation::finished);
transition->setTargetState(m_closedState);
m_closingState->addTransition(transition);
}
/*!
* \internal
*/
QtMaterialAutoCompleteStateMachine::~QtMaterialAutoCompleteStateMachine()
{
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/tongynj/material-pri.git
git@gitee.com:tongynj/material-pri.git
tongynj
material-pri
material-pri
master

搜索帮助