Skip to content

Commit

Permalink
实现了子页面切换动画
Browse files Browse the repository at this point in the history
  • Loading branch information
LapplandSP committed Aug 30, 2022
1 parent 8c03903 commit 2a62e48
Show file tree
Hide file tree
Showing 56 changed files with 231 additions and 314 deletions.
2 changes: 1 addition & 1 deletion QtAdb/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ about::about(QWidget *parent) :
ui->btn_money->setGraphicsEffect(shadowEffect_btn_money);
QGraphicsDropShadowEffect *shadowEffect_btn_money2 = new QGraphicsDropShadowEffect(this);
shadowEffect_btn_money2->setOffset(0,0);
shadowEffect_btn_money2->setColor(Qt::gray);
shadowEffect_btn_money2->setColor(Qt::green);
shadowEffect_btn_money2->setBlurRadius(5);
ui->btn_money_2->setGraphicsEffect(shadowEffect_btn_money2);
QGraphicsDropShadowEffect *shadowEffect_btn_money3 = new QGraphicsDropShadowEffect(this);
Expand Down
10 changes: 5 additions & 5 deletions QtAdb/about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ QToolTip{border:1px solid #BDBDBD; background-color: #ffffff; color:rgba(117, 11
</font>
</property>
<property name="text">
<string>测试版本:beta-v1.2</string>
<string>测试版本:beta-v1.3</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -149,7 +149,7 @@ QToolTip{border:1px solid #BDBDBD; background-color: #ffffff; color:rgba(117, 11
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="toolTip">
<string>网址</string>
<string/>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{background-color:rgba(255,255,255,0.9);border-radius:4px;border:0px;}
Expand Down Expand Up @@ -215,7 +215,7 @@ QPushButton:pressed{background-color:rgba(255,255,255,0.6);}</string>
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="toolTip">
<string>酷安</string>
<string/>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{background-color:rgba(255,255,255,0.9);border-radius:4px;border:0px;}
Expand Down Expand Up @@ -281,7 +281,7 @@ QPushButton:pressed{background-color:rgba(255,255,255,0.6);}</string>
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="toolTip">
<string>Github</string>
<string/>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{background-color:rgba(255,255,255,0.9);border-radius:4px;border:0px;}
Expand Down Expand Up @@ -438,7 +438,7 @@ QPushButton:pressed{background-color:rgba(255,255,255,0.6);}</string>
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="toolTip">
<string>请我吃可乐(3元)</string>
<string/>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{background-color:rgba(255,255,255,0.9);border-radius:4px;border:0px;}
Expand Down
72 changes: 71 additions & 1 deletion QtAdb/animationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,61 @@ void animationWidget::playLoadAnimation(int h)

animation->setEasingCurve(QEasingCurve::OutQuart);

this->show();
animation->start();
//this->setDisabled(true);
emit animationEnd();
}

void animationWidget::playLoadAnimation_sp(int h)
{
animation->setDuration(500);
//animation->setEndValue(QPoint(301,117));
qDebug() << "wgtHeight = " << wgtHeight;
if(parent->width() <= 600)
{
animation->setEndValue(QRect(0,0, parent->width(),h));
}
else
{
animation->setEndValue(QRect(0,0, parent->width(),h));
}
//animation->setStartValue(QPoint(301 + 50,117));
animation->setStartValue(QRect(0,-10, parent->width(),h));

animation->setEasingCurve(QEasingCurve::OutQuart);

this->show();
animation->start();
emit animationEnd();
}

void animationWidget::playLoadAnimation_bp(int h)
{
animation->setDuration(500);
//animation->setEndValue(QPoint(301,117));
qDebug() << "wgtHeight = " << wgtHeight;
if(parent->width() <= 600)
{
animation->setEndValue(QRect(301 - 30, 117 - 6 -11, 600,h));
}
else
{
animation->setEndValue(QRect(301 - 30, 117 - 6 - 11, parent->width(),h));
}
//animation->setStartValue(QPoint(301 + 50,117));
animation->setStartValue(QRect(301 - 30, 117 - 6 - 11 + 10, parent->width(),h));

animation->setEasingCurve(QEasingCurve::OutQuart);

this->show();
animation->start();
emit animationEnd();
}

void animationWidget::playExitAnimation()
{
animation->setDuration(750);
animation->setDuration(300);
//animation->setEndValue(QPoint(301,117));
qDebug() << "wgtHeight = " << wgtHeight;
if(parent->width() <= 600)
Expand All @@ -78,6 +125,29 @@ void animationWidget::playExitAnimation()
emit animationEnd();
}

void animationWidget::playExitAnimation_sp()
{
animation->setDuration(500);
//animation->setEndValue(QPoint(301,117));
qDebug() << "wgtHeight = " << wgtHeight;
if(parent->width() <= 600)
{
animation->setEndValue(QRect(0,-11, parent->width(),wgtHeight));
}
else
{
animation->setEndValue(QRect(0,-11, parent->width(),wgtHeight));
}
//animation->setStartValue(QPoint(301 + 50,117));
animation->setStartValue(QRect(0,0, parent->width(),wgtHeight));

animation->setEasingCurve(QEasingCurve::OutQuart);

this->show();
animation->start();
emit animationEnd();
}

animationWidget::~animationWidget()
{
playExitAnimation();
Expand Down
3 changes: 3 additions & 0 deletions QtAdb/animationwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class animationWidget : public QWidget

void playLoadAnimation();
void playLoadAnimation(int h);
void playLoadAnimation_sp(int h);
void playLoadAnimation_bp(int h);
void playExitAnimation();
void playExitAnimation_sp();

bool isBasePage;
QWidget *parent;
Expand Down
29 changes: 21 additions & 8 deletions QtAdb/basepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ basePage::basePage(QWidget *parent) :
{
ui->setupUi(this);
SPManager = new sonPageManager;
animation_listHide = new QPropertyAnimation(ui->listWidget,"geometry");
parents = parent;

lastPage = NULL;
Expand Down Expand Up @@ -124,7 +125,7 @@ void basePage::slot_createSonPage(int key)
listTimer = new QTimer(this);
connect(listTimer, SIGNAL(timeout()), this, SLOT(slot_spgAnimationEnd()));
listTimer->setSingleShot(true);
listTimer->start(500);
listTimer->start(300);
emit creatingSonPage();

ui->listWidget->setCurrentRow(-1);
Expand All @@ -136,13 +137,14 @@ void basePage::slot_createSonPage(int key)

/**/
//sonPage->setVisible(false);
QPropertyAnimation *animation = new QPropertyAnimation(ui->listWidget,"geometry");

animation->setDuration(750);
animation->setEndValue(QRect(ui->listWidget->geometry().x(),ui->listWidget->geometry().y() + 50, parent->width(),wgtHeight));
animation->setStartValue(ui->listWidget->geometry());
animation->setEasingCurve(QEasingCurve::OutQuart);
animation->start();

animation_listHide->setDuration(300);
animation_listHide->setEndValue(QRect(ui->listWidget->geometry().x(),ui->listWidget->geometry().y() + 50, ui->listWidget->width(),ui->listWidget->height()));
animation_listHide->setStartValue(ui->listWidget->geometry());
animation_listHide->setEasingCurve(QEasingCurve::OutQuart);
animation_listHide->start();
//sonPage->playLoadAnimation_sp();
//animation->deleteLater();

/*
Expand All @@ -169,15 +171,25 @@ void basePage::slot_createSonPage(int key)
ui->listWidget->setCurrentRow(-1);
}

void basePage::spg_return_pushed()
{
sonPage->playExitAnimation_sp();
QTimer *animationTimer = new QTimer(this);
animationTimer->setSingleShot(true);
animationTimer->start(300);
connect(animationTimer, SIGNAL(timeout()), this, SLOT(slot_destroySonPage()));
}

void basePage::slot_destroySonPage()
{
if(sonPage == NULL)
throw "trying to destroy sonPage, but sonPage == NULL;";

delete sonPage;
sonPage = NULL;

ui->listWidget->setVisible(true);
playLoadAnimation();
playLoadAnimation_bp(this->height());
}

QString basePage::whoAmI()
Expand Down Expand Up @@ -231,5 +243,6 @@ void basePage::slot_spgAnimationEnd()
ui->listWidget->setVisible(false);
unlock();
ui->mainLayout->addWidget(sonPage);
sonPage->playLoadAnimation_sp(this->height());
//sonPage->setVisible(true);
}
4 changes: 3 additions & 1 deletion QtAdb/basepage.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class basePage : public animationWidget
QWidget *parents;

basePage *lastPage;
QWidget *sonPage;
animationWidget *sonPage;
QWidget *father;
QString myName;
sonPageManager *SPManager;
Expand All @@ -55,6 +55,7 @@ class basePage : public animationWidget
bool isEnable(int k);

QTimer *listTimer;
QPropertyAnimation *animation_listHide;

//QGraphicsOpacityEffect* exitOpacity;

Expand All @@ -68,6 +69,7 @@ private slots:
void slot_destroySonPage();
void unlock();
void slot_spgAnimationEnd();
void spg_return_pushed();
};

#endif // BASEPAGE_H
8 changes: 5 additions & 3 deletions QtAdb/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ void MainWindow::initBasePage(int key) //槽:生成basePages
/**/

currentPage = new basePage(this);

//qDebug() << "height in initBasePage()" << ui->widget_height->height();
currentPage->wgtHeight = ui->widget_height->height();
//qDebug() << "height2 in initBasePage()" << currentPage->wgtHeight;
Expand All @@ -382,7 +383,7 @@ void MainWindow::initBasePage(int key) //槽:生成basePages
taiChiTimer = new QTimer(this);
connect(taiChiTimer, SIGNAL(timeout()), this, SLOT(slot_taiChi()));
taiChiTimer->setSingleShot(true);
taiChiTimer->start(750);
taiChiTimer->start(700);

break;
}
Expand Down Expand Up @@ -683,8 +684,8 @@ void MainWindow::on_WSABtn_clicked() //槽:连接WSA
QMessageBox * msgBox = new QMessageBox;
msgBox->setWindowIcon(QIcon(":/ico/image/ico/link.svg"));
msgBox->setStyleSheet("background-color:rgba(255,255,255,1);border:0px; border-radius:0px;");
msgBox->setWindowTitle("无线调试");
msgBox->setText("· 已尝试连接,请刷新设备列表并选择WSA");
msgBox->setWindowTitle("WSA");
msgBox->setText("· 已尝试连接,请刷新设备列表并选择WSA\n· 请谨慎对WSA使用某些功能");
msgBox->addButton("", QMessageBox::AcceptRole);
msgBox->show();
}
Expand All @@ -709,6 +710,7 @@ void MainWindow::slot_taiChi()
if(ui->comboBox->currentIndex() != -1)
{
this->unlock();
//currentPage->setDisabled(false);
}
//this->setEnabled(true);
}
Expand Down
7 changes: 5 additions & 2 deletions QtAdb/sonPages/activator/sp_activator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
#include "ui_sp_activator.h"

