chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -8,63 +8,48 @@
|
||||
#include "ElaBreadcrumbBar.h"
|
||||
#include "ElaScrollPage.h"
|
||||
|
||||
ElaScrollPagePrivate::ElaScrollPagePrivate(QObject* parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
ElaScrollPagePrivate::ElaScrollPagePrivate(QObject *parent) : QObject{parent} {}
|
||||
|
||||
ElaScrollPagePrivate::~ElaScrollPagePrivate()
|
||||
{
|
||||
}
|
||||
ElaScrollPagePrivate::~ElaScrollPagePrivate() {}
|
||||
|
||||
void ElaScrollPagePrivate::onNavigationRouteBack(QVariantMap routeData)
|
||||
{
|
||||
void ElaScrollPagePrivate::onNavigationRouteBack(QVariantMap routeData) {
|
||||
// 面包屑
|
||||
Q_Q(ElaScrollPage);
|
||||
QString pageCheckSumKey = routeData.value("ElaScrollPageCheckSumKey").toString();
|
||||
if (pageCheckSumKey == "Navigation")
|
||||
{
|
||||
if (pageCheckSumKey == "Navigation") {
|
||||
QString pageTitle = routeData.value("ElaPageTitle").toString();
|
||||
q->navigation(_centralWidgetMap.value(pageTitle), false);
|
||||
}
|
||||
else if (pageCheckSumKey == "BreadcrumbClicked")
|
||||
{
|
||||
} else if (pageCheckSumKey == "BreadcrumbClicked") {
|
||||
QStringList lastBreadcrumbList = routeData.value("LastBreadcrumbList").toStringList();
|
||||
int widgetIndex = _centralWidgetMap.value(lastBreadcrumbList.last());
|
||||
int widgetIndex = _centralWidgetMap.value(lastBreadcrumbList.last());
|
||||
_switchCentralStackIndex(widgetIndex, _navigationTargetIndex);
|
||||
_navigationTargetIndex = widgetIndex;
|
||||
_breadcrumbBar->setBreadcrumbList(lastBreadcrumbList);
|
||||
}
|
||||
}
|
||||
|
||||
void ElaScrollPagePrivate::_switchCentralStackIndex(int targetIndex, int lastIndex)
|
||||
{
|
||||
QWidget* currentWidget = _centralStackedWidget->widget(lastIndex);
|
||||
QWidget* targetWidget = _centralStackedWidget->widget(targetIndex);
|
||||
void ElaScrollPagePrivate::_switchCentralStackIndex(int targetIndex, int lastIndex) {
|
||||
QWidget *currentWidget = _centralStackedWidget->widget(lastIndex);
|
||||
QWidget *targetWidget = _centralStackedWidget->widget(targetIndex);
|
||||
targetWidget->resize(currentWidget->size());
|
||||
targetWidget->setVisible(true);
|
||||
|
||||
QPropertyAnimation* currentWidgetAnimation = new QPropertyAnimation(currentWidget, "pos");
|
||||
QPropertyAnimation *currentWidgetAnimation = new QPropertyAnimation(currentWidget, "pos");
|
||||
currentWidgetAnimation->setEasingCurve(QEasingCurve::InExpo);
|
||||
currentWidgetAnimation->setDuration(300);
|
||||
|
||||
QPropertyAnimation* targetWidgetAnimation = new QPropertyAnimation(targetWidget, "pos");
|
||||
connect(targetWidgetAnimation, &QPropertyAnimation::finished, this, [=]() {
|
||||
_centralStackedWidget->setCurrentIndex(targetIndex);
|
||||
});
|
||||
QPropertyAnimation *targetWidgetAnimation = new QPropertyAnimation(targetWidget, "pos");
|
||||
connect(targetWidgetAnimation, &QPropertyAnimation::finished, this, [=]() { _centralStackedWidget->setCurrentIndex(targetIndex); });
|
||||
targetWidgetAnimation->setEasingCurve(QEasingCurve::InExpo);
|
||||
targetWidgetAnimation->setDuration(300);
|
||||
if (targetIndex > lastIndex)
|
||||
{
|
||||
//左滑
|
||||
if (targetIndex > lastIndex) {
|
||||
// 左滑
|
||||
currentWidgetAnimation->setStartValue(currentWidget->pos());
|
||||
currentWidgetAnimation->setEndValue(QPoint(-_centralStackedWidget->width(), 0));
|
||||
targetWidgetAnimation->setStartValue(QPoint(_centralStackedWidget->width(), 0));
|
||||
targetWidgetAnimation->setEndValue(QPoint(0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
//右滑
|
||||
} else {
|
||||
// 右滑
|
||||
currentWidgetAnimation->setStartValue(currentWidget->pos());
|
||||
currentWidgetAnimation->setEndValue(QPoint(_centralStackedWidget->width(), 0));
|
||||
targetWidgetAnimation->setStartValue(QPoint(-_centralStackedWidget->width(), 0));
|
||||
|
||||
Reference in New Issue
Block a user