add useless animation
This commit is contained in:
parent
096ff5170b
commit
0ff1e80132
|
@ -11,6 +11,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QGraphicsOpacityEffect>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -73,6 +74,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
m_graphicsView->checkAndDoFitInView();
|
m_graphicsView->checkAndDoFitInView();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_opacityEffect = new QGraphicsOpacityEffect(m_bottomButtonGroup);
|
||||||
|
m_bottomButtonGroup->setGraphicsEffect(m_opacityEffect);
|
||||||
|
m_btnGrpAnimation = new QPropertyAnimation(m_opacityEffect, "opacity");
|
||||||
|
m_btnGrpAnimation->setDuration(300);
|
||||||
|
|
||||||
|
m_opacityEffect->setOpacity(0);
|
||||||
|
|
||||||
centerWindow();
|
centerWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +123,26 @@ void MainWindow::showEvent(QShowEvent *event)
|
||||||
return QMainWindow::showEvent(event);
|
return QMainWindow::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::enterEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
m_btnGrpAnimation->stop();
|
||||||
|
m_btnGrpAnimation->setStartValue(m_opacityEffect->opacity());
|
||||||
|
m_btnGrpAnimation->setEndValue(1);
|
||||||
|
m_btnGrpAnimation->start();
|
||||||
|
|
||||||
|
return QMainWindow::enterEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::leaveEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
m_btnGrpAnimation->stop();
|
||||||
|
m_btnGrpAnimation->setStartValue(m_opacityEffect->opacity());
|
||||||
|
m_btnGrpAnimation->setEndValue(0);
|
||||||
|
m_btnGrpAnimation->start();
|
||||||
|
|
||||||
|
return QMainWindow::leaveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::mousePressEvent(QMouseEvent *event)
|
void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
if (event->buttons() & Qt::LeftButton) {
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QGraphicsOpacityEffect;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class GraphicsView;
|
class GraphicsView;
|
||||||
class BottomButtonGroup;
|
class BottomButtonGroup;
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
|
@ -21,6 +25,8 @@ public:
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
|
void enterEvent(QEvent *event) override;
|
||||||
|
void leaveEvent(QEvent *event) override;
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
@ -35,6 +41,8 @@ protected slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint m_oldMousePos;
|
QPoint m_oldMousePos;
|
||||||
|
QGraphicsOpacityEffect *m_opacityEffect;
|
||||||
|
QPropertyAnimation *m_btnGrpAnimation;
|
||||||
QPropertyAnimation *m_fadeOutAnimation;
|
QPropertyAnimation *m_fadeOutAnimation;
|
||||||
QPropertyAnimation *m_floatUpAnimation;
|
QPropertyAnimation *m_floatUpAnimation;
|
||||||
QParallelAnimationGroup *m_exitAnimationGroup;
|
QParallelAnimationGroup *m_exitAnimationGroup;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user