This commit is contained in:
朱子楚\zhuzi 2023-07-25 21:24:45 +08:00
parent b22e79148b
commit 5d902dc66e
5 changed files with 33 additions and 21 deletions

View File

@ -19,6 +19,7 @@ Window {
}
request.headers["token"] ="yyds"
request.headers["os"] ="pc"
console.debug(JSON.stringify(request))
return request
}
}

View File

@ -166,7 +166,7 @@ CustomWindow {
//StackpopFluPagelaunchMode
pageMode: FluNavigationViewType.Stack
//NoStack
// pageMode: FluNavigationViewType.NoStack
// pageMode: FluNavigationViewType.NoStack
items: ItemsOriginal
footerItems:ItemsFooter
topPadding:FluTools.isMacos() ? 20 : 5
@ -201,15 +201,27 @@ CustomWindow {
}
}
CircularReveal{
id:reveal
target:window.contentItem
anchors.fill: parent
onImageChanged: {
changeDark()
Component{
id:com_reveal
CircularReveal{
id:reveal
target:window.contentItem
anchors.fill: parent
onAnimationFinished:{
//
loader_reveal.sourceComponent = undefined
}
onImageChanged: {
changeDark()
}
}
}
Loader{
id:loader_reveal
anchors.fill: parent
}
function distance(x1,y1,x2,y2){
return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
}
@ -218,11 +230,13 @@ CustomWindow {
if(FluTools.isMacos() || !FluTheme.enableAnimation){
changeDark()
}else{
loader_reveal.sourceComponent = com_reveal
var target = window.contentItem
var pos = button.mapToItem(target,0,0)
var mouseX = pos.x
var mouseY = pos.y
var radius = Math.max(distance(mouseX,mouseY,0,0),distance(mouseX,mouseY,target.width,0),distance(mouseX,mouseY,0,target.height),distance(mouseX,mouseY,target.width,target.height))
var reveal = loader_reveal.item
reveal.start(reveal.width*Screen.devicePixelRatio,reveal.height*Screen.devicePixelRatio,Qt.point(mouseX,mouseY),radius)
}
}
@ -245,5 +259,4 @@ CustomWindow {
}
}
}

View File

@ -6,11 +6,12 @@
CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent)
{
setVisible(false);
_anim = new QPropertyAnimation(this, "radius", this);
_anim->setDuration(333);
_anim->setEasingCurve(QEasingCurve::OutCubic);
connect(_anim, &QPropertyAnimation::finished,this,[=](){
_anim.setDuration(333);
_anim.setEasingCurve(QEasingCurve::OutCubic);
connect(&_anim, &QPropertyAnimation::finished,this,[=](){
update();
setVisible(false);
Q_EMIT animationFinished();
});
connect(this,&CircularReveal::radiusChanged,this,[=](){
update();
@ -31,8 +32,8 @@ void CircularReveal::paint(QPainter* painter)
}
void CircularReveal::start(int w,int h,const QPoint& center,int radius){
_anim->setStartValue(0);
_anim->setEndValue(radius);
_anim.setStartValue(0);
_anim.setEndValue(radius);
_center = center;
_grabResult = _target->grabToImage(QSize(w,h));
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &CircularReveal::handleGrabResult);
@ -43,5 +44,5 @@ void CircularReveal::handleGrabResult(){
update();
setVisible(true);
Q_EMIT imageChanged();
_anim->start();
_anim.start();
}

View File

@ -18,10 +18,11 @@ public:
void paint(QPainter* painter) override;
Q_INVOKABLE void start(int w,int h,const QPoint& center,int radius);
Q_SIGNAL void imageChanged();
Q_SIGNAL void animationFinished();
Q_SLOT void handleGrabResult();
private:
QImage _source;
QPropertyAnimation* _anim;
QPropertyAnimation _anim = QPropertyAnimation(this, "radius", this);
QPoint _center;
QSharedPointer<QQuickItemGrabResult> _grabResult;
};

View File

@ -204,13 +204,11 @@ void FluHttp::download(QString path,QVariantMap params,QVariantMap headers){
addQueryParam(&url,data["params"].toMap());
QNetworkRequest request(url);
addHeaders(&request,data["headers"].toMap());
QFile *file = new QFile(path);
QSharedPointer<QFile> file(new QFile(path));
QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate;
if (!file->open(mode))
{
Q_EMIT error(-1,QString("Url: %1 %2 Non-Writable").arg(request.url().toString(),file->fileName()));
file->deleteLater();
file = nullptr;
Q_EMIT finish();
return;
}
@ -234,9 +232,7 @@ void FluHttp::download(QString path,QVariantMap params,QVariantMap headers){
}
_cache.removeOne(reply);
file->close();
file->deleteLater();
reply->deleteLater();
file = nullptr;
reply = nullptr;
Q_EMIT finish();
});