sp_activator::sp_activator(QWidget *parent) :
QWidget(parent),
animationWidget(parent),
ui(new Ui::sp_activator)
{
ui->setupUi(this);
process = new adbProcess;
parents = parent;

connect(this->ui->back_to_basePage,SIGNAL(clicked()),parent,SLOT(slot_destroySonPage()));
//spg_return_pushed()
//connect(this->ui->back_to_basePage,SIGNAL(clicked()),parent,SLOT(slot_destroySonPage()));
connect(this->ui->back_to_basePage,SIGNAL(clicked()),parent,SLOT(spg_return_pushed()));

QGraphicsDropShadowEffect *shadowEffect_runBtn = new QGraphicsDropShadowEffect(this);
QGraphicsDropShadowEffect *shadowEffect_showOutputBtn = new QGraphicsDropShadowEffect(this);
Expand Down Expand Up @@ -83,6 +85,7 @@ void sp_activator::on_showOutputBtn_clicked(bool checked)
if(checked)
{
page = new standardOutputPage(NULL,process);
page->setWindowTitle("命令行输出");
connect(process,SIGNAL(outputGet(QString)),page,SLOT(update(QString)));
/*
parents->mapToGlobal(parents->pos());
Expand Down
3 changes: 2 additions & 1 deletion QtAdb/sonPages/activator/sp_activator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#include "adbprocess.h"
#include "../sonpagebase.h"
#include "../standardoutputpage.h"
#include "../../animationwidget.h"

namespace Ui {
class sp_activator;
}

class sp_activator : public QWidget
class sp_activator : public animationWidget
{
Q_OBJECT

Expand Down
2 changes: 1 addition & 1 deletion QtAdb/sonPages/advanced/sp_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ui_sp_accounts.h"

sp_accounts::sp_accounts(QWidget *parent) :
QWidget(parent),
animationWidget(parent),
ui(new Ui::sp_accounts)
{
ui->setupUi(this);
Expand Down
3 changes: 2 additions & 1 deletion QtAdb/sonPages/advanced/sp_accounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#include "../../threads/adbthread.h"
#include <QScrollBar>
#include <QFile>
#include "../../animationwidget.h"

namespace Ui {
class sp_accounts;
}

class sp_accounts : public QWidget
class sp_accounts : public animationWidget
{
Q_OBJECT

Expand Down
2 changes: 1 addition & 1 deletion QtAdb/sonPages/advanced/sp_captive_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ui_sp_captive_portal.h"

sp_captive_portal::sp_captive_portal(QWidget *parent) :
QWidget(parent),
animationWidget(parent),
ui(new Ui::sp_captive_portal)
{
ui->setupUi(this);
Expand Down
3 changes: 2 additions & 1 deletion QtAdb/sonPages/advanced/sp_captive_portal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#include "../../threads/adbthread.h"
#include <QScrollBar>
#include <QFile>
#include "../../animationwidget.h"

namespace Ui {
class sp_captive_portal;
}

class sp_captive_portal : public QWidget
class sp_captive_portal : public animationWidget
{
Q_OBJECT

Expand Down
Loading

0 comments on commit 2a62e48

Please sign in to comment.