main
zhuzihcu 2023-06-12 10:53:35 +08:00
parent f2ea9a19a1
commit 2fbc5696f7
2 changed files with 11 additions and 9 deletions

View File

@ -189,12 +189,12 @@ CustomWindow {
Image{ Image{
id:img_cache id:img_cache
visible: false visible: false
anchors.fill: flipable anchors.fill: parent
} }
Canvas{ Canvas{
id:canvas id:canvas
anchors.fill: flipable anchors.fill: parent
property int centerX: canvas.width / 2 property int centerX: canvas.width / 2
property int centerY: canvas.height / 2 property int centerY: canvas.height / 2
property real radius: 0 property real radius: 0
@ -215,11 +215,11 @@ CustomWindow {
onPaint: { onPaint: {
var ctx = canvas.getContext("2d"); var ctx = canvas.getContext("2d");
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvasSize.width, canvasSize.height);
ctx.save() ctx.save()
if(img_cache.source.toString().length!==0){ if(img_cache.source.toString().length!==0){
try{ try{
ctx.drawImage(img_cache.source, 0, 0, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height) ctx.drawImage(img_cache, 0, 0, canvasSize.width, canvasSize.height, 0, 0, canvasSize.width, canvasSize.height)
}catch(e){ }catch(e){
img_cache.source = "" img_cache.source = ""
} }
@ -249,12 +249,13 @@ CustomWindow {
FluTheme.darkMode = FluDarkMode.Dark FluTheme.darkMode = FluDarkMode.Dark
} }
} }
if(Screen.devicePixelRatio===1 && FluTools.isWin()){ if(FluTools.isWin()){
var pos = button.mapToItem(window.contentItem,0,0) var target = window.contentItem
var pos = button.mapToItem(target,0,0)
var mouseX = pos.x var mouseX = pos.x
var mouseY = pos.y var mouseY = pos.y
canvas.maxRadius = Math.max(distance(mouseX,mouseY,0,0),distance(mouseX,mouseY,canvas.width,0),distance(mouseX,mouseY,0,canvas.height),distance(mouseX,mouseY,canvas.width,canvas.height)) canvas.maxRadius = 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))
window.contentItem.grabToImage(function(result) { target.grabToImage(function(result) {
img_cache.source = result.url img_cache.source = result.url
canvas.requestPaint() canvas.requestPaint()
changeDark() changeDark()
@ -264,7 +265,7 @@ CustomWindow {
canvas.radius = 0 canvas.radius = 0
anim_radius.enabled = true anim_radius.enabled = true
canvas.radius = canvas.maxRadius canvas.radius = canvas.maxRadius
}) },canvas.canvasSize)
}else{ }else{
changeDark() changeDark()
} }

View File

@ -13,6 +13,7 @@ FRAMELESSHELPER_USE_NAMESPACE
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
//将样式设置为Basic不然会导致组件显示异常 //将样式设置为Basic不然会导致组件显示异常
// qputenv("QT_FONT_DPI","1");
qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
FramelessHelper::Quick::initialize(); FramelessHelper::Quick::initialize();
QGuiApplication::setOrganizationName("ZhuZiChu"); QGuiApplication::setOrganizationName("ZhuZiChu");