forked from 3dsman/qt-material-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 3dsman#1 from laserpants/master
Syncing from original
- Loading branch information
Showing
27 changed files
with
377 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "qtmaterialautocomplete_internal.h" | ||
#include <QSignalTransition> | ||
#include <QPropertyAnimation> | ||
#include <QtWidgets/QGraphicsOpacityEffect> | ||
#include <QDebug> | ||
|
||
/*! | ||
* \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, SIGNAL(shouldOpen())); | ||
transition->setTargetState(m_openState); | ||
m_closedState->addTransition(transition); | ||
|
||
transition = new QSignalTransition(this, SIGNAL(shouldClose())); | ||
transition->setTargetState(m_closedState); | ||
m_openState->addTransition(transition); | ||
|
||
transition = new QSignalTransition(this, SIGNAL(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, SIGNAL(finished())); | ||
transition->setTargetState(m_closedState); | ||
m_closingState->addTransition(transition); | ||
} | ||
|
||
/*! | ||
* \internal | ||
*/ | ||
QtMaterialAutoCompleteStateMachine::~QtMaterialAutoCompleteStateMachine() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef QTMATERIALAUTOCOMPLETESTATEMACHINE_H | ||
#define QTMATERIALAUTOCOMPLETESTATEMACHINE_H | ||
|
||
#include <QStateMachine> | ||
#include "qtmaterialautocomplete.h" | ||
|
||
class QtMaterialAutoCompleteStateMachine : public QStateMachine | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QtMaterialAutoCompleteStateMachine(QWidget *menu); | ||
~QtMaterialAutoCompleteStateMachine(); | ||
|
||
signals: | ||
void shouldOpen(); | ||
void shouldClose(); | ||
void shouldFade(); | ||
|
||
private: | ||
Q_DISABLE_COPY(QtMaterialAutoCompleteStateMachine) | ||
|
||
QWidget *const m_menu; | ||
QState *const m_closedState; | ||
QState *const m_openState; | ||
QState *const m_closingState; | ||
}; | ||
|
||
#endif // QTMATERIALAUTOCOMPLETESTATEMACHINE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.