您的位置:首页 > Web前端 > HTML

用Popup仿MessageBox 支持HTML语法混排

2016-06-27 18:10 393 查看
Popup {
property var subtext: ""
property var subtitle: ""
id: messsagebox2
x: 0
y: 0
padding: 0
background: Item{}
//是否使用popup背景
//              dim:false
width: parent.width
height: parent.height
modal: true
focus: true
closePolicy: Popup.NoAutoClose

Rectangle {
id: pp
width: parent.width*0.8
height: parent.height/2
anchors.centerIn: parent
color: "#35C47F"
radius: 5
clip: true
Old.ScrollView {
id:flck
width: parent.width
height: parent.height -mok.height
Column{
id:col

Text{
id:title
text:subtitle
font.pointSize: 24
verticalAlignment: Text.AlignVCenter
padding: 15
width: parent.width
height: 40
color: "#FAFCF7"
wrapMode: Text.WrapAnywhere
textFormat: Text.RichText
BorderImage {
id:closeimg
source: "qrc:/HelpUI/res/XX.bmp"
width: 24; height: 24
border.left: 1; border.top: 1
border.right: 1; border.bottom: 1
x:title.width - width - 5
y:title.height/2 - height/2
MouseArea{
anchors.fill: parent
onClicked: {
messsagebox2.close();
}
}
Timer{
id:tttest
running: messsagebox2.visible
repeat: true
interval: 2000
triggeredOnStart: true//第一次先主动触发一次onTriggered
onTriggered: {
console.log("**one  time***")
dh.restart()
mok.width=Math.random()*mok.height*1.7+mok.height*1.5

}
}
NumberAnimation {
id:dh
target: closeimg
running: messsagebox2.visible
property: "rotation"
from:0
to:360
loops:1/*AnimatedSprite.Infinite*/
duration: 500
easing.type: Easing.InOutQuad
}
}
}
Rectangle{width: parent.width*0.75;height: 2;color: "#27AE61"}

//内容
Text{
id: txt
text: subtext
font.pixelSize: 16
font.bold: true
//                    verticalAlignment: Text.AlignVCenter
//                    horizontalAlignment: Text.AlignHCenter
color: "#FAFCF7"
width: flck.width
wrapMode: Text.WrapAnywhere
textFormat: Text.RichText
}

}

}

//确定按钮
Button{
id:mok
//居中
x:pp.width/2 -width/2
anchors.top: flck.bottom
width: height*1.5

height:60
text: "确定"
Material.background:"#35C37F"
Material.foreground:"#FAFCF7"
onClicked: {
messsagebox2.close();
}
Behavior on width {
NumberAnimation{ duration: 2000; easing.type: Easing.OutInBounce}
}

}

layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true//绘制边框阴影
color: "#80000000";
radius: 30.0;
id:drop;

//cached: true;
horizontalOffset: 0;
verticalOffset: 0;
samples: 16;
smooth: true;
}
}
function msg(title , txt)
{
subtitle = title;
subtext = txt;
messsagebox2.open();
}

}




MyMessageBox{
id:gobalMsg
}
function  gMessage(title,txt)
{
gobalMsg.msg(title,txt)
}
gMessage("错误","<img align='middle' src='qrc:/image/TipIcon/warning.png' width='24' height='24' \>账号密码长度不正确")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: