mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-05 01:25:25 +08:00
添加支持windows系统窗口win7-win10(area、blur)、win11(mica、mica-alt)效果切换,修改夜间模式切换动画效果,支持动画打断;
This commit is contained in:
@ -639,7 +639,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="95"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="339"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -659,57 +659,57 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="304"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="302"/>
|
||||
<source>Finish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="305"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="303"/>
|
||||
<source>Next</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="306"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="304"/>
|
||||
<source>Previous</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="308"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="308"/>
|
||||
<source>Here you can switch to night mode.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="312"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<source>Hide Easter eggs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="312"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<source>Try a few more clicks!!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="336"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<source>Upgrade Tips</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="335"/>
|
||||
<source>FluentUI is currently up to date </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="335"/>
|
||||
<source> -- The current app version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="335"/>
|
||||
<source>
|
||||
Now go and download the new version?
|
||||
|
||||
@ -718,17 +718,17 @@ Updated content:
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="340"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="367"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="365"/>
|
||||
<source>The current version is already the latest</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="374"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="372"/>
|
||||
<source>The network is abnormal</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -2264,6 +2264,21 @@ Some contents...</source>
|
||||
<source>Open Blur Window</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="136"/>
|
||||
<source>window tintOpacity</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="153"/>
|
||||
<source>window blurRadius</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="169"/>
|
||||
<source>window effect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_TimePicker</name>
|
||||
|
@ -616,7 +616,7 @@
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="308"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished">夜间模式</translation>
|
||||
</message>
|
||||
@ -648,7 +648,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="95"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="339"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished">取消</translation>
|
||||
</message>
|
||||
@ -668,52 +668,52 @@
|
||||
<translation type="unfinished">搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="304"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="302"/>
|
||||
<source>Finish</source>
|
||||
<translation type="unfinished">完成</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="305"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="303"/>
|
||||
<source>Next</source>
|
||||
<translation type="unfinished">下一步</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="306"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="304"/>
|
||||
<source>Previous</source>
|
||||
<translation type="unfinished">上一步</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="308"/>
|
||||
<source>Here you can switch to night mode.</source>
|
||||
<translation type="unfinished">在这里,您可以切换到夜间模式。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="312"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<source>Hide Easter eggs</source>
|
||||
<translation type="unfinished">隐藏彩蛋</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="312"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="310"/>
|
||||
<source>Try a few more clicks!!</source>
|
||||
<translation type="unfinished">再试几下!!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="336"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="334"/>
|
||||
<source>Upgrade Tips</source>
|
||||
<translation type="unfinished">升级提示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="335"/>
|
||||
<source>FluentUI is currently up to date </source>
|
||||
<translation type="unfinished">FluentUI 目前最新版本 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="335"/>
|
||||
<source> -- The current app version</source>
|
||||
<translation type="unfinished"> -- 当前应用版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="337"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="335"/>
|
||||
<source>
|
||||
Now go and download the new version?
|
||||
|
||||
@ -726,17 +726,17 @@ Updated content:
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="340"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="338"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished">确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="367"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="365"/>
|
||||
<source>The current version is already the latest</source>
|
||||
<translation type="unfinished">当前版本已经是最新版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="374"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="372"/>
|
||||
<source>The network is abnormal</source>
|
||||
<translation type="unfinished">网络异常</translation>
|
||||
</message>
|
||||
@ -2446,6 +2446,21 @@ Some contents...</source>
|
||||
<source>Open Blur Window</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="136"/>
|
||||
<source>window tintOpacity</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="153"/>
|
||||
<source>window blurRadius</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/page/T_Theme.qml" line="169"/>
|
||||
<source>window effect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_TimePicker</name>
|
||||
|
263
example/qml/page/New_TableView.qml
Normal file
263
example/qml/page/New_TableView.qml
Normal file
@ -0,0 +1,263 @@
|
||||
import QtQuick 2.15
|
||||
import FluentUI 1.0
|
||||
import "../component"
|
||||
|
||||
FluPage{
|
||||
title:"表格测试"
|
||||
TableView{
|
||||
columnSource: [
|
||||
{
|
||||
title: "全选",
|
||||
dataIndex: 'patientsex',
|
||||
width:60,
|
||||
readOnly:true,
|
||||
position: 0,
|
||||
delegate: com_checkbox,
|
||||
headerDelegate: com_header_checkbox,
|
||||
frozen: true
|
||||
},
|
||||
|
||||
{
|
||||
title: "检测日期",
|
||||
dataIndex: 'testdate',
|
||||
readOnly:true,
|
||||
// width:150,
|
||||
// delegate: com_action
|
||||
},
|
||||
{
|
||||
title: "条码号",
|
||||
dataIndex: 'barcode',
|
||||
width:80,
|
||||
readOnly:true,
|
||||
position: 0,
|
||||
movable: false,
|
||||
frozen: true
|
||||
// delegate: com_checkbox,
|
||||
// headerDelegate: com_header_checkbox
|
||||
},
|
||||
{
|
||||
title: "样本号",
|
||||
dataIndex: 'sampleid',
|
||||
width:100,
|
||||
position: 1,
|
||||
minimumWidth:100,
|
||||
maximumWidth:100,
|
||||
},
|
||||
{
|
||||
title: "姓名",
|
||||
dataIndex: 'patientname',
|
||||
width:220,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
},
|
||||
{
|
||||
title:"操作",
|
||||
dataIndex:"",
|
||||
delegate:com_action,
|
||||
frozen: true,
|
||||
width: 250
|
||||
},
|
||||
{
|
||||
title: "头像",
|
||||
dataIndex: 'imageurl',
|
||||
width:120,
|
||||
minimumWidth:80,
|
||||
maximumWidth:250,
|
||||
delegate:com_avatar,
|
||||
frozen: true
|
||||
},
|
||||
{
|
||||
title: "性别",
|
||||
dataIndex: 'patientsex',
|
||||
width:130,
|
||||
minimumWidth:50,
|
||||
maximumWidth:250,
|
||||
// delegate:com_avatar
|
||||
},
|
||||
|
||||
{
|
||||
title: "年龄",
|
||||
dataIndex: 'patientage',
|
||||
width:100,
|
||||
minimumWidth:80,
|
||||
maximumWidth:330
|
||||
},
|
||||
{
|
||||
title: "电话",
|
||||
dataIndex: 'patienttel',
|
||||
width:200,
|
||||
minimumWidth:100,
|
||||
maximumWidth:300,
|
||||
editMultiline: true
|
||||
},
|
||||
{
|
||||
title: "身份证号",
|
||||
dataIndex: 'patientidenno',
|
||||
width:120,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
},
|
||||
{
|
||||
title: "检测项目",
|
||||
dataIndex: 'hisitemnamelist',
|
||||
width:120,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
},
|
||||
{
|
||||
title: "开单科室",
|
||||
dataIndex: 'deptname',
|
||||
width:150,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
},
|
||||
{
|
||||
title: "开单医生",
|
||||
dataIndex: 'doctorname',
|
||||
width:140,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
}
|
||||
,
|
||||
{
|
||||
title: "接收时间",
|
||||
dataIndex: 'incepttime',
|
||||
width:120,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
},
|
||||
{
|
||||
title: "核收时间",
|
||||
dataIndex: 'accepttime',
|
||||
width:220,
|
||||
minimumWidth:100,
|
||||
maximumWidth:250
|
||||
}
|
||||
]
|
||||
model: ListModel{
|
||||
id: customModel
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
// generateTestData(1000) // 生成100条测试数据
|
||||
for (var i = 0; i < 100000; i++) {
|
||||
customModel.append(generateTestData(i))
|
||||
}
|
||||
// uvRecord.setProperty()
|
||||
}
|
||||
Component{
|
||||
id:com_avatar
|
||||
Item{
|
||||
anchors.fill: parent
|
||||
FluClip{
|
||||
anchors.centerIn: parent
|
||||
width: Math.min(parent.width,parent.height)
|
||||
height: width
|
||||
radius: [width/2,width/2,width/2,width/2]
|
||||
Image{
|
||||
anchors.fill: parent
|
||||
source: display
|
||||
sourceSize: Qt.size(80,80)
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: com_checkbox
|
||||
Item{
|
||||
FluCheckBox {
|
||||
width: 15
|
||||
height: 15
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: com_header_checkbox
|
||||
Item{
|
||||
FluCheckBox {
|
||||
width: 15
|
||||
height: 15
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
Component{
|
||||
id: com_action
|
||||
Item{
|
||||
Row{
|
||||
anchors.centerIn: parent
|
||||
FluTextButton{
|
||||
text:"插入"
|
||||
onClicked: {
|
||||
// uvRecord.insertRecord(row)
|
||||
uvRecord.insert(row,generateTestData(row))
|
||||
}
|
||||
}
|
||||
FluTextButton{
|
||||
text:"上移"
|
||||
onClicked:{
|
||||
if (row > 0) {
|
||||
uvRecord.move(row, row - 1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
FluTextButton{
|
||||
text:"下移"
|
||||
onClicked:{
|
||||
if (row < uvRecord.rowCount() - 1) {
|
||||
uvRecord.move(row, row + 2, 1) // 注意这里是 row + 2
|
||||
}
|
||||
}
|
||||
}
|
||||
FluTextButton{
|
||||
text:"查看"
|
||||
onClicked: {
|
||||
showSuccess(JSON.stringify(control.model.get(row)))
|
||||
}
|
||||
}
|
||||
FluTextButton{
|
||||
text:"删除"
|
||||
onClicked: {
|
||||
uvRecord.remove(row)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateTestData(i) {
|
||||
var sexes = ["男", "女"]
|
||||
var departments = ["内科", "外科", "儿科", "妇科", "眼科"]
|
||||
var doctors = ["张医生", "李医生", "王医生", "刘医生", "陈医生"]
|
||||
var images = [
|
||||
"qrc:/res/image/pages/exchange.png",
|
||||
"qrc:/res/image/pages/nuclear.png",
|
||||
"qrc:/res/image/pages/ocr.png",
|
||||
"qrc:/res/image/pages/room-temperature.png",
|
||||
"qrc:/res/image/pages/rt-pcr-machine.png"
|
||||
]
|
||||
return {
|
||||
testdate: new Date().toLocaleDateString(),
|
||||
barcode: "BC" + (1000000 + i).toString(),
|
||||
sampleid: "S" + (100000 + i).toString(),
|
||||
patientname: "患者" + (i + 1),
|
||||
patientsex: sexes[Math.floor(Math.random() * sexes.length)],
|
||||
patientage: Math.floor(Math.random() * 80 + 1) + "岁",
|
||||
patienttel: "1" + Math.floor(Math.random() * 9000000000 + 1000000000),
|
||||
patientidenno: (310000000000000000 + i).toString(),
|
||||
hisitemnamelist: "项目1,项目2,项目3",
|
||||
deptname: departments[Math.floor(Math.random() * departments.length)],
|
||||
doctorname: doctors[Math.floor(Math.random() * doctors.length)],
|
||||
incepttime: new Date().toLocaleString(),
|
||||
accepttime: new Date().toLocaleString(),
|
||||
imageurl: images[Math.floor(Math.random() * images.length)],
|
||||
_minimumHeight: 42,
|
||||
_maximumHeight: 800,
|
||||
height: 42
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ FluScrollablePage{
|
||||
|
||||
FluFrame{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 408
|
||||
Layout.fillHeight: true
|
||||
padding: 10
|
||||
|
||||
ColumnLayout{
|
||||
@ -124,12 +124,69 @@ FluScrollablePage{
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluToggleSwitch{
|
||||
id: toggle_blur
|
||||
Layout.topMargin: 5
|
||||
checked: FluTheme.blurBehindWindowEnabled
|
||||
onClicked: {
|
||||
FluTheme.blurBehindWindowEnabled = !FluTheme.blurBehindWindowEnabled
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
visible: FluTheme.blurBehindWindowEnabled || window.effect === "dwm-blur"
|
||||
text: qsTr("window tintOpacity")
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluSlider{
|
||||
visible: FluTheme.blurBehindWindowEnabled || window.effect === "dwm-blur"
|
||||
Layout.topMargin: 5
|
||||
to:1
|
||||
stepSize:0.1
|
||||
onValueChanged: {
|
||||
window.tintOpacity = value
|
||||
}
|
||||
Component.onCompleted: {
|
||||
value = window.tintOpacity
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
visible: FluTheme.blurBehindWindowEnabled
|
||||
text: qsTr("window blurRadius")
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluSlider{
|
||||
visible: FluTheme.blurBehindWindowEnabled
|
||||
Layout.topMargin: 5
|
||||
to:100
|
||||
stepSize:1
|
||||
onValueChanged: {
|
||||
window.blurRadius = value
|
||||
}
|
||||
Component.onCompleted: {
|
||||
value = window.blurRadius
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text: qsTr("window effect")
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
Row{
|
||||
spacing: 10
|
||||
Repeater{
|
||||
model: window.availableEffects
|
||||
delegate: FluRadioButton{
|
||||
checked: window.effect === modelData
|
||||
text: qsTr(`${modelData}`)
|
||||
clickListener:function(){
|
||||
window.effect = modelData
|
||||
if(window.effective){
|
||||
FluTheme.blurBehindWindowEnabled = false
|
||||
toggle_blur.checked = Qt.binding( function() {return FluTheme.blurBehindWindowEnabled})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CodeExpander{
|
||||
|
@ -236,6 +236,7 @@ FluWindow {
|
||||
id: reveal
|
||||
target: window.containerItem()
|
||||
anchors.fill: parent
|
||||
darkToLight: FluTheme.dark
|
||||
onAnimationFinished:{
|
||||
//动画结束后释放资源
|
||||
loader_reveal.sourceComponent = undefined
|
||||
@ -256,17 +257,14 @@ FluWindow {
|
||||
}
|
||||
|
||||
function handleDarkChanged(button){
|
||||
if(!FluTheme.animationEnabled || window.fitsAppBarWindows === false){
|
||||
if(FluTools.isMacos() || !FluTheme.animationEnabled){
|
||||
changeDark()
|
||||
}else{
|
||||
if(loader_reveal.sourceComponent){
|
||||
return
|
||||
}
|
||||
loader_reveal.sourceComponent = com_reveal
|
||||
var target = window.containerItem()
|
||||
var pos = button.mapToItem(target,0,0)
|
||||
var mouseX = pos.x
|
||||
var mouseY = pos.y
|
||||
var mouseX = pos.x + button.width / 2
|
||||
var mouseY = pos.y + button.height / 2
|
||||
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)
|
||||
|
@ -25,13 +25,32 @@ void CircularReveal::paint(QPainter *painter) {
|
||||
path.moveTo(_center.x(), _center.y());
|
||||
path.addEllipse(QPointF(_center.x(), _center.y()), _radius, _radius);
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Clear);
|
||||
painter->fillPath(path, Qt::black);
|
||||
if(_darkToLight){
|
||||
painter->fillPath(path, Qt::white);
|
||||
}else{
|
||||
QPainterPath outerRect;
|
||||
outerRect.addRect(0, 0, width(), height());
|
||||
outerRect = outerRect.subtracted(path);
|
||||
painter->fillPath(outerRect, Qt::black);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
[[maybe_unused]] void CircularReveal::start(int w, int h, const QPoint ¢er, int radius) {
|
||||
_anim->setStartValue(0);
|
||||
_anim->setEndValue(radius);
|
||||
if (_anim->state() == QAbstractAnimation::Running) {
|
||||
_anim->stop();
|
||||
int currentRadius = _radius;
|
||||
_anim->setStartValue(currentRadius);
|
||||
_anim->setEndValue(_darkToLight ? 0 : radius);
|
||||
} else {
|
||||
if(_darkToLight){
|
||||
_anim->setStartValue(radius);
|
||||
_anim->setEndValue(0);
|
||||
}else{
|
||||
_anim->setStartValue(0);
|
||||
_anim->setEndValue(radius);
|
||||
}
|
||||
}
|
||||
_center = center;
|
||||
_grabResult = _target->grabToImage(QSize(w, h));
|
||||
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this,
|
||||
|
@ -10,6 +10,7 @@ class CircularReveal : public QQuickPaintedItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QQuickItem *, target)
|
||||
Q_PROPERTY_AUTO(int, radius)
|
||||
Q_PROPERTY_AUTO(bool, darkToLight)
|
||||
public:
|
||||
explicit CircularReveal(QQuickItem *parent = nullptr);
|
||||
void paint(QPainter *painter) override;
|
||||
|
Reference in New Issue
Block a user