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["token"] ="yyds"
request.headers["os"] ="pc" request.headers["os"] ="pc"
console.debug(JSON.stringify(request))
return request return request
} }
} }

View File

@ -166,7 +166,7 @@ CustomWindow {
//StackpopFluPagelaunchMode //StackpopFluPagelaunchMode
pageMode: FluNavigationViewType.Stack pageMode: FluNavigationViewType.Stack
//NoStack //NoStack
// pageMode: FluNavigationViewType.NoStack // pageMode: FluNavigationViewType.NoStack
items: ItemsOriginal items: ItemsOriginal
footerItems:ItemsFooter footerItems:ItemsFooter
topPadding:FluTools.isMacos() ? 20 : 5 topPadding:FluTools.isMacos() ? 20 : 5
@ -201,14 +201,26 @@ CustomWindow {
} }
} }
Component{
id:com_reveal
CircularReveal{ CircularReveal{
id:reveal id:reveal
target:window.contentItem target:window.contentItem
anchors.fill: parent anchors.fill: parent
onAnimationFinished:{
//
loader_reveal.sourceComponent = undefined
}
onImageChanged: { onImageChanged: {
changeDark() changeDark()
} }
} }
}
Loader{
id:loader_reveal
anchors.fill: parent
}
function distance(x1,y1,x2,y2){ function distance(x1,y1,x2,y2){
return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
@ -218,11 +230,13 @@ CustomWindow {
if(FluTools.isMacos() || !FluTheme.enableAnimation){ if(FluTools.isMacos() || !FluTheme.enableAnimation){
changeDark() changeDark()
}else{ }else{
loader_reveal.sourceComponent = com_reveal
var target = window.contentItem var target = window.contentItem
var pos = button.mapToItem(target,0,0) var pos = button.mapToItem(target,0,0)
var mouseX = pos.x var mouseX = pos.x
var mouseY = pos.y 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 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) 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) CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent)
{ {
setVisible(false); setVisible(false);
_anim = new QPropertyAnimation(this, "radius", this); _anim.setDuration(333);
_anim->setDuration(333); _anim.setEasingCurve(QEasingCurve::OutCubic);
_anim->setEasingCurve(QEasingCurve::OutCubic); connect(&_anim, &QPropertyAnimation::finished,this,[=](){
connect(_anim, &QPropertyAnimation::finished,this,[=](){ update();
setVisible(false); setVisible(false);
Q_EMIT animationFinished();
}); });
connect(this,&CircularReveal::radiusChanged,this,[=](){ connect(this,&CircularReveal::radiusChanged,this,[=](){
update(); update();
@ -31,8 +32,8 @@ void CircularReveal::paint(QPainter* painter)
} }
void CircularReveal::start(int w,int h,const QPoint& center,int radius){ void CircularReveal::start(int w,int h,const QPoint& center,int radius){
_anim->setStartValue(0); _anim.setStartValue(0);
_anim->setEndValue(radius); _anim.setEndValue(radius);
_center = center; _center = center;
_grabResult = _target->grabToImage(QSize(w,h)); _grabResult = _target->grabToImage(QSize(w,h));
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &CircularReveal::handleGrabResult); connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &CircularReveal::handleGrabResult);
@ -43,5 +44,5 @@ void CircularReveal::handleGrabResult(){
update(); update();
setVisible(true); setVisible(true);
Q_EMIT imageChanged(); Q_EMIT imageChanged();
_anim->start(); _anim.start();
} }

View File

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

View File

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