Merge pull request #65 from mentalfl0w/dev

Imporve FluContentDialog and add relative example.
This commit is contained in:
zhuzichu 2023-04-20 18:49:53 +08:00 committed by GitHub
commit 689843fbef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 142 additions and 43 deletions

View File

@ -18,14 +18,14 @@ FluScrollablePage{
height: 68 height: 68
paddings: 10 paddings: 10
Layout.topMargin: 20 Layout.topMargin: 20
FluButton{ FluButton{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Layout.topMargin: 20 Layout.topMargin: 20
text:"Show Dialog" text:"Show Double Button Dialog"
onClicked: { onClicked: {
dialog.open() double_btn_dialog.open()
}
} }
}
} }
CodeExpander{ CodeExpander{
Layout.fillWidth: true Layout.fillWidth: true
@ -35,6 +35,7 @@ FluScrollablePage{
title:"友情提示" title:"友情提示"
message:"确定要退出程序么?" message:"确定要退出程序么?"
negativeText:"取消" negativeText:"取消"
buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
onNegativeClicked:{ onNegativeClicked:{
showSuccess("点击取消按钮") showSuccess("点击取消按钮")
} }
@ -42,15 +43,15 @@ FluScrollablePage{
onPositiveClicked:{ onPositiveClicked:{
showSuccess("点击确定按钮") showSuccess("点击确定按钮")
} }
} }
dialog.open() dialog.open()'
'
} }
FluContentDialog{ FluContentDialog{
id:dialog id:double_btn_dialog
title:"友情提示" title:"友情提示"
message:"确定要退出程序么?" message:"确定要退出程序么?"
buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
negativeText:"取消" negativeText:"取消"
onNegativeClicked:{ onNegativeClicked:{
showSuccess("点击取消按钮") showSuccess("点击取消按钮")
@ -61,5 +62,61 @@ dialog.open()
} }
} }
FluArea{
Layout.fillWidth: true
height: 68
paddings: 10
Layout.topMargin: 20
FluButton{
anchors.verticalCenter: parent.verticalCenter
Layout.topMargin: 20
text:"Show Triple Button Dialog"
onClicked: {
triple_btn_dialog.open()
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluContentDialog{
id:dialog
title:"友情提示"
message:"确定要退出程序么?"
negativeText:"取消"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
negativeText:"取消"
onNegativeClicked:{
showSuccess("点击取消按钮")
}
positiveText:"确定"
onPositiveClicked:{
showSuccess("点击确定按钮")
}
neutralText:"最小化"
onNeutralClicked:{
showSuccess("点击最小化按钮")
}
}
dialog.open()'
}
FluContentDialog{
id:triple_btn_dialog
title:"友情提示"
message:"确定要退出程序么?"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
negativeText:"取消"
onNegativeClicked:{
showSuccess("点击取消按钮")
}
positiveText:"确定"
onPositiveClicked:{
showSuccess("点击确定按钮")
}
neutralText:"最小化"
onNeutralClicked:{
showSuccess("点击最小化按钮")
}
}
} }

View File

@ -46,6 +46,32 @@ FluWindow {
} }
} }
FluContentDialog{
id:close_app
title:"退出"
message:"确定要退出程序吗?"
negativeText:"最小化"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
onNegativeClicked:{
showSuccess("最小化成功")
window.hide()
}
positiveText:"退出"
neutralText:"取消"
onPositiveClicked:{
window.destoryWindow()
FluApp.closeApp()
}
}
onClosing:
{
window.show()
window.raise()
window.requestActivate()
close_app.open()
}
FluNavigationView{ FluNavigationView{
id:nav_view id:nav_view

View File

@ -7,11 +7,19 @@ Popup {
id: popup id: popup
property string title: "Title" property string title: "Title"
property string message: "Messaeg" property string message: "Message"
property string neutralText: "Neutral"
property string negativeText: "Negative" property string negativeText: "Negative"
property string positiveText: "Positive" property string positiveText: "Positive"
signal neutralClicked
signal negativeClicked signal negativeClicked
signal positiveClicked signal positiveClicked
enum ButtonFlag{
NegativeButton=1
,NeutralButton=2
,PositiveButton=4
}
property int buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
property var minWidth: { property var minWidth: {
if(Window.window==null) if(Window.window==null)
return 400 return 400
@ -74,40 +82,48 @@ Popup {
right: parent.right right: parent.right
} }
Item { RowLayout{
id:divider anchors
width: 1 {
height: parent.height centerIn: parent
anchors.centerIn: parent margins: spacing
} fill: parent
}
spacing: 15
FluButton{
id:neutral_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags&FluContentDialog.NeutralButton
text: neutralText
onClicked: {
popup.close()
neutralClicked()
}
}
FluButton{ FluButton{
anchors{ id:negative_btn
left: parent.left Layout.fillWidth: true
leftMargin: 20 Layout.fillHeight: true
rightMargin: 10 visible: popup.buttonFlags&FluContentDialog.NegativeButton
right: divider.left text: negativeText
verticalCenter: parent.verticalCenter onClicked: {
popup.close()
negativeClicked()
}
} }
text: negativeText
onClicked: {
popup.close()
negativeClicked()
}
}
FluFilledButton{ FluFilledButton{
anchors{ id:positive_btn
right: parent.right Layout.fillWidth: true
left: divider.right Layout.fillHeight: true
rightMargin: 20 visible: popup.buttonFlags&FluContentDialog.PositiveButton
leftMargin: 10 text: positiveText
verticalCenter: parent.verticalCenter onClicked: {
} popup.close()
text: positiveText positiveClicked()
onClicked: { }
popup.close()
positiveClicked()
} }
} }
} }